Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))

x.sort
y.sort

if x[-1] <= y[0] and X <= y[0] and x[-1] =< Y:
  print("No War")
else:
  print("War")
  
  

Fixed submission:
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))

x=sorted(x)
y=sorted(y)

if x[-1] < y[0] and X < y[0] and x[-1] < Y:
  print("No War")
else:
  print("War")
Buggy python submission (verdict: Time Limit Exceeded):
import collections
S = input()
T = input()
N = len(S)
ss = set(S)
st = set(T)


sa = [0]*N
ta = [0]*N
table = collections.defaultdict(set)
table2 = collections.defaultdict(set)

for i, xy in enumerate(zip(S, T)):
    x, y = xy
    table[x].add(i)
    table2[y].add(i)

flag = True
for x, y in zip(S, T):

    if table[x] == table2[y]:
        continue
    else:
        flag = False
        break

if flag:
    print("Yes")
else:
    print("No")


Fixed submission:
import collections
S=input()
T=input()
tableS=collections.defaultdict(list)
tableT=collections.defaultdict(list)

for i in range(len(S)):
  tableS[S[i]].append(i)
  tableT[T[i]].append(i)
listS=tableS.values()
listT=tableT.values()

for x in listS:
  flag=False
  for y in listT:
    if x in y or x in listT:
      flag=True
      break
  if not flag:
    print("No")
    exit(0)
print("Yes")

Buggy python submission (verdict: Time Limit Exceeded):
import collections
S = input()
T = input()
N = len(S)
ss = set(S)
st = set(T)


sa = [0]*N
ta = [0]*N
table = collections.defaultdict(set)
table2 = collections.defaultdict(set)

for i, xy in enumerate(zip(S, T)):
    x, y = xy
    table[x].add(i)
    table2[y].add(i)

flag = True
for x, y in zip(S, T):

    if table[x] == table2[y]:
        continue
    else:
        flag = False
        break

if flag:
    print("Yes")
else:
    print("No")


Fixed submission:
import collections
S=input()
T=input()
tableS=collections.defaultdict(list)
tableT=collections.defaultdict(list)

for i in range(len(S)):
  tableS[S[i]].append(i)
  tableT[T[i]].append(i)
listS=tableS.values()
listT=tableT.values()

for x in listS:
  flag=False
  for y in listT:
    if x in y or x in listT:
      flag=True
      break
  if not flag:
    print("No")
    exit(0)
print("Yes")
Buggy python submission (verdict: Runtime Error):
import collections
N=int(input())
siritori=collections.defaultdict(int)
prev=""
for i in range(N):
  word = input()
  if word in siritori:
    print("No")
  elif prev[-1]==word[0]:
    print("No")
  siritori[word]+=1
  prev=word
print("Yes")

Fixed submission:
import collections
N=int(input())
siritori=collections.defaultdict(int)
prev=" "
for i in range(N):
  word = input()
  if word in siritori:
    print("No")
    exit(0)
  elif prev[-1]!=word[0] and i != 0:
    print("No")
    exit(0)
  siritori[word]+=1
  prev=word
print("Yes")

Buggy python submission (verdict: Runtime Error):
import collections
N=int(input())
siritori=collections.defaultdict(int)
prev=""
for i in range(N):
  word = imput()
  if word in siritori:
    print("No")
  elif prev[-1]==word[0]:
    print("No")
  siritori[word]+=1
  prev=word
print("Yes")

Fixed submission:
import collections
N=int(input())
siritori=collections.defaultdict(int)
prev=" "
for i in range(N):
  word = input()
  if word in siritori:
    print("No")
    exit(0)
  elif prev[-1]!=word[0] and i != 0:
    print("No")
    exit(0)
  siritori[word]+=1
  prev=word
print("Yes")

Buggy python submission (verdict: Runtime Error):
import collections
N=int(input())
siritori=collections.defaultdict(int)
prev=""
for i in range(N):
  word = imput()
  if word in siritori:
    print("No")
  elif prev[-1]==word[0]:
    print("No")
    siritori[word]+=1
print("Yes")

Fixed submission:
import collections
N=int(input())
siritori=collections.defaultdict(int)
prev=" "
for i in range(N):
  word = input()
  if word in siritori:
    print("No")
    exit(0)
  elif prev[-1]!=word[0] and i != 0:
    print("No")
    exit(0)
  siritori[word]+=1
  prev=word
print("Yes")
Buggy python submission (verdict: Runtime Error):
x1,y1,x2,y2=map(int,input().split())
dx=x1-x2
dy=y1-y2

x3=x2+dy
y3=y2-dx

x4=x1+dy
y4=y1-dx
ans=[x3,y3,x4,y4]
print("".join(list(map(str,ans)))

Fixed submission:
x1,y1,x2,y2=map(int,input().split())
dx=x1-x2
dy=y1-y2

x3=x2+dy
y3=y2-dx

x4=x1+dy
y4=y1-dx
ans=[x3,y3,x4,y4]
print(" ".join(list(map(str,ans))))
Buggy python submission (verdict: Runtime Error):
import bisect
N, K = map(int, input().split())
x = list(map(int, input().split()))
id = bisect.bisect_left(x, 0)
ans = max(x) - min(0, min(x))
if id >= K:
    ans = min(ans, x[id-K])
if id + K - 1 < N:
    ans = min(ans, x[id+K-1])

for i in range(max(0, id - K + 1), id):
    ans = min(ans, -x[i]*2 + x[i+K-1], -x[i]+x[i+K-1]*2)

print(ans)


Fixed submission:
N, K = map(int, input().split())
x = list(map(int, input().split()))
import bisect
id = bisect.bisect_left(x,0)
ans=10**10
if id == N:
  print(abs(x[N-K]))
  exit(0)
for i in range(max(0,(K+id)-N),min(id+1,K)):
  right = x[K+id-1-i]
  left=0
  if i>0:
    left =x[id-i]
  tmp=min(abs(left)*2+right,right*2+abs(left)) 
  ans=min(tmp,ans)
print(ans)

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

plus = [i for i in x if i >= 0]
minus = [i for i in x if i <= 0]
ans = (x[-1] - x[0])*2
if len(plus) >= K:
    ans = plus[K-1]
if len(minus) >= K:
    ans = min(ans, minus[-K])
for i in range(1, min(len(plus), len(minus))):
    tmp = plus[K-1-i] - (minus[-i])*2
    ans = min(tmp, ans)

    tmp = plus[K-1-i]*2 - minus[-i]
    ans = min(tmp, ans)

print(ans)


Fixed submission:
N, K = map(int, input().split())
x = list(map(int, input().split()))
import bisect
id = bisect.bisect_left(x,0)
ans=10**10
if id == N:
  print(abs(x[N-K]))
  exit(0)
for i in range(max(0,(K+id)-N),min(id+1,K)):
  right = x[K+id-1-i]
  left=0
  if i>0:
    left =x[id-i]
  tmp=min(abs(left)*2+right,right*2+abs(left)) 
  ans=min(tmp,ans)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))

com_sum = [0] * (N+1)
for i in range(N):
    com_sum[i+1] = A[i] + com_sum[i]
ans = 0
for i in range(N):
    for j in range(i+1, N+1):
        if (com_sum[j] - com_sum[i]) % M == 0:
            ans += 1
print(ans)


Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
import collections
mod_table=collections.defaultdict(int)
com_sum = [0] * (N+1)
for i in range(N):
    com_sum[i+1] = A[i] + com_sum[i]
ans = 0
for i in range(N+1):
    mod = com_sum[i] % M
    mod_table[mod]+=1
    
for x in mod_table:
  y = mod_table[x]
  if y > 1:
    ans += y*(y-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))

com_sum = [0] * (N+1)
for i in range(N):
    com_sum[i+1] = A[i] + com_sum[i]
ans = 0
for i in range(N):
    for j in range(i+1, N+1):
        if (com_sum[j] - com_sum[i]) % M == 0:
            ans += 1
print(ans)


Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
import collections
mod_table=collections.defaultdict(int)
com_sum = [0] * (N+1)
for i in range(N):
    com_sum[i+1] = A[i] + com_sum[i]
ans = 0
for i in range(N+1):
    mod = com_sum[i] % M
    mod_table[mod]+=1
    
for x in mod_table:
  y = mod_table[x]
  if y > 1:
    ans += y*(y-1)//2

print(ans)
Buggy python submission (verdict: Runtime Error):
R = int(input())
if R < 1200:
  print("ABC")
else:
    if R < 2800:
      print("ARC")
  else:
      print("AGC")
  

Fixed submission:
R = int(input())
if R < 1200:
  print("ABC")
else:
  if R < 2800:
    print("ARC")
  else:
    print("AGC")

Buggy python submission (verdict: Runtime Error):
R = int(input())
if R < 1200:
  print("ABC")
else:
    if R < 2800:
    print("ARC")
  else:
    print("AGC")
  

Fixed submission:
R = int(input())
if R < 1200:
  print("ABC")
else:
  if R < 2800:
    print("ARC")
  else:
    print("AGC")
Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
ss=s+s
n=len(s)
for i in range(n):
  if ss[i:]=t:
    print("Yes")
    exit(0)

print("No")


Fixed submission:
S=input()
T=input()
for i in range(len(S)):
  if S[i:]+S[:i]==T:
    print("Yes")
    exit(0)
    
print("No")

Buggy python submission (verdict: Runtime Error):
S,T=input().split()
for i in range(len(S)):
  if S[i:]+S[:i]==T:
    print("Yes")
    exit(0)
    
print("No")

Fixed submission:
S=input()
T=input()
for i in range(len(S)):
  if S[i:]+S[:i]==T:
    print("Yes")
    exit(0)
    
print("No")

Buggy python submission (verdict: Runtime Error):
S,T=input().split()
for i in range(len(S)):
  if S[i:]+S[:i]==T:
    print("Yes")
    exit(0)
    
print("No")

Fixed submission:
S=input()
T=input()
for i in range(len(S)):
  if S[i:]+S[:i]==T:
    print("Yes")
    exit(0)
    
print("No")

Buggy python submission (verdict: Runtime Error):
S,T=input.split()
for i in range(len(S)):
  if S[i:]+S[:i]==T:
    print("Yes")
    exit(0)
    
print("No")

Fixed submission:
S=input()
T=input()
for i in range(len(S)):
  if S[i:]+S[:i]==T:
    print("Yes")
    exit(0)
    
print("No")
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
ab=[tuple(map(int,input().split())) for i in range(M)]

ab.sort()
l=1,r=N
ans=1
for a,b in ab:
  l=max(a,l)
  r=min(b,r)
  if l>=r:
    ans+=1
    l=a
    r=b
print(ans)
  

Fixed submission:
import bisect
N, M = map(int, input().split())


ab = [tuple(map(int, input().split())) for i in range(M)]
ab = [tuple([ab[i][0], ab[i][1], i]) for i in range(M)]

ans = 1
tmp = 0

a = sorted(ab, key=lambda x: x[0])
b = sorted(ab, key=lambda x: x[1])

checked = set()

for i in range(M):
    if b[tmp][1] <= a[i][0]:
        ans += 1
        while(b[tmp][1] <= a[i][0] or b[tmp][2] in checked):
            tmp += 1
    checked.add(a[i][2])


print(ans)
Buggy python submission (verdict: Runtime Error):
import collections
import math
N=int(input())
A=list(map(int,input().split()))
diff_dic=collections.defaultdict(int)


B=[A[i]-(i+1) for i in range(N)]
for i in range(N):
  diff_dic[B[i]]+=1
  
diff_list=sorted(list(diff_dic.items()), key=lambda x:x[1],reverse=True)
ans=diff_list[0][0]
temp=0

ans=sum(diff_list) / N
temp=0
for j in range(N):
  temp+= abs(A[j] - (int(ans) + j + 1) )


temp2=0
for j in range(N):
  temp2+= abs(A[j] - (math.ceil(ans) + j + 1) )
print(min(temp,temp2))

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

B=[A[i]-i for i in range(N)]
B.sort()
temp=0

if N%2==0:
  ans = B[N//2]
  ans2= B[N//2 -1]
  temp=0
  for j in range(N):
    temp+= abs(B[j] - ans)
  temp2=0
  for j in range(N):
    temp2+= abs(B[j] - ans2)
  ans= min(temp,temp2)
else:
  ans = B[N//2]
  temp=0
  for j in range(N):
    temp+= abs(B[j] - ans )
  ans=temp
print(ans)

Buggy python submission (verdict: Runtime Error):
import collections
import math
N=int(input())
A=list(map(int,input().split()))
diff_dic=collections.defaultdict(int)


B=[A[i]-(i+1) for i in range(N)]
for i in range(N):
  diff_dic[B[i]]+=1
  
diff_list=sorted(list(diff_dic.items()), key=lambda x:x[1],reverse=True)
ans=diff_list[0][0]
temp=0

ans=sum(diff_list) / N
temp=0
for j in range(N):
  temp+= abs(A[j] - (int(ans) + j + 1) )
print(temp)

temp2=0
for j in range(N):
  temp2+= abs(A[j] - (math.ceil(ans) + j + 1) )
print(temp2)

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

B=[A[i]-i for i in range(N)]
B.sort()
temp=0

if N%2==0:
  ans = B[N//2]
  ans2= B[N//2 -1]
  temp=0
  for j in range(N):
    temp+= abs(B[j] - ans)
  temp2=0
  for j in range(N):
    temp2+= abs(B[j] - ans2)
  ans= min(temp,temp2)
else:
  ans = B[N//2]
  temp=0
  for j in range(N):
    temp+= abs(B[j] - ans )
  ans=temp
print(ans)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
import math
A=int(input().split())
ans=1
ans+=math.ceil(N-K)/(K-1)
print(ans)

Fixed submission:
N,K=map(int,input().split())
import math
A=list(map(int,input().split()))
ans=1
ans+=math.ceil((N-K)/(K-1))
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B = map(int, input().split())
if A < = 8 and B <= 8:
    print("Yay!")
else:
    print(":(")

Fixed submission:
A,B = map(int, input().split())
if A <= 8 and B <= 8:
    print("Yay!")
else:
    print(":(")
Buggy python submission (verdict: Runtime Error):
import collections
N=int(input())
S =input()
def countchar(s1,s2):
  table=collections.defaultdict(int)
  for x in s1:
    table[x]+=1
  for x in s2:
    if x in table and table[x]>0:
      ret+=1
      table[x]=0
  return(ret)
ans=0
for i in range(1,N):
  X=S[:i]
  Y=S[i:]
  ans=max(ans,countchar(X,Y))
print(ans)

Fixed submission:
import collections
N=int(input())
S =input()
def countchar(s1,s2):
  ret=0
  table=collections.defaultdict(int)
  for x in s1:
    table[x]+=1
  for x in s2:
    if x in table and table[x]>0:
      ret+=1
      table[x]=0
  return(ret)
ans=0
for i in range(1,N):
  X=S[:i]
  Y=S[i:]
  ans=max(ans,countchar(X,Y))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())

s = [0]*N

for i in range(N):
    s[i] += S[:i].count('W')
    s[i] += S[i+1:].count('E')

print(min(s))


Fixed submission:
N = int(input())
S = list(input())

s = [0]*(N+1)
e = [0]*(N+1)
for i in range(1, N+1):
    k = 0
    if S[i-1] == "W":
        k = 1
    s[i] = s[i-1] + k

for i in reversed(range(0, N)):
    k = 0
    if S[i] == "E":
        k = 1
    e[i] = e[i+1] + k

ans = N
for i in range(1, N+1):
    ans = min(ans, s[i-1]+e[i])


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))

s=[0]*(N+1)
xs=[0]*(N+1)
for i in range(N):
  s[i+1]=s[i]+A[i]
  xs[i+1]=xs[i] ^ A[i]
ans=0
for l in range(N):
  for r in range(l,N):
    #print(s[r+1],s[l],xs[r+1],xs[l])
    if s[r+1]-s[l] == xs[r+1]^xs[l]:
      ans+=1
    else:
      break
print(ans)



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

s=[0]*(N+1)
xs=[0]*(N+1)
for i in range(N):
  s[i+1]=s[i]+A[i]
  xs[i+1]=xs[i] ^ A[i]
ans=0
l=0
for r in range(N+1):
    #print(l,r)
    
    if r == N:
      ans+=((r-l)*(r+1-l))//2
      continue   
    while(r != l):
      if s[r+1]-s[l] == xs[r+1]^xs[l]:
        break
      else:         
        ans+=r-l
        l+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
import collections
s = input()
K = int(input())

abc = collections.defaultdict(list)

for i in range(len(s)):
  for j in range(1,K+1):
    if i+j < len(s):
        abc[s[i:i+j]].append(i)


abc = list(abc.items())
abc.sort(key=lambda x: x[0])


print(abc[K][0])


Fixed submission:
import collections
s = input()
K = int(input())

abc = collections.defaultdict(list)

for i in range(len(s)):
  for j in range(1,K+1):
    if i+j <= len(s):
        abc[s[i:i+j]].append(i)


abc = list(abc.items())
abc.sort(key=lambda x: x[0])

print(abc[K-1][0])
Buggy python submission (verdict: Runtime Error):
a=list(map(int,input().split()))
K=int(input)
maxa=a.pop(a.index(max(a)))
print((maxa*(2**K))+sum(a))

Fixed submission:
a=list(map(int,input().split()))
K=int(input())
maxa=a.pop(a.index(max(a)))
print((maxa*(2**K))+sum(a))
Buggy python submission (verdict: Runtime Error):
import collections
from itertools import combinations
N = int(input())


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


num = [i for i in range(2, 55556)]
num = collections.deque(num)
dp = [set() for i in range(N)]
dp[0] = {num.popleft()}
for i in range(1, N):
    if i < 5:
        tmp = num.popleft()
        while(is_prime(tmp) != True):
            tmp = num.popleft()
        dp[i] = dp[i-1] | {tmp}
    else:
        flag = False

        while(flag != True):
            tmp = num.popleft()
            while(is_prime(tmp) != True):
                tmp = num.popleft()
            for x in combinations(dp[i-1], 4):
                if is_prime(sum(x) + tmp):
                    flag = False
                    break
                else:
                    flag = True
        if flag:
            dp[i] = dp[i-1] | {tmp}

print(" ".join(map(str, dp[N-1])))


Fixed submission:
def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

from itertools import combinations
N=int(input())

prime_list=primes(55555)
id=4
ans=[prime_list[i] for i in range(len(prime_list)) if prime_list[i]%5==2]

print(" ".join(map(str,ans[:N])))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

sumA = [0]*(N+1)

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

print(ans)


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

sumA = [0]*(N+1)
table = collections.defaultdict(int)
table[0] += 1
for i in range(N):
    sumA[i+1] = sumA[i]+A[i]
    table[sumA[i+1]] += 1
ans = 0
table = table.values()
table = [x for x in table if x > 1]
for x in table:
    ans += x*(x-1)//2

print(ans)
Buggy python submission (verdict: Runtime Error):
print(700+100*input().count("o")

Fixed submission:
print(700+100*input().count("o"))
Buggy python submission (verdict: Runtime Error):
N,M,X=map(int,input().split())
A=list(map(int,input().split()))
left = [A[i] for i in range(N+1) if A[i] < X ]
right = [A[i] for i in range(N+1) if A[i] > X]
print(min(len(left),len(right)))

Fixed submission:
N,M,X=map(int,input().split())
A=list(map(int,input().split()))
left = [A[i] for i in range(M) if A[i] < X ]
right = [A[i] for i in range(M) if A[i] > X]
print(min(len(left),len(right)))
Buggy python submission (verdict: Runtime Error):
import math
import bisect


def cmb(n, r):
    if n - r < r:
        r = n - r
    if r == 0:
        return 1
    if r == 1:
        return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


n = int(input())

a = list(map(int, input().split()))
a.sort()

ncr = 0
ans = [0, 0]

id = bisect.bisect_left(a[:n-1], a[n-1]//2)
if abs(a[-1]/2 - a[id]) <= abs(a[-1] - a[id+1]):
    ans = id
else:
    ans = id+1

print(a[-1], a[ans])


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


ans=a.pop(a.index(max(a)))

for i in range(n - 1):
    if a[i] > ans / 2:
        a[i] = [ans - a[i],a[i]]
    else:
        a[i] = [a[i],a[i]]
a = sorted(a,reverse = True)

print(str(ans) + " " + str(a[0][1]))
Buggy python submission (verdict: Runtime Error):
ABC=map(int,input().split())
ABC.sort()
ans=0
ans+=(ABC[2]-ABC[0])//2
if (ABC[2]-ABC[0])%2==1:
  ans+=(ABC[2]-ABC[0])//2
  ABC[0]=ABC[2]-1
  ans+=(ABC[2]-ABC[1])//2
  if (ABC[2]-ABC[1])%2 == 1:
    ans+=1
  else:
    ans+=2  
else:
  ans+=(ABC[2]-ABC[1])//2
  if (ABC[2]-ABC[1])%2 == 1:
    ans+=2
  else:
    ans+=1
print(ans)

Fixed submission:
ABC=list(map(int,input().split()))
ABC.sort()
ans=0
ans+=(ABC[2]-ABC[0])//2
if (ABC[2]-ABC[0])%2==1:
  ans+=(ABC[2]-ABC[1])//2
  if (ABC[2]-ABC[1])%2 == 1:
    ans+=1
  else:
    ans+=2  
else:
  ans+=(ABC[2]-ABC[1])//2
  if (ABC[2]-ABC[1])%2 == 1:
    ans+=2

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))

cost=[abs(A[i]-A[i+1]) for i in range(N-1)]

for i in range(N):
  total=sum(cost)+abs(A[0])+abs(A[N-1])
  if i == 0:
    total-=abs(A[i])
    total-=cost[i]
    total+=abs(A[i+1])
  elif i == N-1:
    total-=abs(A[i])
    total+=abs(A[i-1])
    total-=cost[i-1]
  else:
    total-=cost[i]
    total-=cost[i-1]
    total+=abs(A[i+1]-A[i-1])
  print(total)

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

cost=[abs(A[i]-A[i+1]) for i in range(N-1)]
costsum=total=sum(cost)+abs(A[0])+abs(A[N-1])
for i in range(N):
  total=costsum
  if i == 0:
    total-=abs(A[i])
    total-=cost[i]
    total+=abs(A[i+1])
  elif i == N-1:
    total-=abs(A[i])
    total+=abs(A[i-1])
    total-=cost[i-1]
  else:
    total-=cost[i]
    total-=cost[i-1]
    total+=abs(A[i+1]-A[i-1])
  print(total)

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

cost=[abs(A[i]-A[i+1] for i in range(N-1))]

for i in range(N):
  total=sum(cost)+abs(A[0])+abs(A[N-1])
  if i == 0:
    total-=abs(A[i])
    total-=cost[i]
    total+=abs(A[i+1])
  elif i == N-1:
    total-=abs(A[i])
    total+=abs(A[i-1])
    total-=cost[i-1]
  else:
    total-=cost[i]
    total-=cost[i-1]
    total+=abs(A[i+1]-A[i-1])
  print(total)

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

cost=[abs(A[i]-A[i+1]) for i in range(N-1)]
costsum=total=sum(cost)+abs(A[0])+abs(A[N-1])
for i in range(N):
  total=costsum
  if i == 0:
    total-=abs(A[i])
    total-=cost[i]
    total+=abs(A[i+1])
  elif i == N-1:
    total-=abs(A[i])
    total+=abs(A[i-1])
    total-=cost[i-1]
  else:
    total-=cost[i]
    total-=cost[i-1]
    total+=abs(A[i+1]-A[i-1])
  print(total)