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

Fixed submission:
num = int(input())
A = input().split(" ")
B = input().split(" ")
C = input().split(" ")
result = 0
 
for i in range(num):
  result += int(B[int(A[i])-1])
  if i > 0 and (int(A[i]) - int(A[i-1]) == 1):
    result += int(C[int(A[i])-2])
 
print(result)

Buggy submission (verdict: Runtime Error):
num = int(input())
A = input().split(" ")
B = input().split(" ")
C = input().split(" ")
result = 0

for i in range(num):
  result += int(B[int(A[i])])
  if i > 0 and (int(A[i]) - int(A[i-1]) == 1):
    result += int(C[int(A[i-1])

print(result)
Problem p02935 (python)

Fixed submission:
num = int(input())
lines = input().split(" ")
int_lines = [int(i) for i in lines]
int_lines.sort()
count = 1
 
if num == 2:
  result = (int_lines[0] + int_lines[1]) / 2
  print(result)
else:
  itr = iter([j for j in int_lines])
  for j in itr:
    if count == 1:
        x = j
        count += 1
    elif count == 2:
        y = j
        count += 1
    else:
        x = (x + y) / 2
        y = j
        count += 1
  x = (x + y) / 2
    
  print(x)

Buggy submission (verdict: Runtime Error):
num = int(input())
lines = input().split(" ")
int_lines = [int(i) for i in lines]
int_lines.sort()
set_lines = set(int_lines)
count = 1
 
if num == 2:
  result = (int_lines[0] + int_lines[1]) / 2
  print(result)
else:
  itr = iter([int(j) for j in list(set_lines)])
  for j in itr:
    if count == 1:
        x = j
        count += 1
    elif count == 2:
        y = j
        count += 1
    else:
        x = (x + y) / 2
        y = j
        count += 1
  x = (x + y) / 2
    
  print(x)

Buggy submission (verdict: Runtime Error):
num = int(input())
lines = input().split(" ")
int_lines = [int(i) for i in lines]
int_lines.sort()
set_lines = set(int_lines)
count = 1

if num == 2:
  result = (int_lines[0] + int_lines[1]) / 2
  print(result)
elif len(set_lines) == 1:
  print(set_lines[0])
elif len(set_lines) == 2:
  result = (set_lines[0] + set_lines[1]) / 2
  print(result)
else:
  itr = iter([int(j) for j in list(set_lines)])
  for j in itr:
    if count == 1:
        x = j
        count += 1
    elif count == 2:
        y = j
        count += 1
    else:
        x = (x + y) / 2
        y = j
        count += 1
  x = (x + y) / 2
    
  print(x)

Buggy submission (verdict: Runtime Error):
num = int(input())
lines = input().split(" ")
int_lines = [int(i) for i in lines]
int_lines.sort()
set_lines = set(int_lines)
count = 1

if num == 2:
  result = (int(lines[0]) + int(lines[1])) / 2
  print(result)
elif len(set_lines) == 1:
  print(int(set_lines[0]))
elif len(set_lines) == 2:
  result = (int(set_lines[0]) + int(set_lines[1])) / 2
  print(result)
else:
  itr = iter([int(j) for j in list(set_lines)])
  for j in itr:
    if count == 1:
        x = j
        count += 1
    elif count == 2:
        y = j
        count += 1
    else:
        x = (x + y) / 2
        y = j
        count += 1
  x = (x + y) / 2
    
  print(x)
Problem p02951 (python)

Fixed submission:
numbers = input().split(" ")
A = int(numbers[0])
B = int(numbers[1])
C = int(numbers[2])

amount = C - (A - B)
if amount < 0:
  amount = 0
print(amount)

Buggy submission (verdict: Runtime Error):
numbers = input().split(" ")
A = numbers[0]
B = numbers[1]
C = numbers[2]

amount = C - (A - B)
print(amount)
Problem p03075 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
arr = [a,b,c,d,e]
bool = True

for i in range(len(arr)):
  for j in range(len(arr)):
    if i != j and abs(arr[i] - arr[j]) > k:
      bool = False
      break;
      
if bool:
  print("Yay!")
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
arr = [a,b,c,d,e]
bool = True

for i in range(len(arr)):
  for j in range(len(arr)):
    if i != j && abs(arr[i] - arr[j]) > k:
      bool = False
      break;
      
if bool:
  print("Yay!")
else:
  print(":(")
Problem p02831 (python)

Fixed submission:
import math
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

(a, b) = [int(e) for e in input().split(" ")[:2]]
print(int(lcm(a, b)))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
import math

def lcm(x, y):
    return (x * y) / math.gcd(x, y)

(a, b) = [int(e) for e in input().split(" ")][:2]
print(int(lcm(a, b)))
Problem p02831 (python)

Fixed submission:
import fractions
l = input().split()
a = int(l[0])
b = int(l[1])

print(a * b // fractions.gcd(a, b))

Buggy submission (verdict: Runtime Error):
l = input().split()
a = int(l[0])
b = int(l[1])

def gcd(ac, bc):
  x = max(ac, bc)
  y = min(ac, bc)

  while x%y != 0:
    z = x%y
    x = y
    y = z
  else:
    return z

print(a * b // gcd(a, b))
Problem p03107 (python)

Fixed submission:
S = list(input())

last = S.pop(0)
stack = [last]
can_pop = True
cnt = 0
for s in S:
    if last != s and can_pop:
        stack.pop()
        if len(stack) == 0:
            can_pop = False
        # stack.append(s) 読み捨て
        cnt += 2
    else:
        stack.append(s)
        last = s
        can_pop = True

print(cnt)

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

last = S.pop(0)
stack = [last]
cnt = 0
for s in S:
    if last != s:
        stack.pop()
        # stack.append(s) 読み捨て
        cnt += 2
    else:
        stack.append(s)
        last = s

print(cnt)
Problem p02753 (python)

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

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

x=int(n/(a+b))
if x*(a+b)+a <= n:
  print(a*(x+1))
else:
  print(n-b*x)

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

x=int(n/(a+b))
if x*(a+b)+a <= n:
	print(a*(x+1))
else:
	print(n-b*x)

Buggy submission (verdict: Runtime Error):
n=input()
if n=='AAA' or n=='BBB':
  print('No')
else:
  pritn('Yes')

Buggy submission (verdict: Runtime Error):
n=input()
if n=='AAA' or n=='BBB':
	print('No')
else:
	pritn('Yes')

Buggy submission (verdict: Runtime Error):
n=input()
if n=='AAA' or n=='BBB':
	print('No')
else:
	pritn('Yes')
Problem p02754 (python)

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

x=int(n/(a+b))
if x*(a+b)+a <= n:
	print(a*(x+1))
else:
	print(n-b*x)

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

x=int(n/(a+b))
if x*(a+b)+a <= n:
	print(a*(x+1))
else:
	print(n-b*x)
Problem p02933 (python)

Fixed submission:
s=[]
s.append(int(input()))
s.append(str(input()))
if s[0] >= 3200:
	print(s[1])
else:
  print("red")

Buggy submission (verdict: Runtime Error):

s = [input() for i in range(2)]
if s[0] >= 3200:
	print(s[1])
else:
  print("red")
Problem p02785 (python)

Fixed submission:
n,k=map(int,input().split())
a=list(int(x) for x in input().split())
a.sort()
s=0
if n <= k:
	print(0)
else:
		s = sum(a[:n-k])
		print(s)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(int(x) for x in input().split())
s=0
if k <= n:
	print(s)
else:
	i for i in range(n-k):
		s += i
		print(s)
Problem p02879 (python)

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

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
for i in range(1,10):
    for j in range(1,i+1):
        a.append(i*j)
if n in a:
  print("Yes")
else:
  print("No")
Problem p03207 (python)

Fixed submission:
n=int(input())
p=[]
for _ in range(n):
	x=int(input())
	p.append(x)
ans=sum(p)-(max(p) // 2)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
p=[]
for_ in range(n):
	x=int(input())
	p.append(x)
ans=sum(p)-(max(p) // 2)
print(ans)
Problem p03265 (python)

Fixed submission:
x1,y1,x2,y2=map(int,input().split())
dx=abs(x1-x2)
dy=abs(y1-y2)
if x1<x2 and y1<=y2:
    x3=x2-dy
    y3=y2+dx
    x4=x3-dx
    y4=y3-dy
elif x1>=x2 and y1<y2:
    x3=x2-dy
    y3=y2-dx
    x4=x3+dx
    y4=y3-dy
elif x1>x2 and y1>=y2:
    x3=x2+dy
    y3=y2-dx
    x4=x3+dx
    y4=y3+dy
elif x1<=x2 and y1>y2:
    x3=x2+dy
    y3=y2+dx
    x4=x3-dx
    y4=y3+dy
else:
    print("NA")
print(x3,y3,x4,y4)

Buggy submission (verdict: Runtime Error):
x1,x2,x3,x4=map(int,input().split())
dx=abs(x1-x2)
dy=abs(y1-y2)
if x1<x2 and y1<=y2:
    x3=x2-dy
    y3=y2+dx
    x4=x3-dx
    y4=y3-dy
    #ok
elif x1>=x2 and y1<y2:
    x3=x2-dy
    y3=y2-dx
    x4=x3+dx
    y4=y3-dy
    #ok
elif x1>x2 and y1>=y2:
    x3=x2+dy
    y3=y2-dx
    x4=x3+dx
    y4=y3+dy
elif x1<=x2 and y1>y2:
    x3=x2+dy
    y3=y2+dx
    x4=x3-dx
    y4=y3+dy
else:
    print("NA")
print(x3,y3,x4,y4)
Problem p03317 (python)

Fixed submission:
n,k=map(int,input().split())
*a,=map(int,input().split())
print((n-2)//(k-1)+1)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
*a,=map(int,input().split())
print(((n-2)//(k-1)+1)
Problem p03745 (python)

Fixed submission:
n=int(input())
*a,=map(int,input().split())
cnt=0
mode=0
for i in range(n-1):
    if mode==0:
        if a[i]<a[i+1]:
            cnt+=1
            mode="inc"
        elif a[i]>a[i+1]:
            cnt+=1
            mode="dec"
    if a[i]<a[i+1]:
        if mode=="inc":
            pass
        else:
            mode=0
    elif a[i]>a[i+1]:
        if mode=="dec":
            pass
        else:
            mode=0
if mode==0:
    print(cnt+1)
else:
    print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
*a,=map(int,input().split())
cnt=0
mode=0
for i in range(n-1):
    if mode==0:
        if a[i]<a[i+1]:
            cnt+=1
            mode="inc"
        elif a[i]>a[i+1]:
            cnt+=1
            mode="dec"
    if a[i]<a[i+1]:
        if mode=="inc":
            pass
        else:
            mode=0
    elif a[i]>a[i+1]:
        if mode=="dec":
            pass
        else:
            mode=0
if mode==0:
    print(cnt+1)
else:
    prnt(cnt)
Problem p02753 (python)

Fixed submission:
s=input()
print("Yes" if len(set(s))==2 else "No")

Buggy submission (verdict: Runtime Error):
s=input()
print("Yes" if lens(set(s))==1 else "No")
Problem p02754 (python)

Fixed submission:
n,a,b=[int(v) for v in input().split()]
try:
    loop=n//(a+b)
except:
    loop=0
try:
    remainder=n%(a+b)
except:
    remainder=0
print(loop*a+min(remainder,a))

Buggy submission (verdict: Runtime Error):
n,a,b=input().split()
try:
    loop=n//(a+b)
except:
    loop=0
try:
    remainder=n%(a+b)
except:
    remainder=0
print(loop*a+min(reminder,a)
Problem p02891 (python)

Fixed submission:
def cad(s, k):
    if len(s) == 1:
        return k // 2
    if len(set(s)) == 1:
        return len(s) * k // 2

    l = list(s)

    count = 0
    new_l = l.copy()

    first_len = 1
    first_block = True
    for i, c in enumerate(s[1:]):
        if c == new_l[i]:
            new_l[i + 1] = 0
            count += 1

        if first_block:
            if c == s[0]:
                first_len += 1
            else:
                first_block = False

    result = count * k

    if new_l[0] == new_l[-1] and first_len % 2 == 1:
        result += k - 1

    return result


s = input()
k = int(input())
print(cad(s, k))

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

l = list(s)

count = 0
new_l = l.copy()

for i, c in enumerate(s[1:]):

    if c == new_l[i]:
        new_l[i + 1] = 0
        count += 1

result = count * k

if new_l[0] == new_l[-1] and s[0]!=s[1]:
    result = +k - 1
print(result)
Problem p03135 (python)

Fixed submission:
T, X = [int(_) for _ in input().split()]
T, X = int(T), int(X)
time = T/X
print(time)

Buggy submission (verdict: Runtime Error):
import sys

T, X = sys.argv[1], sys.argv[2]
T, X = int(T), int(X)
time = T/X
print(time)
Problem p02831 (python)

Fixed submission:
A, B  = (int(i) for i in input().split())

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
  
print((A * B) // gcd(A, B))

Buggy submission (verdict: Runtime Error):
A, B  = (int(i) for i in input().split())

import math

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

Fixed submission:
N = int(input()) 
W = list(map(int, input().split()))
x = sum(W)
 
for i in range(N):
	S_1 = sum(W[:i+1])
	S_2 = sum(W) - S_1
	x_current = abs(S_2 - S_1)
	if x_current < x:
		x = x_current

print(x)

Buggy submission (verdict: Runtime Error):
N = int(input()) 
W = list(map(int, input().split()))
x = sum(W)

for i in range(N):
	S_1 = sum(W[:i+1])
	S_2 = sum(W) - S_1
    x_current = abs(S_2 - S_1)
    if x_current < x:
      x = x_current

print(x)
Problem p02879 (python)

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

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
if (1 <= A <= 9) and (1 <= B <= 9):
    print(a * b)
else:
    print(-1)
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()))
res = 0
res += B[A[0]-1]
for i in range(1, N):
    res += B[A[i]-1]
    if A[i - 1] == A[i] - 1:
        res += C[A[i - 1]-1]

print(res)

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()))
res = 0
res += B[A[0]]
for i in range(1, N):
    res += B[A[i]-1]
    if A[i - 1] == A[i] - 1:
        res += C[A[i - 1]-1]

print(res)

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()))
res = 0
res += B[A[0]-1]
for i in range(1, N):
    res += B[A[i]-1]
    if A[i - 1] == A[i] - 1:
        res += C[A[i - 1]]

print(res)

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()))
res = 0
res += B[0]
for i in range(1, N):
    res += B[i]
    if A[i - 1] = A[i] - 1:
        res += C[i - 1]

print(res)
Problem p02933 (python)

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

Buggy submission (verdict: Runtime Error):
a = int(input())
s = input()
if a >= '3200':
    print(s)
else:
    print('red')
Problem p02990 (python)

Fixed submission:
def fuctorial(n):
    ret = 1
    while n > 0:
        ret *= n
        n -= 1
    return ret

def combination(n, k, MOD):
    return (fuctorial(n) // (fuctorial(n-k) * fuctorial(k)))%MOD


def main():
    N, K = map(int, input().split())
    MOD = 10**9+7
    for i in range(1, K + 1):
        if i > N - K + 1:
            print(0)
        else:
            print(combination(N - K + 1, i,MOD) * combination(K - 1, i - 1,MOD) % MOD)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from math import factorial

def combination(n, k, MOD):
    return(factorial(n) // (factorial(n-k) * factorial(k))) % MOD


def main():
    N, K = map(int, input().split())
    MOD = 10**9+7
    for i in range(1,K+1):
        print(combination(N - K + 1, i,MOD) * combination(K - 1, i - 1,MOD) % MOD)

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

Fixed submission:
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    BC = []

    D = []
    for i in range(M):
        b, c = map(int, input().split())
        BC.append((b, c))
    BC.sort(key=lambda x: x[1], reverse=True)
    ld = 0
    for b, c in BC:
        D += [c] * b
        ld += b
        if ld > N:
            break
    
    res = 0
    A.sort()
    for i in range(N):
        if i < ld:
            res += max(A[i], D[i])
        else:
            res += A[i]
    

    print(res)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    BC = []

    D = []
    for i in range(M):
        b, c = map(int, input().split())
        BC.append((b, c))
    BC.sort(key=lambda x: x[1], reverse=True)
    ld = 0
    for b, c in BC:
        D += [c] * b
        ld += b
        if ld > N:
            break
    
    res = 0
    A.sort()
    for i in range(N):
        res += max(A[i], D[i])
        

    res = 0
    for i in range(N):
        if i < ld:
            res += max(A[i], D[i])
        else:
            res += A[i]
    

    print(res)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    BC = []

    D = []
    for i in range(M):
        b, c = map(int, input().split())
        BC.append((b, c))
    BC.sort(key=lambda x: x[1], reverse=True)
    ld = 0
    for b, c in BC:
        D += [c] * b
        ld += b
        if ld > N:
            break
    
    res = 0
    A.sort()
    for i in range(N):
        res += max(A[i], D[i])
        

    res = 0
    for i in range(N):
        res += max(A[i], D[i])

    print(res)

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

Fixed submission:
#UnionFindクラス
class UnionFind(object):
 
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0 for i in range(n)]
        self.size=[1 for i in range(n)]
 
    def find(self, x):
  
        if self.par[x] == x:
            return x
        else:
            self.par[x]=self.find(self.par[x])
            return self.par[x]
        
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x]+=self.size[y]
            
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def tree_size(self,x):
        return self.size[self.find(x)]
    
def main():
    n,m = map(int, input().split())
    uf = UnionFind(n)
    for i in range(m):
        x, y, z = map(int, input().split())
        x -= 1
        y -= 1
        if not uf.same(x,y):
            uf.union(x,y)
    res = 0
    for i in range(n):
        if uf.par[i] == i:
            res += 1
    print(res)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#UnionFindクラス
class UnionFind(object):
 
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0 for i in range(n)]
        self.size=[1 for i in range(n)]
 
    def find(self, x):
  
        if self.par[x] == x:
            return x
        else:
            self.par[x]=self.find(self.par[x])
            return self.par[x]
        
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x]+=self.size[y]
            
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def tree_size(self,x):
        return self.size[self.find(x)]
    
def main():
    n,m = map(int, input().split())
    uf = UnionFind(n)
    for i in range(m):
        x,y,z = map(int, input().split())
        uf.union(x,y)
    res = n
    for i in range(n):
        if uf.par[i] == i:
            res -= 1
    print(res)

if __name__ == '__main__':
    main()
Problem p03137 (python)

Fixed submission:
n,m = (int(i) for i in input().split())
x = list(int(i) for i in input().split())
x = sorted(x)
if m>1:
    res = x[-1]-x[0]
    dif = []
    for i in range(m-1):
        dif.append(abs(x[i+1]-x[i]))
        
    dif = sorted(dif,reverse = True)
    if n<m:
        for i in range(n-1):
            res -= dif[i]
    else:
        res = 0
else:
    res = 0
print(res)

Buggy submission (verdict: Runtime Error):
n,m = (int(i) for i in input().split())
x = list(int(i) for i in input().split())
x = sorted(x)
if m>1:
    res = x[-1]-x[0]
    dif = []
    for i in range(m-1):
        dif.append(abs(x[i+1]-x[i]))
        
    dif = sorted(dif,reverse = True)
    for i in range(n-1):
        res -= dif[i]
else:
    res = 0
print(res)
Problem p03209 (python)

Fixed submission:
n , x = map(int, input().split())
# ABCの長さ
a = [1]
for i in range(n):
    a.append(a[i] * 2 + 3)

# パティの枚数
p = [1]
for i in range(n):
    p.append(p[i] * 2 + 1)

def f(n, x):
    if n == 0:
        return 0 if x <= 0 else 1
    elif x == 1:
        return 0
    elif 1 <  x <=  1 + a[n - 1]:
        return f(n - 1, x - 1)
    elif x == 2 + a[n-1]:
        return p[n-1] + 1
    elif 2 + a[n - 1] < x <= 2 + 2 * a[n - 1]:
        return f(n - 1, x - 2 - a[n - 1]) + p[n-1] + 1
    elif x == 3 + 2 * a[n - 1]:
        return 2 * p[n-1] + 1

print(f(n, x))

Buggy submission (verdict: Runtime Error):
n,x=(int(i) for i in input().split())

def makeBurger(s):
    return "B"+s+"P"+s+"B"
s = "P"
for i in range(n):
    s = makeBurger(s)
count = 0
for i in range(x):
    if s[i]=='P':
        count += 1
print(count)
Problem p03221 (python)

Fixed submission:
N,M = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(M)]

cs = [[] for i in range(N+1)]
for i,(p,y) in enumerate(src):
    cs[p].append((y,i))
for cc in cs:
    cc.sort()

ans = [None] * M
for p in range(len(cs)):
    for i,(_,j) in enumerate(cs[p]):
        s = str(p).zfill(6) + str(i+1).zfill(6)
        ans[j] = s
print(*ans, sep='\n')

Buggy submission (verdict: Runtime Error):
n,m = (int(i) for i in input().split())
res = list([] for i in range(n))
p,y = [],[]
for i in range(m):
    tmp = list(int(i) for i in input().split())
    p.append(tmp[0])
    y.append(tmp[1])
    res[tmp[0]-1].append(tmp[1])

for i in range(n):
    res[i] = sorted(res[i])

for i in range(n):
    print("{0:06d}{1:06d}".format(p[i], res[p[i]-1].index(y[i])+1))
Problem p03307 (python)

Fixed submission:
N = int(input())
if N % 2 == 0:
    print(N)
else:
    print(2*N)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(int(i) for i in input().split())
a.sort(reverse = True)
print(a[0]-a[-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(int(i) for i in input().split())
a.sort(reverse = True)
print(a[0]-a[-1])
Problem p03776 (python)

Fixed submission:
def fuct(n:int)->int:
    if n<=1:
        return 1
    else:
        return n * fuct(n-1)

def main():
    n,a,b = map(int, input().split())
    v = list(map(int, input().split()))
    v = sorted(v, reverse=True)
    print(sum(v[:a])/a)
    res = 0

    if v[0]==v[a-1]:
        vn = v.count(v[0])
        for r in range(a,b+1):
            res += fuct(vn)//(fuct(vn-r) * fuct(r))
    else:
        vn = v.count(v[a-1])
        r = v[:a].count(v[a-1])
        res += fuct(vn)//(fuct(vn-r) * fuct(r))

    print(res)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def fuct(n:int)->int:
    if n==1:
        return 1
    else:
        return n * fuct(n-1)

def main():
    n,a,b = map(int, input().split())
    v = list(map(int, input().split()))
    v = sorted(v, reverse=True)
    print(sum(v[:a])/a)
    res = 0

    if v[0]==v[a-1]:
        vn = v.count(v[0])
        for r in range(a,b+1):
            res += fuct(vn)//(fuct(vn-r) * fuct(r))
    else:
        vn = v.count(v[a-1])
        r = v[:a].count(v[a-1])
        res += fuct(vn)//(fuct(vn-r) * fuct(r))

    print(res)

if __name__ == '__main__':
    main()