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

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

s = [-1] * n
c = [1]
t = 0
now = 0
while s[now] == -1:
    s[now] = t
    now = a[now] - 1
    c.append(now+1)
    t += 1

start_cycle = c.index(c[-1])
loop = c[start_cycle:-1]
cycle = len(loop)

if k < start_cycle:
    print(c[k])
else:
    k -= start_cycle
    k %= cycle
    print(loop[k])

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

s = [True] * n
c = [1]
now = 0
while s[now]:
    s[now-1] = False
    now = a[now]
    c.append(now)

start_cycle = c.index(c[-1])
loop = c[start_cycle:-1]
cycle = len(loop)

if k < start_cycle:
    print(c[k])
else:
    k -= start_cycle
    k %= cycle
    print(loop[k])

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

s = [-1] * n
c = [1]
now = 0
while s[now] == -1:
    s[now] = t
    now = a[now] - 1
    c.append(now+1)

start_cycle = c.index(c[-1])
loop = c[start_cycle:-1]
cycle = len(loop)

if k < start_cycle:
    print(c[k])
else:
    k -= start_cycle
    k %= cycle
    print(loop[k])
Problem p02687 (python)

Fixed submission:
s = input()

if s == 'ABC':
    print('ARC')
else:
    print('ABC')

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

for i in range(-200,200):
    for j in range(-200,200):
        if i ** 5 - j ** 5 == x:
            print(i,j)
            quit()
Problem p02702 (python)

Fixed submission:
s = input()
#s = '9' * 200000

mod = [1] + [0]*2018
t = 0
a = 1
n = len(s)
s = s[::-1]
for i in range(n):
    t = (t + int(s[i])*a) % 2019
    a = a * 10 % 2019
    mod[t] += 1
ans = 0
for i in range(2019):
    ans += mod[i]*(mod[i]-1)//2
print(ans)

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

mod = [1] + [0]*2018
t = 0
a = 0
n = len(s)
s = reversed(s)
for i in range(n):
    t += int(s[i]) * (10 ** a)
    a += 1
    mod[t%2019] += 1
    print(t,t%2019)
ans = 0
for i in range(2019):
    ans += mod[i]*(mod[i]-1)//2
print(ans)
Problem p02727 (python)

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

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p = p[:x]
q = q[:y]
apple = p + q + r
apple.sort(reverse=True)
ans = sum(apple[:x+y])
print(ans)

Buggy submission (verdict: Runtime Error):
x, y, a, b, c = map(int,input().split())
p = [list(map(int,input().split())) for _ in range(3)]

for i, e in enumerate(p):
    p[i] = list(sorted(e,reverse=True))

g, h = 0, 0
ans = 0
for i in range(x):
    if p[0][i] >= p[2][g]:
        ans += p[0][i]
    else:
        if p[1][h] < p[0][i]:
            ans += p[0][i]
            h += 1
        else:
            ans += p[2][g]
            g += 1
            p[2][g] = 0

for i, e in enumerate(p):
    p[i] = list(sorted(e,reverse=True))

g = 0
for i in range(y):
    if p[1][i] >= p[2][g]:
        ans += p[1][i]
    else:
        if g >= c:
            ans += p[1][i]
        else:
            ans += p[2][g]
            g += 1
print(ans)

Buggy submission (verdict: Runtime Error):
x, y, a, b, c = map(int,input().split())
p = [list(map(int,input().split())) for _ in range(3)]

for i, e in enumerate(p):
    p[i] = list(sorted(e,reverse=True))

g, h = 0, 0
ans = 0
for i in range(x):
    if p[0][i] >= p[2][g]:
        ans += p[0][i]
    else:
        if p[1][h] < p[0][i]:
            ans += p[0][i]
            h += 1
        else:
            ans += p[2][g]
            g += 1
            p[2][g] = 0

for i, e in enumerate(p):
    p[i] = list(sorted(e,reverse=True))

g = 0
for i in range(y):
    print(p[1][i],p[2][g])
    if p[1][i] >= p[2][g]:
        ans += p[1][i]
    else:
        ans += p[2][g]
        g += 1
print(ans)
Problem p02732 (python)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int,input().split()))

c = Counter(a)
key = c.keys()
comb = 0
for i in key:
    comb += (c[i]) * (c[i]-1) // 2

for i in a:
    ans = comb - (c[i]-1)
    print(ans)

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

n = int(input())
a = list(map(int,input().split()))
a_s = set(a)
for i in range(n):
    l = a[i]
    a[i] = 'X'
    ans = 0
    for j in a_s:
        c = a.count(j)
        if c < 2:
            continue
        ans += factorial(c) / factorial(2) / factorial(c - 2)
    print(int(ans))
    a[i] = l

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

n = int(input())
a = list(map(int,input().split()))
a_s = set(a)
for i in range(n):
    l = a[i]
    a[i] = 'X'
    ans = 0
    for j in a_s:
        c = a.count(j)
        if c < 2:
            continue
        ans += factorial(c) / factorial(2) / factorial(c - 2)
    print(int(ans))
    a[i] = l
Problem p02761 (python)

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

for i in range(10**n):
    i = str(i)
    flag = True
    if len(i) == n:
        for j in range(m):
            if i[sc[j][0]-1] != str(sc[j][1]):
                flag = False
        if flag:
            print(i)
            quit()

print(-1)

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

sc.sort(key=lambda x: x[0],reverse=True)
n = len(sc)
for i in range(1,1000):
    i = str(i)
    if len(i) < sc[0][0]:
        continue
    c = n
    for j in range(m):
        if i[sc[j][0]-1] == str(sc[j][1]):
            c -= 1
    if c == 0:
        print(i)
        quit()

print(-1)

Buggy submission (verdict: Runtime Error):
n, m = map(int,input().split())
s = [list(map(int,input().split())) for _ in range(m)]
s.sort(key=lambda x: x[0])
if m == 0:
    print(10**(n-1))
for i in range(1,1000):
    num = str(i)
    count = 0
    if s[-1][0] > len(num):
        continue
    for j in range(m):
        if num[s[j][0]-1] == str(s[j][1]):
            count += 1
        else:
            break
    if n == count:
        print(num)
        quit()
print(-1)

Buggy submission (verdict: Runtime Error):
n, m = map(int,input().split())
s = [list(map(int,input().split())) for _ in range(m)]
s.sort(key=lambda x: x[0])
for i in range(1,1000):
    num = str(i)
    count = 0
    if s[-1][0] > len(num):
        continue
    for j in range(m):
        if num[s[j][0]-1] == str(s[j][1]):
            count += 1
        else:
            break
    if n == count:
        print(num)
        quit()
print(-1)

Buggy submission (verdict: Runtime Error):
n, m = map(int,input().split())
s = [list(map(int,input().split())) for _ in range(m)]
s.sort(key=lambda x: x[0])
for i in range(1,1000):
    num = str(i)
    count = 0
    if s[-1][0] > len(num):
        continue
    for j in range(m):
        if num[s[j][0]-1] == str(s[j][1]):
            count += 1
        if n == count:
            print(num)
            quit()
print(-1)

Buggy submission (verdict: Runtime Error):
n, m = map(int,input().split())
s = [list(map(int,input().split())) for _ in range(m)]
s.sort(key=lambda x: x[0])
for i in range(1,1000):
    num = str(i)
    count = 0
    if s[-1][0] > len(num):
        continue
    for j in range(m):
        if num[s[j][0]-1] == str(s[j][1]):
            count += 1
        else:
            break
        if len(num) == count:
            print(num)
            quit()

print(-1)
Problem p02789 (python)

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

if n == m:
    print('Yes')
else:
    print('No')

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

ans = 0
for i in range(n):
    if i == 0:
        ans += 1
        m = p[0]
        continue
    if p[i] <= m:
        ans += 1
        m = p[i]

print(ans)
Problem p02817 (python)

Fixed submission:
s,t = map(str,input().split())
print(t+s)

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

print(t+s)
Problem p02886 (python)

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

r  = 0
for i in range(N-1):
    for j in range(i + 1,N):
        r += d[i] * d[j]
print(r)

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

r  = 0
for i in range(N-1):
    for f in range(i + 1,N):
        r += d[i] * d[j]
print(r)
Problem p02947 (python)

Fixed submission:
from collections import Counter
from scipy import misc
n = int(input())
s = [list(input()) for _ in range(n)]

ss = []
for i in range(n):
    a = sorted(s[i])
    a = ''.join(a)
    ss.append(a)

ss = Counter(ss)
ans = 0
n = len(ss)
k = ss.keys()
for i in k:
    if ss[i] == 1:
        continue
    if ss[i] >= 2:
        ans += round(float(misc.comb(ss[i],2)))
print(int(ans))

Buggy submission (verdict: Runtime Error):
from collections import Counter
from math import factorial
n = int(input())
s = [list(input()) for _ in range(n)]

ss = []
for i in range(n):
    a = sorted(s[i])
    a = ''.join(a)
    ss.append(a)

ss = Counter(ss)
ans = 0
n = len(ss)
k = ss.keys()
for i in k:
    if ss[i] == 1:
        continue
    if ss[i] > 2:
        ans += factorial(ss[i]) / 2 / factorial(ss[i]-2)
    else:
        ans += 1
print(int(ans))

Buggy submission (verdict: Runtime Error):
from collections import Counter
from math import factorial
n = int(input())
s = [list(input()) for _ in range(n)]

ss = []
for i in range(n):
    a = sorted(s[i])
    a = ''.join(a)
    ss.append(a)

ss = Counter(ss)
ans = 0
n = len(ss)
k = ss.keys()
for i in k:
    if ss[i] == 1:
        continue
    if ss[i] > 2:
        ans += factorial(ss[i]) / 2 / factorial(ss[i]-2)
    else:
        ans += 1
print(int(ans))
Problem p02995 (python)

Fixed submission:
import fractions
a, b, c, d = map(int,input().split())

l = int(fractions.gcd(c,d) * c / fractions.gcd(c,d) * d / fractions.gcd(c,d))
#print(l)
x = b // c - a // c
y = b // d - a // d
z = b // l - a // l
if a % c == 0 or a % d == 0:
    print(int(b-a-(x+y-z)))
else:
    print(int(b-a-(x+y-z))+1)
#print(x,y,z)

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

l = int(math.gcd(c,d) * c / math.gcd(c,d) * d / math.gcd(c,d))
#print(l)
x = b // c - a // c
y = b // d - a // d
z = b // l - a // l
if a % c == 0 or a % d == 0:
    print(int(b-a-(x+y-z)))
else:
    print(int(b-a-(x+y-z))+1)
#print(x,y,z)
Problem p03160 (python)

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

dp = [0] * n

for i in range(1,n):
    if i == 1:
        dp[i] = abs(h[i]-h[0])
        continue
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
h = list(map(int,input().split()))

dp = [math.inf] * n
dp[0] = 0

for i in range(1,n):
    if i == 1:
        dp[i] = abs(h[i]-h[0])
        continue
    #print(dp)
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])
Problem p03163 (python)

Fixed submission:
n, w = map(int,input().split())
wv = [list(map(int,input().split())) for _ in range(n)]

def knapsack(n,w,wv):
    inf = float('inf')
    dp = [[-inf for _ in range(w+1)] for _ in range(n+1)]
    for i in range(w+1): dp[0][i] = 0

    for i in range(n):
        for w in range(w+1):
            if wv[i][0]<=w:
                dp[i+1][w] = max(dp[i][w-wv[i][0]]+wv[i][1],dp[i][w])
            else:
                dp[i+1][w] = dp[i][w]
    return dp[n][w]

print(knapsack(n,w,wv))

Buggy submission (verdict: Runtime Error):
v
Problem p03260 (python)

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

Buggy submission (verdict: Runtime Error):
a, b = map(int,input())
if (a*b) % 2 != 0:
    print('Yes')
else:
    print('No')
Problem p03455 (python)

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

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

x = 0
y = 0
for i in range(n):
    t = l[i][0]
    x = l[i][1]
    y = l[i][2]
    d = x + y
    if d <= t and (d - t) % 2 == 0:
        continue
    else:
        print('No')
        quit()
print('Yes')
Problem p03477 (python)

Fixed submission:
a, b, c, d = map(int, input().split())
l = a + b
r = c + d
if l > r:
	print ("Left")
elif l == r:
	print ("Balanced")
else:
	print ("Right")

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
L = a + b
R = c + d
if L > R:
    print('Left')
elif L == R:
    print('balanced')
else L < R:
    print('Right')
Problem p03679 (python)

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

if a >= b:
    print('delicious')
elif b - a < x+1:
    print('safe')
else:
    print('dangerous')

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

mod = 10**9 + 7

if abs(n-m) > 1:
    print(0)
    quit()

elif abs(n-m) == 1:
    a = max(n,m)
    b = min(n,m)
    ans = 1
    for i in range(1,a+1):
        ans *= (i%mod)
        ans %= mod
    for i in range(1,b+1):
        ans *= (i%mod)
        ans %= mod
    print(ans%mod)

else:
    ans = 1
    for i in range(1,n+1):
        ans *= i
        ans %= mod
    for i in range(1,n+1):
        ans *= i
        ans %= mod
    print((2*ans)%mod)
Problem p03773 (python)

Fixed submission:
a, b = map(int,input().split())
print((a+b)%24)

Buggy submission (verdict: Runtime Error):
n = int(input())
ele = []
i = 1
while i * i <= n:
    if n % i == 0:
        ele.append([len(str(i)),len(str(n // i))])
    i += 1

k = max(ele[0][1],ele[0][0])
for i in range(len(ele)):
    k = min(max(ele[i][0],ele[i][1]),k)
print(k)
Problem p04025 (python)

Fixed submission:
import statistics
n = int(input())
a = list(map(int,input().split()))

mean = round(statistics.mean(a))

ans = 0
for i in range(n):
    ans += (a[i]-mean)**2

print(ans)

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

mean = round(statistics.mean(a))

ans = 0
for i in range(n):
    ans += (a[i]-mean)**2

print(ans)
Problem p02630 (python)

Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]
freq = [0 for i in range(10**5+1)]
for x in A:
    freq[x] += 1
ans = sum(A)
for q in range(int(input())):
    B, C = map(int,input().split())
    ans -= B*freq[B]
    ans += C*freq[B]
    freq[C] += freq[B]
    freq[B] = 0
    print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]
freq = [0 for i in range(10**5)]
for x in A:
    freq[x] += 1
ans = sum(A)
for q in range(int(input())):
    B, C = map(int,input().split())
    ans -= B*freq[B]
    ans += C*freq[B]
    freq[C] += freq[B]
    freq[B] = 0
    print(ans)
Problem p03545 (python)

Fixed submission:
def conv(c): return '+' if c==1 else '-'
def main():
	num = [int(c) for c in input()]
	choices = [-1,1]
	for a in choices:
		for b in choices:
			for c in choices:
				if num[0]+num[1]*a+num[2]*b+num[3]*c==7:
					print("{}{}{}{}{}{}{}=7".format(num[0],conv(a),num[1],conv(b),num[2],conv(c),num[3]))
					return
main()

Buggy submission (verdict: Runtime Error):
def conv(c): return '+' if c==1 else '-'
def main():
	num = [int(c) for c in input()]
	choices = [-1,1]
    for a in choices:
		for b in choices:
			for c in choices:
				if num[0]+num[1]*a+num[2]*b+num[3]*c==7:
					print("{}{}{}{}{}{}{}=7".format(num[0],conv(a),num[1],conv(b),num[2],conv(c),num[3]))
                    return
main()
Problem p02658 (python)

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

aa = set(A)
ans = 1
for i in range(len(A)):
    if(ans > 10**18):
        if(0 not in aa):
            ans = -1
            break
        else:
            ans = 0
    ans *= A[i]

if(ans > 10**18):
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
import decimal
N = int(input())
A = list(input().split())

ans = 1
for i in range(len(A)):
    ans *= decimal.Decimal(A[i])
    
if(len(str(ans)) >= 18):
    print(-1)
else:
    print(ans)
Problem p02664 (python)

Fixed submission:
T = input()

ans = ""
for i in range(len(T)):
    if(T[i] == "?"):
        ans +="D"
    else:
        ans += T[i]
print(ans)

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

ans = ""
for i in range(len(T)):
    if(T[i] == "P" or T[i] == "D"):
        ans += T[i]
    elif(i != 0 and ans[i-1] == "P"):
        ans += "D"
    elif(i != len(T)-1 and T[i+1] == "?"):
        ans += "P"
    elif(i != len(T)-1 and T[i+1] == "D"):
        ans += "P"

print(ans)
Problem p02760 (python)

Fixed submission:
import numpy as np
Flg = "No"
A = [[0]*3 for i in range(3)]
for i in range(3):
    A[i][0], A[i][1], A[i][2] = map(int, input().split())    
N = int(input())
b = [0]*N
for j in range(N):
    b[j] = int(input())

for i in range(3):
    for j in range(3):
        for k in range(N):
            if(A[i][j] == b[k]):
                A[i][j] = "*"
A_T = np.array(A).T
                
for i in range(3):
    if(A[i][0] == A[i][1] == A[i][2] == "*"):
        Flg = "Yes"        
        break
    if(A_T[i][0] == A_T[i][1] == A_T[i][2] == "*"):
        Flg = "Yes"
        break

if(A[0][0] == A[1][1] == A[2][2] == "*"):
    Flg = "Yes"

if(A[0][2] == A[1][1] == A[2][0] == "*"):
    Flg = "Yes"

print(Flg)

Buggy submission (verdict: Runtime Error):
port numpy as np
Flg = "No"
A = [[0]*3 for i in range(3)]
for i in range(3):
    A[i][0], A[i][1], A[i][2] = map(int, input().split())    
N = int(input())
b = [0]*N
for j in range(N):
    b[j] = int(input())

for i in range(3):
    for j in range(3):
        for k in range(N):
            if(A[i][j] == b[k]):
                A[i][j] = "*"
A_T = np.array(A).T
                
for i in range(3):
    if(A[i][0] == A[i][1] == A[i][2] == "*"):
        Flg = "Yes"        
        break
    if(A_T[i][0] == A_T[i][1] == A_T[i][2] == "*"):
        Flg = "Yes"
        break

if(A[0][0] == A[1][1] == A[2][2] == "*"):
    Flg = "Yes"

if(A[0][2] == A[1][1] == A[2][0] == "*"):
    Flg = "Yes"

print(Flg)

Buggy submission (verdict: Runtime Error):
import numpy as np
Flg = "No"
A = [[0]*3]*3
b = [0]*N
for i in range(3):
    A[i][0], A[i][1], A[i][2] = map(int, input().split())    
N = int(input())
for j in range(N):
    b[j] = int(input())
    
for i in range(3):
    for j in range(3):
        for k in range(N):
            if(A[i][j] == b[k]):
                A[i][j] = 0
A_T = np.array(A).T
                
for i in range(3):
    if(A[i][0] == A[i][1] == A[i][2] == 0):
        Flg = "Yes"        
        break
    if(A_T[i][0] == A_T[i][1] == A_T[i][2] == 0):
        Flg = "Yes"
        break

if(A[0][0] == A[1][1] == A[2][2] == 0):
    Flg = "Yes"

print(Flg)
Problem p02787 (python)

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

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

dp = [0 for _ in range(10**5)]

for i in range(H):
    dp[i] = min(dp[i-a]+b for a, b in magic)

print(dp[H-1])

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

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

dp = [0 for _ in range(H+1)]

for i in range(H):
    dp[i] = min(dp[i-a]+b for a, b in magic)

print(dp[H-1])
Problem p02882 (python)

Fixed submission:
from math import degrees, atan, radians
a, b, x = map(int, input().split())

if(x <= 0.5*a*a*b):
    y = x/(0.5*b*a)
    ans = 90-degrees(atan(y/b))
    print(ans)
elif(x == a*a*b):    
    print(0)
else:
    y = x/(0.5*a**2)-b
    ans = 90-degrees(atan((a/(b-y))))
    print(ans)

Buggy submission (verdict: Runtime Error):
from math import degrees, atan, radians
a, b, x = map(int, input().split())

if(x < 0.5*a*a*b):
    y = x/(0.5*b*a)
    ans = 90-degrees(atan(y/b))
    print(ans)
elif(x == 0.5*a*a*b)    
    print(0)
else:
    y = x/(0.5*a**2)-b
    ans = 90-degrees(atan((a/(b-y))))
    print(ans)

Buggy submission (verdict: Runtime Error):
from math import degrees, atan, radians
a, b, x = map(int, input().split())

if(x <= 0.5*a*a*b):
    y = x/(0.5*b*a)
    ans = 90-degrees(atan(y/b))
    print(ans)
else:
    y = x/(0.5*a**2)-b
    ans = 90-degrees(atan((a/(b-y))))
    print(ans)
Problem p02947 (python)

Fixed submission:
import collections
import math

def combinations_count(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

N = int(input())
s = [""]*N
for i in range(N):
    s[i] = ','.join(sorted(input()))

c = collections.Counter(s)
ans = 0
for value in c.values():
    if(value == 1):
        continue
    ans += combinations_count(value, 2)
    
print(ans)

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

def combinations_count(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

N = int(input())
s = [""]*N
for i in range(N):
    s[i] = ','.join(sorted(input()))

c = collections.Counter(s)
ans = 0
for value in c.values():
    ans += combinations_count(value, 2)
    
print(ans)
Problem p02982 (python)

Fixed submission:
import math
N, D = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(N)]

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        tmp = 0
        for k in range(D):
            tmp+=(x[i][k]-x[j][k])**2
        if(math.sqrt(tmp).is_integer()):
            cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
import math
N, D = map(int, input().split())
for i in range(N):
    x = list(map(int, input().split()))

cnt = 0
for i in range(D):
    for j in range(i+1, D):
        tmp = 0.0
        for k in range(D):
            tmp += (x[i][k]-x[j][k])**2
        if(math.sqrt(tmp).is_integer()):
            cnt += 1
print(cnt)
Problem p02995 (python)

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

num = (C*D)//(fractions.gcd(C, D))
if(A%C==0):
    num1 = A//C-1
else:
    num1 = A//C
if(A%D==0):
    num2 = A//D-1
else:
    num2 = A//D
if(A%num == 0):
    num3 = A//num-1
else:
    num3 = A//num
print(int(B-A+1-((B//C-num1)+(B//D-num2)-(B//num-num3))))

Buggy submission (verdict: Runtime Error):
import math
A, B, C, D = map(int, input().split())

num = (C*D)//(math.gcd(C, D))
if(A%C==0):
    num1 = A//C-1
else:
    num1 = A//C
if(A%D==0):
    num2 = A//D-1
else:
    num2 = A//D
if(A%num == 0):
    num3 = A//num-1
else:
    num3 = A//num
print(int(B-A+1-((B//C-num1)+(B//D-num2)-(B//num-num3))))

Buggy submission (verdict: Runtime Error):
import math
A, B, C, D = map(int, input().split())

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

num = lcm(C, D)
if(A%C==0):
    num1 = A//C-1
else:
    num1 = A//C
if(A%D==0):
    num2 = A//D-1
else:
    num2 = A//D
if(A%num == 0):
    num3 = A//num-1
else:
    num3 = A//num
print(int(B-A+1-((B//C-num1)+(B//D-num2)-(B//num-num3))))
Problem p03006 (python)

Fixed submission:
import collections

N = int(input())
X = []
for i in range(N):
    X.append(list(map(int, input().split())))

div = []
for i in range(N):
    for j in range(N):
        if(i == j):
            continue
        div.append(tuple((X[i][0]-X[j][0], X[i][1]-X[j][1])))
        
c = collections.Counter(div)
c_s = sorted(c.items(), key=lambda x:x[1], reverse=True)

if(N == 1):
    print(1)
else:
    print(N-c_s[0][1])

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())
X = []
for i in range(N):
    X.append(list(map(int, input().split())))

div = []
for i in range(N):
    for j in range(N):
        if(i == j):
            continue
        div.append(tuple((X[i][0]-X[j][0], X[i][1]-X[j][1])))
        
c = collections.Counter(div)
c_s = sorted(c.items(), key=lambda x:x[1], reverse=True)

print(N-c_s[0][1])
Problem p03047 (python)

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

Buggy submission (verdict: Runtime Error):
n, k = map(int, input())
print(n-k+1)
Problem p03068 (python)

Fixed submission:
N = int(input())
S = input()
K = int(input())
ans = ""

for i in range(N):
    if(S[K-1] != S[i]):
        ans += "*"
    else:
        ans += S[K-1]
print(ans)

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

for i in range(N):
    if(S[K] != S[i]):
        ans += "*"
    else:
        ans += S[K]
print(ans)