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

Fixed submission:
import collections
import math

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

N = int(input())
s = [""]*N
S = []
for i in range(N):
    s[i] = input()
    test = list(s[i])
    test.sort()
    S.append("".join(test))
ana = sorted(collections.Counter(S).values())
count = 0
for i in ana:
    if i >= 2:
        count += combinations_count(i,2)
print(count)

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

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

N = int(input())
s = [""]*N
S = []
for i in range(N):
    s[i] = input()
    test = [*s[i]]
    test.sort()
    S.append("".join(test))
ana = sorted(collections.Counter(S).values())
count = 0
for i in ana:
    if i >= 2:
        count += combinations_count(i,2)
print(count)

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

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

N = int(input())
s = [""]*N
S = []
for i in range(N):
    s[i] = input()
    # print(s[i])
    # test = sorted(collections.Counter(input()))
    test = [*s[i]]
    test.sort()
    S.append("".join(test))
ana = sorted(collections.Counter(S).values())
count = 0
for i in ana:
    if i >= 2:
        count += combinations_count(i,2)
print(count)

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

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

N = int(input())
s = [""]*N
S = []
for i in range(N):
    s[i] = input()
    # print(s[i])
    # test = sorted(collections.Counter(input()))
    test = [*s[i]]
    test.sort()
    S.append("".join(test))
ana = sorted(collections.Counter(S).values())
count = 0
for i in ana:
    if i >= 2:
        count += combinations_count(i,2)
print(count)

Buggy submission (verdict: Runtime Error):
import collections
import numpy as np
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N = int(input())
s = [""]*N
S = []
for i in range(N):
    s[i] = input()
    # print(s[i])
    # test = sorted(collections.Counter(input()))
    test = [*s[i]]
    test.sort()
    S.append("".join(test))
# print(s)
# print(S)
# count = 0
# for i in range(N-1):
#     for j in range(i+1,N):
#         if S[i] == S[j]:
#             count+=1
# print(count)
ana = sorted(collections.Counter(S).values())
ana_test = np.array(ana) - np.array([1]*(len(ana)))
# print(ana)
count = 0
for i in ana:
    if i >= 2:
        count += combinations_count(i,2)

print(count)
Problem p02972 (python)

Fixed submission:
import math
def func1(lst, value):
    return [i+1 for i, x in enumerate(lst) if x == value]
N = int(input())
a = list(map(int,input().split()))

b = [0] * N
# half = math.ceil(N/2)
summ = 0
for i in reversed(range(N)):
# print(i)
    x = N//(i+1)
# print("x",x)
    if x == 1:
        b[i] = a[i]
    else:
        for j in range(x):
            # print(j)
            summ += b[(i+1)*(j+1)-1]
        # summ -= a[i]
        # print("sum=",summ)
        judge=summ%2
        # print("judge",judge)
        if (judge==0 and a[i]==0) or (judge==1 and a[i]==1):
            b[i] = 0
        else:
            b[i] = 1
        summ = 0
        judge = 0
# print(b)
print(sum(b))
if sum(b) != 0:
    ans = func1(b,1)
    # print(ans)
    if len(ans)>1:
        ans = map(str,ans)
        print(" ".join(ans))
    else:
        print(str(ans.pop()))

Buggy submission (verdict: Runtime Error):
import math
def func1(lst, value):
    return [i+1 for i, x in enumerate(lst) if x == value]
N = int(input())
a = list(map(int,input().split()))

b = [0] * N
half = math.ceil(N/2)
summ = 0
for i in reversed(range(N)):
    # print(i)
    if i >= half-1:
        b[i] = a[i]
    else:
    x = N//(i+1)
    # print("x",x)
        if x == 1:
            b[i] = a[i]
        else:
            for j in range(x):
                # print(j)
                summ += a[(i+1)*(j+1)-1]
            summ -= a[i]
            # print("sum=",summ)
            judge=summ%2
            # print("judge",judge)
            if (judge==0 and a[i]==0) or (judge==1 and a[i]==1):
                b[i] = 0
            else:
                b[i] = 1
            summ = 0
            judge = 0
# print(b)
print(sum(b))
if sum(b) != 0:
    ans = func1(b,1)
    # print(ans)
    if len(ans)>1:
        ans = map(str,ans)
        print(" ".join(ans))
    else:
        print(ans.pop())
Problem p02993 (python)

Fixed submission:
flag = True
S = input()
for i in range(1,len(S)):
  if S[i] == S[i-1]:
    flag = False

if flag:
  print("Good")
else:
  print("Bad")

Buggy submission (verdict: Runtime Error):
flag = True
S = input()
for i in range(1,len(S)):
  if S[i] == S[i-1]:
    flag = False

if flag:
  print("Good"):
else:
  print("Bad")
Problem p03043 (python)

Fixed submission:
#C
import math
N,K = map(int,input().split())
p=0
for i in range(N):
    #   print(i)
    if i+1 >= K:
        X =0
    else:
        X = math.ceil((math.log2(K/(i+1))))
    p +=(1/2)**X
p = p/N
print(p)

Buggy submission (verdict: Runtime Error):
import math
N,K = map(int,input().split())
p=0
for i in range(N):
    #   print(i)
    if i+1 >= K:
        X =0
    else:
        X = math.ceil((math.log2(K/(i+1))))
        # X = round(math.log2(K-1/(i+1))+1)
        # print(math.log2(K-1/(i+1))+1)
        # print(math.log2(K/(i+1)))
        # print(round(math.log2(K/(i+1))))
        # print(X)
        # print(math.log2(K/(i+1)))
        # print(X)
    p +=(1/2)**X
p = p/N
print(p)
Problem p03079 (python)

Fixed submission:
a,b,c = (int(x) for x in input().split())
if a == b and b == c:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
s = input()
r = 0
b = 0
for cap in s:
    if cap == 'R':
        r+=1
    elif cap == 'B':
        b+=1
if r>b:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
s = input()
r = 0
b = 0
for cap in s:
    if cap == 'R':
        r+=1
    elif cap == 'B':
        b+=1
if r>b:
    print('Yes')
else:
    print('No')
Problem p02801 (python)

Fixed submission:
c = input()

alphabet = 'abcdefghijklmnopqrstuvwxyz'

index = alphabet.index(c)
print(alphabet[index+1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
solve_problem = []
d = {i: 0 for i in range(1, N+1)}
ans = 0
penalty = 0
for i in range(M):
    p, S = input().split()
    if S == 'AC' and p not in solve_problem:
        solve_problem.append(p)
        ans += 1
        penalty += d[int(p)]
    if S == 'WA':
        d[int(p)] += 1

print('{} {}'.format(ans, penalty))
Problem p03361 (python)

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

S = ["."*(W+2)]
ans = 'Yes'
for i in range(H):
    s = input()
    S.append('.'+s+'.')

S.append('.'*(W+2))

for i in range(1, H+1):
    for j in range(1, W+1):
        if S[i][j] == '#':
            if S[i][j+1] == '#' or S[i][j-1] == '#' or S[i+1][j] == '#' or S[i-1][j] == '#':
                continue
            else:
                ans = 'No'
                break

print(ans)

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

S = ["."*W]
ans = 'Yes'
for i in range(H):
    s = input()
    S.append('.'+s+'.')

S.append('.'*W)

for i in range(1, H+1):
    for j in range(1, W+1):
        if S[i][j] == '#':
            if S[i][j+1] == '#' or S[i][j-1] == '#' or S[i+1][j] == '#' or S[i-1][j] == '#':
                continue
            else:
                ans = 'No'
                break

print(ans)
Problem p03386 (python)

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

if b-a+1>2*k:
    for i in range(a, a+k):
        print(i)
    for i in range(b-k+1, b+1):
        print(i)
else:
    for i in range(a, b+1):
        print(i)

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

l = list(range(a, b+1))


if a + k -1 >= b -k +1:
    for i in l:
        print(i)
else:
    for i in range(k):
        print(a+i)
    for i in range(k):
        print(b-k+i+1)

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

l = list(range(a, b+1))

small = l[0:k]
large = l[-k:]

ans = set(small+large)

for i in ans:
    print(i)
Problem p03545 (python)

Fixed submission:
S = input()
A = S[0]
B = S[1]
C = S[2]
D = S[3]

op = ['+', '-']

def check(A, B, C, D):
    for i in range(2):
        for j in range(2):
            for k in range(2):
                x = A+op[i]+B+op[j]+C+op[k]+D
                if eval(x) == 7:
                    return x

print(check(A, B, C, D)+'=7')

Buggy submission (verdict: Runtime Error):
S = input()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

for i in range(2):
    s = A
    op1 = '+' if i == 0 else '-'
    s += B if op1 == '+' else -1 * B
    for j in range(2):
        op2 = '+' if j == 0 else '-'
        s += C if op2 == '+' else -1 * C
        for k in range(2):
            op3 = '+' if k == 0 else '-'
            s += D if op3 == '+' else -1 * D
            if s == 7:
                ans = str(A)+op1+str(B)+op2+str(C)+op3+str(D)+'=7'

print(ans)

Buggy submission (verdict: Runtime Error):
A, B, C, D = list(input())
A = int(A)
B = int(B)
C = int(C)
D = int(D)

for i in range(2):
    s = A
    op1 = '+' if i == 0 else '-'
    s += B if op1 == '+' else -1 * B
    for j in range(2):
        op2 = '+' if j == 0 else '-'
        s += C if op2 == '+' else -1 * C
        for k in range(2):
            op3 = '+' if k == 0 else '-'
            s += D if op3 == '+' else -1 * D
            if s == 7:
                ans = str(A)+op1+str(B)+op2+str(C)+op3+str(D)+'=7'

print(ans)
Problem p03779 (python)

Fixed submission:
X = int(input())

t = 0
i = 1
while True:
    t += i
    if t >= X:
        print(i)
        break
    else:
        i += 1

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

ans = 10**9

def func(current, t):
    global ans
    if ans < t or current > X:
        return
    if current == X :
        ans = min([ans, t])
        return

    func(current+(t+1), t+1)
    func(current-(t+1), t+1)
    func(current, t+1)

func(0, 0)

print(ans)
Problem p03854 (python)

Fixed submission:
S = input()

ans = 'YES'

while S:
    if S.endswith('eraser'):
        S = S[:-6]
    elif S.endswith('erase'):
        S = S[:-5]
    elif S.endswith('dreamer'):
        S = S[:-7]
    elif S.endswith('dream'):
        S = S[:-5]
    else:
        ans = 'NO'
        break

print(ans)

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

ans = 'NO'
def func(T):
    global ans
    if len(T) > len(S):
        return
    if S == T:
        ans = 'YES'
        return

    if S[len(T)] == 'd':
        func(T+'dream')
        func(T+'dreamer')
    if S[len(T)] == 'e':
        func(T+'erase')
        func(T+'eraser')

func('')

print(ans)

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

ans = 'NO'
def func(T):
    global ans
    if len(T) > len(S):
        return
    if S == T:
        ans = 'YES'
        return

    func(T+'dream')
    func(T+'dreamer')
    func(T+'erase')
    func(T+'eraser')

func('')

print(ans)
Problem p03047 (python)

Fixed submission:
IN1 = input().split()
N = int(IN1[0])
K = int(IN1[1])
print(N - K + 1)

Buggy submission (verdict: Runtime Error):
N = int(input())
K = int(input())
print(N - K + 1)
Problem p02818 (python)

Fixed submission:
In = input().split(" ")
T = int(In[0])
A = int(In[1])
K = int(In[2])
 
if K <= T:
  print("{0} {1}".format(T-K,A))
elif K <= T+A:
  print("0 {0}".format(A-(K-T)))
else:
  print("0 0")

Buggy submission (verdict: Runtime Error):
In = input().split(" ")
T = int(In[0])
A = int(In[1])
K = int(In[2])
 
if K>=T+A:
  print("0 0")
else:
	if (K > T):
  		print("0 {0}".format(A-(K-T)))
	elif (T > K):
  		print("{0} {1}".format(T-K, A))
	else:
  		for i in range(K):
    		if T >= 1:
     			 T -= 1
    		else:
    			if A >= 1:
      				A -= 1
    			else:
      				break
  		print("{0} {1}".format(T, A))
Problem p02886 (python)

Fixed submission:
N = int(input())
List = [int(j) for j in input().split(" ")]
Sum = 0
for n in range(0,N-1):
  for m in range(n+1,N):
    Sum += List[n]*List[m]
print(Sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
List = [int(j) for j in input().split(" ")]
Sum = 0
for n in range(0,N-1):
  for m in range(n+1,N):
    Sum += List[i]*List[j]
print(Sum)
Problem p02898 (python)

Fixed submission:
N,K = map(int,input().split(" "))
List = [int(i) for i in input().split(" ") if int(i)>=K]
print(len(List))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split(" "))
List = sorted([int(i) for i in input().split(" ")],reverse=True)
h=0
while(List[h]>=K):
    h+=1
print(h)
Problem p02921 (python)

Fixed submission:
S = input()
T = input()
count = 0

for i in range(len(S)):
  if S[i]==T[i]:
    count += 1
    
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
print(int(N*(N-1)/2))

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

for i in range(len(S)):
  if S[i]==T[i]:
    count += 1
    
print(count)
Problem p02947 (python)

Fixed submission:
N = int(input())
str = [''.join(sorted(input())) for i in range(N)]
dict = {}
sum = 0

for i in range(N):
  try:
    dict[str[i]] += 1
  except KeyError:
    dict[str[i]] = 1

for i in dict.values():
  sum += (i*(i-1))//2

print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
str = [input().sort for i in range(N)]
dict = {}
count = 0

print(str)
Problem p02995 (python)

Fixed submission:
import fractions
A, B, C, D = map(int, input().split(" "))
W = (B-A+1)
x = C*D//fractions.gcd(C,D)

c = (B//C) - ((A-1)//C)
d = (B//D) - ((A-1)//D)
j = (B//x) - ((A-1)//x)

div = (c+d-j)
print(W-div)

Buggy submission (verdict: Runtime Error):
import math
A, B, C, D = map(int, input().split(" "))
W = (B-A+1)
x = C*D//math.gcd(C,D)

c = (B//C) - ((A-1)//C)
d = (B//D) - ((A-1)//D)
j = (B//x) - ((A-1)//x)

div = (c+d-j)
print(W-div)
Problem p03000 (python)

Fixed submission:
N, X = map(int,input().split(" "))
L = [int(i) for i in input().split(" ")]
D = 0
count = 1
for i in range(N):
    D+=L[i]
    if D<=X:
        count+=1
    
print(count)

Buggy submission (verdict: Runtime Error):
def next_pos(D,L):
    return D+L
    
N, X = map(int,input().split(" "))
L = [int(i) for i in input().split(" ")]
D = 0
count = 0
i = 0

while(D<=X or i<N):
    D = next_pos(D,L[i])
    count+=1
    i+=1
    
print(count)

Buggy submission (verdict: Runtime Error):
def next_pos(D,L):
    return D+L
    
N, X = map(int,input().split(" "))
L = [int(i) for i in input().split(" ")]
D = 0
count = 0
i = 0

while(D<=X):
    D = next_pos(D,L[i])
    count+=1
    i+=1
    
print(count)
Problem p03001 (python)

Fixed submission:
W,H,x,y = map(int,input().split(" "))

Max = W*H/2

if x*2 == W and y*2 == H:
    ver = 1
else:
    ver = 0
    
print("{} {}".format(Max,ver))

Buggy submission (verdict: Runtime Error):
W,H,x,y = map(float,input().split(" "))

WH = W*H
W,H,x,y = map(float,input().split(" "))

WH = W*H

w = (W-x)*H
h = (H-y)*W

if (WH-w)<w:
    w = (WH-w)
if (WH-h)<h:
    h = (WH-h)

if w>h:
    print("{} ".format(w),end="")
else:
    print("{} ".format(h),end="")

if w!=h:
    print("0")
else:
    print("1")
Problem p03035 (python)

Fixed submission:
Age, Fee = map(int,input().split(" "))
if Age>=13:
  print(Fee)
elif Age<13 and Age>=6:
  print(Fee//2)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
if Age>=13:
  print(Fee)
elif Age<13 and Age>=6:
  print(Fee//2)
else:
  print(0)
Problem p03076 (python)

Fixed submission:
N = 5
D = [int(input()) for _ in range(N)]

srv_t = 0
last_srv = 0

for d in D:
   if d%10!=0:
       t = 10 - d%10
   else:
       t = 0
    
   srv_t += (d+t)
    
   last_srv = max(last_srv,t)
    
print(srv_t-last_srv)

Buggy submission (verdict: Runtime Error):
N = 5
Dishes = [int(input()) for _ in range(N)]
Dishes_10 = [0]*N

for i in range(N):
    d = int(str(Dishes[i])[-1])
    if d!=0:
        Dishes_10[i] = Dishes[i]+10-d
    else:
        Dishes_10[i] = Dishes[i]

Max=0
for i in range(N):
    
    if (Dishes_10[i]-Dishes[i])>Max:
        posi = i
        Max = Dishes_10[i]-Dishes[i]
        
Dishes_10[posi] = Dishes[posi]

print(sum(Dishes_10))

Buggy submission (verdict: Runtime Error):
N = 5
Dishes = [int(input()) for _ in range(N)]
Dishes_10 = []

for i in range(N):
    d = int(str(Dishes[i])[-1])
    if d!=0:
        Dishes_10.append(int(Dishes[i])+10-d)
    else:
        Dishes_10.append(int(Dishes[i]))

for i in range(N):
    Max=0
    if (Dishes_10[i]-Dishes[i])>Max:
        posi = i
        Max = Dishes_10[i]-Dishes[i]

Dishes_10[posi] = Dishes[posi]

print(sum(Dishes_10))
Problem p03294 (python)

Fixed submission:
from fractions import gcd
from functools import reduce
def lcm_base(x,y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
    
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
    
N = int(input())
a = [int(i) for i in input().split(" ")]

x = lcm_list(a)-1
Sum = 0
for a_ in a:
    Sum += x%a_
print(Sum)

Buggy submission (verdict: Runtime Error):
from math import gcd
from functools import reduce
def lcm_base(x,y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
    
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
    
N = int(input())
a = [int(i) for i in input().split(" ")]

x = lcm_list(a)-1
Sum = 0
for a_ in a:
    Sum += x%a_
print(Sum)
Problem p03360 (python)

Fixed submission:
List = sorted([int(i) for i in input().split(" ")],reverse=True)
K = int(input())
List[0] = List[0]*(2**K)
print(sum(List))

Buggy submission (verdict: Runtime Error):
List = sorted([int(i) for i in input().split(" ")],reversed=True)
K = int(input())
List[0] = List[0]*(2**K)
print(sum(List))
Problem p04033 (python)

Fixed submission:
a,b = map(int,input().split())
if (a<=0 and b>=0) :
    print("Zero")
else:
    if a>0:
        print("Positive")
    elif b<0:
        if (b-a+1)%2==0:
            print("Positive")
        else:
            print("Negative")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if (a<0 and b>0) or a == 0 or b == 0:
    print("Zero")
else:
    nega = [i for i in list(range(a,b+1)) if i<0]
    if len(nega)%2==0:
        print("Positive")
    else:
        print("Negative")
Problem p02607 (python)

Fixed submission:
"""
NTC here
"""


#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase

profile = 0
pypy = 1


def iin(): return int(input())


def lin(): return list(map(int, input().split()))



def main():
    T = 1
    while T:
        T -= 1
        n = iin()
        a = lin()
        ans = [1 for i in range(n) if a[i]%2 and i%2==0]
        print( sum(ans) if ans else 0)




    
        










    




                

        

 
 
 
 
 
 
# region fastio
 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
if pypy:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
    input = lambda: sys.stdin.readline().rstrip("\r\n")
 
# endregion
 
if __name__ == "__main__":
    if profile:
        import cProfile
        cProfile.run('main()')
    else:
        main()

Buggy submission (verdict: Runtime Error):
n = iin()
a = list(map(int, input().split()))
ans = [1 for i in range(n) if a[i]%2 and i%2==0]
print(sum(ans))
Problem p02854 (python)

Fixed submission:
"""
NTC here
"""
from sys import stdin, setrecursionlimit
setrecursionlimit(10**7)

def iin(): return int(stdin.readline())
 
 
def lin(): return list(map(int, stdin.readline().split()))

# range = xrange
# input = raw_input
def main():
    n=iin()
    a=lin()
    s2=sum(a)
    s1=0
    mn=abs(s2-s1)
    for i in range(n-1):
        s1+=a[i]
        s2-=a[i]
        mn=min(mn,abs(s1-s2))
    print(mn)

"""
1 2 5 8 15 20 23 11 45
"""
        


    
    
            



    
                











main()

Buggy submission (verdict: Runtime Error):
"""
NTC here
"""
from sys import stdin, setrecursionlimit
setrecursionlimit(10**7)

def iin(): return int(stdin.readline())
 
 
def lin(): return list(map(int, stdin.readline().split()))

# range = xrange
# input = raw_input
from math import gcd
gcd=gcd
def lcm(a,b):
    return (a*b)//(gcd(a,b))
def main():
    n=iin()
    a=lin()
    s2=sum(a)
    s1=0
    mn=abs(s2-s1)
    for i in range(n-1):
        s1+=a[i]
        s2-=a[i]
        mn=min(mn,abs(s1-s2))
    print(mn)

"""
1 2 5 8 15 20 23 11 45
"""
        


    
    
            



    
                











main()
Problem p03162 (python)

Fixed submission:
"""
NTC here
"""
import sys
input= sys.stdin.readline
# import t  hreading
# setrecursionlimit(10**6)
# threading.stack_size(2**26)

def iin(): return int(input())
def lin(): return list(map(int, input().split()))

# range = xrange
# input = raw_input

def main():
    n = iin()
    Q = [lin() for i in range(n)]
    ans = [[0, 0, 0] for i in range(n+1)] 
   # print(ans)
    for i in range(n-1, -1, -1):
        for j in range(3):
            ans[i][j]=Q[i][j]+max([
                ans[i+1][k] for k in range(3) if k!=j
            ])
  #  print(ans)
    print(max(ans[0]))

        



                









        
main()
#threading.Thread(target=main).start()

Buggy submission (verdict: Runtime Error):
"""
NTC here
"""
import sys
input= sys.stdin.readline
# import t  hreading
# setrecursionlimit(10**6)
# threading.stack_size(2**26)

def iin(): return int(input())
def lin(): return list(map(int, input().split()))

# range = xrange
# input = raw_input

def main():
    n, k= lin()
    h=lin()
    ans=[0]*(n)
    for i in range(n-2,-1,-1):
        ans[i]=min(
            [abs(h[i]-h[j+i+1])+ans[i+j+1] for j in range(min(n-i-1,k))]
            )
    print(ans[0])
        



                









        
main()
#threading.Thread(target=main).start()
Problem p02641 (python)

Fixed submission:
x, n = map(int, input().split())
lst = []
if n > 0:
  lst = list(map(int, input().split()))
a = 100
b = 0

for i in range(0, 102):
  if i in lst:
    continue

  if a > abs(x-i):
    a = abs(x-i)
    b = i

print(b)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
lst = [int(input()) for _ in range(n)]
a = 100
b = 0

for i in range(1, 102):
  if i in lst:
    continue

  if a > abs(x-i):
    a = abs(x-i)
    b = i

print(i)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
lst = [int(input()) for _ in range(n)]
a = 100
b = ''

for i in range(1, 102):
  if i in lst:
    continue

  if a > abs(x-i):
    a = abs(x-i)
    b = i

print(i)