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

Fixed submission:
import sys
sys.setrecursionlimit(100000)

N=int(input())
edges = [[] for i in range(N)]
colors = [-1]*N
for i in range(N-1):
    u,v,w=[int(a) for a in input().split()]
    edges[u-1].append((v-1,w))
    edges[v-1].append((u-1,w))
 
diff = lambda n: 1 if n==0 else 0
 
def dfs(prev,curr):
    for node,d in edges[curr]:
        if node==prev:
            continue
        colors[node] = colors[curr] if d%2==0 else diff(colors[curr])
        dfs(curr,node)
 
colors[0]=0
dfs(1000000,0)
for i in range(N):
    print(colors[i])

Buggy submission (verdict: Runtime Error):
N=int(input())
edges = [[] for i in range(N)]
colors = [-1]*N
for i in range(N-1):
    u,v,w=[int(a) for a in input().split()]
    edges[u-1].append((v-1,w))
    edges[v-1].append((u-1,w))

diff = lambda n: 1 if n==0 else 0

def dfs(prev,curr):
    for node,d in edges[curr]:
        if node==prev:
            continue
        colors[node] = colors[curr] if d%2==0 else diff(colors[curr])
        dfs(curr,node)

colors[0]=0
dfs(1000000,0)
for i in range(N):
    print(colors[i])
Problem p03059 (python)

Fixed submission:
A, B,  T = [int(s) for s in input().split()]
print(B*(T//A))

Buggy submission (verdict: Runtime Error):
from functools import reduce
from fractions import gcd

N = int(input())
A = [int(a) for a in input().split(" ")]
if N==2:
    print(gcd(*A))
else:
    left = reduce(lambda acc, x: acc+[gcd(x, acc[-1])], A, A[:1])
    right = reduce(lambda acc, x: acc+[gcd(x, acc[-1])], A[::-1], A[-1:])[::-1]

    ans = max([gcd(left[i-1], right[i+1]) for i in range(1,N-1)])
    ans = max([right[1], ans, left[-2]])
    print(ans)

Buggy submission (verdict: Runtime Error):
from functools import reduce
from math import gcd

N = int(input())
A = [int(a) for a in input().split(" ")]
if N==2:
    print(gcd(*A))
else:
    left = reduce(lambda acc, x: acc+[gcd(x, acc[-1])], A, A[:1])
    right = reduce(lambda acc, x: acc+[gcd(x, acc[-1])], A[::-1], A[-1:])[::-1]

    ans = max([gcd(left[i-1], right[i+1]) for i in range(1,N-1)])
    ans = max([right[1], ans, left[-2]])
    print(ans)
Problem p03061 (python)

Fixed submission:
from functools import reduce
from fractions import gcd

N = int(input())
A = [int(a) for a in input().split(" ")]
if N==2:
    print(max(A))
else:
    left, right = [-1]*(N-1), [-1]*(N-1)
    lacc, racc = (A[0], A[-1])
    for i in range(N-1):
        lacc, racc = gcd(lacc, A[i]), gcd(racc, A[N-1-i])
        left[i], right[i] = lacc, racc
    ans = max(right[-1], left[-1])
    for l, r in zip(left[:-1], reversed(right[:-1])):
        ans = max(ans, gcd(l,r))
    print(ans)

Buggy submission (verdict: Runtime Error):
from functools import reduce
from math import gcd

N = int(input())
A = [int(a) for a in input().split(" ")]
if N==2:
    print(gcd(*A))
else:
    left = reduce(lambda acc, x: acc+[gcd(x, acc[-1])], A, A[:1])
    right = reduce(lambda acc, x: acc+[gcd(x, acc[-1])], A[::-1], A[-1:])[::-1]

    ans = max([gcd(left[i-1], right[i+1]) for i in range(1,N-1)])
    ans = max([right[1], ans, left[-2]])
    print(ans)

Buggy submission (verdict: Runtime Error):
from functools import reduce
from math import gcd

N = int(input())
A = [int(a) for a in input().split(" ")]
if N==2:
    print(gcd(*A))
    exit()

left = reduce(lambda acc, x: acc+[gcd(x, acc[-1])], A, A[:1])
right = reduce(lambda acc, x: acc+[gcd(x, acc[-1])], A[::-1], A[-1:])[::-1]

ans = max([gcd(left[i-1], right[i+1]) for i in range(1,N-1)])
ans = max([right[1], ans, left[-2]])
print(ans)
Problem p03101 (python)

Fixed submission:
H, W = [int(s) for s in input().split()]
h, w = [int(s) for s in input().split()]
print((H-h)*(W-w))

Buggy submission (verdict: Runtime Error):
from math import *
num_digit = lambda n: int(log2(n)+1)    
A, B = [int(s) for s in input().split()]

ret = 0
N = (B-A)+1
nd = num_digit(B)
for i in range(nd):
    nb = int(pow(2, i+1) if i>0 else pow(2, i+2))
    nr = N%nb
    s = sum([(A+j) >> i for j in range(nr)])
    ret += ((s%2) << i)
    
print(ret)
Problem p03105 (python)

Fixed submission:
A, B, C = [int(a) for a in input().split()]
print(min(C, B//A))

Buggy submission (verdict: Runtime Error):
def find(tab, a):
    try:
        if tab[0][a]==-1:
            return a
        tab[0][a] = find(tab, tab[0][a])
        return tab[0][a]
    except:
        pass

def union(tab, a, b):
    p1, p2 = find(tab, a), find(tab, b)
    if p1 != p2:
        tab[0][p1] = p2
        tab[1][p2] += tab[1][p1]

def size(tab, a):
    return tab[1][a]

N, M = [int(a) for a in input().split(" ")]
ABs = [[int(a) for a in input().split(" ")] for i in range(M)]
tab = [[-1]*N, [1]*N]
arr = []



for a, b in reversed(ABs):
    a, b = a-1, b-1
    pa, pb = find(tab, a), find(tab, b)
    na, nb = size(tab, pa), size(tab, pb)
    if pa!=pb:
        dn = ((na+nb)*(na+nb-1)//2)-(na*(na-1)//2)-(nb*(nb-1)//2)
        arr.append(dn)
        union(tab, a, b)
    else:
        arr.append(0)

acc = 0
for cp in reversed(arr):
    acc += cp
    print(acc)
Problem p03111 (python)

Fixed submission:
N, A, B, C = [int(a) for a in input().split(" ")]
ls = [int(input()) for i in range(N)]
tab = [([float("inf")]*N, ref) for ref in (A, B, C)]
INF = float("inf")
from heapq import heappush, heappop, heapreplace
maxtarg = max(A, B, C)

# O(n)
def solve(ls):
    n = len(ls)
    qs = [[(-INF, -1)]*3 for i in range(3)]
    # 3*n times
    for ref, q in zip((A, B, C), qs):
        for i in range(n):
            val = -abs(ref-ls[i])
            if q[0][0] < val:
                heapreplace(q, (val, i))
    ans = INF
    # 9 times
    for a, i in qs[0]:
        for b, j in qs[1]:
            for c, k in qs[2]:
                if i!=j and j!=k and k!=i:
                    ans = min(ans, -(a+b+c))
    return ans
dic = {}
def dfs(ls):
    key = tuple(sorted(ls))
    if key in dic:
        return dic[key]
    n = len(ls)
    if n < 3: return INF
    ans = solve(ls)
    for i in range(n-1):
        for j in range(i+1,n):
            tmp = ls[i]+ls[j]
            if min(maxtarg-ls[i], maxtarg-ls[j]) < 10:
                continue
            ls2 = ls[:i]+ls[i+1:]
            ls2[j-1] = tmp
            ans = min(ans, 10+dfs(ls2))
    dic[key] = ans
    return ans

print(dfs(ls))

Buggy submission (verdict: Runtime Error):
A, B, Q = [int(a) for a in input().split(" ")]
S = sorted([int(input()) for i in range(A)])
T = sorted([int(input()) for i in range(B)])
X = [int(input()) for i in range(Q)]
INF = float("inf")

def search(arr, x):
    l, r = (0, len(arr))
    while r-l>1:
        med = (l+r)//2
        if arr[med] == x:
            return med
        l, r = (l, med) if x<arr[med] else (med+1, r)
    return l

for x in X:
    s1 = min(search(S, x), len(S)-1)
    t1 = min(search(T, x), len(T)-1)
    ss, ts = None, None
    
    if S[s1]==x:
        ss = (0, 0)
    elif s1==0 and x<S[s1]:
        ss = (INF, abs(S[s1]-x))
    elif s1==len(S)-1 and S[s1]<x:
        ss = (abs(S[s1]-x), INF)
    elif S[s1]<x:
        ss = (abs(S[s1]-x), abs(S[s1+1]-x))
    else:
        ss = (abs(S[s1-1]-x), abs(S[s1]-x))
    
    if T[t1]==x:
        ts = (0, 0)
    elif t1==0 and x<T[t1]:
        ts = (INF, abs(T[t1]-x))
    elif t1==len(T)-1 and T[t1]<x:
        ts = (abs(T[t1]-x), INF)
    elif T[t1]<x:
        ts = (abs(T[t1]-x), abs(T[t1+1]-x))
    else:
        ts = (abs(T[t1-1]-x), abs(T[t1]-x))

    ans = min([max(ss[0], ts[0]), max(ss[1], ts[1]),
               2*ss[0]+ts[1], 2*ss[1]+ts[0], ss[0]+2*ts[1], ss[1]+2*ts[0]])
    print(ans)
Problem p03128 (python)

Fixed submission:
N, M = [int(a) for a in input().split(" ")]
ctab = {"1":2,"2":5,"3":5,"4":4,"5":5,"6":6,"7":3,"8":7,"9":6}
A = sorted([(a, ctab[a]) for a in input().split(" ")], key=lambda t:t[0])
prev, curr = ([""]*(N+1), [""]*(N+1))

def maxs(s1, s2):
    return max(s1, s2, key=lambda s:len(s)) if len(s1)!=len(s2) else max(s1,s2)

char, cost = A[0]
for i in range(1, N+1):
    d, r = divmod(i, cost)
    prev[i] = char*d if r==0 else None
for char, cost in A[1:]:
    for i in range(1, N+1):
        if i-cost >= 0 and curr[i-cost] is not None:
            tmp = char+curr[i-cost]
            curr[i] = maxs(tmp, prev[i]) if prev[i] else tmp
        else:
            curr[i] = prev[i]
    curr, prev = prev, curr
print(prev[-1])

Buggy submission (verdict: Runtime Error):
N, M = [int(a) for a in input().split(" ")]
ctab = {"1":2,"2":5,"3":5,"4":4,"5":5,"6":6,"7":3,"8":7,"9":6}
A = [(a, ctab[a]) for a in input().split(" ")]
prev, curr = ([None]*(N+1), [None]*(N+1))
for char, cost in A:
    if not prev[cost] or char>prev[cost]:
        prev[cost] = char
ans = ""
while any(prev):
    for i in range(1, N+1):
        curr[i] = None
    for i in range(1, N+1):
        s = prev[i]
        if not s:
            continue
        for char, cost in A:
            if i+cost <= N:
                tmps = char+s
                if not curr[i+cost] or tmps > curr[i+cost]:
                    curr[i+cost] = tmps
    if curr[N] is not None:
        ans = curr[N]
    curr, prev = prev, curr
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = [int(a) for a in input().split(" ")]
ctab = {"1":2,"2":5,"3":5,"4":4,"5":5,"6":6,"7":3,"8":7,"9":6}
A = [(a, ctab[a]) for a in input().split(" ")]
prev = [None]*(N+1)
curr = [None]*(N+1)
for char, cost in A:
    if not prev[cost] or char>prev[cost]:
        prev[cost] = char

ans = ""
while any(prev):
    for i in range(1, N+1):
        curr[i] = None
    for i in range(1, N+1):
        s = prev[i]
        if not s:
            continue
        for char, cost in A:
            tmps = char+s
            if i+cost <= N:
                if not curr[i+cost] or tmps > curr[i+cost]:
                    curr[i+cost] = tmps
    if curr[N] is not None:
        ans = curr[N]
    curr, prev = prev, curr
print(ans)

Buggy submission (verdict: Runtime Error):
from bisect import insort_left
N, M = [int(a) for a in input().split(" ")]
ctab = {"1":2,"2":5,"3":5,"4":4,"5":5,"6":6,"7":3,"8":7,"9":6}
A = [(a, ctab[a]) for a in input().split(" ")]
prev = [None]*(N+1)
curr = [None]*(N+1)
for char, cost in A:
    if not prev[cost] or char>prev[cost]:
        prev[cost] = char

def insert(s, char):
    ls = list(s)[::-1]
    insort_left(ls, char)
    return int("".join(ls[::-1]))

tmp = ""
while any(prev):
    for i in range(1, N+1):
        maxval = -1
        for char, cost in A:
            if i-cost>=0 and prev[i-cost]:
                val = insert(prev[i-cost], char)
                maxval = val if val > maxval else maxval
        curr[i] = str(maxval) if maxval > 0 else None
    if curr[N] is not None:
        tmp = curr[N]
    curr, prev = prev, curr
print(tmp)
Problem p03280 (python)

Fixed submission:
A,B=[int(a) for a in input().split(" ")]
print((A-1)*(B-1))

Buggy submission (verdict: Runtime Error):
A,B=[int(a) for input().split(" ")]
print((A-1)*(B-1))
Problem p03579 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000)

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

colors = [0]*N
def dfs(curr, c):
    colors[curr] = c
    for node in edges[curr]:
        if colors[node] == colors[curr]:
            return False
        if colors[node]== 0 and not dfs(node, -c):
            return False
    return True

if not dfs(0, 1):
    print((N*(N-1))//2 - M)
else:
    WH = [c==1 for c in colors]
    nw = sum(WH)
    print(nw*(N-nw)-sum([WH[a-1]^WH[b-1] for a, b in AB]))

Buggy submission (verdict: Runtime Error):
N,M=[int(a) for a in input().split()]
AB=[[int(a) for a in input().split()] for _ in range(M)]
edges = [[] for _ in range(N)]
for a, b in AB:
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

visited = [False]*N
WH = [None]*N

def dfs(curr, is_white):
    if visited[curr]:
        return WH[curr]^is_white
    WH[curr] = is_white
    visited[curr] = True
    ans = False
    for node in edges[curr]:
        ans |= dfs(node, not is_white)
    return ans

if dfs(0, True):
    print((N*(N-1))//2 - M)
else:
    nw = sum(WH)
    print(nw*(N-nw)-sum([WH[a-1]^WH[b-1] for a, b in AB]))
Problem p03660 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000)

N=int(input())
edges=[[] for _ in range(N)]
for _ in range(N-1):
    A,B=map(int,input().split())
    edges[A-1].append(B-1)
    edges[B-1].append(A-1)
prevs=[0]*N
def dfs(prev,curr):
    prevs[curr]=prev
    if curr == N-1:
        return
    for c in edges[curr]:
        if c!=prev:
            dfs(curr,c)
dfs(-1,0)
paths=[N-1]
tmp=N-1
while tmp!=0:
    paths.append(prevs[tmp])
    tmp=prevs[tmp]
paths=paths[::-1]

points=[0,0]
def count(prev,curr,player):
    points[player]+=1
    for c in edges[curr]:
        if c!=prev:
            count(curr,c,player)

nf = (len(paths)+1)//2
f,s = paths[nf-1],paths[nf]
count(s,f,0)
count(f,s,1)
pf,ps=points
print("Fennec" if pf>ps else "Snuke")

Buggy submission (verdict: Runtime Error):
N=int(input())
edges=[[] for _ in range(N)]
for _ in range(N-1):
    A,B=map(int,input().split())
    edges[A-1].append(B-1)
    edges[B-1].append(A-1)
prevs=[0]*N
def dfs(prev,curr):
    prevs[curr]=prev
    if curr == N-1:
        return
    for c in edges[curr]:
        if c!=prev:
            dfs(curr,c)
dfs(-1,0)
paths=[N-1]
tmp=N-1
while tmp!=0:
    paths.append(prevs[tmp])
    tmp=prevs[tmp]

points=[0,0]
def count(prev,curr,player):
    points[player]+=1
    for c in edges[curr]:
        if c!=prev:
            count(curr,c,player)

nf = (len(paths)+1)//2
f,s = paths[nf-1],paths[nf]
count(s,f,0)
count(f,s,1)
pf,ps=points
print("Fennec" if pf>ps else "Snuke")

Buggy submission (verdict: Runtime Error):
N=int(input())
edges=[[] for _ in range(N)]
for _ in range(N):
    A,B=map(int,input().split())
    edges[A-1].append(B-1)
    edges[B-1].append(A-1)
prevs=[0]*N
def dfs(prev,curr):
    prevs[curr]=prev
    if curr == N-1:
        return
    for c in edges[curr]:
        if c!=prev:
            dfs(curr,c)
dfs(-1,0)
paths=[N-1]
tmp=N-1
while tmp!=0:
    paths.append(prevs[tmp])
    tmp=prevs[tmp]

points=[0,0]
def count(prev,curr,player):
    points[player]+=1
    for c in edges[curr]:
        if c!=prev:
            count(curr,c,player)

nf = (len(paths)+1)//2
f,s = paths[nf-1],paths[nf]
count(s,f,0)
count(f,s,1)
pf,ps=points
print("Fennec" if pf>ps else "Snuke")
Problem p03688 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
min_,max_=min(A),max(A)

def f(n,k):
    return n%k==0 if k>0 else False

ans=None
if max_-min_ > 1:
    ans=False
elif max_-min_ == 1:
    k=max_
    nk=len([a for a in A if a==max_])
    nk1=N-nk
    ans=f(nk,k-nk1)
else:
    ans=f(N,min_) or f(N,min_+1)

if ans is True:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
min_,max_=min(A),max(A)
ans=None

if max_-min_ > 1:
    ans=False
elif max_-min_ == 1:
    A=max_
    y=len([a for a in A if a==max_])
    x=N-y
    nc=A-x
    ans=(A-x)>0 and y >=2*(A-x)
else:
    ans=N>=2*min_ or min_+1==N

print("Yes" if ans else "No")
Problem p03716 (python)

Fixed submission:
import numpy as np
from heapq import heapreplace, heapify
N=int(input())
A=np.array([int(a) for a in input().split(" ")])
lheap, rheap = list(A[:N]), list(-A[2*N:])
heapify(lheap)
heapify(rheap)
Lsum, Rsum = sum(lheap), sum(rheap)
left = [Lsum]
right = [Rsum]

for i in range(N):
    if A[N+i] > lheap[0]:
        Lsum += (A[N+i]-lheap[0])
        heapreplace(lheap, A[N+i])
    
    if -A[2*N-i-1] > rheap[0]:
        Rsum += (-A[2*N-i-1]-rheap[0])
        heapreplace(rheap, -A[2*N-i-1])
    
    left.append(Lsum)
    right.append(Rsum)
print(max(np.array(left)+np.array(right)[::-1]))

Buggy submission (verdict: Runtime Error):
import numpy as np
from heapq import heapreplace, heapify
N=int(input())
A=np.array([int(a) for a in input().split(" ")])
lheap, rheap = list(A[:N]), list(-A[2*N:])
heapify(lheap)
heapify(rheap)
Lsum, Rsum = sum(lheap), sum(rheap)
left = [Lsum]
right = [Rsum]

for i in range(N):
    if A[N+i] > lheap[0]:
        Lsum += (A[N+i]-lheap[0])
        heapreplace(lheap, A[N+i])
    
    if -A[2*N-i-1] > rheap[0]:
        Rsum += (-A[2*N-i-1]-rheap[0])
        heapreplace(rheap, -A[2*N-i-1])
    
    left.append(Lsum)
    right.append(Rsum)
print(max(np.array(left)+np.array(right)[::-1]))
Problem p03746 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000)

N,M=map(int,input().split())
edges=[[] for _ in range(N)]
for _ in range(M):
    A,B=map(int,input().split())
    edges[A-1].append(B-1)
    edges[B-1].append(A-1)

visited=[False]*N
path=[]

def dfs(curr):
    visited[curr] = True
    path.append(curr)
    for dst in edges[curr]:
        if not visited[dst]:
            dfs(dst)
            return

dfs(0)
path=path[1:][::-1]
dfs(0)

print(len(path))
print(" ".join([str(v+1) for v in path]))

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
edges=[[] for _ in range(N)]
for _ in range(M):
    A,B=map(int,input().split())
    edges[A-1].append(B-1)
    edges[B-1].append(A-1)
visited=[False]*N

path=[]

def dfs(curr):
    visited[curr] = True
    path.append(curr)
    for dst in edges[curr]:
        if not visited[dst]:
            return dfs(dst)

dfs(0)
path=path[1:][::-1]
dfs(0)

print(len(path))
print(" ".join([str(v+1) for v in path]))

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
edges=[[] for _ in range(N)]
for _ in range(M):
    A,B=map(int,input().split())
    edges[A-1].append(B-1)
    edges[B-1].append(A-1)
visited=[False]*N

def dfs(curr, path):
    visited[curr] = True
    path.append(curr)
    for dst in edges[curr]:
        if not visited[dst]:
            return dfs(dst, path)
    return path

path1 = dfs(0,[])
path2 = dfs(0,[])
path = path2[::-1] + path1[1:]

print(len(path))
print(" ".join([str(v+1) for v in path]))

Buggy submission (verdict: Runtime Error):
def dfs(curr, path, N, edges, visited):
    visited[curr] = True
    path.append(curr)
    for dst in edges[curr]:
        if not visited[dst]:
            return dfs(dst, path, N, edges, visited)
    return path

N,M=map(int,input().split())
edges=[[] for _ in range(N)]
for _ in range(M):
    A,B=map(int,input().split())
    edges[A-1].append(B-1)
    edges[B-1].append(A-1)
visited=[False]*N
path1 = dfs(0,[],N,edges,visited)
path2 = dfs(0,[],N,edges,visited)
path = path2[::-1] + path1[1:]

print(len(path))
print(" ".join([str(v+1) for v in path]))

Buggy submission (verdict: Runtime Error):
def dfs(curr, path, N, edges, visited):
    visited[curr] = True
    path.append(curr)
    for dst in edges[curr]:
        if not visited[dst]:
            return dfs(dst, path, N, edges, visited)
    return path

N,M=map(int,input().split())
edges=[[] for _ in range(N)]
for _ in range(M):
    A,B=map(int,input().split())
    edges[A-1].append(B-1)
    edges[B-1].append(A-1)
visited=[False]*N
path1 = dfs(0,[],N,edges,visited)
path2 = dfs(0,[],N,edges,visited)
path = path2[::-1] + path1[1:]
print(" ".join([str(v+1) for v in path]))
Problem p02899 (python)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
ans=[0]*n
for i in range(n):
  ans[A[i]-1]=i+1
print(*ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[0]*n
for i in range(n):
       a[int(input())]=i+1
print(a)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
for i in range(n):
       a〔int(input())〕=i+ 1
print(a)
Problem p03399 (python)

Fixed submission:
A,B,C,D=[int(input()) for i in range(4)]
print(min(A,B)+min(C,D))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for i in range(n)]
a.append(0)
a.insert(0,0)
print(a)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for i in range(n)]
cost=abs(a[n-1])
print(a)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for i in range(n)]
cost=abs(a[n-1])
a.append(0)
a.insert(0,0)
for i in range(3):
    tmp=abs(a[i]-a[i+1])
    cost+=tmp
for i in range(3):
    ans=cost+abs(a[i]-a[i+2])-abs(a[i+1]-a[i])-abs(a[i+1]-a[i+2])
    print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for i in range(n)]
cost=abs(a[n-1])
a.append(0)
a.insert(0,0)
for i in range(n):
    tmp=abs(a[i]-a[i+1])
    cost+=tmp
Problem p03401 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
cost=abs(a[n-1])
a.append(0)
a.insert(0,0)
for i in range(n):
    tmp=abs(a[i]-a[i+1])
    cost+=tmp
for i in range(n):
    ans=cost+abs(a[i]-a[i+2])-abs(a[i+1]-a[i])-abs(a[i+1]-a[i+2])
    print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for i in range(n)]
cost=abs(a[n-1])
a.append(0)
a.insert(0,0)
print(a)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for i in range(n)]
cost=abs(a[n-1])
a.append(0)
a.insert(0,0)

for i in range(n):
    ans=cost+abs(a[i]-a[i+2])-abs(a[i+1]-a[i])-abs(a[i+1]-a[i+2])
    print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for i in range(n)]
cost=abs(a[n-1])
tmp=0
ans=0
a.append(0)
a.insert(0,0)
for i in range(n):
    tmp=abs(a[i]-a[i+1])
    cost+=tmp
for i in range(n):
    ans=cost+abs(a[i]-a[i+2])-abs(a[i+1]-a[i])-abs(a[i+1]-a[i+2])
    print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for i in range(n)]
cost=abs(a[n-1])
a.append(0)
a.insert(0,0)
for i in range(n):
    tmp=abs(a[i]-a[i+1])
    cost+=tmp
for j in range(n):
    ans=cost+abs(a[j]-a[j+2])-abs(a[j+1]-a[j])-abs(a[j+1]-a[j+2])
    print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for i in range(n)]
cost=abs(a[n-1])
a.append(0)
a.insert(0,0)
for i in range(n):
    tmp=abs(a[i]-a[i+1])
    cost+=tmp
for i in range(n):
    ans=cost+abs(a[i]-a[i+2])-abs(a[i+1]-a[i])-abs(a[i+1]-a[i+2])
    print(ans)
Problem p02909 (python)

Fixed submission:
d = {
    'Sunny': 'Cloudy',
    'Cloudy': 'Rainy',
    'Rainy': 'Sunny'
}

i = input()

print(d[i])

Buggy submission (verdict: Runtime Error):
from fractions import gcd as bltin_gcd


def coprime2(a, b):
    return bltin_gcd(a, b) == 1


def cf(x1,x2):
    cf = [1]
    for i in range(2, min(x1, x2) + 1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf


A, B = map(int, input().split())

# 公約数
divisor_list = cf(A, B)

# print(divisor_list)

counts = []
for i in divisor_list:
    if i == 1:
        continue

    other_list = list(filter(lambda x: x != i, divisor_list))

    count = 0
    nums = []
    for j in other_list:
        if coprime2(i, j):
            for n in nums:
                if not coprime2(j, n):
                    break
            else:
                nums.append(j)
                count = count + 1

    counts.append(count)

if not counts:
    print(1)
else:
    print(max(counts) + 1)

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

adict = {i + 1: k for i in range(n)}

answer = [int(input()) for _ in range(q)]

for k, v in adict.items():
    adict[k] = v - (q - answer.count(k))

    if adict[k] > 0:
        print('Yes')
    else:
        print('No')
Problem p03853 (python)

Fixed submission:
H,W = map(int,input().split())
pic = [input().split() for i in range(H)]
for i in range(H):
  print(''.join(pic[i]))
  print(''.join(pic[i]))

Buggy submission (verdict: Runtime Error):
W,H = map(int, input().split())
pic = [input().split() for i in range(H)]
for i in range(H):
  print(''.join(pic[i]))
  print(''.join(pic[i]))
Problem p03861 (python)

Fixed submission:
import math
a,b,x = map(int,input().split())
def f(p):
  if p >= 0:
    return p//x + 1
  else:
    return 0
print(f(b)-f(a-1))

Buggy submission (verdict: Runtime Error):
a,b,x = map(int,input().split())
n = 0
for i in range(a,b+1):
  if x % i == 0:
    n += 1
  else:
    pass
print(n)
Problem p02899 (python)

Fixed submission:
# coding: utf-8
n = int(raw_input())
li = map(int, raw_input().split())

listb = []
listb = sorted(range(len(li)), key=lambda k: li[k])

s = str(map(lambda x: x+1, listb))

print s.replace("[","").replace("]","").replace(",","")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from __future__ import print_function

n = int(raw_input())
li = map(int, raw_input().split())

for i in xrange(1,n+1):
    li[i-1] = li.index(i) +1
    
print(*li, sep=' ')