Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
 
a, b, c = input().split()
a, b, c = int(a), int(b), int(c)
 
if 4*a*b < (c - a - b)**2:
  if (c - a - b) < 0:
    print("No")
  else:
	print("Yes")
else:
  print("No")

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

d = c - a - b

if (4*a*b < d*d) and (0 < d):
  print("Yes")
else:
  print("No")

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

a, b, c = input().split()
a, b, c = int(a), int(b), int(c)

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

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

d = c - a - b

if (4*a*b < d*d) and (0 < d):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
#coding: utf-8
import sys
def input():
    return sys.stdin.readline()[:-1]
"""
N人が1列に並んでおり、前からi番目の人の身長は A_iです。
それぞれの人の足元に、高さが0以上の踏み台を設置し、全ての人が次の条件を満たすようにしたいです。
条件：踏み台を込めて身長を比較したとき、自分より前に、自分より背の高い人が存在しない
この条件を満たす時の、踏み台の高さの合計の最小値を求めてください。
"""
N = int(input())
A = list(map(int, input().split()))
out = 0
for x, a in enumerate(A):
    if x==0:
        continue
    out += max(0, max(A[:x])-a)
print(out)

Fixed submission:
#coding: utf-8
import sys
def input():
    return sys.stdin.readline()[:-1]
"""
N人が1列に並んでおり、前からi番目の人の身長は A_iです。
それぞれの人の足元に、高さが0以上の踏み台を設置し、全ての人が次の条件を満たすようにしたいです。
条件：踏み台を込めて身長を比較したとき、自分より前に、自分より背の高い人が存在しない
この条件を満たす時の、踏み台の高さの合計の最小値を求めてください。
"""
N = int(input())
A = list(map(int, input().split()))
out = 0
# for x, a in enumerate(A):
#     if x==0:
#         continue
#     out += max(0, max(A[:x])-a)
vmax = 0
for a in A:
    vmax = max(vmax, a)
    out += vmax - a
print(out)
Buggy python submission (verdict: Runtime Error):
table = [0] + [chr(i) for i in range(97, 97+26)]

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = table[X_dumy%n]+out
        X_dumy = int(X_dumy/n)
    return out

print(Base_10_to_n(int(input()),26))


Fixed submission:
table = list("abcdefghijklmnopqrstuvwxyz")
N = int(input())

ans = []
while True:
    ans.append(N%26)
    if N%26 == 0:
        N -= 1
    if  N//26 == 0:
        break
    N//=26
for x in reversed(ans):
    print(table[x-1],end='')

print()
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input(),aplit())

path = [[] for i in range(N)]

for _ in range(M):
	a,b = map(int,input(),split())
	path[a-1],append(b-1)
    path[b-1],append(a-1)
vis = [0 for i in range(N)]
cnt = 0

def dfs(now,path):
	global cnt
  	if depth == N: cnt+=1
	for new in path[now]:
    	if vis[new] == 0:
			vis[new] = 1
        	dfs(new,depth+1)
          	vis[new] = 0

vis[0] = 1
dfs(0,1)
print(cnt)

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

path = [[] for i in range(N)]

for _ in range(M):
	a,b = map(int,input().split())
	path[a-1].append(b-1)
	path[b-1].append(a-1)
vis = [0 for i in range(N)]
cnt = 0

def dfs(now,depth):
	global cnt
	if depth == N: cnt+=1
	for new in path[now]:
		if vis[new] == 0:
			vis[new] = 1
			dfs(new,depth+1)
			vis[new] = 0

vis[0] = 1
dfs(0,1)
print(cnt)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
s = input()
k = int(input())

ones = 0
i = 0
while s[i] == '1':
    ones += 1
    i += 1

if ones >= k:
    print('1')
else:
    print(s[i])


Fixed submission:
# -*- coding: utf-8 -*-
s = input()
k = int(input())

l = len(s)
ones = 0
i = 0
while s[i] == '1':
    ones += 1
    i += 1
    if i == l:
        break

if ones >= k:
    print('1')
else:
    print(s[i])
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from itertools import accumulate, combinations
from collections import defaultdict

n, m = map(int, input().split())
ary = [int(_) for _ in input().split()]

sum_ary = accumulate(ary, lambda x, y: x + y)
mod_table = defaultdict(int)
for mod in [s % m for s in (ary[0], *sum_ary)]:
    mod_table[mod] += 1

print(sum([len(list(combinations(range(v), 2))) for v in mod_table.values()]))


Fixed submission:
# -*- coding: utf-8 -*-
from itertools import accumulate
from collections import defaultdict

n, m = map(int, input().split())
ary = [int(_) for _ in input().split()]

sum_ary = list(accumulate(ary, lambda x, y: x + y))
mod_ary = [s % m for s in sum_ary]
mod_table = defaultdict(int)
for mod in mod_ary:
    mod_table[mod] += 1
mod_table[0] += 1

print(sum([mod * (mod - 1) // 2 for mod in mod_table.values()]))

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from itertools import accumulate, combinations
from collections import defaultdict

n, m = map(int, input().split())
ary = [int(_) for _ in input().split()]

sum_ary = accumulate(ary, lambda x, y: x + y)
mod_table = defaultdict(int)
for mod in [s % m for s in (ary[0], *sum_ary)]:
    mod_table[mod] += 1

print(sum([len(list(combinations(range(v), 2))) for v in mod_table.values()]))


Fixed submission:
# -*- coding: utf-8 -*-
from itertools import accumulate
from collections import defaultdict

n, m = map(int, input().split())
ary = [int(_) for _ in input().split()]

sum_ary = list(accumulate(ary, lambda x, y: x + y))
mod_ary = [s % m for s in sum_ary]
mod_table = defaultdict(int)
for mod in mod_ary:
    mod_table[mod] += 1
mod_table[0] += 1

print(sum([mod * (mod - 1) // 2 for mod in mod_table.values()]))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
D, G = map(int, input().split())

cp = [tuple(map(int, input().split())) for i in range(D)]
cpg = [(c, (i + 1) * 100, (i + 1) * 100 * c + p)
       for i, (c, p) in enumerate(cp)]

cnt = 0
while True:

    c, p, g = cpg.pop()
    if G - g > 0:
        if cpg:
            cn, pn, gn = cpg[-1]
            if G - gn <= 0:
                cnt += cn
                break

        G -= g
        cnt += c
        continue

    else:

        if G / p < c:
            cnt += G // p if G % p == 0 else G // p + 1
            break

        if cpg:
            cn, pn, gn = cpg[-1]
            if G - gn <= 0 and cn < c:
                cnt += cn
                break

        else:
            cnt += c
            break

print(cnt)


Fixed submission:
# -*- coding: utf-8 -*-
from itertools import product

D, G = map(int, input().split())
pc_table = [tuple(map(int, input().split())) for _ in range(D)]

bit_table = list(product([0, 1], repeat=D))
cnts = []
for bits in bit_table:
    g = sum([
        pc_table[i][1] + 100 * (i + 1) * pc_table[i][0]
        for i, bit in enumerate(bits) if bit
    ])
    cnt = sum([pc_table[i][0] for i, bit in enumerate(bits) if bit])

    if g >= G:
        cnts.append(cnt)

    else:
        max_p = max([i for i, bit in enumerate(bits) if not bit])
        for _ in range(pc_table[max_p][0]):
            g += 100 * (max_p + 1)
            cnt += 1
            if g >= G:
                cnts.append(cnt)
                break

print(min(cnts))

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
D, G = map(int, input().split())

cp = [tuple(map(int, input().split())) for i in range(D)]
cpg = [(c, (i + 1) * 100, (i + 1) * 100 * c + p)
       for i, (c, p) in enumerate(cp)]

cnt = 0
while True:
    c, p, g = cpg.pop()

    if G - g > 0:
        G -= g
        cnt += c
        continue

    else:

        if G / p < c:
            cnt += G // p if G % p == 0 else G // p + 1
            break

        if cpg:
            cn, pn, gn = cpg[-1]
            if G - gn <= 0 and cn < c:
                cnt += cn
                break
        else:
            cnt += c
            break

print(cnt)


Fixed submission:
# -*- coding: utf-8 -*-
from itertools import product

D, G = map(int, input().split())
pc_table = [tuple(map(int, input().split())) for _ in range(D)]

bit_table = list(product([0, 1], repeat=D))
cnts = []
for bits in bit_table:
    g = sum([
        pc_table[i][1] + 100 * (i + 1) * pc_table[i][0]
        for i, bit in enumerate(bits) if bit
    ])
    cnt = sum([pc_table[i][0] for i, bit in enumerate(bits) if bit])

    if g >= G:
        cnts.append(cnt)

    else:
        max_p = max([i for i, bit in enumerate(bits) if not bit])
        for _ in range(pc_table[max_p][0]):
            g += 100 * (max_p + 1)
            cnt += 1
            if g >= G:
                cnts.append(cnt)
                break

print(min(cnts))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
n, m = map(int, input().split())
demands = [
    tuple(map(int,
              line.strip().split())) for line in sys.stdin.readlines()
]
demands.sort(key=lambda demand: demand[1])

bridge = -1
cnt = 0
for ai, bi in demands:

    if ai <= bridge:
        continue

    else:
        bridge = bi - 1
        cnt += 1

print(cnt)


Fixed submission:
# -*- coding: utf-8 -*-
from itertools import permutations

ary = map(int, input().split())

min_val = float('inf')
for vals in permutations(ary):
    tmp_val = 0
    for i, val in enumerate(vals):
        if i > 0:
            tmp_val += abs(val - vals[i - 1])

    if min_val > tmp_val:
        min_val = tmp_val

print(min_val)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
INF = 10**10
n = int(input())
a = [int(_) - (i + 1) for i, _ in enumerate(input().split())]

grief = INF
for b in set(a):
    tmp = sum([abs(ai - b) for ai in a])
    if tmp < grief:
        bb = b
        grief = tmp

print(grief)


Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
a = [int(_) - (i + 1) for i, _ in enumerate(input().split())]

# INF = 10**10
# grief = INF
# for b in set(a):
#     tmp = sum([abs(ai - b) for ai in a])
#     if tmp < grief:
#         bb = b
#         grief = tmp

# print(grief)  # running time limit error

a.sort()
med = a[len(a) // 2]
grief = sum([abs(ai - med) for ai in a])
print(grief)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
INF = 10**10
n = int(input())
a = [int(_) - (i + 1) for i, _ in enumerate(input().split())]
a.sort()

grief = INF
for b in set(a):
    tmp = sum([abs(ai - b) for ai in a])
    if tmp < grief:
        grief = tmp

print(grief)


Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
a = [int(_) - (i + 1) for i, _ in enumerate(input().split())]

# INF = 10**10
# grief = INF
# for b in set(a):
#     tmp = sum([abs(ai - b) for ai in a])
#     if tmp < grief:
#         bb = b
#         grief = tmp

# print(grief)  # running time limit error

a.sort()
med = a[len(a) // 2]
grief = sum([abs(ai - med) for ai in a])
print(grief)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
INF = 10**10
n = int(input())
a = [int(_) - (i + 1) for i, _ in enumerate(input().split())]
a.sort()

grief = INF
for b in range(a[0], a[-1] + 1):
    tmp = sum([abs(ai - b) for ai in a])
    if tmp < grief:
        grief = tmp

print(grief)


Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
a = [int(_) - (i + 1) for i, _ in enumerate(input().split())]

# INF = 10**10
# grief = INF
# for b in set(a):
#     tmp = sum([abs(ai - b) for ai in a])
#     if tmp < grief:
#         bb = b
#         grief = tmp

# print(grief)  # running time limit error

a.sort()
med = a[len(a) // 2]
grief = sum([abs(ai - med) for ai in a])
print(grief)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a = int(input())
b = int(input())

if a > 8 or b > 8:
    print(':(')
else:
    print('Yay!')


Fixed submission:
# -*- coding: utf-8 -*-
a, b = map(int, input().split())

if a > 8 or b > 8:
    print(':(')
else:
    print('Yay!')

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a = int(input())
b = int(input())

if a > 8 or b > 8:
    print(': (')
else:
    print('Yay!')


Fixed submission:
# -*- coding: utf-8 -*-
a, b = map(int, input().split())

if a > 8 or b > 8:
    print(':(')
else:
    print('Yay!')
Buggy python submission (verdict: Runtime Error):
s=input()
temp=0
if(s=="RRR"):print(3)
elif(s=="RRS" or s="SRR"):print(2)
elif(s=="SSS"):print(0)
else:print(1)  

Fixed submission:
s=input()
temp=0
if(s=="RRR"):print(3)
elif(s=="RRS" or s=="SRR"):print(2)
elif(s=="SSS"):print(0)
else:print(1)
Buggy python submission (verdict: Runtime Error):
A, B, C, K = map(int, input().split())

abc = [1]*A + [0]*B + [-1]*C
print(sum(abc[:K]))

Fixed submission:
A, B, C, K = map(int, input().split())
out = min(A, K)
if A+B < K:
  out -= (K-A-B)
print(out)
Buggy python submission (verdict: Runtime Error):
import itertools
import numpy as np

N, M, X = map(int, input().split())
items = np.array([list(map(int, input().split())) for _ in range(N)], dtype=np.int32)

out = 10**18
for c in itertools.product([False, True], repeat=M):
    tmp = np.sum(items[np.where(c)], axis=0)
    if np.any(tmp):
      if M == np.count_nonzero(tmp[1:] >= X):
        out = min(out, tmp[0])
if out == 10**18:
  print(-1)
else:
  print(out) 

Fixed submission:
import itertools
import numpy as np

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

items = np.array([list(map(int, input().split())) for _ in range(N)])

min_v = 10**18
for n in range(1, N+1):
  for c in itertools.combinations(range(N), n):
    tmp = np.sum(items[[c]], axis=0)
    c = tmp[0]
    a = tmp[1:]
    if M == np.count_nonzero(a >= X):
      min_v = min(min_v, c)
if min_v == 10**18:
  print(-1)
else:
  print(min_v)

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

N, M, X = map(int, input().split())
items = np.array([list(map(int, input().split())) for _ in range(N)], dtype=np.int32)

out = 10**18
for c in itertools.product([False, True], repeat=M):
    tmp = np.sum(items[[np.where(c)]], axis=0)
    if np.any(tmp):
      if M == np.count_nonzero(tmp[1:] >= X):
        out = min(out, tmp[0])
if out == 10**18:
  print(-1)
else:
  print(out) 

Fixed submission:
import itertools
import numpy as np

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

items = np.array([list(map(int, input().split())) for _ in range(N)])

min_v = 10**18
for n in range(1, N+1):
  for c in itertools.combinations(range(N), n):
    tmp = np.sum(items[[c]], axis=0)
    c = tmp[0]
    a = tmp[1:]
    if M == np.count_nonzero(a >= X):
      min_v = min(min_v, c)
if min_v == 10**18:
  print(-1)
else:
  print(min_v)

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

N, M, X = map(int, input().split())
items = np.array([list(map(int, input().split())) for _ in range(N)], dtype=np.int32)

out = 10**18
for c in itertools.product([False, True], repeat=M):
    tmp = np.sum(items[[np.where(c)]], axis=0)
    if np.any(tmp):
      if M == np.count_nonzero(tmp[1:] >= X):
        out = min(out, tmp[0])
if out == 10**18:
  print(-1)
else:
  print(out) 

Fixed submission:
import itertools
import numpy as np

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

items = np.array([list(map(int, input().split())) for _ in range(N)])

min_v = 10**18
for n in range(1, N+1):
  for c in itertools.combinations(range(N), n):
    tmp = np.sum(items[[c]], axis=0)
    c = tmp[0]
    a = tmp[1:]
    if M == np.count_nonzero(a >= X):
      min_v = min(min_v, c)
if min_v == 10**18:
  print(-1)
else:
  print(min_v)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))

t_zero = [-1] * N

t = 0
a = 1

while t_zero[a-1] == -1:
  if t == K:
    break
  t_zero[a-1] = t
  t += 1
  a = A[a-1]
else:
  k = (K - t_zero[a-1]) % (t - t_zero[a-1])
  a = t_zero.index(t_zero[a] + k)
print(a)

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

t_zero = [-1] * N

t = 0
a = 1

while t_zero[a-1] == -1:
  if t == K:
    break
  t_zero[a-1] = t
  t += 1
  a = A[a-1]
else:
  k = (K - t_zero[a-1]) % (t - t_zero[a-1])
  for _ in range(k):
    a = A[a-1]
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
N, M, K = map(int, input().split())
out = 0
mod = 998244353

def comb(n,k,p):
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

for k in range(K+1):
  out += M * pow(M-1, N-k-1, mod) * comb(N-1, k, mod)
  out %= mod
print(out)

Fixed submission:
N, M, K = map(int, input().split())
out = 0
mod = 998244353

c = 1

for k in range(K+1):
  out += M * pow(M-1, N-k-1, mod) * c
  out %= mod
  c *= (N-k-1) * pow(k+1, mod-2, mod)
  c %= mod
print(out)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = []
for i in range(K):
  d = input()
  A += list(map(int, input()))
print(N - len(set(A)))

Fixed submission:
N, K = map(int, input().split())
A = set()
for _ in range(K):
  d = input()
  A = A.union(set(map(int, input().split())))
print(N - len(A))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

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

count = sum([j-i == A[i-1]+A[j-1] for i, j in itertools.combinations_with_replacement(range(1, N+1), 2)])

print(count)

Fixed submission:
import collections

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

L = [i + A[i] for i in range(N)]
R = [i - A[i] for i in range(N)]

countL = collections.Counter(L)
countR = collections.Counter(R)

print(sum([countL[n] * countR[n] for n in countL.keys()]))

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

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

count = sum([j-i == A[i-1]+A[j-1] for i, j in itertools.combinations_with_replacement(range(1, N+1), 2)])

print(count)

Fixed submission:
import collections

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

L = [i + A[i] for i in range(N)]
R = [i - A[i] for i in range(N)]

countL = collections.Counter(L)
countR = collections.Counter(R)

print(sum([countL[n] * countR[n] for n in countL.keys()]))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

empty = [True]*N

for m in range(M, 0, -1):
  i = 0
  while not(empty[i] and empty[i + m]):
    i += 1
  empty[i] = False
  empty[i+m] = False
  print(i+1, i+m+1)

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

halfPos = -(-N//2)

qPos = halfPos // 2

q3Pos = qPos + halfPos

for m in range(1, M+1):
  if m % 2:
    print(qPos-m//2, qPos+m//2+1)
  else:
    print(q3Pos-m//2, q3Pos+m//2)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
S = input()
N = len(S)
M = [0]
mod = 0
ten = 1
for s in S[::-1]:
  mod += (int(s) * ten) % 2019
  mod %= 2019
  M.append(mod)
  ten *= 10
count = collections.Counter(M)
print(sum([c*(c-1)//2 for c in count.values()]))

Fixed submission:
import collections
S = input()
N = len(S)
M = [0]
mod = 0
ten = 1
for s in S[::-1]:
  mod += (int(s) * ten) % 2019
  mod %= 2019
  M.append(mod)
  ten *= 10
  ten %= 2019 
count = collections.Counter(M)
print(sum([c*(c-1)//2 for c in count.values()]))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
S = input()
N = len(S)
M = [0]
mod = 0
ten = 1
for s in S[::-1]:
  mod += (int(s) * ten) % 2019
  mod %= 2019
  M.append(mod)
  ten *= 10
count = collections.Counter(M)
print(sum([c*(c-1)//2 for c in count.values()]))

Fixed submission:
import collections
S = input()
N = len(S)
M = [0]
mod = 0
ten = 1
for s in S[::-1]:
  mod += (int(s) * ten) % 2019
  mod %= 2019
  M.append(mod)
  ten *= 10
  ten %= 2019 
count = collections.Counter(M)
print(sum([c*(c-1)//2 for c in count.values()]))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
S = input()
N = len(S)
M = [0]
for i in range(N):
  M.append(int(S[:i+1] + '0' * (N-1-i)) % 2019)
count = collections.Counter(M)
print(sum([c*(c-1)//2 for c in count.values()]))

Fixed submission:
import collections
S = input()
N = len(S)
M = [0]
mod = 0
ten = 1
for s in S[::-1]:
  mod += (int(s) * ten) % 2019
  mod %= 2019
  M.append(mod)
  ten *= 10
  ten %= 2019 
count = collections.Counter(M)
print(sum([c*(c-1)//2 for c in count.values()]))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
S = input()
N = len(S)
M = [0]
for i in range(N):
  M.append(int(S[:i+1] + '0' * (N-1-i)) % 2019)
count = collections.Counter(M)
print(sum([c*(c-1)//2 for c in count.values()]))

Fixed submission:
import collections
S = input()
N = len(S)
M = [0]
mod = 0
ten = 1
for s in S[::-1]:
  mod += (int(s) * ten) % 2019
  mod %= 2019
  M.append(mod)
  ten *= 10
  ten %= 2019 
count = collections.Counter(M)
print(sum([c*(c-1)//2 for c in count.values()]))
Buggy python submission (verdict: Runtime Error):
from heapq import *

T = [[10**18 for _ in range(2451)] for _ in range(N)]

act = [[] for _ in range(N)]

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

for i in range(M):
  U, V, A, B = tuple(map(int, input().split()))
  U -= 1
  V -= 1
  act[U] += [(V, A, B)]
  act[V] += [(U, A, B)]

for i in range(N):
  C, D = tuple(map(int, input().split()))
  act[i] += [(i, -C, D)]

que = [(0, 0, S)]

while que:
  (currentT, n, coins) = heappop(que)
  for m, cost, t in act[n]:
    # もし「払える金額で」「最小時間T[移動先][所持金]を更新できるとき」に値を更新、キューに状態を追加。
    if coins >= cost and currentT + t < T[m][min(2450, coins - cost)]:
      T[m][min(2450, coins - cost)] = currentT + t
      heappush(que, (currentT + t, m, min(2450, coins - cost)))

for i in range(1, N):
  print(min(T[i]))

Fixed submission:
from heapq import *

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

T = [[10**18 for _ in range(2451)] for _ in range(N)]

act = [[] for _ in range(N)]

for i in range(M):
  U, V, A, B = tuple(map(int, input().split()))
  U -= 1
  V -= 1
  act[U] += [(V, A, B)]
  act[V] += [(U, A, B)]

for i in range(N):
  C, D = tuple(map(int, input().split()))
  act[i] += [(i, -C, D)]

que = [(0, 0, S)]

while que:
  (currentT, n, coins) = heappop(que)
  for m, cost, t in act[n]:
    # もし「払える金額で」「最小時間T[移動先][所持金]を更新できるとき」に値を更新、キューに状態を追加。
    if coins >= cost and currentT + t < T[m][min(2450, coins - cost)]:
      T[m][min(2450, coins - cost)] = currentT + t
      heappush(que, (currentT + t, m, min(2450, coins - cost)))

for i in range(1, N):
  print(min(T[i]))

Buggy python submission (verdict: Runtime Error):
from heapq import *

T = [[10**18 for _ in range(2451)] for _ in range(N)]

act = [[] for _ in range(N)]

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

for i in range(M):
  U, V, A, B = tuple(map(int, input().split()))
  maxV = max(maxV, A)
  U -= 1
  V -= 1
  act[U] += [(V, A, B)]
  act[V] += [(U, A, B)]

for i in range(N):
  C, D = tuple(map(int, input().split()))
  act[i] += [(i, -C, D)]

que = [(0, 0, S)]

while que:
  (currentT, n, coins) = heappop(que)
  for m, cost, t in act[n]:
    # もし「払える金額で」「最小時間T[移動先][所持金]を更新できるとき」に値を更新、キューに状態を追加。
    if coins >= cost and currentT + t < T[m][min(2450, coins - cost)]:
      T[m][min(2450, coins - cost)] = currentT + t
      heappush(que, (currentT + t, m, min(2450, coins - cost)))

for i in range(1, N):
  print(min(T[i]))

Fixed submission:
from heapq import *

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

T = [[10**18 for _ in range(2451)] for _ in range(N)]

act = [[] for _ in range(N)]

for i in range(M):
  U, V, A, B = tuple(map(int, input().split()))
  U -= 1
  V -= 1
  act[U] += [(V, A, B)]
  act[V] += [(U, A, B)]

for i in range(N):
  C, D = tuple(map(int, input().split()))
  act[i] += [(i, -C, D)]

que = [(0, 0, S)]

while que:
  (currentT, n, coins) = heappop(que)
  for m, cost, t in act[n]:
    # もし「払える金額で」「最小時間T[移動先][所持金]を更新できるとき」に値を更新、キューに状態を追加。
    if coins >= cost and currentT + t < T[m][min(2450, coins - cost)]:
      T[m][min(2450, coins - cost)] = currentT + t
      heappush(que, (currentT + t, m, min(2450, coins - cost)))

for i in range(1, N):
  print(min(T[i]))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

for n in range(N):
  print(A.count(n+1))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
i = -1
A = sorted(A) + [0]
for n in range(N):
  count = 0
  while(A[i+1] == n+1):
    i += 1
    count += 1
  print(count)