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

Fixed submission:
N,C = map(int,input().split())
D = [[int(i) for i in input().split()] for j in range(C)]
c = [[int(i) for i in input().split()] for j in range(N)]

c_sum = [[0]*C for _ in range(3)]
for i in range(N):
    for j in range(N):
        c_sum[(i+j)%3][c[i][j]-1] += 1

D_sum = [[0]*C for _ in range(3)]
for i in range(C):
    for j in range(C):
        for k in range(3):
            D_sum[k][j] += D[i][j] * c_sum[k][i]

ans = 1000*500*500
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i==j or j==k or k==i:
                continue
            else:
                ans = min(ans, D_sum[0][i]+D_sum[1][j]+D_sum[2][k])
print(ans)

Buggy submission (verdict: Runtime Error):
import sys

s = sys.stdin.readlines()

N,C = map(int,s[0].split())
D = [[int(i) for i in s[j+1].split()] for j in range(C)]
c = [[int(i) for i in s[c+1+j].split()] for j in range(N)]

c_sum = [[0]*C for _ in range(3)]
for i in range(N):
    for j in range(N):
        c_sum[(i+j)%3][c[i][j]-1] += 1

D_sum = [[0]*C for _ in range(3)]
for i in range(C):
    for j in range(C):
        for k in range(3):
            D_sum[k][j] += D[i][j] * c_sum[k][i]

ans = 1000*500*500
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i==j or j==k or k==i:
                continue
            else:
                ans = min(ans, D_sum[0][i]+D_sum[1][j]+D_sum[2][k])
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
s =sys.stdin.readlines()
N,C = map(int,s[0].split())
D = [[int(i) for i in sys[1+j].split()] for j in range(C)]
c = [[int(i) for i in sys[C+j].split()] for j in range(N)]

D_sum = [[0]*C for _ in range(3)]

for i in range(C):
    for j in range(N):
        for k in range(N):
            D_sum[(j+k)%3][i] += D[c[j][k]-1][i]
            
ans = 1000*500*500
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i==j or j==k or k==i:
                continue
            else:
                ans = min(ans, D_sum[0][i]+D_sum[1][j]+D_sum[2][k])
print(ans)
Problem p03359 (python)

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

if a<=b:
    print(a)
else:
    print(a-1)

Buggy submission (verdict: Runtime Error):
A = list(map(int,input().split()))
K = int(input())
 
A = A.sort
ans =A[0]+A[1]+A[2]*(2**K)

print(ans)

Buggy submission (verdict: Runtime Error):
A = list(map(int,input().split()))
K = int(input())
 
A.sort()
print(A[0]+A[1]+A[2]*2**K)

Buggy submission (verdict: Runtime Error):
A = list(map(int,input().split()))
K = int(input())
 
A.sort()
ans =A[0]+A[1]+A[2]*(2**K)

print(ans)
Problem p03363 (python)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

B = {}
B[0] = 1

s = 0
ans = 0

for a in A:
    s += a
    ans += B.get(s,0)
    B[s] = B.get(s,0)+1

print(ans)

Buggy submission (verdict: Runtime Error):
inport bisect

N = int(input())
A = [int(i) for i in input().split()]

B = [0]
X = [0]
ans = 0

for i in range(N):
    X.append(X[i]+A[i])
    insert_index = bisect.bisect_left(B,X[i+1])
    for j in range(insert_index,i+1):
        if B[j] == X[i+1]:
            ans += 1
        else:
            break

    B.insert(insert_index,X[i+1])

print(ans)

Buggy submission (verdict: Runtime Error):
import bisect

N = int(input())
A = [int(i) for i in input().split()]
 
B = [0]
X = [0]
ans = 0
for i in range(N):
    X.append(X[i]+A[i])
    insert_index = bisect.bisect_left(B,X[i+1])
    ans += bisect.bisect_right(B,X[i+1])-insert_incex
    B.insert(insert_index,X[i+1])
 
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split())]

ans = 0

for i in range(0,N-1):
 for j in range(i+1,N):
  if sum(A[i:j])==0:
   ans +=1

print(ans)
Problem p03372 (python)

Fixed submission:
N,C = map(int,input().split())
XV = [[0,0]] + [[int(i) for i in input().split()] for _ in range(N)] + [[C,0]]

Sum_left = [0] * (N+1)
Sum_right = [0] * (N+1)
for i in range(N):
    Sum_left[i+1] = Sum_left[i] + XV[i+1][1]
    Sum_right[i+1] = Sum_right[i] + XV[N-i][1]

Sum_right_maxA = [0] * (N+1)
Sum_right_maxB = [0] * (N+1)
for i in range(1,N+1):
    Sum_right_maxA[i] = max(Sum_right_maxA[i-1], Sum_right[i] - 2 * (C - XV[N+1-i][0]))
    Sum_right_maxB[i] = max(Sum_right_maxB[i-1], Sum_right[i] - (C - XV[N+1-i][0]))

ans = 0
for i in range(N+1):
    ans = max(ans, Sum_left[i] + Sum_right_maxA[N-i] - XV[i][0], Sum_left[i] + Sum_right_maxB[N-i] - 2*XV[i][0])
print(ans)

Buggy submission (verdict: Runtime Error):
N,C = map(int,input().split()) 
XV = [[0,0]] + [[int(i) for i in input().split()] for _ in range(N)] + [[C,0]]

Sum_left = [0] * (N+1)
Sum_right = [0] * (N+1)
for i in range(N):
    Sum_left[i+1] = Sum_left[i] + XV[i+1][1]
    Sum_right[i+1] = Sum_right[i] + XV[N-i][1]

ans = 0
for i in range(N+1):
    for j in range(N+1-i):
        ans = max(ans, Sum_left[i] + Sum_right[j] - XV[i][0] - 2 * (C - XV[N+1-j][0]), Sum
_left[i] + Sum_right[j] - 2 * XV[i][0] - (C - XV[N+1-j][0]))

print(ans)

Buggy submission (verdict: Runtime Error):
N,C = map(int,input().split()) 
XV = [[0,0]] + [[int(i) for i in input().split()] for _ in range(N)] + [[C,0]]

print(XV)

Sum_left = [0] * (N+1)
Sum_right = [0] * (N+1)
for i in range(N):
    Sum_left[i+1] = Sum_left[i] + XV[i+1][1]
    Sum_right[i+1] = Sum_right[i] + XV[N-i][1]

ans = 0
for i in range(N+1):
    for j in range(N+1-i):
        ans = max(ans, Sum_left[i] + Sum_right[j] - XV[i][0] - 2 * (C - XV[N+1-j][0]), Sum
_left[i] + Sum_right[j] - 2 * XV[i][0] - (C - XV[N+1-j][0]))

print(ans)

Buggy submission (verdict: Runtime Error):
N,C = map(int,input().split())
XV = [0,0] + [[int(i) for i in input().split()] for _ in range(N)] + [C,0]

Sum_left = [0] * (N+1)
Sum_right = [0] * (N+1)
for i in range(N):
    Sum_left[i+1] = Sum_left[i] + XV[i+1][1]
    Sum_right[i+1] = Sum_right[i] + XV[N-i][1]

ans = 0
for i in range(N+1):
    for j in range(N+1-i):
        ans = max(ans, Sum_left[i] + Sum_right[j] - XV[i][0] - 2 * (C - XV[N+1-j][0]), Sum
_left[i] + Sum_right[j] - 2 * XV[i][0] - (C - XV[N+1-j][0]))

print(ans)
Problem p03402 (python)

Fixed submission:
A,B = map(int,input().split())
print("100 100")
ans = [["#"]*100 for _ in range(50)] + [["."]*100 for _ in range(50)]
A -=1
B -=1

wR = 0 
while A>=50:
    A -= 50
    for i in range(0,100,2):
        ans[wR][i]="."
    wR += 2
     
wC = 0
while A>0:
    A -= 1
    ans[wR][wC]="."
    wC += 2
    
bR=99
while B>=50:
    B -= 50
    for i in range(0,100,2):
        ans[bR][i]="#"
    bR -= 2
    
bC = 0
while B>0:
    B -= 1
    ans[bR][bC]="#"
    bC += 2

[print("".join(i)) for i in ans]

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
print("100 100")
ans = [["#"]*100 for _ in range(50)] + [["."]*100 for _ in range(50)]
A -=1
B -=1

wR = 0 
while A>=50:
    A -= 50
    [ans[wR][i]="." for i in range(0,100,2)]
    wR += 2
     
wC = 0
while A>0:
    A -= 1
    ans[wR][wC]="."
    wC += 2
    
bR=99
while B>=50:
    B -= 50
    [ans[bR][i]="#" for i in range(0,100,2)]
    bR -= 2
    
bC = 0
while B>0:
    B -= 1
    ans[bR][bC]="#"
    bC += 2

[print("".join(i)) for i in ans]
Problem p03424 (python)

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

ans = "Three"

for s in S:   
    if s == "Y":
        ans = "Four"
        break
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = [s for _ in input().split()]

ans = "Three"

for s in S:   
    if s == "Y":
        ans = "Four"
        break
print(ans)
Problem p03435 (python)

Fixed submission:
C = []
for _ in range(3):
    c = list(map(int,input().split()))
    C.append(c)

if((C[0][0]-C[1][0]==C[0][1]-C[1][1])and(C[0][0]-C[1][0]==C[0][2]-C[1][2])
        and(C[0][0]-C[2][0]==C[0][1]-C[2][1])and(C[0][0]-C[2][0]==C[0][2]-C[2][2])
        and(C[0][0]-C[0][1]==C[1][0]-C[1][1])and(C[0][0]-C[0][1]==C[2][0]-C[2][1])
        and(C[0][0]-C[0][2]==C[1][0]-C[1][2])and(C[0][0]-C[0][2]==C[2][0]-C[2][2])):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
C = [[int(c) for c in input.split()] for _ in range(3)]

if((C[0][0]-C[1][0]==C[0][1]-C[1][1]==C[0][2]-C[1][2])                    
        and(C[0][0]-C[2][0]==C[0][1]-C[2][1]==C[0][2]-C[2][2])):                  
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
C = []
for _ in range(3):
    c = list(map(int,input().split()))
    C.append(c)

if((C[0][0]-C[1][0]==C[0][1]-C[1][1]==C[0][2]-C[1][2])                    
        and(C[0][0]-C[2][0]==C[0][1]-C[2][1]==C[0][2]-C[2][2]):                   
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
C = []
for _ in range(3):
    c = list(map(int,input().split()))
    C.append(c)

if((C[1][1]-C[2][1]==C[1][2]-C[2][2])and(C[1][1]-C[2][1]==C[1][3]-C[2][3])
        and(C[1][1]-C[3][1]==C[1][2]-C[3][2])and(C[1][1]-C[3][1]==C[1][3]-C[3][3])
        and(C[1][1]-C[1][2]==C[2][1]-C[2][2])and(C[1][1]-C[1][2]==C[3][1]-C[3][2])
        and(C[1][1]-C[1][3]==C[2][1]-C[2][3])and(C[1][1]-C[1][3]==C[3][1]-C[3][3])):
    print("Yes")
else:  
    print("No")
Problem p03437 (python)

Fixed submission:
X,Y = map(int,input().split())
if X%Y==0:
  print(-1)
else:
  print(X)

Buggy submission (verdict: Runtime Error):
X,Y = map(int,input())
if X==Y:
  print(-1)
elif 2*X!=Y:
  print(2*X)
else:
  print(3*X)
Problem p03450 (python)

Fixed submission:
INF = 10**20
N,M = map(int,input().split())
node = [[] for _ in range(N)]
for _ in range(M):
  l,r,d = map(int,input().split())
  node[l-1].append([r-1,d])
  node[r-1].append([l-1,-1*d])

ans = "Yes"
pos = [INF]*N
for i in range(N):
  if pos[i]==INF:
    que = [[i,0]]
    while(que):
      c,cp = que.pop()
      if pos[c]==INF:
        pos[c] = cp
        for n,d in node[c]:
          if pos[n]==INF:
            que.append([n,cp+d])
          elif pos[n] != cp+d:
            ans="No"
            break
        else:
          continue
        break
      elif pos[c] != cp:
        ans="No"
        break
    else:
      continue
    break
print(ans)

Buggy submission (verdict: Runtime Error):
INF = 10**20
N,M = map(int,input().split())
node = [[] for _ in range(N)]
for _ in range(M):
  l,r,d = map(int,input().split())
  node[l-1].append([r-1,d])
  node[r-1].append([l-1,-1*d])

ans = "Yes"
pos = [INF]*N
for i in range(N):
  if pos[i]==INF:
    que = [[i,0]]
    while(que):
      c,cp = que.pop()
      if pos[c]=INF:
        pos[c] = cp
        for n,d in node[c]:
          if pos[n]==INF:
            que.append([n,cp+d])
          elif pos[n] != cp+d:
            ans="No"
            break
        else:
          continue
        break
      elif pos[c] != cp:
        ans="No"
        break
    else:
      continue
    break
print(ans)
Problem p03504 (python)

Fixed submission:
N,C = map(int,input().split())
ST = []
for _ in range(N):
  s,t,c = map(int,input().split())
  ST.append([s,0,c])
  ST.append([t,1,c])
ST.sort(key=lambda x:x[0])
ST.sort(key=lambda x:x[2])
for i in range(len(ST)-1):
  if ST[i][2]==ST[i+1][2] and ST[i][0]==ST[i+1][0]:
    ST[i][1]=2
    ST[i+1][1]=2

ST.sort(key=lambda x:x[1])
ST.sort(key=lambda x:x[0])

ans =[0]
for st in ST:
  if st[1]==0:
    ans.append(ans[-1]+1)
  elif st[1]==1:
    ans.append(ans[-1]-1)
print(max(ans))

Buggy submission (verdict: Runtime Error):
N,C = map(int,input().split())
ST = []
STC = [[] for _ in range(C)]
for _ in range(N):
  s,t,c = map(int,input().split())
  STC[c-1].append([s,t])
for i in range(C):
  STC[i].sort(key=lambda x:x[0])
  s=STC[i][0][0]
  t=STC[i][0][1]
  for j in range(1,len(STC[i])):
    if t==STC[i][j][0]:
      t=STC[i][j][1]
      if j==len(STC[i])-1:
        ST.append([s,0])
        ST.append([t,1])
    else:
      ST.append([s,0])
      ST.append([t,1])
ST.sort(key=lambda x:x[1])
ST.sort(key=lambda x:x[0])

ans =[0]
for st in ST:
  if st[1]==0:
    ans.append(ans[-1]+1)
  else:
    ans.append(ans[-1]-1)
print(max(ans))
Problem p03524 (python)

Fixed submission:
S = list(input())
dic = {"a":0,"b":0,"c":0}
for s in S:
  dic[s] += 1
if max(dic.values())<=min(dic.values())+1:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
S = list(input())
dic = {"a":0,"b":0,"c":0}
for s in S:
  dic[s] += 1
if max(dic.value)<=min(dic.value)+1:
  print("YES")
else:
  print("NO")
Problem p03546 (python)

Fixed submission:
import heapq

H,W = map(int,input().split())
C = [[int(x) for x in input().split()] for _ in range(10)]
num = [0] * 10
for _ in range(H):
    for x in input().split():
        if int(x) != -1:
            num[int(x)] += 1

que = []
flag = [True]*10
flag[1] = False
cost = [10**10]*10
cost[1] = 0

for i in range(10):
    if flag[i]:
        heapq.heappush(que,[C[i][1],i])

while que:
    a,b = heapq.heappop(que)
    if flag[b]:
        flag[b] = False
        cost[b] = a
        for i in range(10):
            if flag[i]:
                heapq.heappush(que,[C[i][b]+a,i])

ans = 0
for i in range(10):
    ans += num[i]*cost[i]
print(ans)

Buggy submission (verdict: Runtime Error):
import heapq

H,W = map(int,input().split())
C = [[int(x) for x in input().split()] for _ in range(10)]
num = [0] * 10
for _ in range(H):
    for x in input().split():
        if int(x) != -1
            num[int(x)] += 1

que = []
flag = [True]*10
flag[1] = False
cost = [10**10]*10
cost[1] = 0

for i in range(10):
    if flag[i]:
        heapq.heappush(que,[C[i][1],i])

while que:
    a,b = heapq.heappop(que)
    if flag[b]:
        flag[b] = False
        cost[b] = a
        for i in range(10):
            if flag[i]:
                heapq.heappush(que,[C[i][b]+a,i])

ans = 0
for i in range(10):
    ans += num[i]*cost[i]
print(ans)

Buggy submission (verdict: Runtime Error):
import heqpq

H,W = map(int,input().split())
C = [[int(x) for x in input().split()] for _ in range(10)]
num = [0] * 10
for _ in range(H):
    for x in input().split():
        num[int(x)] += 1

que = []
flag = [True]*10
flag[1] = False
cost = [10**10]*10
cost[1] = 0

for i in range(10):
    if flag[i]:
        heqpq.heappush(que,[C[i][1],i])

while que:
    a,b = heapq.heappop(que)
    if flag[b]:
        flag[b] = False
        cost[b] = a
        for i in range(10):
            if flag[i]:
                heapq.heappush(que,[C[i][b]+a,i])

ans = 0
for i in range(10):
    ans += num[i]*cost[i]
print(ans)
Problem p03547 (python)

Fixed submission:
X,Y = input().split() 
if X>Y:
  print(">")
elif X<Y:
  print("<")
else:
  print("=")

Buggy submission (verdict: Runtime Error):
X,Y = map(ord,intput().split())
if X>Y:
  print(">")
elif X<Y:
  print("<")
else:
  print("=")

Buggy submission (verdict: Runtime Error):
X,Y = intput().split()
if X>Y:
  print(">")
elif X<Y:
  print("<")
else:
  print("=")
Problem p03593 (python)

Fixed submission:
H,W = map(int,input().split())
dic = {}
for h in range(H):
  s = list(input())
  for x in s:
    dic[x] = dic.get(x,0) + 1

c1 = 0
c2 = 0
for x in dic.values():
  if x%2 == 1:
    c1 += 1
    x -= 1
  if x%4 == 2:
    c2 += 1
if c1>(H%2)*(W%2):
  print("No")
elif c2>((W*(H%2))//2)+((H*(W%2))//2):
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
dic = {}
for h in range(H):
  s = list(input())
  for x in s:
    dic[x] = dic.get(x,0) + 1

c1 = 0
c2 = 0
for x in dic.values():
  if x%2 == 1:
    c1 += 1
    x -= 1
  if x%4 == 2:
    c2 += 1
if c1>(H%2)*(W%2):
  print("No")
  return
if c2>((W*(H%2))//2)+((H*(W%2))//2):
  print("No")
  return
print("Yes")
Problem p03627 (python)

Fixed submission:
N=int(input())
A = [int(a) for a in input().split()]

d = {}
for a in A:
  d[a] = d.get(a,0) + 1
B = [0,0]
for k in d:
  if d[k] >= 4:
    B.append(k)
    B.append(k)
  elif d[k] >=2:
    B.append(k)
B.sort()
print(B[-1]*B[-2])

Buggy submission (verdict: Runtime Error):
N=int(input())
A = [int(a) for a in input().split()]

d = {}
for a in A:
  d[a] = d.get(a,0) + 1
B = []
for k in d:
  if d[k] >= 4:
    B.append(k)
    B.append(k)
  elif d[k] >=2:
    B.append(k)
B.sort()
print(B[-1]*B[-2])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(a) for a in input().split()]

dic = {}
for a in A:
  dic[a] = dic.get(a,0) + 1

2p = []
ans = 0

for k in dic:
  if dic[k] >= 4:
    ans = max(ans,dic[k]**2)
  elif dic[k] >= 2:
    2p.append(dic[k])
if len(2p)>=2:
  2p.sort(reverse=True)
  ans = max(ans,2p[0]*2p[1])
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(a) for a in input().split()]

dic = {}
for a in A:
  dic[a] = dic.get(a,0) + 1

B=[]
for k in dic:
  if dic[k]>=2:
    B.append(k)

B.sort()
if B>=2:
  print(B[-1]*B[-2])
else:
  print(0)
Problem p03633 (python)

Fixed submission:
N = int(input())
T = []
[T.append(int(input())) for _ in range(N)]

def gcd(a,b):
    if max(a,b)%min(a,b) == 0:
        return min(a,b)
    return gcd(max(a,b)%min(a,b),min(a,b))

ans = 1
for t in T:
    ans = ans * t // gcd(ans,t)

print(ans)

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

N = int(input())
T = [int(input()) for _ in range(N)]

ans = 1
for i in range(N):
    ans = ans * T[i] // math.gcd(ans, T[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
T = []
[T.append(int(input())) for _ in range(N)]


ans = 1
for t in T:
    ans = ans * t // math.gcd(ans,t)

print(ans)
Problem p03660 (python)

Fixed submission:
N = int(input())
g = [[] for _ in range(N+1)]

for _ in range(N-1):
        a,b = map(int,input().split())
        g[a].append(b)
        g[b].append(a)

def BFS(v):
        d = [N]*(N+1)
        d[v] = 0
        q = [v]

        while q:
                u = q.pop()
                for i in g[u]:
                        if d[i] == N:
                                d[i] = d[u] + 1
                                q.append(i)

        return d

db = BFS(1)
dw = BFS(N)

b = 0
w = 0

for i in range(1,N+1):
        if db[i] <= dw[i]:
                b += 1
        else:
                w += 1

if b > w:
        print("Fennec")
else:
        print("Snuke")

Buggy submission (verdict: Runtime Error):
N = int(input())
g = [[] for _ in range(N+1)]

for _ in range(N-1):
        a,b = map(int,input().split())
        g[a].append(b)
        g[b].append(a)


s = ["n"]*(N+1)
s[1] = "b"
s[N] = "w"

def DFS(v):
        global s
        for i in g[v]:
                if s[i] == "w":
                        return
                if s[i] == "n":
                        s[i] = "r"
                        DFS(i)
                        s[i] = "n"

DFS(1)

sb = g[1]
sw = g[N]

while True:
        for i in sb:
                if s[i] == "r":
                        s[i] = "b"
                        sb.extend(g[i])
                        break
        else:
                for i in sb:
                        if s[i] == "n":
                                s[i] = "b"
                                sb.extend(g[i])
                                break
                else:
                        print("Snuke")
                        exit()

        for i in sw:
                if s[i] == "r":
                        s[i] = "w"
                        sw.extend(g[i])
                        break
        else:
                for i in sw:
                        if s[i] == "n":
                                s[i] = "w"
                                sb.extend(g[i])
                                break
                else:
                        print("Fennec")
                        exit()
Problem p03720 (python)

Fixed submission:
N,M = map(int,input().split())
ans = [0]*N
for _ in range(M):
    a,b = map(int,input().split())
    ans[a-1] += 1
    ans[b-1] += 1

for a in ans:
  print(a)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
ans = [0]*N
for _ in range(M):
  ans[int(input())-1] += 1

for a in ans:
  print(a)
Problem p03777 (python)

Fixed submission:
a,b = input().split()
if((a=='H')^(b=='H')):
  print("D")
else:
  print("H")

Buggy submission (verdict: Runtime Error):
a,b = input().split()
if a=='H' xor b=='H':
  print("D")
else:
  print("H")
Problem p03798 (python)

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

def makeans(ans):
        for c in s:
                if (ans[-1] == "S") ^ (c == "o") ^ (ans[-2] == "W"):
                        ans += "W"
                else:
                        ans += "S"

        return ans

for initial in ["SS","SW","WS","WW"]:
        ans = makeans(initial)
        if ans[0] == ans[-2] and ans[1] == ans[-1]:
                print(ans[1:-1])
                exit()

print("-1")

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

def DFS(ans):
        if len(ans) == N+2:
                return ans

        if (ans[-1] == "S") ^ (s[len(ans)-2] == "o") ^ (ans[-2] == "W"):
                ans += "W"
        else:
                ans += "S"

        return DFS(ans)

for initial in ["SS","SW","WS","WW"]:
        ans = DFS(initial)
        if ans[0] == ans[-2] and ans[1] == ans[-1]:
                print(ans[1:-1])
                exit()

print("-1")
Problem p03818 (python)

Fixed submission:
import sys
N = int(input())
A = [int(a) for a in sys.stdin.readline().split()]

dic = {}
for a in A:
  dic[a] = dic.get(a,0) + 1

evenodd = [0,0]
for k in dic:
  evenodd[dic[k]%2] += 1
if evenodd[0]%2==0:
  print(len(dic))
else:
  print(len(dic)-1)

Buggy submission (verdict: Runtime Error):
import sys
N = int(input())
A = [int(a) for a in sys.stdin.readline().split()]

dic = {}
for a in A:
  dic[a] = dic.get(a,0) + 1

evenodd = [0,0]
for k in dic:
  evenodd[dic[k]%2] += 1
if evenodd[0]%2==0:
  return len(dic)
else:
  return len(dic)-1
Problem p03837 (python)

Fixed submission:
N,M=map(int,input().split())
INF = 10**5
D=[[INF]*N for _ in range(N)]
for i in range(N):
  D[i][i]=0
path=[]
for i in range(M):
  a,b,c = map(int,input().split())
  D[a-1][b-1]=c
  D[b-1][a-1]=c
  path.append([a-1,b-1,c])
for k in range(N):
  for i in range(N-1):
    for j in range(i+1,N):
      D[i][j]=min(D[i][j],D[i][k]+D[j][k])
      D[j][i]=D[i][j]
ans=0
for a,b,c in path:
  if D[a][b]<c:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
INF = 10**5
D=[[INF]*N for _ in range(N)]
for i in range(N):
  D[i][i]=0
path=[]
for i in range(M):
  a,b,c = map(int,input().split())
  D[a][b]=c
  D[b][a]=c
  path.append([a,b,c])
for k in range(N):
  for i in range(N-1):
    for j in range(i+1,N):
      D[i][j]=min(D[i][j],D[i][k]+D[j][k])
      D[j][i]=D[i][j]
ans=0
for a,b,c in path:
  if D[a][b]>c:
    ans+=1
print(ans)
Problem p03838 (python)

Fixed submission:
x,y = map(int,input().split())
ans = 0
while True:
  if x == y:
    print(ans)
    break
  
  if x == -y:
    x = -x
    ans += 1
    continue

  if (abs(x)<abs(y) and x<0) or (abs(y)<abs(x) and 0<=x):
    x = -x
    ans += 1
    continue
  
  ans += abs(abs(x)-abs(y))
  x += abs(abs(x)-abs(y))

Buggy submission (verdict: Runtime Error):
x,y = map(int,input())
ans = 0
while True:
  if x == y:
    print(ans)
    break
  
  if x == -y:
    x = -x
    ans += 1
    continue

  if (abs(x)<abs(y) and x<0) or (abs(y)<abs(x) and 0<=x):
    x = -x
    ans += 1
    continue
  
  ans += abs(abs(x)-abs(y))
  x += abs(abs(x)-abs(y))