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

Fixed submission:
import sys
K = int(input())
count = 0
nine = ""

arr = []
arr_sunuke = []
for k in range(14):
    for i in range(10):
        for j in range(10):
            for l in range(10):
                if i == 0 and nine != "":
                    pass
                else:
                    arr.append(int(str(i)+str(j)+str(l)+nine))
                    arr_sunuke.append(i + j + l + k*9)
    nine = nine + str(9)

arr.remove(0)
arr_sunuke.remove(0)
arr_sunuke2 = [arr[i]/arr_sunuke[i] for i in range(len(arr))]

ans = []
tmp = 10**15
for i in range(len(arr)-1, -1, -1):
    if arr_sunuke2[i] <= tmp:
        ans.append(arr[i])
        tmp = arr_sunuke2[i]

ans = ans[::-1]
for i in range(K):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
import sys
K = int(input())
count = 0
nine = ""

arr = [i for i in range(1,10)]
arr_sunuke = [i for i in range(1,10)]
for k in range(13):
    for i in range(1,10):
        for j in range(10):
            arr.append(int(str(i)+str(j)+nine))
            arr_sunuke.append(i + j + k*9)
    nine = nine + str(9)


arr_sunuke2 = [arr[i]/arr_sunuke[i] for i in range(len(arr))]

ans = []
tmp = 100000000000000
for i in range(len(arr)-1, -1, -1):
    if arr_sunuke2[i] <= tmp:
        ans.append(arr[i])
        tmp = arr_sunuke2[i]

ans = ans[::-1]
for i in range(K):
    print(ans[i])
Problem p03713 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

H, W = map(int, input().split())

if H < W:
    H, W = W, H

S = H * W
for i in range(1, H):
    A = i * W
    BH1 = ((H-i)//2) * W
    BH2 = ((H-i)//2+(H-i)%2) * W
    BW1 = (W//2) * (H-i)
    BW2 = (W//2+W%2) * (H-i)
    SH = max(A,BH1,BH2) - min(A,BH1,BH2)
    SW = max(A,BW1,BW2) - min(A,BW1,BW2)
    S = min(S, SH, SW)

for i in range(1, W):
    A = i * H
    BH1 = ((W-i)//2) * H
    BH2 = ((W-i)//2+(W-i)%2) * H
    BW1 = (H//2) * (W-i)
    BW2 = (H//2+H%2) * (W-i)
    SH = max(A,BH1,BH2) - min(A,BH1,BH2)
    SW = max(A,BW1,BW2) - min(A,BW1,BW2)
    S = min(S, SH, SW)

print(S)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

H, W = map(int, input().split())

if H > W:
    H, W = W, H

if H%3 == 0 or W%3 == 0:
    print(0)
elif H%2 == 0:
    H_div = H//2
    W_div = round(W/3)
    print(abs(H_div*(W-W_div) - H*W_div))
    print(a)
else:
    H_div = round(H/3)
    W_div = W//2
    H_div2 = H//2
    W_div2 = round(W/3)
    print(min(abs(H_div*W - (H-H_div)*W_div), abs(W_div*H - (W-W_div)*H_div)))
Problem p03951 (python)

Fixed submission:
N = int(input())
s = input()
t = input()

count = 0
for i in range(len(s)):
    if t[:i+1] in s[-i-1:]:
        count = i+1
    else:
        pass

print(len(s)+len(t)-count)

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

count = 0
for i in range(len(s)):
    if t[i] == s[-i-1]:
        count += 1
    else:
        break

if s = t:
    print(len(s))
else:
    print(len(s)+len(t)-count)
Problem p02814 (python)

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

n,M = map(int,input().split())
a = list(map(int,input().split()))

a = sorted(list(set(a)))
b = [a[i]//2 for i in range(len(a))]

owa = 0
saiko = b[0]

for i in range(1,len(a)):
    t1 = b[i]
    koe = gcd(saiko,t1)
    saiko = (saiko*t1)//koe
    if (saiko//b[i])%2 == 0:
        break

for i in range(len(a)):
    check = saiko//(b[i])
    if check%2 == 0:
        owa = 1
        break

if owa == 1:
    print(0)
else:
    if (M//saiko)%2 == 0:
        print((M//saiko)//2 )
    else:
        print(((M//saiko)+1)//2)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    if a%b == 0:
        return b
    else:
        return gcd(b,a%b)

n,M = map(int,input().split())
a = list(map(int,input().split()))

saiko = 0
t = a[0]//2
for i in range(1,n):
    t1 = a[i]//2
    koe = gcd(t1,t)
    saiko = (t*t1)//koe


if (M//saiko)%2 == 0:
    print((M//saiko)//2 )
else:
    print(((M//saiko)+1)//2)
Problem p02963 (python)

Fixed submission:
s = int(input())
m = int(s**0.5)

l = s - m*m
if l<0:
    m = m-1
    l = s - m*m



if l < 1000000000 and m < 1000000000:
    print(0,1,m,0,l,m+1)
    #print(m*m + l)
elif m == 1000000000:
    print(0,0,m,0,0,m)
else:
    l = (m+1)*(m+1)-s
    if l < 1000000000:
        print(0,0,m+1,1,l,m+1)
    else:
        for i in range(2,int(l**0.5) +1):
            if l%i == 0:
                t =i
                break
        print(0,0,m+1,t,l//t,m+1)

Buggy submission (verdict: Runtime Error):
import math
s = int(input())
m = int(s**0.5)

l = s - m*m
if l<0:
    m = m-1
    l = s - m*m



if l < 1000000000 and m < 1000000000:
    print(0,1,m,0,l,m+1)
    #print(m*m + l)
elif m = 1000000000:
    print(0,0,m,0,0,m)
Problem p03006 (python)

Fixed submission:
import collections


n = int(input())

l = []
for i in range(n):
    xa,ya = map(int,input().split())
    l.append([xa,ya])
if n == 1:
    print(1)
else:
    s = []
    for i in range(n):
        for k in range(i+1,n):
            xdis = l[k][0]-l[i][0]
            ydis = l[k][1]-l[i][1]
            if xdis < 0 and ydis < 0:
                xdis = xdis*(-1)
                ydis = ydis*(-1)
            if xdis < 0 and ydis == 0:
                xdis = xdis*(-1)
            if xdis < 0 and ydis >0:
                xdis = xdis*(-1)
                ydis = ydis*(-1)
            if xdis == 0 and ydis < 0:
                ydis = ydis*(-1)
            dist = (xdis,ydis)
            s.append(dist)

    #print(s)

    c = collections.Counter(s)
    #print(c)
    print(n - c.most_common()[0][1])

Buggy submission (verdict: Runtime Error):
import collections


n = int(input())

l = []
for i in range(n):
    xa,ya = map(int,input().split())
    l.append([xa,ya])

s = []
for i in range(n):
    for k in range(i+1,n):
        if (l[k][0]-l[i][0] > 0) == (l[k][1]-l[i][1] > 0):
            sign = 1
        else:
            sign = 0
        dist = ((l[k][0]-l[i][0]),(l[k][1]-l[i][1]),sign)
        s.append(dist)

#print(s)

c = collections.Counter(s)
print(n - c.most_common()[0][1])
Problem p03078 (python)

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

a = sorted(a)
b = sorted(b)
c = sorted(c)

la = []

for i in range(x):
    s = x-i
    for n in range(max(y-5-3000//s,0),y):
        u = y-n
        for m in range(max(z-5-3000//(s*u),0),z):
            #print(s,u,m)
            la.append(a[i]+b[n]+c[m])

la = sorted(la)

for i in range(k):
    print(la[-i-1])

Buggy submission (verdict: Runtime Error):
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a = sorted(a)
b = sorted(b)
c = sorted(c)

la = []

for i in range(x):
    s = 3000-i
    for n in range(max(y-5-3000/s,0),y):
        u = 3000-n
        for m in range(max(z-5-3000/(s*u),0),z):
            la.append(a[i]+b[n]+c[m])

la = sorted(la)

for i in range(k):
    print(la[-i-1])

Buggy submission (verdict: Runtime Error):
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a = sorted(a)
b = sorted(b)
c = sorted(c)

la = []

for i in range(x):
    for n in range(max(y-3000//(i+1),0),y):
        for m in range(max(z-3000//((i+1)*(k+1)),0),z):
            la.append(a[i]+b[n]+c[m])

la = sorted(la)

for i in range(k):
    print(la[-i-1])

Buggy submission (verdict: Runtime Error):
x,y,z,q = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a = sorted(a)
b = sorted(b)
c = sorted(c)



if  x*y*z <100000
    la = []
    for i in range(x):
        for k in range(y):
            for m in range(z):
                la.append(a[i]+b[k]+c[m])
    la = sorted(la)

    for p in range(q):
        print(la[-p-1])

else:
    la  = []
    for i in range(x):
        for k in range(3000//i, y):
            for m in range(3000//(i*k), z):
                la.append(a[i]+b[k]+c[m])
    la = sorted(la)
    for i in range(q):
        print(la[-i-1])
Problem p03087 (python)

Fixed submission:
N,Q = list(map(int, input().split()))
S = str(input())
lr=[]
for i in range(Q):
    lr.append(list(map(int, input().split())))


count=[0]

k = 0
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        k += 1
    count.append(k)

for i,j in lr:
    print(count[j-1]-count[i-1])

Buggy submission (verdict: Runtime Error):
N,Q = list(map(int, input().split()))
S = str(input())
lr=[]
for i in range(Q):
    lr.append(list(map(int, input().split())))
 
import numpy as np
 
count=np.array([0 for i in range(N)])
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        count[i+1:]+=1
 
for i,j in lr:
    print(count[j-1]-count[i-1])
Problem p03128 (python)

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

dp = [[] for k in range(n+1)]

cost = [0,2,5,5,4,5,6,3,7,6]

#dpの初期化
for i in range(m):
    if cost[a[i]] <= n:
        dp[cost[a[i]]]= [a[i]]


for i in range(0,n+1):
    for k in range(m):
        if i > cost[a[k]]:
            #print(cost[a[k]])
            tmp = copy.copy(dp[i-cost[a[k]]])
            tmp.append(a[k])
            tmp.sort(reverse = True)
            #print(i,tmp)
            if len(tmp) > len(dp[i]) and len(tmp) != 1:
                dp[i] = tmp
            elif len(tmp) == len(dp[i]) and len(tmp) != 1:
                big = 0

                for s in range(len(tmp)):
                    if tmp[s] > dp[i][s]:
                        big = 1
                        break
                    elif tmp[s] < dp[i][s]:
                        big = 0
                        break
                if(big):
                    dp[i] = tmp
            #print(dp)

ans = ""
for cha in dp[n]:
    ans = ans + str(cha)
print(ans)

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

dp = [[] for k in range(n+1)]

cost = [0,2,5,5,4,5,6,3,7,6]

#dpの初期化
for i in range(m):
    dp[cost[a[i]]]= [a[i]]


for i in range(0,n+1):
    for k in range(m):
        if i > cost[a[k]]:

            tmp = copy.copy(dp[i-cost[a[k]]])
            tmp.append(a[k])
            tmp.sort(reverse = True)
            #print(i,tmp)
            if len(tmp) > len(dp[i]) and len(tmp) != 1:
                dp[i] = tmp
            elif len(tmp) == len(dp[i]) and len(tmp) != 1:
                big = 1
                for s in range(len(tmp)):
                    if tmp[s] < dp[i][s]:
                        big = 0
                if(big):
                    dp[i] = tmp

ans = ""
for cha in dp[n]:
    ans = ans + str(cha)
print(ans)
Problem p03213 (python)

Fixed submission:
n = int(input())
prits = [0 for i in range(n+1)]

for i in range(1,n+1):
    k = 2
    while k*k<=i:
        while i%k == 0:
            i = i//k
            prits[k] += 1
        k += 1
    if i>1 :
        prits[i] += 1
#print(prits)

a,b,c,d,e = [],[],[],[],[]

for i in range(len(prits)):
    num = prits[i]
    if num >=2:
        e.append(i)
    if num >=4:
        d.append(i)
    if num >=14:
        c.append(i)
    if num >=24:
        b.append(i)
    if num >=74:
        a.append(i)

#print(len(a),len(b),len(c),len(d),len(e))

ans = 0
ans += len(a)
ans += len(c)*(len(d)-1)
ans += len(b)*(len(e)-1)
ans += len(d)*(len(d)-1)*(len(e)-2)//2

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
import sympy
prits = [0 for i in range(n+1)]

for i in range(1,n+1):
    k = 2
    while k*k<=i:
        while i%k == 0:
            i = i//k
            prits[k] += 1
        k += 1
    if i>1 :
        prits[i] += 1
#print(prits)

a,b,c,d,e = [],[],[],[],[]

for i in range(len(prits)):
    num = prits[i]
    if num >=2:
        e.append(i)
    if num >=4:
        d.append(i)
    if num >=14:
        c.append(i)
    if num >=24:
        b.append(i)
    if num >=74:
        a.append(i)

#print(len(a),len(b),len(c),len(d),len(e))

ans = 0
ans += len(a)
ans += len(c)*(len(d)-1)
ans += len(b)*(len(e)-1)
ans += len(d)*(len(d)-1)*(len(e)-2)//2

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
import sympy
prits = [0 for i in range(n+1)]

for i in range(1,n+1):
    nums = sympy.factorint(i)
    #print(nums)
    for k in nums:
        prits[k] += nums[k]

#print(prits)

a,b,c,d,e = [],[],[],[],[]

for i in range(len(prits)):
    num = prits[i]
    if num >=2:
        e.append(i)
    if num >=4:
        d.append(i)
    if num >=14:
        c.append(i)
    if num >=24:
        b.append(i)
    if num >=74:
        a.append(i)

#print(len(a),len(b),len(c),len(d),len(e))

ans = 0
ans += len(a)
ans += len(c)*(len(d)-1)
ans += len(b)*(len(e)-1)
ans += len(d)*(len(d)-1)*(len(e)-2)//2

print(ans)
Problem p03287 (python)

Fixed submission:
n,m = map(int,input().split())
a = list(map(int,input().split()))
sums = [0]
sum = 0
ans = 0

for i in range(n):
    sum += a[i]
    sums.append(sum)



dic = {}

for i in range(n+1):
    dic.setdefault(str(sums[i]%m),0)
    dic[str(sums[i]%m)] += 1

for key in dic.keys():
    k = dic[key]
    if k>1:
        ans += k*(k-1)//2

print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = list(map(int,input().split()))
sums = []
sum = 0
ans = 0

for i in range(n):
    sum += a[i]
    sums.append(sum)



dic = {}
for i in range(n):
    dic.setdefault(str(sums[i]%m),0)
    dic[str(sums[i]%m)] += 1
dic["0"]+= 1
#print(dic)

for key in dic.keys():
    k = dic[key]
    if k>1:
        ans += k*(k-1)//2

print(ans)
Problem p03324 (python)

Fixed submission:
d,n = map(int,input().split())
if d == 0 and n != 100:
    print(n)
elif d == 0 and n == 100:
    print(101)
elif d == 1 and n != 100:
    print(n*100)
elif d == 1 and n == 100:
    print(10100)
elif d == 2 and n != 100:
    print(n*10000)
else:
    print(1010000)

Buggy submission (verdict: Runtime Error):
d,n = map(int,input().split())
if d == 0 and n != 100:
    print(n)
elif d == 0 and n == 100:
    print(101)
elif d == 1 and n != 100:
    print(n*100)
elif d == 1 and n == 100:
    print(10100)
elif d == 2 and n != 100:
    print(n*10000)
elif:
    print(1010000)
Problem p03352 (python)

Fixed submission:
x = int(input())
if x != 1:
  a = []
  for i in range(2,34):
      n = i**2
      while n <= x:
          a.append(n)
          n = n*i

  print(max(a))
else:
  print(1)

Buggy submission (verdict: Runtime Error):
x = int(input())
a = []
for i in range(2,34):
	n = i**2
	while n <= x:
		a.append(n)
		n = n*i

print(max(a))
Problem p03353 (python)

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

c = []


for i in range(len(s)):
    for k in range(1,m+1):
        c.append(s[i:i+k])

b = sorted(list(set(c)))


print(b[m-1])

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

c = []

if len(s) < 100:

    for i in range(len(s)):
        for k in range(1,len(s)+1):
            c.append(s[i:i+k])

    b = sorted(list(set(c)))

    print(b[m-1])

else:
    po = []
    for i in range(len(s)):
        if s[i] not in po:
            po.append(s[i])

    for i in range(len(s)):
        if s[i:i+2] not in po:
            po.append(s[i:i+2])

    for i in range(len(s)):
        if s[i:i+3] not in po:
            po.append(s[i:i+3])
    print(po[m-1])

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

c = []

if len(s) < 100:

    for i in range(len(s)):
        for k in range(1,len(s)+1):
            c.append(s[i:i+k])

    b = sorted(list(set(c)))

    print(b[m-1])

else:
    po = []
    for i in range(len(s)):
        po.append(s[i])
    po = sorted(set(po))
    print(po[m-1])
Problem p03385 (python)

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

Buggy submission (verdict: Runtime Error):
S = list(input().split())
if "a" in S and "b" in S and "c" in S:
	print("YES)
else:

Buggy submission (verdict: Runtime Error):
S = input()
if "a" in S and "b" in S and "c" in S:
	print("YES)
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <string>

int main(){
  string S;
  cin >> S;
  if (s.find("a") != std::string::npos && s.find("b") != std::string::npos && s.find("c") != std::string::npos){
  cout << "YES" << endl;
  }
  else
  cout << "NO" << endl;
}
Problem p03447 (python)

Fixed submission:
x = int(input())
a = int(input())
b = int(input())

print((x-a)%b)

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

x = [-1 for k in range(n)]
ans = "Yes"


for i in range(m):
    b = input().split()
    if i == 0:
        x[int(b[0])-1] = 0
        x[int(b[1])-1] = x[int(b[0])-1] + int(b[2])

    else:
        if (x[int(b[1])-1] != -1) and (x[int(b[1])-1] != (x[int(b[0])-1] + int(b[2]))):
            ans = "No"
            break
        else:
        	x[int(b[1])-1] = x[int(b[0])-1] + int(b[2])
        	

print(ans)
Problem p03543 (python)

Fixed submission:
N = input()
a = N[0]
b = N[1]
c = N[2]
d = N[3]
if a == b and b == c and c == d:
    print("Yes")
elif a == b and b == c:
    print("Yes")
elif b == c and c == d:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
a = n[0]
b = n[1]
c = n[2]
d = n[3]
if a == b and b == c and c == d:
    print("Yes")
elif a == b and b == c:
    print("Yes")
elif b == c and c == d:
    print("Yes")
else:
    print("No")
Problem p03557 (python)

Fixed submission:
import bisect

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a =sorted(a)
b =sorted(b)
c =sorted(c)

ans = 0
for i in range(n):
    in_a = bisect.bisect_left(a,b[i])
    in_c = bisect.bisect_right(c,b[i])
    ans += (in_a)*(n-in_c)


print(ans)

Buggy submission (verdict: Runtime Error):
import bisect

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a =sorted(a)
b =sorted(b)
c =sorted(c)

ans = 0
for i in range(n):
    in_in = bisect.bisect_left(b,a[i])
    if a[i] == b[in_in]:
        in_in += 1
    for k in range(in_in,n):
        insert_index = bisect.bisect_left(c,b[k])
        if b[k] == c[insert_index]:
            insert_index += 1
        ans += n-insert_index


print(ans)
Problem p03587 (python)

Fixed submission:
S =str(input())
a=S.count("1")
print(a)

Buggy submission (verdict: Runtime Error):
a
Problem p03657 (python)

Fixed submission:
a,b =map(int,input().split())
k = a%3
s = b%3
if k == s and k != 0:
  print("Impossible")
else:
  print("Possible")

Buggy submission (verdict: Runtime Error):
a,b =map(int,input().split())
k = a%3
s = b%3
if k ==s and k != 0:
  print("Impossible)
else:
  print("Possible")
Problem p03660 (python)

Fixed submission:
n = int(input())
a = [[] for i in range(n)]
for i in range(n-1):
    x,y = map(int,input().split())
    a[x-1].append(y-1)
    a[y-1].append(x-1)

def dfs(v):
    d = [-1 for i in range(n)]
    q = []
    d[v] = 0
    q.append(v)
    while len(q):
        v = q.pop()
        for i in a[v]:
            if d[i] == -1:
                d[i] = d[v]+1
                q.append(i)
    return d
c1 = dfs(0)
c2 = dfs(n-1)
c = 0
for i in range(n):
    if c1[i]>c2[i]:
        c += 1
if c>= n/2:
    print("Snuke")
else:
    print("Fennec")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [[] for i in range(n)]
for i in range(n):
    x,y = map(int,input().split())
    a[x-1].append(y-1)
    a[y-1].append(x-1)

def dfs(v):
    d = [-1 for i in range(n)]
    q = []
    d[v] = 0
    q.append(v)
    while len(q):
        v = q.pop()
        for i in a[v]:
            if d[i] == -1:
                d[i] = d[v]+1
                q.append(i)
    return d
c1 = dfs(0)
c2 = dfs(n-1)
c = 0
for i in range(n):
    if c1[i]>c2[i]:
        c += 1
if c>= n/2:
    print("Snuke")
else:
    print("Fennec")
Problem p03837 (python)

Fixed submission:
n,M =map(int,input().split())
inf = 10**15

dist = [[inf for i in range(n)] for i in range(n)]
route = [[ [] for i in range(n)] for i in range(n)]
import copy

for i in range(M):
    ak,bk,ck = map(int,input().split())
    dist[ak-1][bk-1]  =ck
    dist[bk-1][ak-1]  =ck

for i in range(n):
    for k in range(n):
        route[i][k] = [i,k]
        route[k][i] = [k,i]


for a in range(n):
    for b in range(n):
        for c in range(n):
            #print(a,b,c)
            if dist[b][a]+dist[a][c] < dist[b][c]:
                route[b][c] = copy.deepcopy(route[b][a]) + (copy.deepcopy(route[a][c])[1:])
                dist[b][c] =  dist[b][a]+dist[a][c]


#for i in range(n):
    #print(route[i])

used = [[0 for i in range(n)] for i in range(n)]
for i in range(n):
    for k in range(n):
        for m in range(len(route[i][k])-1):
            used[route[i][k][m]][route[i][k][m+1]] = 1
            used[route[i][k][m+1]][route[i][k][m]] = 1
#for i in range(n):
    #print(used[i])

ans = 0
for i in range(n):
    for k in range(n):
        if used[i][k]:
            ans += 1

print(M-(ans//2))

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

dist = [[inf for i in range(n)] for i in range(n)]
route = [[ [] for i in range(n)] for i in range(n)]
import copy

for i in range(m):
    ak,bk,ck = map(int,input().split())
    dist[ak-1][bk-1]  =ck
    dist[bk-1][ak-1]  =ck

for i in range(n):
    for k in range(n):
        route[i][k] = [i,k]
        route[k][i] = [k,i]

for a in range(n):
    for b in range(n):
        for c in range(n):
            if dist[b][a]+dist[a][c] < dist[b][c]:
                if route[b][a] == None:
                    route[b][c] = copy.deepcopy(route[a][c])[1:]
                else:
                    route[b][c] = copy.deepcopy(route[b][a]).extend(copy.deepcopy(route[a][c])[1:])
                dist[b][c] =  dist[b][a]+dist[a][c]

ans = 0
for i in range(n):
    for k in range(n):
        if route[i][k]:
            ans += 1

print(m-ans//2)

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

dist = [[inf for i in range(n)] for i in range(n)]
route = [[ [] for i in range(n)] for i in range(n)]
import copy

for i in range(m):
    ak,bk,ck = map(int,input().split())
    dist[ak-1][bk-1]  =ck
    dist[bk-1][ak-1]  =ck

for i in range(n):
    for k in range(n):
        route[i][k] = [i,k]
        route[k][i] = [k,i]

for a in range(n):
    for b in range(n):
        for c in range(n):
            if dist[b][a]+dist[a][c] < dist[b][c]:
                route[b][c] = copy.deepcopy(route[b][a]).extend(copy.deepcopy(route[a][c])[1:])
                dist[b][c] =  dist[b][a]+dist[a][c]
ans = 0
for i in range(n):
    for k in range(n):
        if route[i][k]:
            ans += 1

print(m-ans//2)
Problem p03261 (python)

Fixed submission:
n = int(input())
w = [""] * n 
result = "Yes"

for i in range(n):
    tmp = input()
    if tmp in w:
        result = "No"
    w[i] = tmp 
for i in range(n-1):
    if w[i][-1] == w[i+1][0]:
        pass
    else:
        result = "No"
print(result)

Buggy submission (verdict: Runtime Error):
n = int(input())
w = [""] * n 
result = "Yes"

for i in range(n):
    tmp = input()
    if tmp in w:
        result = "No"
        break
    w[i] = tmp 
for i in range(n-1):
    if w[i][-1] == w[i+1][0]:
        pass
    else:
        result = "No"
print(result)

Buggy submission (verdict: Runtime Error):
n = int(input())
w = [0] * n 
result = "Yes"

for i in range(n):
    tmp = input()
    if tmp in w:
        result = "No"
        break
    w[i] = tmp 
for i in range(n-1):
    if w[i][-1] == w[i+1][0]:
        pass
    else:
        result = "No"
print(result)

Buggy submission (verdict: Runtime Error):
n = int(input())
w = [0] * n 
result = "Yes"

for i in range(n):
    w[i] = int(input())
for i in range(n-1):
    if w[i][-1] == w[i+1][0]:
        pass
    else:
        result = "No"
print(result)