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

Fixed submission:
p, q = map(int, input().split())
import fractions
 
def lcm(a, b):
    return (a * b) // fractions.gcd(a, b)

print(lcm(p, q))

Buggy submission (verdict: Runtime Error):
p, q = map(int, input().split())
 
def lcm(a, b):
    return (a * b) // math.gcd(a, b)


print(lcm(p, q))

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

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

print(lcm(p, q))

Buggy submission (verdict: Runtime Error):
ソースコード 

Copy
Copy
p, q = map(int, input().split())
import fractions
 
def lcm(a, b):
    return (a * b) // fractions.gcd(a, b)
 
print(lcm(p, q))

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

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

print(lcm(p, q))

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

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

print(lcm(p, q))

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

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

print(lcm(p, q))

Buggy submission (verdict: Runtime Error):
p, q = map(int, input().split())
import math
def lcm(a, b):
    return (a * b) // math.gcd(a, b)

print(lcm(p, q))

Buggy submission (verdict: Runtime Error):
p, q = map(int, input().split())
import math
gcd = math.gcd(p, q)

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

print(lcm(p, q))
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 = (ans + v[i])/2
print(ans)

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

while True:
    if n == 2:
            break
    else:
        if n % 2 == 0:
            n = n // 2
            cnt += 1
        else:
            n = n // 2 + 1
            cnt += 1

l = [[] for _ in range(cnt+1)]
l[0] = list(map(int, input().split()))
l[0].sort()


for i in range(cnt):
    for j in range(0,n,2):
        l[i+1].append((l[i][j] + l[i][j+1]) / 2)
        if n // 2 == 1:
            l[i+1].append(l[i][n])

print((l[cnt][0] + l[cnt][1]) / 2)
Problem p02970 (python)

Fixed submission:
n, d = map(int, input().split())
k = d * 2 + 1
if n % k == 0:
    print(n//k)
else:
    print(n//k + 1)

Buggy submission (verdict: Runtime Error):
n, d = mpa(int, input().split())
k = d * 2 + 1
if n % k == 0:
    print(n//k)
else:
    print(n//k + 1)
Problem p03011 (python)

Fixed submission:
p, q, r = map(int, input().split())
a = p + q  
b = q + r
c = r + p 
print(min(a,min(b,c)))

Buggy submission (verdict: Runtime Error):
p, q, r = map(int, input().split())
p + q = a
q + r = b
r + p = c
print(min(a,min(b,c)))
Problem p03042 (python)

Fixed submission:
s = input()
i = int(s[:2])
j = int(s[2:])
if 1 <= i and i <= 12:
    if 1 <= j and j <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:    
    if 1 <= j and j <= 12:
        print('YYMM')
    else:
        print('NA')

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

if 1 <= int(s[0:2]) and int(s[0:2]) <= 12:
    if 1 <= int(s[2:4]) and int(s[2:4]) <= 12:
        print('AMBIGUOUS')
    else:
        if int(s[2:4]) != 0:
            print('MMYY')
        else:
            print('NA')
elif int(s[0:2]) == 0:
    print('NA')
else:
    if 1 <= int(s[2:4]) and int(s[2:4]) <= 12:
        if int(s[2:4]) != 0:
            print('YYMM')
        else:
            print('NA')
    else:
        print('NA')

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

if 1 <= int(s[0:2]) and int(s[0:2]) <= 12:
    if 1 <= int(s[2:4]) and int(s[2:4]) <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= int(s[2:4]) and int(s[2:4]) <= 12:
        print('YYMM')
    else:
        print('NA')
Problem p02753 (python)

Fixed submission:
S = input()
if S[0] == S[1] and S[1] == S[2]:
	print('No')
else:
	print('Yes')

Buggy submission (verdict: Runtime Error):
S = input()
if S[0] == S[1] and S[1] == S[2]:
print('No')
else:
print('Yes')

Buggy submission (verdict: Runtime Error):
#include <stdio.h>

int main() {
    S = input()
    if S[0] == S[1] and S[1] == S[2]:
    print('No')
    else:
    print('Yes')
    
    
    
    
	return 0;
}
Problem p02860 (python)

Fixed submission:
n=int(input())
s=input()

if(n%2==1):
    print('No')
    exit()

else:  
   
    if s[0:n//2]==s[(n//2):n]:
     	print('Yes')
    else:
        print("No")

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


if(n%2==1):
  print('No')

else:  
   
    
    if s[0:n//2]==s[(n//2)+1:n]:
    print('Yes')
    else:
      print("No")
Problem p02688 (python)

Fixed submission:
N,K=map(int,input().split())
c=[0]*N
for _ in range(K):
    d=int(input())
    l=list(map(int,input().split()))
    for i in range(d):
        c[l[i]-1]+=1
print(c.count(0))

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
c=[0,0,0]
for _ in range(K):
    d=int(input())
    l=list(map(int,input().split()))
    for i in range(d):
        c[l[i]-1]+=1
print(c.count(0))

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
c=[0,0,0]
for i in range(K):
    d=int(input())
    l=list(map(int,input().split()))
    for i in range(d):
        c[l[i]-1]+=1
print(c.count(0))
Problem p02711 (python)

Fixed submission:
x = input()
j = False
for i in range(len(x)):
  if x[i] == '7':
    j = True
if j:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
x = int(input())
j = False
for i in range(len(x)):
  if x[i] == 7:
    j = True
if j:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
x = int(input())
j = False
for i in range(len(x))
  if x[i] == 7:
    j = True
if j:
  print('Yes')
else:
  print('No')
Problem p02723 (python)

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

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

Fixed submission:
A,B=map(int, input().split())
import math
def comb(n, r):
  if n < 2:
    return 0
  else:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
print(comb(A,2)+comb(B,2))

Buggy submission (verdict: Runtime Error):
A,B=map(int, input().split())
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
print(comb(A,2)+comb(B,2))
Problem p02766 (python)

Fixed submission:
N,K = map(int, input().split())
c = 1
K_ = 1
i=True
while i==True:
  K_ = K_ *K
  if N < K_:
    print(c)
    i=False
  c += 1

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())
c = 1
K_ = 1
i=True
while i==True:
  K_ = K_ * K
  if N < K_:
    print(c)
    i=False
  counter += 1

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())
c = 1
K_ = 1
i=True
while i==True:
  K_ *= K
  if N < K_:
    print(c)
    i=False
  counter += 1

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())
counter = 0
K_ = 1
while i=True:
  K_ = K_ * K
  if K > K_:
    print(counter)
    i=False
  counter += 1
Problem p02771 (python)

Fixed submission:
# -*- coding: utf-8 -*-
a, b, c = map(int, input().split())
l = [a, b, c]
counter = 0
if a == b:
  counter += 1
if b == c:
  counter += 1
if a == c:
  counter += 1
if counter == 1:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a = int(input())
judge = True
for i in range(a):
  b = int(input())
  if (b % 2 == 0) and ((b % 3 == 0) or (b % 5 == 0)):
    judge = False
# 出力
if judge:
  print("APPROVED")
else:
  print("DENIED")
Problem p02622 (python)

Fixed submission:
S= list(input())
T= list(input())
count=0
for i in range(len(S)):
    if S[i]!=T[i]:
        count=count+1
print(count)

Buggy submission (verdict: Runtime Error):
S,T = list(input().split())
count=0
for i in range(len(S)):
    if S[i]!=T[i]:
        count+=1
print(count)

Buggy submission (verdict: Runtime Error):
S,T = list(input().split())
count=0
for i in range(len(S)):
    if S[i]!=T[i]:
        count+=1
print(count)
Problem p02688 (python)

Fixed submission:
n, k = map(int, input().split())
d = [0] * k
sunuke = {}
for i in range(n):
    sunuke.setdefault(str(i), 0)
    #print(sunuke)

for i in range(k):
    d[i] = int(input())
    A = list(map(int,input().split()))
    #print(d[i],A)
    for j in range(d[i]):
        sunuke[str(A[j]-1)] += 1

ans = list(sunuke.values()).count(0)

print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
n, k = map(int, input().split())
a = []
n= map(str, list(range(1,n+1)))
for num in range(k):
    d = int(input())
    a.append(list(input()))
list1 = list(set(list(itertools.chain.from_iterable(a))))
list1.remove(' ')
list1.sort()
result =list(set(n)-set(list1))
print(len(result))
Problem p02682 (python)

Fixed submission:
import sys
line = list(map(lambda x: int(x), input().split(" ")))
a, b, c, k = line[0], line[1], line[2], line[3]
 
if a >= k:
  print(k)
  sys.exit(0)
 
tmp = k - a
if b >= tmp:
  print(a)
  sys.exit(0)
 
print(a - (k - a -b))

Buggy submission (verdict: Runtime Error):
line = input().split(" ")
a, b, c, k = line[0], line[1], line[2], line[3]

if a >= k:
  print(k)
  return 

tmp = k - a
if b >= tmp:
  print(a)
  return

print(a - (k - a -b))
Problem p02777 (python)

Fixed submission:
S, T = input().split()
A, B = map(int,input().split())
U = input()
if U == S:
    A -= 1
else:
    B -= 1
print(str(A)+' '+str(B))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = input().split()
for i in A:
    A = [j for j in A if j != i]
    if len(A) == N - 1:
        N -= 1
        continue
    else:
        print("NO")
        break
if N == 0:
    print("YES")
Problem p02790 (python)

Fixed submission:
a , b =input().split()
print(a*int(b) if a<=b else b*int(a))

Buggy submission (verdict: Runtime Error):
a , b =map(int(),input().split())
A=str(a)
B=str(b)
for i in a:
    X+="A"
for j in b:
    Y+="B"

if a<b:
    print(X)
if a>b:
    print(Y)

Buggy submission (verdict: Runtime Error):
a , b =map(int,input().split())
A=str(a)
B=str(b)
for(int i=0; i<a; i++):
    X+="A"
for(int j=0; j<b; j++):
    Y+="B"

if a<b:
    print(X)
if a>b:
    print(Y)
Problem p02860 (python)

Fixed submission:
N = int(input())
S = input()

if N%2 != 0:
  print('No')
elif S[0:int(N/2)] == S[int(N/2):int(N+1)]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()

if N%2 != 0:
  print('No')
elif S[0:int(N/2)] == S[int(N/2):int(N+1)]:
  print('Yes')
else:
  print('No')
Problem p02693 (python)

Fixed submission:
n=int(input())

a,b=[int(x) for x in input().split()]
flag=0
for i in range(a,b+1):
    if i%n==0:
        flag=1
        break
if flag==0:
    print("NG")
else:
    print("OK")

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

a,b=[int(x) for x in input().split()]
flag=0
for i in range(a,b+1):
    if i%k==0:
        flag=1
        break
if flag==0:
    print("NG")
else:
    print("OK")
Problem p02725 (python)

Fixed submission:
k,n=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
 
sol=[]
for i in range(n-1):
  sol.append(a[i+1]-a[i])
sol.append(a[0]-a[n-1]+k)
 
sol.sort()
print(sum(sol[:n-1]))

Buggy submission (verdict: Runtime Error):
l,n=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
 
sol=[]
for i in range(n-1):
  sol.append(a[i+1]-a[i])
sol.append(a[0]-a[n-1]+k)
sol.sort()
#unwanted segment of max length removed while printing
print(sum(sol[0:n-1]))

Buggy submission (verdict: Runtime Error):
n,k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
 
sol=[]
for i in range(n-1):
  sol.append(a[i+1]-a[i])
sol.append(a[0]-a[n-1]+k)
 
sol.sort()
#unwanted segment of max length removed while printing
print(sum(sol[0:n-1]))

Buggy submission (verdict: Runtime Error):
n,k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
 
sol=[]
for i in range(n-1):
  sol.append(a[i+1]-a[i])
sol.append(a[0]-a[n-1]+k)
 
sorted(sol)
#unwanted segment of max length removed while printing
print(sum(sol[0:n-1]))

Buggy submission (verdict: Runtime Error):
n,k=[int(x) for x in input.split()]
a=[int(x) for x in input.split()]
 
sol=[]
for i in range(n-1):
  sol.append(a[i+1]-a[i])
sol.append(a[0]-a[n-1]+k)
 
sorted(sol)
#unwanted segment of max length removed while printing
print(sum(sol[0:n-1]))

Buggy submission (verdict: Runtime Error):
=[int(x) for x in input.split()]
a=[int(x) for x in input.split()]
 
sol=[]
for i in range(n-1):
  sol.append(a[i+1]-a[i])
sol.append(a[0]-a[n-1]+k)
 
sol.sort()
#unwanted segment of max length removed while printing
print(sum(sol)[0:n-1])

Buggy submission (verdict: Runtime Error):
n,k=[int(x) for x in input.split()]
a=[int(x) for x in input.split()]

sol=[]
for i in range(n-1):
  sol.append(a[i+1]-a[i])
sol.append(a[0]-a[n-1]+k)

sol.sorted()
#unwanted segment of max length removed while printing
print(sum(sol)[0:n-1])
Problem p02785 (python)

Fixed submission:
n,k=[int(x) for x in input().split()]
arr=[int(x) for x in input().split()]
s=0
arr.sort()
if(n>k):
    for i in range(n-k):
        s+=arr[i]
    print(s)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
n,k=[int(x) for x in input().split()]
arr=[int(x) for x in input().split()]
s=0
if(n>k):
	for i in range(n-k):
  		s+=arr[i]
    print(s)
else:
  print(0)
Problem p02682 (python)

Fixed submission:
A,B,C,K = input().split()
a = int(A)
b = int(B)
c = int(C)
k = int(K)

B_number = 0
C_number = 0

A_number = min(a,k)
k1 = k - a
if k1 > 0:
    B_number = min(b,k1)
    k2 = k1 - b
    if k2 > 0:
        C_number = min(c,k2)

print(A_number-C_number)

Buggy submission (verdict: Runtime Error):
A,B,C,K = input().split()
a = int(A)
b = int(B)
k = int(K)

B_number = 0
C_number = 0

A_number = min(a,k)
k1 = k - a
if k1 > 0:
    B_number = min(b,k1)
    k2 = k1 - b
    if k2 > 0:
        C_number = min(c,k2)

print(A_number-C_number)

Buggy submission (verdict: Runtime Error):
A,B,C,K = input().split()
a = int(A)
b = int(B)
k = int(K)

B_number = 0
C_number = 0

A_number = min(a,k)
k1 = k - a
if k1 > 0:
    B_number = min(b,k1)
    k2 = k1 - b
    if k2 > 0:
    C_number = min(c,k2)

print(A_number-C_number)
Problem p02622 (python)

Fixed submission:
a=0
S=list(input())
T=list(input())
for i in range(len(S)): 
	if S[i]!=T[i]:	
		a=a+1
print(a)

Buggy submission (verdict: Runtime Error):
a=o
S=list(input())
T=list(input())
for i in range(len(S)): 
	if S[i]!=T[i]:	
		a=a+1
print(a)

Buggy submission (verdict: Runtime Error):
a=o
S=list(input())
T=list(input())
for i in range(len(S)): 
	if S[i]！=T[i]:	
		a=a+1
print(a)

Buggy submission (verdict: Runtime Error):
a=o
S=list(input())
T=list(input())
for i in range(len(S)): 
  if S[i]！=T[i]:	
      a=a+1
print(a)
Problem p02659 (python)

Fixed submission:
from decimal import*
a,b=map(Decimal,input().split())
print(int(a*b))

Buggy submission (verdict: Runtime Error):
a, b = input().split()
A = int(a)
B_list = list(b)
 
count = -1
check = -1
B = ""
 
for char in B_list:
  if char == ".":
    count = 0
    check = 0
  else:
    if check == 0:
      if count >= 0:
        count += 1
    B += char
 
result = A * int(B)  
result_list = list(str(result))
if count >= len(result_list):
  for n in range(count - len(result_list) + 1):
    result_list.insert("0", 0)
else:
  result_list.insert(- count, ".")
answer = ""
for char in result_list:
  if char == ".":
  	break
  answer += char
print(answer)
Problem p02725 (python)

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

    li = []
    for i in range(N - 1):
        li.append(A[i + 1] - A[i]) 

    li.append(abs(A[0] + (K - A[-1])))
    print(sum(li) - max(li))
except:
    pass

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

li = []
for i in range(N - 1):
  li.append(A[i + 1] - A[i]) 

li.append(abs(A[0] + (K - A[-1])))
print(sum(li) - max(li))
Problem p02729 (python)

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

s=N*M
m=N+M

d=(m*(m-1))/2

print(int(d-s))

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
if N>=2:
    n=(N*(N-1))/2
if M>=2:
    m=(M*(M-1))/2
a=n+m
print(a)
Problem p02753 (python)

Fixed submission:
S=list(map(str,input()))

if S[0]!=S[1]:
    print("Yes")

elif S[0]!=S[2]:
    print("Yes")

elif S[1]!=S[2]:
    print("Yes")

else:
    print("No")

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


sum=0

if A==0:
    print(0)
else:
    a=N//(A+B)
    b=N%(A+B)

    # print(a)
    # print(b)
    if b>A:
        sum=A*a+A
        print(sum)
    else:
        sum=A*a+b
        print(sum)
Problem p02754 (python)

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


sum=0

if A==0:
    print(0)
else:
    a=N//(A+B)
    b=N%(A+B)

    # print(a)
    # print(b)
    if b>=A:
        sum=A*a+A
        print(sum)
    if b<A:
        sum=A*a+b
        print(sum)

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


s=0

if A==0:
    print(0)
else:
    a=N//(A+B)
    b=N%(A+B)

    # print(a)
    # print(b)
    if b>A:
    sum=A*a+A
    print(s)
    else:
    s=A*a+b
    print(s)
Problem p02933 (python)

Fixed submission:
a=int(input())
s=str(input())

if a>=3200:
    print(s)
else:
    print("red")

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

if a>=3200:
    input(s)
else:
    input("red")

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

if a>=3200:
    input(s)
else:
    input("red")
Problem p02951 (python)

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

D=A-B
E=C-D

if E<=0:
    print(0)
else:
    print(E)

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

for i in range(N-1):
    if H[i]>H[i+1]:
        H[i]=H[i]-1
        # if H[i] > H[i + 1]:
        #     A = "no"
        #     break
        # else:
        #     A="yes"



for i in range(N-1):
    if H[i]>H[i+1]:
        A="no"
        break
    else:
        A="yes"

print(A)
Problem p02723 (python)

Fixed submission:
S = input()
ans = 'No'
if S[2] == S[3] and S[4] == S[5]:
   ans = 'Yes'
print(ans)

Buggy submission (verdict: Runtime Error):
K, N = map(int,input().split())
A = list(map(int, input().split()))
a = A[0]
sub = []
for _ in range(N):
    p = A.pop()
    sub.append(K-p)
    K = p
sub[0] += a
sub.remove(max(sub))
print(sum(sub))

Buggy submission (verdict: Runtime Error):
K, N = map(int,input().split())
A = list(map(int, input().split()))
sub = [A[0]+K-A[N-1]]
for _ in range(N-1):
    p = A.pop()
    sub.append(K-p)
    K = p
sub.remove(max(sub))
print(sum(sub))
Problem p02729 (python)

Fixed submission:
N, M = map(int,input().split())
import math
def comb(n, r):
    if (n-r) >= 0:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    else:
        return 0
base = comb(N,2)
base2 = comb(M,2)
print(base+base2)

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
base = comb(N,2)
base2 = comb(M,2)
print(base+base2)

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
from scipy.special import comb
base = comb(N, 2, exact=True)
base2 = comb(M, 2, exact=True)
print(base + base2)
Problem p02659 (python)

Fixed submission:
from decimal import *

getcontext().prec = 20
 
N = list(map(str, input().split()))
A = Decimal(N[0])
B = Decimal(N[1])
  
print(int(A*B))

Buggy submission (verdict: Runtime Error):
from decimal import *
getcontext().prec = 2
 
N = list(map(str, input().split()))
A = Decimal(N[0])
B = Decimal(N[1])
  
print(math.floor(A*B/100))
Problem p02682 (python)

Fixed submission:
a, b, c, k =map(int, input().split())
if k <a:
  print(k)
elif k<=a+b:
  print(a)
else:
  print(a-(k-(a+b)))

Buggy submission (verdict: Runtime Error):
a, b, c, k =map(int, input().split())
if k<=a+b:
  print(a)
else:
  print(a-(k-(a+b))
Problem p02859 (python)

Fixed submission:
i_r = int(input())
print(i_r * i_r)

Buggy submission (verdict: Runtime Error):
i_r = input()
print(i_r * i_r)
Problem p02695 (python)

Fixed submission:
n,m,q=map(int,input().split())
a=[0]*q
b=[0]*q
c=[0]*q
d=[0]*q
A=[]
for i in range(q):
  a[i],b[i],c[i],d[i]=map(int,input().split())
def score(A):
  sum=0
  for (ai,bi,ci,di) in zip(a,b,c,d):
    if A[bi-1]-A[ai-1]==ci:
      sum+=di
  return sum
def fbs(A):
  if len(A)==n:
    return score(A)
  if len(A)>0:
    pre_last=A[-1]
  else:
    pre_last=0
  res=0
  for v in range(pre_last,m):
    A.append(v)
    res=max(res,fbs(A))
    A.pop()
  return res

print(fbs(A))

Buggy submission (verdict: Runtime Error):
n,m,q=map(int,input().split())
a=[0]*q
b=[0]*q
c=[0]*q
d=[0]*q
A=[]
for i in range(q):
  a[i],b[i],c[i],d[i]=map(int,input().split())
def score(A):
  sum=0
  for (ai,bi,ci,di) in zip(a,b,c,d):
    if A[ai-1]-A[bi-1]==A[ci-1]:
      sum+=di
  return sum
def fbs(A):
  if len(A)==n:
    return score(A)
  res=0
  for v in range(1,m+1):
    A.append(v)
    res=max(res,fbs(A))
    A.pop()
  return res

print(fbs(A))
Problem p02682 (python)

Fixed submission:
a, b, c, k = map(int, input().split())
ans = 0
if k <= a:
    ans = k
elif k <= a+b:
    ans = a
else:
    ans = a + (-1)*(k-a-b)
print(ans)

Buggy submission (verdict: Runtime Error):
a, b, c, k = map(int, input().split())
list1 = [1] * a
list0 = [0] * b
list_m1 = [-1] * c

list1.extend(list0)
list1.extend(list_m1)

list1.sort(reverse=True)

ans = 0
for i in range(k):
    ans += list1[i]

print(ans)
Problem p02935 (python)

Fixed submission:
n = int(input())
v = [int(e) for e in input().split()]
v.sort()
result = v[0]
for i in range(1, n):
  result = (result + v[i]) / 2
print(result)

Buggy submission (verdict: Runtime Error):
N=int(input())
V=sorted(list(map(int, input().split())), reverse=True)

result=V[0]
for i in range(1,N):
  result =(result + v[i])/2
print(result)
Problem p02622 (python)

Fixed submission:
s1 = list(input())
s2 = list(input())
ans = 0
for i in range(len(s1)):
  if s1[i] != s2[i]:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
s1 = list(input())
s2 = list(input())
ans = 0
for i in range(s1):
  if s1[i] =! s2[i]:
    ans+=1
print(ans)
Problem p02689 (python)

Fixed submission:
n,m = map(int,input().split())
h = list(map(int,input().split()))
ans = [1]*n
for i in range(m):
    a,b = map(int,input().split())
    if h[a-1]>h[b-1]:
        ans[b-1] = 0
    elif h[b-1]>h[a-1]:
        ans[a-1] = 0
    else:
        #print("a")
        ans[a-1] = 0
        ans[b-1] = 0
print(ans.count(1))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
h = list(map(int,input().split()))
ans = [1]*n
for i in range(m):
    print(ans)
    a,b = map(int,input().split())
    if h[a-1]>h[b-1]:
        ans[b-1] = 0
    else if h[b-1]>h[a-1]:
        ans[a-1] = 0
    else:
        print("a")
        ans[a-1] = 0
        ans[b-1] = 0
print(ans.count(1))
Problem p02729 (python)

Fixed submission:
import math

data = input()
data = data.split()
n = data[0]
m = data[1]
v1 = 0
v2 = 0

if int(n) > 1:
	v1 = (math.factorial(int(n)) // (math.factorial(int(n) - 2) * math.factorial(2)))

if int(m) > 1:
    v2 = (math.factorial(int(m)) // (math.factorial(int(m) - 2) * math.factorial(2)))

print(v1+v2)

Buggy submission (verdict: Runtime Error):
import math

data = input()
data = data.split()
n = data[0]
m = data[1]

v = (math.factorial(int(n)) // (math.factorial(int(n) - 2) * math.factorial(2)))+(math.factorial(int(m)) // (math.factorial(int(m) - 2) * math.factorial(2)))

print(v)
Problem p02622 (python)

Fixed submission:
S=input()
T=input()

count=0
for i in range(len(S)):
  if S[i]!=T[i]:
    count+=1
    
print(count)

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

print(a+a**2+a**3)