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

Fixed submission:
def prime_factor(n):
    p = {}
    for i in range(2,n):
        if n % i == 0:
            p[i] = 0
        while n % i == 0:
            n //= i
            p[i] += 1
        if i * i > n: break
    if n != 1:
        p[n] = 1
    return p

N = int(input())
if N == 1:
    print(0)
else:
    
    pN = {}
    for i in range(2,N+1):
        p = prime_factor(i)
        for x in p:
            if x not in pN:
                pN[x] = p[x]
            else:
                pN[x] += p[x]
    
    # 75 = 3 * 5 * 5
    res = 0
    for x in pN:
        for y in pN:
            for z in pN:
                if (x < y and y < z):
                    if(pN[x]>=2 and pN[y]>=4 and pN[z]>=4):
                        res+=1
                    if(pN[x]>=4 and pN[y]>=2 and pN[z]>=4):
                        res+=1
                    if(pN[x]>=4 and pN[y]>=4 and pN[z]>=2):
                        res+=1
    
    # 75 = 3 * 25
    for x in pN:
        for y in pN:
            if x < y:
                if(pN[x]>=24 and pN[y]>= 2):
                    res+=1
                if(pN[x]>= 2 and pN[y]>=24):
                    res+=1
    
    # 75 = 15 * 5
    for x in pN:
        for y in pN:
            if x < y:
                if(pN[x]>=14 and pN[y]>= 4):
                    res+=1
                if(pN[x]>= 4 and pN[y]>=14):
                    res+=1
    
    if pN[2] >= 74:
        res += 1
        
    print(res)

Buggy submission (verdict: Runtime Error):
def prime_factor(n):
    p = {}
    for i in range(2,n):
        if n % i == 0:
            p[i] = 0
        while n % i == 0:
            n //= i
            p[i] += 1
        if i * i > n: break
    if n != 1:
        p[n] = 1
    return p

N = int(input())
pN = {}
for i in range(2,N+1):
    p = prime_factor(i)
    for x in p:
        if x not in pN:
            pN[x] = p[x]
        else:
            pN[x] += p[x]

# 75 = 3 * 5 * 5
res = 0
for x in pN:
    for y in pN:
        for z in pN:
            if (x < y and y < z):
                if(pN[x]>=2 and pN[y]>=4 and pN[z]>=4):
                    res+=1
                if(pN[x]>=4 and pN[y]>=2 and pN[z]>=4):
                    res+=1
                if(pN[x]>=4 and pN[y]>=4 and pN[z]>=2):
                    res+=1

# 75 = 3 * 25
for x in pN:
    for y in pN:
        if x < y:
            if(pN[x]>=24 and pN[y]>= 2):
                res+=1
            if(pN[x]>= 2 and pN[y]>=24):
                res+=1

# 75 = 15 * 5
for x in pN:
    for y in pN:
        if x < y:
            if(pN[x]>=14 and pN[y]>= 4):
                res+=1
            if(pN[x]>= 4 and pN[y]>=14):
                res+=1

if pN[2] >= 74:
    res += 1
    
print(res)
Problem p03260 (python)

Fixed submission:
a,b = map(int,input().split())
 
if a == 2 or b == 2:
	print('No')
else:
	print('Yes')

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

if a == 2 or b == 2;
	print('No')
else:
	print('Yes')
Problem p03262 (python)

Fixed submission:
import fractions as f
N,X = map(int,input().split())
x = [int(_) for _ in input().split()]
y = [abs(x[i]-X) for i in range(N)]
ans = 0
for i in range(N):
    ans = f.gcd(ans,y[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import math
N,X = map(int,input().split())
x = [int(_) for _ in input().split()]
y = [x[i]-X for i in range(N)]
ans = 0
for i in range(N):
    ans = math.gcd(ans,y[i])
print(ans)
Problem p03293 (python)

Fixed submission:
S = input()
T = input()
ans = False
for i in range(len(S)):
    if list(S) == [list(T)[(i+j)%(len(T))] for j in range(len(T))]:
        ans = True
if ans:
    print('Yes')
if not ans:
    print('No')

Buggy submission (verdict: Runtime Error):
S,T = map(str,input().split())
ans = False
for i in range(len(S)):
    if list(S) == [list(T)[(i+j)%(len(T))] for j in range(len(T))]:
        ans = True
if ans:
    print('Yes')
if not ans:
    print('No')
Problem p03371 (python)

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


if a+b <= 2*c:
    print(a*x+b*y)
else:
    if x>=y:
        if a <= 2*c:
            print(y*(2*c)+a*(x-y))
        else:
            print(2*c*x)
    else:
        if b<= 2*c:
            print(x*2*c+b*(y-x))
        else:
            print(2*c*y)

Buggy submission (verdict: Runtime Error):
if a+b <= 2*c:
    print(a*x+b*y)
else:
    if x>=y:
        if a <= 2*c:
            print(y*(2*c)+a*(x-y))
        else:
            print(2*c*x)
    else:
        if b<= 2*c:
            print(x*2*c+b*(y-x))
        else:
            print(2*c*y)
Problem p03417 (python)

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

if n == 1 and m == 1:
    print(1)
if n != 1 and m == 1:
    print(n-2)
if n == 1 and m != 1:
    print(m-2)
if n != 1 and m != 1:
    print((n-2)*(m-2))

Buggy submission (verdict: Runtime Error):
if n == 1 and m == 1:
    print(1)
if n != 1 and m == 1:
    print(m-2)
if n == 1 and m != 1:
    print(n-2)
if n != 1 and m != 1:
    print((n-2)*(m-2))
Problem p03455 (python)

Fixed submission:
a,b = (int(j) for j in input().split())
if a*b % 2 == 0:
  print('Even')
else:
  print('Odd')

Buggy submission (verdict: Runtime Error):
a,b = int(input().split())
if a*b % 2 ==0:
  print(Even)
else:
  print(Odd)
Problem p03598 (python)

Fixed submission:
n = int(input())
k = int(input())
x = [int(_) for _ in input().split()]
res = 0
for i in range(n):
  res += min(x[i],abs(k-x[i]))
print(res*2)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
x = [int(_) for _ in input().split()]
res = 0
for i in range(n):
  res += min(x[i],abs(k-x[i]))
print(res*2)
Problem p03624 (python)

Fixed submission:
s =input()
ab = [chr(97+i) for i in range(26)]
res = 'None'
for i in ab:
    if i not in s:
        res = i
        break
print(res)

Buggy submission (verdict: Runtime Error):
s = input()
s =input()
ab = [chr(97+i) for i in range(26)]
res = 'None'
for i in ab:
    if i not in s:
        res = i
        break
print(res)
Problem p03693 (python)

Fixed submission:
r,g,b = input().split()
if int(r+g+b)%4==0: print('YES')
else: print('NO')

Buggy submission (verdict: Runtime Error):
r,g,b = input().split()
if int(r+g+b)%4==0: print('YES')
else print('NO')
Problem p02946 (python)

Fixed submission:
N,X = map(int,input().split())
for i in range(max(-1000000,X-N+1),min(X+N,1000001)):
    print(i)

Buggy submission (verdict: Runtime Error):
N,X = map(int,input().split())
for i in range(max(−1000000,X-N+1),min(X+N,1000001)):
    print(i)

Buggy submission (verdict: Runtime Error):
N,X = map(int,input().split())
for i in range(max(−1000000,X-N+1),max(X+N,1000001)):
    print(i)
Problem p04044 (python)

Fixed submission:
N,K = map(int, input().split())
lst = []
for z in range(N):
    lst.append(input())
lst.sort()
print("".join(lst))

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())
lst = []
for z in range(K):
    lst.append(input())
lst.sort()
print("".join(lst))
Problem p02848 (python)

Fixed submission:
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    s = input()
    if s == 'SUN':
        print(7)
    if s == "MON":
        print(6)
    if s == "TUE":
        print(5)
    if s == "WED":
        print(4)
    if s == "THU":
        print(3)
    if s == "FRI":
        print(2)
    if s == "SAT":
        print(1)
    return


# B
def B():
    al = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
    n = I()
    s = S()
    for i in range(len(s)):
        ni = (al.index(s[i]) + n) % 26
        s[i] = al[ni]
    print(''.join(s))
    return


# C
def C():
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    B()
    return


# Solve
if __name__ == "__main__":
    B()

Buggy submission (verdict: Runtime Error):
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    s = input()
    if s == 'SUN':
        print(7)
    if s == "MON":
        print(6)
    if s == "TUE":
        print(5)
    if s == "WED":
        print(4)
    if s == "THU":
        print(3)
    if s == "FRI":
        print(2)
    if s == "SAT":
        print(1)
    return


# B
def B():
    al = list("ABCDEFGHIJKLMNOIQRSTUVWXYZ")
    n = I()
    s = S()
    for i in range(len(s)):
        ni = (al.index(s[i]) + n) % 26
        s[i] = al[ni]
    print(''.join(s))
    return


# C
def C():
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    B()
    return


# Solve
if __name__ == "__main__":
    B()
Problem p02882 (python)

Fixed submission:
import sys
import math
from collections import defaultdict, deque
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    return


# B
def B():
    return


# C
def C():
    n = I()
    for i in range(int(n ** 0.5), 0, -1):
        if n % i == 0:
            print(i + n // i - 2)
            return
    return


# D
def D():
    a, b, x = LI()
    if (x <= a * a * b / 2):
        print(math.degrees(math.atan(a * b * b / x / 2)))
    else:
        print(math.degrees(math.atan(2 * (a * a * b - x) / a ** 3)))
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    D()
    return


# Solve
if __name__ == "__main__":
    D()

Buggy submission (verdict: Runtime Error):
import sys
import math
from collections import defaultdict, deque
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    return


# B
def B():
    return


# C
def C():
    n = I()
    for i in range(int(n ** 0.5), 0, -1):
        if n % i == 0:
            print(i + n // i - 2)
            return
    return


# D
def D():
    a,b,x=LI()
    if (x <= a**2*b/2):
        print(math.degrees(math.atan(x/a/b/b)))
    else:
        print(math.degrees(math.atan(a**3/(a**2*b-x))))
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    D()
    return


# Solve
if __name__ == "__main__":
    D()
Problem p02898 (python)

Fixed submission:
import sys


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


sys.setrecursionlimit(1000000)
mod = 1000000007


# A
def A():
    return


# B
def B():
    n, k = LI()
    h = LI()
    ans = 0
    for i in h:
        if i >= k:
            ans += 1
    print(ans)
    return


# C
def C():
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Solve
if __name__ == "__main__":
    B()

Buggy submission (verdict: Runtime Error):
import sys


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


# A
def A():


# B
def B():
    n, k = LI()
    h = LI()
    ans = 0
    for i in h:
        if i >= k:
            ans += 1
    print(ans)


# C
def C():


# D
def D():


# E
def E():


# F
def F():


# Solve
if __name__ == "__main__":
    B()

Buggy submission (verdict: Runtime Error):
import sys


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


# A
def A():


# B
def B():
    n,k=LI()
    h=LI()
    ans=0
    for i in h:
        if i>=k:
            ans+=1;
    print(ans)

# C
def C():


# D
def D():


# E
def E():


# F
def F():


# Solve
if __name__ == "__main__":
    B()
Problem p02910 (python)

Fixed submission:
import sys


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


# A
def A():
    s = input()
    if s == "Sunny":
        print("Cloudy")
    elif s == "Cloudy":
        print("Rainy")
    else:
        print("Sunny")
    return


# B
def B():
    s = S()
    for i in range(len(s)):
        if i % 2:
            if s[i] not in ["L", "U", "D"]:
                print("No")
                return
        else:
            if s[i] not in ["R", "U", "D"]:
                print("No")
                return
    print("Yes")
    return


# C
def C():
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    B()
    return


# Solve
if __name__ == "__main__":
    B()

Buggy submission (verdict: Runtime Error):
import sys


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


# A
def A():
    s = input()
    if s == "Sunny":
        print("Cloudy")
    elif s == "Cloudy":
        print("Rainy")
    else:
        print("Sunny")
    return


# B
def B():
    s = S()
    for i in range(len(s))
        if i % 2:
            if s[i] not in ["L", "U", "D"]:
                print("No")
                return
        else:
            if s[i] not in ["R", "U", "D"]:
                print("No")
                return
    print("Yes")
    return


# C
def C():
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    B()
    return


# Solve
if __name__ == "__main__":
    B()

Buggy submission (verdict: Runtime Error):
import sys


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


# A
def A():
    s = input()
    if s == "Sunny":
        print("Cloudy")
    elif s == "Cloudy":
        print("Rainy")
    else:
        print("Sunny")
    return


# B
def B():
    s = S()
    for i in range(len(s))
        if i % 2:
            if s[i] not in ["L", "U", "D"]:
                print("No")
                return
        else:
            if s[i] not in ["R", "U", "D"]:
                print("No")
                return
    print("Yes")
    return


# C
def C():
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    B()
    return


# Solve
if __name__ == "__main__":
    B()
Problem p02755 (python)

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

mn=max(b*10,a*12.5)
if mn==a*12.5 and a%2==1:
    mn=int(mn)+1
mx=min((b+1)/0.1,(a+1)/0.08)
if mn<mx:
    print(int(mn))
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import math
import fractions
a,b=map(int,input().split())
#mn=math.ceil(max(b/0.1,a/0.08))
mn=fractions.ceil(max(b/0.1,a/0.08))

mx=min((b+1)/0.1,(a+1)/0.08)
if mn<=mx:
    print(int(mn))
else:
    print(-1)
Problem p02782 (python)

Fixed submission:
r1,c1,r2,c2=map(int,input().split())
MOD=10**9+7
idx=r2+c2+3
perm=[1]*(idx+1)
for i in range(1,idx+1):
    perm[i]=perm[i-1]*i
    perm[i]%=MOD
def inv_mod(a):
  return pow(a,MOD-2,MOD)

def comb(n,m,p=10**9+7):
    if n < m : return 0
    if n < 0 or m < 0:return 0
    m = min(m, n-m)
    top = bot = 1
    for i in range(m):
        top = top*(n-i) % p
        bot = bot*(i+1) % p
    bot = pow(bot, p-2, p)
    return top*bot % p
def g(i,j):
    return comb(i+j+2,i+1,MOD)
def s(n,m):
    return comb(n+m+2, m+1, MOD)
res=g(r2,c2)-g(r2,c1-1)-g(r1-1,c2)+g(r1-1,c1-1)
res%=MOD

ans = s(r2,c2) - s(r2, c1-1) - s(r1-1, c2) + s(r1-1, c1-1)
ans %= MOD
print(res)

Buggy submission (verdict: Runtime Error):
r1,c1,r2,c2=map(int,input().split())
MOD=10**9+7
idx=r2+c2+3
perm=[1]*(idx+1)
for i in range(1,idx+1):
    perm[i]=perm[i-1]*i
    perm[i]%=MOD
def inv_mod(a):
  return pow(a,MOD-2,MOD)

def comb(n,m,p=10**9+7):
    if n < m : return 0
    if n < 0 or m < 0:return 0
    m = min(m, n-m)
    top = bot = 1
    for i in range(m):
        top = top*(n-i) % p
        bot = bot*(i+1) % p
    bot = pow(bot, p-2, p)
    return top*bot % p
def g(i,j):
    return comb(i+j+2,i+1,mod)
def s(n,m):
    return comb(n+m+2, m+1, mod)
res=g(r2,c2)-g(r2,c1-1)-g(r1-1,c2)+g(r1-1,c1-1)

mod = 10**9+7
ans = s(r2,c2) - s(r2, c1-1) - s(r1-1, c2) + s(r1-1, c1-1)
ans %= mod
print(res)
Problem p02850 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000000)
n=int(input())
ab=[]
root=[[] for i in range(n)] 
for i in range(n-1):
    a,b=map(int,input().split())
    root[a-1].append((i,b-1))
    root[b-1].append((i,a-1))
c=0
for i in range(n):
    c=max(c,len(root[i]))
print(c)
color=[0]*(n-1)

def dfs(node,par,c):
    if c!=1:
        i=1
    else:
        i=2
    for idx,x in root[node]:
        if x==par:
            continue
        if color[idx]==0:
            color[idx]=i
            dfs(x,node,i)
            i+=1
            if i==c:
                i+=1
dfs(0,-1,0)
for i in range(n-1):
    print(color[i])

Buggy submission (verdict: Runtime Error):
n=int(input())
ab=[]
root=[[] for i in range(n)] 
for i in range(n-1):
    a,b=map(int,input().split())
    root[a-1].append((i,b-1))
    root[b-1].append((i,a-1))
c=0
for i in range(n):
    c=max(c,len(root[i]))
print(c)
color=[0]*(n-1)

def dfs(node,par,c):
    if c!=1:
        i=1
    else:
        i=2
    for idx,x in root[node]:
        if x==par:
            continue
        if color[idx]==0:
            color[idx]=i
            dfs(x,node,i)
            i+=1
            if i==c:
                i+=1
dfs(0,-1,0)
for i in range(n-1):
    print(color[i])

Buggy submission (verdict: Runtime Error):
n=int(input())
ab=[]
root=[[] for i in range(n)] 
for i in range(n-1):
    a,b=map(int,input().split())
    ab.append((a-1,b-1))
    root[a-1].append((i,b-1))
    root[b-1].append((i,a-1))
c=0
for i in range(n):
    c=max(c,len(root[i]))
print(c)
color=[0]*(n-1)

def dfs(node,par,c):
    if c!=1:
        i=1
    else:
        i=2
    for idx,x in root[node]:
        if x==par:
            continue
        if color[idx]==0:
            color[idx]=i
            dfs(x,node,i)
            i+=1
dfs(0,0,0)
for i in range(n-1):
    print(color[i])
Problem p02866 (python)

Fixed submission:
import sys
n=int(input())
d=list(map(int,input().split()))
if d[0]!=0:
    print(0)
    sys.exit()
d.sort()
mx=d[-1]
count=[0]*(mx+1)
MOD=998244353
for i in range(n):
    count[d[i]]+=1
c=1
#print(d,count)
if count[0]!=1:
    print(0)
    sys.exit()
for i in range(1,mx+1):
    c*=pow(count[i-1],count[i],MOD)
    c%=MOD
print(c)

Buggy submission (verdict: Runtime Error):
import sys
n=int(input())
d=list(map(int,input().split()))
d.sort()
mx=d[-1]
count=[0]*(mx+1)
j=0
MOD=998244353
if d[0]!=0:
    print(0)
    sys.exit()
count[0]=1
j=1
for i in range(1,n):
    if d[i]==j:
        count[j]+=1
    elif d[i]==j+1 and count[i]>0:
        j+=1
        count[j]+=1
    else:
        print(0)
        sys.exit()
c=1
#print(d,count)
for i in range(1,mx+1):
    c*=pow(count[i-1],count[i],MOD)
    c%=MOD
print(c)
Problem p02929 (python)

Fixed submission:
import sys
from sys import stdin

def main():
 
    n = int(stdin.readline().rstrip())
    s = stdin.readline().rstrip()
    MOD=10**9+7
    perm=1
    for i in range(1,n+1):
        perm=perm*i%MOD
    ans=1

    dp=1#L
    l=1
    r=0
    for i in range(1,2*n):
        if s[i]==s[i-1]:
            dp=1-dp
        if dp==1:
            l+=1
        else:
            r+=1
            ans*=l-r+1
            ans%=MOD
    if s[0]=='W' or s[-1]=='W' or l!=r:
        print(0)
        sys.exit()

    print(ans*perm%MOD)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
MOD=10**9+7
perm=[1]*(n+1)
for i in range(1,n+1):
    perm[i]=perm[i-1]*i%MOD
ans=1
dp=[0]*(2*n+1)
for i in range(1,2*n+1):
    if (dp[i-1]+1)%2==(s[i]=='B'):
        dp[i]=dp[i-1]+1
    else:
        ans*=dp[i-1]%MOD
        dp[i]=dp[i-1]-1
#print(dp)
print(ans*perm[n]%MOD)
Problem p02949 (python)

Fixed submission:
"""解説を見てから解いたコード"""
N, M, P = map(int, input().split())
edges = []
for _ in range(M):
    a, b, c = map(int, input().split())
    edges.append((a, b, c-P))

INF = float('inf')

coin_map = [-INF] * (N+1)
coin_map[1] = 0

for i in range(2*N):
    for a, b, c in edges:
        if coin_map[b] < coin_map[a] + c:
            coin_map[b] = coin_map[a] + c
            if i >= N:
                coin_map[b] = INF

    if i == N - 1:
        ans = coin_map[N]

if ans != coin_map[N]:
    print(-1)
else:
    print(max(0, coin_map[N]))

Buggy submission (verdict: Runtime Error):
n,m,p=map(int,input().split())
A=[]
for i in range(m):
    a,b,c=map(int,input().split())
    A.append((a,b,p-c))

def BellmanFord(edges,num_v,source):
    #グラフの初期化
    inf=float("inf")
    dist=[inf for i in range(num_v)]
    dist[source-1]=0
  
    #辺の緩和
    buf=0
    for i in range(num_v*2):
        for edge in edges:
            if dist[edge[0]] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
                dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
                if i>=num_v:
                    dist[edge[1]-1] =-inf
        if i==num_v-2:
            buf=dist[-1]
    if dist[-1]!=buf or dist[-1]==inf:
        return False
    return dist[-1]*-1

x=BellmanFord(A,n,1)
if x==False:
    print(-1) 
else:
    print(x if x>0 else 0)
Problem p02995 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a  
nc=b//c-(a-1)//c
nd=b//d-(a-1)//d
x=c*d//gcd(c,d)
ncd=b//x-(a-1)//x
#print(nc,nd,x,ncd)
print(b-a+1-nc-nd+ncd)

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
nc=b//c-(a-1)//c
nd=b//d-(a-1)//d
x=c*d//math.gcd(c,d)
ncd=b//x-(a-1)//x
#print(nc,nd,x,ncd)
print(b-a+1-nc-nd+ncd)
Problem p03006 (python)

Fixed submission:
n=int(input())
z=[]
for i in range(n):
    x,y=map(int,input().split())
    z.append([x,y])
z.sort(reverse=True)
dif=[]
for i in range(n):
    for j in range(n):
        if i<j:
            x=z[j][0]-z[i][0]
            y=z[j][1]-z[i][1]
            dif.append([x,y])
dif.sort(reverse=True)
count=-1
buf=0
comp=[0,0]
ans=[0,0]
l=len(dif)
for i in range(l):
    if comp==dif[i]:
        buf+=1
    else:
        if count<buf:
            count=buf
            ans=comp
        buf=1
        comp=dif[i]
if count<buf:
    count=buf
    ans=comp
print(n-count)

Buggy submission (verdict: Runtime Error):
n=int(input())
z=[]
for i in range(n):
    x,y=map(int,input().split())
    z.append([x,y])
z.sort(reverse=True)
dif=[]
for i in range(n-1):
    x=z[i+1][0]-z[i][0]
    y=z[i+1][1]-z[i][1]
    dif.append([x,y])
dif.sort(reverse=True)
count=-1
buf=1
comp=dif[0]
ans=dif[0]
for i in range(1,n-1):
    if comp==dif[i]:
        #print(comp,dif[i])
        buf+=1
    else:
        #print(comp,dif[i],buf)
        if count<buf:
            count=buf
            ans=comp
        buf=0
        comp=dif[i]
if count<buf:
    count=buf
    ans=comp
print(n-count)