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

Fixed submission:
from heapq import heappop, heappush
n, m = map(int, input().split())
lst = [list(map(int, input().split())) for i in range(n)]
lst_f = [[] for i in range(m)]
#lst = sorted(lst, key=lambda x:x[0])
#lst = sorted(lst, key=lambda x:x[1], reverse=True)
cnt = 0
ans = 0
cntup = m
for a, b in lst:
  if a <= m:
    lst_f[a-1].append(b)
  #print(filter(lambda y:y<=m-i, map(lambda x:x[0], lst)))
  #lst2 = list(filter(lambda y:y[1]<=m-i, lst))
avb = [] 
for i in lst_f:
  for j in i:
    heappush(avb, -j)
  if avb != []:
    ans -= heappop(avb)
print(ans)

Buggy submission (verdict: Runtime Error):
#from heapq import heappop, heappush
from numpy import argmin
n, m = map(int, input().split())
lst = [list(map(int, input().split())) for i in range(n)]
lst_f = [[] for i in range(m)]
#lst = sorted(lst, key=lambda x:x[0])
#lst = sorted(lst, key=lambda x:x[1], reverse=True)
cnt = 0
ans = 0
cntup = m
for a, b in lst:
  if a <= m:
    lst_f[a-1].append(b)
  #print(filter(lambda y:y<=m-i, map(lambda x:x[0], lst)))
  #lst2 = list(filter(lambda y:y[1]<=m-i, lst))
avb = [] 
for i in lst_f:
  for j in i:
    avb.append(-j)
  if avb != []:
    ans -= avb.pop(argmin(avb))
print(ans)

Buggy submission (verdict: Runtime Error):
from heapq import heappop, heappush
n, m = map(int, input().split())
lst = [list(map(int, input().split())) for i in range(n)]
lst_f = [[] for i in range(m)]
#lst = sorted(lst, key=lambda x:x[0])
#lst = sorted(lst, key=lambda x:x[1], reverse=True)
cnt = 0
ans = 0
cntup = m
for a, b in lst:
  if a <= m:
    lst_f[a-1].append(b)
  #print(filter(lambda y:y<=m-i, map(lambda x:x[0], lst)))
  #lst2 = list(filter(lambda y:y[1]<=m-i, lst))
avb = [] 
for i in lst_f:
  for j in i:
    avb.append(-j)
  if avb != []:
    ans -= avb.pop(min(avb))
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
lst = [list(map(int, input().split())) for i in range(n)]
lst = sorted(lst, key=lambda x:x[0], reverse=True)
lst = sorted(lst, key=lambda x:x[1], reverse=True)
#print(lst)
cnt = 0
for i in range(m):
  lst = [j for j in lst if j[0]<=m-i]
  #print(filter(lambda y:y<=m-i, map(lambda x:x[0], lst)))
  #lst2 = list(filter(lambda y:y[1]<=m-i, lst))
  #print(lst_f)
  if lst != []:
    #print(lst)
    cnt += lst[0][1]
    remove(lst[0])
  else:
    break
print(cnt)
Problem p02707 (python)

Fixed submission:
N = int(input())
A = [0]*N

for i in [int(s) for s in input().split()]:
    A[i-1] +=1

for j in range(N):
    print(A[j])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [0]*N
for i in [int(s) for s in input().split()]:
    A[i-1] +=1

for j in range(N+1):
    print(A[j])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [0]*N

print(A)
for i in [int(s) for s in input().split()]:
    A[i-1] +=1

for j in range(N+1):
    print(A[j])
Problem p02676 (python)

Fixed submission:
k = int(input())
s = list(map(str, input()))
if len(s) > k:
    for i in range(k):
        print(s[i], end="")
    print("...")
else:
    for i in s:
        print(i, end='')
    print()

Buggy submission (verdict: Runtime Error):
k = int(input())
s = list(map(str, input()))
if len(s) > k:
    for i in range(k):
        print(s[i], end="")
    print("...")
else:
    for i in s:
        print(s[i], end='')
    print()
Problem p02711 (python)

Fixed submission:
l = list(map(int, input()))
if 7 in l:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
l = list(map(int, input()))
if 7 in list:
  print("Yes")
else:
  print("No")
Problem p02753 (python)

Fixed submission:
s = input()
if s == "AAA" or s == "BBB":
    print("No")
else:
    print("Yes")

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

if s == "AAA" || s == "BBB":
  print("No")
else:
  print("Yes")
Problem p02688 (python)

Fixed submission:
N, K = map(int, input().split())
A = [0] * N

for i in range(K):
    d = int(input())
    targets = list(map(int, input().split()))
    for j in range(d):
        index = targets[j] -1
        A[index] = 1

count = 0
for i in range(N):
    if A[i] == 0:
        count += 1

print(count)

Buggy submission (verdict: Runtime Error):

N, K = map(int, input().split())
A = [0] * N

for i in range(K):
    d = int(input())
    targets = list(map(int, input().split()))
    for j in range(d):
        index = targets[j-1]
        A[index] = 1

count = 0
for i in range(N):
    if A[i] == 0:
        count += 1

print(count)
Problem p02723 (python)

Fixed submission:
val = input()
if val[2] == val[3] and val[4] == val[5]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
val = input()
if val[2] == val[3] && val[4] == val[5]:
    print("Yes")
else:
    print("No")
Problem p02676 (python)

Fixed submission:
k = int(input())
s = input()
 
if len(s) <= k:
  print(s)
  
else:
  print(s[:k] + "...")

Buggy submission (verdict: Runtime Error):
k = int()
s = input()
 
if len(k) <= k:
  print(s)
  
else:
  print(s[:k] + "...")

Buggy submission (verdict: Runtime Error):
k = input()
s = int(input())
 
if len(k) <= k:
  print(s)
  
else:
  print(s[:k] + "...")

Buggy submission (verdict: Runtime Error):
k = int()
s = int(input())
 
if len(s) <= k:
  print(s)
  
else:
  print(s[:k] + "...")

Buggy submission (verdict: Runtime Error):
k = int(input())
s = int()

if len(s) <= s:
  print(k)
  
else:
  print(k[:s] + "...")
Problem p02693 (python)

Fixed submission:
K = int(input())
A,B = map(int,input().split())
list = []
n = range(A,B+1)
ind = range(B-A+1)
for i in n:
    list.append(i)
counter = 0

for i in ind:
    if list[i] % K == 0:
        counter += 1
    else:
        counter += 0
if counter >= 1:
    print("OK")
else:
    print("NG")

Buggy submission (verdict: Runtime Error):
A,B,N = map(int,input().split())
a = 0

for x in range(N+1):
    if (int((A*x)/B)-A*int(x/B)) > a:
        a = (int((A*x)/B)-A*int(x/B))
print(a)

Buggy submission (verdict: Runtime Error):
K = int(input())
A,B = map(int,input().split())

n = range(A,B+1)
ind = range(B-A)
for i in n:
    list.append(i)
counter = 0

for i in ind:
    if list[i]%K == 0:
        counter += 1
    else:
        counter += 0
if counter > 0:
    print("OK")
else:
    print("NG")
Problem p02699 (python)

Fixed submission:
S,W = map(int,input().split())
if S>W:
  print("safe")
else:
  print("unsafe")

Buggy submission (verdict: Runtime Error):
N = int(input())
S = [int(input()) for _ in N]
print(len(set(s)))

Buggy submission (verdict: Runtime Error):
A,B,C,D = map(int,input().split())
while A > 0 and C > 0:
    C -= B
    if C <= 0:
        print("Yes")
    else:
        A -= D
        if A <= 0:
            print("No")
Problem p02701 (python)

Fixed submission:
N = int(input())
S = [input() for _ in range(N)]
print(len(set(S)))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = [input() for _ in range(N)]
print(len(set(s)))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = [int(input()) for _ in N]
print(len(set(s)))

Buggy submission (verdict: Runtime Error):
N = int(input())
S_list = list(map(str, input().split()))

for i in range(N):
  S_list.remove(S_list[i])
  N -= (N-len(S_list)-1)
  
print(N)
Problem p02695 (python)

Fixed submission:
n,m,q=map(int,input().split(" "))
arr=[list(map(int, input().split(" "))) for i in range(q)]
ans=0
for i1 in range(1,m+1):
	for i2 in range(i1,m+1):
		for i3 in range(i2, m+1):
			for i4 in range(i3, m+1):
				for i5 in range(i4, m+1):
					for i6 in range(i5, m+1):
						for i7 in range(i6, m+1):
							for i8 in range(i7, m+1):
								for i9 in range(i8, m+1):
									for i10 in range(i9, m+1):
										tmp=0
										arrs=[0,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10]
										for a,b,c,d in arr:
											if arrs[b]-arrs[a]==c:
												tmp+=d
										ans=max(ans,tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,q=map(int,input().split(" "))
arr=[list(map(int, input().split(" "))) for i in range(q)]
ans=0
for i1 in range(1,m+1):
	for i2 in range(i1,m+1):
		for i3 in range(i2, m+1):
			for i4 in range(i3, m+1):
				for i5 in range(i4, m+1):
					for i6 in range(i5, m+1):
						for i7 in range(i6, m+1):
							for i8 in range(i7, m+1):
								for i9 in range(i8, m+1):
									for i10 in range(i9, m+1):
										tmp=0
										arrs=[i1,i2,i3,i4,i5,i6,i7,i8,i9,i10]
										for a,b,c,d in arr:
											if arrs[b]-arrs[a]==c:
												tmp+=d
										ans=max(ans,tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,q=map(int,input().split(" "))
arr=[list(map(int, input().split(" "))) for i in range(q)]
ans=0
for i1 in range(1,m+1):
	for i2 in range(i1,m+1):
		for i3 in range(i2, m+1):
			for i4 in range(i3, m+1):
				for i5 in range(i4, m+1):
					for i6 in range(i5, m+1):
						for i7 in range(i6, m+1):
							for i8 in range(i7, m+1):
								for i9 in range(i8, m+1):
									for i10 in range(i9, m+1):
										tmp=0
										arrs=[i1,i2,i3,i4,i5,i6,i7,i8,i9,i10]
										for a,b,c,d in arr:
											if arrs[b]-arrs[a]==c:
												tmp+=d
										ans=max(ans,tmp)
print(ans)
Problem p02729 (python)

Fixed submission:
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]
  
n,m =map(int, input().split())
if n==m==1:
    print(0)
elif n==1 or n==0:
    print(cmb(m,2))
elif m==1 or m==0:
    print(cmb(n,2))
else:
    print(cmb(n,2)+cmb(m,2))

Buggy submission (verdict: Runtime Error):
n,m =map(int, input().split())
if n==m==1:
    print(0)
elif n==1 or n==0:
    print(cmb(m,2))
elif m==1 or m==0:
    print(cmb(n,2))
else:
    print(cmb(n,2)+cmb(m,2))

Buggy submission (verdict: Runtime Error):
n,m =map(int, input().split())
if n==m==1:
    print(0)
elif n==1:
    print(cmb(m,2))
elif m==1:
    print(cmb(n,2))
else:
    print(cmb(n,2)+cmb(m,2))
Problem p03631 (python)

Fixed submission:
a,b,c=input()
print("Yes" if a==c else "No")

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
if b<c or d<a:
    print(0)
elif a<=c<d<=b:
    print(d-c)
elif c<a<b<d:
    print(b-a)
else:
    print(b-c)

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
if b<c or d<a:
    print("0")
elif a<c<d<b:
    print(d-c)
elif c<a<b<d:
    print(b-a)
else:
    print(b-c)
Problem p02790 (python)

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

s1 = ''
s2 = ''

for i in range(b):
  s1 += str(a)

for i in range(a):
  s2 += str(b)
  
if a < b:
  print(s1)
else:
  print(s2)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())

s1 = ''
s2 = ''

for i in range(a):
  s1 += str(a)

for i in range(b):
  s2 += str(b)
  
if a < b:
  print(s1)
else:
  print(s2)
Problem p02819 (python)

Fixed submission:
import random

def is_prime(n):
    if n == 2: return True
    if n == 1 or n & 1 == 0: return False

    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    for k in range(100):
        a = random.randint(1, n - 1)
        t = d
        y = pow(a, t, n)

        while t != n - 1 and y != 1 and y != n - 1:
            y = (y * y) % n
            t <<= 1

        if y != n - 1 and t & 1 == 0:
            return False

    return True

a = int(input())

while True:
 if is_prime(a) == 1:
  break
 a = a + 1

print(a)

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

def is_prime3(q,k=50):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    for i in xrange(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True


a = int(input())
while True:
 if is_prime3(a) == 1:
  break
 a = a + 1

print(a)

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

def is_prime3(q,k=50):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in xrange(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True


a = int(input())
while True:
 if is_prime(a) == 1:
  break
 a = a + 1

print(a)
Problem p02879 (python)

Fixed submission:

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

Buggy submission (verdict: Runtime Error):
#include <iostream>
using namespace std;

int main(){
 int a,b;
 cin >> a >> b;
 if(a <= 9 && b <= 9){
  cout << a * b << endl;
 }else{
  cout << -1 << endl;
 }
 return 0;
}
Problem p03075 (python)

Fixed submission:
# abc123_a.py
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

l=[]
# l=[a,b,c,d,e]
l.append(a)
l.append(b)
l.append(c)
l.append(d)
l.append(e)

size=len(l)
for i in range(size):
 for j in range(i,size):
  if i == j:
   continue
  if (l[j]-l[i]) > k:
   print(":(")
   exit()

print("Yay!")

Buggy submission (verdict: Runtime Error):
# abc123_a.py
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

l=[]
# l=[a,b,c,d,e]
l.append(a)
l.append(b)
l.append(c)
l.append(d)
l.append(e)

size=len(l)
for i in range(size):
 for j in range(i,size):
  if i == j:
   continue
  if (l[j]-l[i]) > k:
   print(":(")
   exit(-1)

print("Yay!")

Buggy submission (verdict: Runtime Error):
# abc123_a.py
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

l=[a,b,c,d,e]
size=len(l)
for i in range(size):
 for j in range(i,size):
  if i == j:
   continue
  if (l[j]-l[i]) > k:
   print(":(")
   exit(-1)

print("Yay!")

Buggy submission (verdict: Runtime Error):
# abc123_a.py
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

l=[a,b,c,d,e]
size=len(l)
for i in range(size-1):
 if (l[i+1]-l[i]) > k:
  print(":(")
  exit(-1)

print("Yay!")

Buggy submission (verdict: Runtime Error):
# abc123_a.py
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

l=[a,b,c,d,e]
size=len(l)
for i in range(size):
 for j in range(i,size):
  if i == j:
   continue
  if (l[j]-l[i]) > k:
   print(":(")
   exit(-1)

print("Yay!")
Problem p03221 (python)

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

for i in range(m):
    l[i].append(i)
l = sorted(l,key=lambda x: (x[0],x[1]))

l[0].append(1)
for i in range(1,m):
    if l[i][0]!=l[i-1][0]:
        l[i].append(1)
    else:
        l[i].append(l[i-1][3]+1)

for i in range(m):
    l[i].append(str(l[i][0]).zfill(6) + str(l[i][3]).zfill(6))

l=sorted(l,key=lambda x:(x[2]))

for i in range(m):
    print(l[i][4])

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

for i in range(m):
    l[i].append(i)
l = sorted(l,key=lambda x: (x[0],x[1]))

l[0].append(1)
for i in range(1,m):
    if l[i][0]!=l[i-1][0]:
        l[i].append(1)
    else:
        l[i].append(l[i-1][3]+1)

for i in range(m):
    l[i].append(str(l[i][0]).zfill(6) + l[i][3].zfill(6))

l=sorted(l,key=lambda x:(x[2]))

for i in range(m):
    print(l[i][4])

Buggy submission (verdict: Runtime Error):
n,m=map(int, input().split())
l=[input().split() for i in range(m)]
m={}
for j in range(len(l)):
    if l[j][0] not in m.keys():
        m[l[j][0]]=[]
    m[l[j][0]].append(l[j][1])
lab=[0]*(n+1)
for k in m.keys():
    m[k] = sorted(m[k], reverse=False)
    p='0'*(6-len(k))+k
    for h in range(len(m[k])):
        q='0'*(6-len(str(h+1)))+str(h+1)
        key=l.index([k,m[k][h]])
        lab[key]=p+q
for v in lab:
    print(v)
Problem p02847 (python)

Fixed submission:
s = input()

d = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']

print(7- d.index(s))

Buggy submission (verdict: Runtime Error):

s = input()

d = ['SUN', 'MON', 'TUE', 'WEN', 'THU', 'FRI', 'SAT']

if s == 'SUN':
  print(0)
else:
  print(7- d.index(s))

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

d = ['SUN', 'MON', 'TUE', 'WEN', 'THU', 'FRI', 'SAT']

index = 7- d.index(s)

print(index)
Problem p02699 (python)

Fixed submission:
def main():
    num = input().split()
    if int(num[0]) <= int(num[1]):
        print("unsafe")
    else:
        print("safe")

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys

def main():
    args = sys.argv
    if int(args[0]) <= int(args[1]):
        print("unsafe")
    else:
        print("safe")

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys

def main():
    args = sys.argv
    if int(args[1]) <= int(args[2]):
        print("unsafe")
    else:
        print("safe")

if __name__ == "__main__":
    main()
Problem p02831 (python)

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

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

print((A*B)//gcd(A, B))

Buggy submission (verdict: Runtime Error):
import math

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

print((A*B)//math.gcd(A, B))
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print('red')

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

stack = [[] for _ in range(n+1)]
stack[0].append(1)
for i in range(n-1):
  a,b = map(int, input().split())
  stack[a].append(b)

ans = [0] * n
pool = {}
def dfs(cur, num):
	ans[cur-1] += num
	if len(stack[cur]) <= 0:
		return
	for c in stack[cur]:
		dfs(c, num)

for i in range(q):
  p, x = map(int, input().split())
  pool[p] = pool.get(p, 0) + x
for k, v in pool.items():
  dfs(k, v)
print(*ans)

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(n-1)]
PX = [list(map(int, input().split())) for _ in range(q)]

stack = [[] for _ in range(n+1)]
stack[0].append(1)
for i in range(n-1):
	stack[AB[i][0]].append(AB[i][1])

ans = [0] * n
pool = {}
def dfs(cur, num):
	ans[cur-1] += num
	if len(stack[cur]) <= 0:
		return
	for c in stack[cur]:
		dfs(c, num)

for px in PX:
	pool[px[0]] = pool.get(px[0], 0) + px[1]
for k, v in pool.items():
  	dfs(k, v)
print(*ans)
Problem p02935 (python)

Fixed submission:
n = int(input())
V = sorted(list(map(int, input().split())))
ans = V[0]
for i in range(1, n):
  ans = (V[i] + ans)/2

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
V = sorted(list(map(int, input().split())))
print(ans)
for i in range(1, n):
  ans = (V[i] + ans)/2

print(ans)
Problem p02948 (python)

Fixed submission:
import heapq
n, m = map(int, input().split())
jobs = [[] for _ in range(m)]

for i in range(n):
  a, b = map(int, input().split())
  if a > m:
    continue
  jobs[m-a].append(b)

que = []#候補入れ
ans = 0
for i in range(m-1, -1, -1):
  for wage in jobs[i]:
    heapq.heappush(que, wage*-1)
  if len(que):
    ans += heapq.heappop(que)*-1
    
print(ans)

Buggy submission (verdict: Runtime Error):
import heapq
n, m = map(int, input().split())
jobs = [[] for _ in range(n)]

for i in range(n):
  a, b = map(int, input().split())
  if a > m:
    continue
  jobs[m-a].append(b)

que = []#候補入れ
ans = 0
for i in range(m-1, -1, -1):
  for wage in jobs[i]:
    heapq.heappush(que, wage*-1)
  if len(que):
    ans += heapq.heappop(que)*-1
    
print(ans)
Problem p02990 (python)

Fixed submission:
from operator import mul
from functools import reduce
n,k = map(int,input().split())
mod = 10**9+7

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

for l in range(1,k+1):
  if n-k+1 < l:
    print(0)
    continue
  a = cmb(k-1,l-1)
  b = cmb(n-k+1,l)
  print(a*b%mod)

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce
n,k = map(int,input().split())
mod = 10**9+7

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

for l in range(1,k+1):
  a = cmb(k-1,l-1)
  b = cmb(n-k+1,l)
  print(a*b%mod)
Problem p03011 (python)

Fixed submission:
times = list(map(int, input().strip().split()))

times.sort()
print(times[0] + times[1])

Buggy submission (verdict: Runtime Error):
#nn
N,M=map(int,input().split())
a = [int(input()) for _ in range(M)]
dp = [0]*(N+1)
j = 0
dp[0] = 1
mod = 10**9+7
for i in range(1, N+1):
    if j < M and i == a[j]:
        j += 1
    elif i == 1:
        dp[i] = 1
    else:
        dp[i] = (dp[i-1]+dp[i-2]) % mod
print(dp[N])
Problem p03013 (python)

Fixed submission:
N,M=map(int,input().split())
a = [int(input()) for _ in range(M)]
dp = [0]*(N+1)
j = 0
dp[0] = 1
mod = 10**9+7
for i in range(1, N+1):
    if j < M and i == a[j]:
        j += 1
    elif i == 1:
        dp[i] = 1
    else:
        dp[i] = (dp[i-1]+dp[i-2]) % mod
print(dp[N])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(input()) for i in range(M)]
dp = [0]*(N+1)
div = 10**9 + 7
#dp[x] = dp[x-1] + dp[x-2]になる
dp[0] = 1
dp[1] = 1 if a[0] != 1 else 0

for x in range(2, N+1):
  if (x-1 in a and x-2 in a) or (x in a):
    dp[x] = 0
  elif x-1 in a:
    dp[x] = dp[x-2]
  elif x-2 in a:
    dp[x] = dp[x-1]
  else:
    dp[x] = dp[x-1]+dp[x-2]
  dp[x] = dp[x] % div
print(dp[-1]%div)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(input()) for i in range(M)]
dp = [0]*(N+1)
div = 10**9 + 7
#dp[x] = dp[x-1] + dp[x-2]になる
dp[0] = 1
dp[1] = 1 if a[0] != 1 else 0

for x in range(2, N+1):
  if (x-1 in a and x-2 in a) or (x in a):
    dp[x] = 0
  elif x-1 in a:
    dp[x] = dp[x-2]
  elif x-2 in a:
    dp[x] = dp[x-1]
  else:
    dp[x] = dp[x-1]+dp[x-2]

print(dp[-1]%div)
Problem p03221 (python)

Fixed submission:
N, M = map(int, input().split())
D = [[] for i in range(N)]
 
for i in range(M):
  p, y = map(int, input().split())
  D[p-1].append((y, i)) 

ans = [None]*M
 
for i, d in enumerate(D): 
  d.sort()
  for k, (y, j) in enumerate(d): 
    ans[j] = str(i+1).zfill(6) + str(k+1).zfill(6)
print(*ans, sep = '\n')

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
PY = [list(map(int, input().split())) for _ in range(m)]
def make_id(num):
  s = len(str(num))
  add_zero = '0'*(6-s)
  return add_zero + str(num)

P = [[] for _ in range(m)]
for i in range(len(PY)):
  P[PY[i][0]-1].append(PY[i][1])
  P[PY[i][0]-1].sort()
for i in range(len(PY)):
  p,y=PY[i][0],PY[i][1]
  ord = P[p-1].index(y)+1
  print(make_id(p)+make_id(ord))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
PY = [list(map(int, input().split())) for _ in range(m)]
def make_id(num):
  s = len(str(num))
  add_zero = '0'*(6-s)
  return add_zero + str(num)

P = [[] for _ in range(m)]
for i in range(len(PY)):
  P[PY[i][0]-1].append(PY[i][1])
  P[PY[i][0]-1].sort()
print(P)
for i in range(len(PY)):
  p,y=PY[i][0],PY[i][1]
  ord = P[p-1].index(y)+1
  print(make_id(p)+make_id(ord))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
PY = [list(map(int, input().split())) for _ in range(m)]
def make_id(num):
  s = len(str(num))
  add_zero = '0'*(6-s)
  return add_zero + str(num)

P = [[] for _ in range(m)]
ans = []
sort_P = []
for i in range(len(PY)):
  P[PY[i][0]-1].append(PY[i][1])
for i in range(len(P)):
  sort_P.append(sorted(P[i]))
for i in range(len(PY)):
  p,y=PY[i][0],PY[i][1]
  ord = sort_P[p-1].index(y)+1
  print(make_id(p)+make_id(ord))