Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# -*- coding utf-8 -*-

n = int(input())
k = int(input())
x = int(input())
y = int(input())

if n <= k :
    print(n*x)
elif k < n :
    ans = (k*x) + (y*(n-k))
    print(ans)


Fixed submission:
# -*- coding utf-8 -*-

a = int(input())
b = int(input())
h = int(input())

x = (a+b)*h/2

print(round(x))
Buggy python submission (verdict: Runtime Error):
# -*- coding utf-8 -*-

n,l=map(int,input().split())

s =[str(input()) for i in range(n)]

s.sort()

print(*s,sep="")


Fixed submission:
# -*- coding utf-8 -*-

x = list(map(int,input().split()))

x.sort() 
if x == [5,5,7]:
    print ("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,D = list(map(int, input().split()))

n_list=[i for i in range(A,B+1) if  i%C!=0 and i%D!=0]
print(len(n_list))

Fixed submission:
from fractions import gcd
A,B,C,D = map(int, input().split())

c_div=B//C
d_div=B//D
dc_div=B//((C*D)//gcd(C,D))

not_div1 = B-(d_div+c_div-dc_div)

A =A-1
c_div=A//C
d_div=A//D
dc_div=A//((C*D)//gcd(C,D))

not_div2 = A-(d_div+c_div-dc_div)

print(not_div1-not_div2)

Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,D = list(map(int, input().split()))

n_list=[i for i in range(A,B+1) if  i%C!=0 and i%D!=0]
print(len(n_list))

Fixed submission:
from fractions import gcd
A,B,C,D = map(int, input().split())

c_div=B//C
d_div=B//D
dc_div=B//((C*D)//gcd(C,D))

not_div1 = B-(d_div+c_div-dc_div)

A =A-1
c_div=A//C
d_div=A//D
dc_div=A//((C*D)//gcd(C,D))

not_div2 = A-(d_div+c_div-dc_div)

print(not_div1-not_div2)
Buggy python submission (verdict: Runtime Error):
N, X = list(map(int, input().split()))
l = list(map(int, input().split()))

D=0
i=0
c=0
while D <= X:
    c+=1
    D+=l[i]
    i+=1
    if i>len(l):
        break

print(c)


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

D=0
i=0
c=0
while D <= X:
    try:
        c+=1
        # if i>len(l):
        #     break
        D+=l[i]
        i+=1
    except IndexError:
        break

print(c)

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

D=0
i=0
c=0
while D <= X:
    c+=1
    D+=l[i]
    i+=1


print(c)

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

D=0
i=0
c=0
while D <= X:
    try:
        c+=1
        # if i>len(l):
        #     break
        D+=l[i]
        i+=1
    except IndexError:
        break

print(c)

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

D=0
i=0
c=0
while D <= X:
    D+=l[i]
    i+=1
    c+=1

print(c)

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

D=0
i=0
c=0
while D <= X:
    try:
        c+=1
        # if i>len(l):
        #     break
        D+=l[i]
        i+=1
    except IndexError:
        break

print(c)
Buggy python submission (verdict: Runtime Error):
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    S= list(sys.stdin.readline().rstrip())
    l = ["A","C","G","T"]

    c=0
    c_l=[]
    for e in S:
        if e in l:
            c+=1
        else:
            c_l.append(c)
            c=0

    print(max(c_l))


Fixed submission:
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    S= list(sys.stdin.readline().rstrip())
    N = len(S)

    ans=0
    for i in range(N):
        for j in range(i,N):
            if all("ACGT".count(c) == 1 for c in S[i:j+1]): #all()は中身がすべてTrueならTrueを返す。S部分文字列から１個ずつ取り出して"ACGT".count(c) == 1で判定
                ans = max(ans, j-i+1)
            # print(all("ACGT".count(c) == 1 for c in S[i:j+1]))

    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    N,Q= map(int, sys.stdin.readline().split())
    S = sys.stdin.readline().rstrip()
    l= [list(map(int,list(sys.stdin.readline().split()))) for i in range(Q)]
    # print(l[1][0])

    for i in range(Q):
        n0=l[i][0]
        n1=l[i][1]
        s_l=S[n0-1:n1]
        print(s_l.count("AC"))



Fixed submission:
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd
from itertools import accumulate

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    N,Q= map(int, sys.stdin.readline().split())
    S = sys.stdin.readline().rstrip()
    l= [list(map(int,list(sys.stdin.readline().split()))) for i in range(Q)]
    # 累積和
    flg = []
    for i in range(N-1):
        tmp_S = S[i:i+2] #２文字ずつ
        if tmp_S == "AC":
            flg.append(1)
        else:
            flg.append(0)

    flg2 = [0] + flg
    flg2 = list(accumulate(flg2)) #accumurateで累積和[0, 1, 1, 2, 2, 2, 3, 3]

    for e in l:
        print(flg2[e[1]-1] - flg2[e[0]-1]) #累積和から順番で引っ張ってくる
Buggy python submission (verdict: Runtime Error):
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

import functools
from functools import reduce


def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    N,X = map(int, sys.stdin.readline().split())
    x = list(map(int, sys.stdin.readline().split()))
    l=[]
    for i in range(N):
        l.append(abs(X-x[i]))
    ans = functools.reduce(math.gcd,l)
    print(ans)

Fixed submission:
from functools import reduce
from fractions import gcd
N,X=map(int,input().split())
x=[abs(X-int(i)) for i in input().split()]
print(reduce(gcd,x))

Buggy python submission (verdict: Runtime Error):
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

import functools

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    N,X = map(int, sys.stdin.readline().split())
    x = list(map(int, sys.stdin.readline().split()))
    l=[]
    for i in range(N):
        l.append(abs(X-x[i]))
    ans = functools.reduce(math.gcd,l)
    print(ans)

Fixed submission:
from functools import reduce
from fractions import gcd
N,X=map(int,input().split())
x=[abs(X-int(i)) for i in input().split()]
print(reduce(gcd,x))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
sl=list([input() for i in range(n)])
def sort_str(s):
    cl = list(s)
    cl.sort()
    return ''.join(cl)
sum=0
al=['']*n
for i in range(n):
    al[i] = sort_str(sl[i])
    for j in range(i+1,n):
        if al[j]=='':
            al[j] = sort_str(sl[j])
        if al[i]==al[j]:
            sum+=1
print(sum)

Fixed submission:
n=int(input())
sl=list([input() for i in range(n)])
def sort_str(s):
    cl = list(s)
    cl.sort()
    return ''.join(cl)
m={}
sum=0
for i in range(n):
    s = sort_str(sl[i])
    if not s in m:
        m[s]=0
    else:
        m[s]+=1
        sum+=m[s]
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
sl=list([input() for i in range(n)])
sum=0
for i in range(n):
    sl1 = list(sl[i])
    sl1.sort()
    s1 = ''.join(sl1)
    for j in range(i+1,n):
        sl2 = list(sl[j])
        sl2.sort()
        s2 = ''.join(sl2)
        if s1==s2:
            sum+=1
print(sum)

Fixed submission:
n=int(input())
sl=list([input() for i in range(n)])
def sort_str(s):
    cl = list(s)
    cl.sort()
    return ''.join(cl)
m={}
sum=0
for i in range(n):
    s = sort_str(sl[i])
    if not s in m:
        m[s]=0
    else:
        m[s]+=1
        sum+=m[s]
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
il=list(map(int, input().split()))
yn="Yes"
l=len(il)
for i in range(1, l):
    if i == 0:
        continue
    for j in range(0,i-1):
        if il[j] > il[i] + 1:
            yn = "No"
            break
print(yn)

Fixed submission:
n=int(input())
il=list(map(int, input().split()))
m=il[0]
yn="Yes"
for a in il[1:]:
    if m - 1 <= a:
        m=max([m, a])
        continue
    yn="No"
    break
print(yn)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
il=list(map(int, input().split()))
yn="Yes"
l=len(il)
for i in range(1, l):
    if i == 0:
        continue
    for j in range(0,i-1):
        if il[j] > il[i] + 1:
            yn = "No"
            break
print(yn)

Fixed submission:
n=int(input())
il=list(map(int, input().split()))
m=il[0]
yn="Yes"
for a in il[1:]:
    if m - 1 <= a:
        m=max([m, a])
        continue
    yn="No"
    break
print(yn)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n = int(input())
a = [int(input()) for _ in range(n)]
tree = [a[0]]

for a in a[1:]:
  index = bisect.bisect_left(tree, a)
  if index == 0:
    bisect.insort(tree, a)
  else:
    tree[index-1] = a
print(len(tree))

    


    
    

Fixed submission:
import bisect
from collections import deque
n = int(input())
a = [int(input()) for _ in range(n)]
tree = deque([]) 
tree.append(a[0])

for a in a[1:]:
  index = bisect.bisect_left(tree, a)
  if index == 0:
    tree.appendleft(a)
  else:
    tree[index-1] = a
print(len(tree))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n = int(input())
a = [int(input()) for _ in range(n)]
tree = [a[0]]

for i in range(1,n):
  index = bisect.bisect_left(tree, a[i])
  if index == 0:
    bisect.insort(tree, a[i])
  else:
    tree[index-1] = a[i]
print(len(tree))

    


    
    

Fixed submission:
import bisect
from collections import deque
n = int(input())
a = [int(input()) for _ in range(n)]
tree = deque([]) 
tree.append(a[0])

for a in a[1:]:
  index = bisect.bisect_left(tree, a)
  if index == 0:
    tree.appendleft(a)
  else:
    tree[index-1] = a
print(len(tree))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n = int(input())
a = [int(input()) for _ in range(n)]
tree = [a[0]]

for i in range(1,n):
  tmpmin = tree[0]
  if a[i] > tmpmin:
  #  bisect.insort(tree, a[i])
  #else:
    index = bisect.bisect_left(tree, a[i])
    del tree[index - 1]
  bisect.insort(tree, a[i])
  #print(tree)
    
print(len(tree))

    


    
    

Fixed submission:
import bisect
from collections import deque
n = int(input())
a = [int(input()) for _ in range(n)]
tree = deque([]) 
tree.append(a[0])

for a in a[1:]:
  index = bisect.bisect_left(tree, a)
  if index == 0:
    tree.appendleft(a)
  else:
    tree[index-1] = a
print(len(tree))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n = int(input())
a = [int(input()) for _ in range(n)]
tree = [a[0]]

for i in range(1,n):
  tmpmin = tree[0]
  if a[i] <= tmpmin:
    bisect.insort(tree, a[i])
  else:
    index = bisect.bisect_left(tree, a[i])
    del tree[index - 1]
    bisect.insort(tree, a[i])
  #print(tree)
    
print(len(tree))

    


    
    

Fixed submission:
import bisect
from collections import deque
n = int(input())
a = [int(input()) for _ in range(n)]
tree = deque([]) 
tree.append(a[0])

for a in a[1:]:
  index = bisect.bisect_left(tree, a)
  if index == 0:
    tree.appendleft(a)
  else:
    tree[index-1] = a
print(len(tree))
Buggy python submission (verdict: Runtime Error):
from heapq import *
f_inf = float('inf')

def dijkstra(start,node,edge):
    #始点sから各頂点への最短距離
    #node:頂点数
    #d:各頂点へのコスト(存在しないときはinf)
    #q:キュー(スタートからのコスト,頂点)
    d = [[f_inf, f_inf, f_inf] for _ in [0]*node]
    d[start][0] = 0
    #スタートをキューに入れる
    q = [(0,start)]

    while(len(q) != 0):
    #キューの先頭を取得
      ci,i = heappop(q)
    #キューの先頭から繋がっている頂点を探索
      for j in edge[i]:
        nc = ci + 1
        if (d[j][nc%3] > nc):
          d[j][nc%3] = nc
          heappush(q,(nc, j))
    return d
#入力
N,M = (int(x) for x in input().split())
#二種類のエッジ
E = [[] for _ in [0]*N]

for i in range(M):
  a,b = (int(x) for x in input().split())
  E[a-1].append(b-1)

S,T = (int(x) for x in input().split())
d = dijkstra(S, N, E)
ans = d[T][0]

if ans == f_inf:
  print(-1)
else:
  print(ans//3)

Fixed submission:
from heapq import *
f_inf = float('inf')

def dijkstra(start,node,edge):
    #始点sから各頂点への最短距離
    #node:頂点数
    #d:各頂点へのコスト(存在しないときはinf)
    #q:キュー(スタートからのコスト,頂点)
    d = [[f_inf, f_inf, f_inf] for _ in [0]*node]
    d[start][0] = 0
    #スタートをキューに入れる
    q = [(0,start)]

    while(len(q) != 0):
    #キューの先頭を取得
      ci,i = heappop(q)
    #キューの先頭から繋がっている頂点を探索
      for j in edge[i]:
        nc = ci + 1
        if (d[j][nc%3] > nc):
          d[j][nc%3] = nc
          heappush(q,(nc, j))
    return d
#入力
N,M = (int(x) for x in input().split())
#エッジ
E = [[] for _ in [0]*N]

for i in range(M):
  a,b = (int(x) for x in input().split())
  E[a-1].append(b-1)

S,T = (int(x)-1 for x in input().split())
d = dijkstra(S, N, E)
ans = d[T][0]

if ans == f_inf:
  print(-1)
else:
  print(ans//3)
Buggy python submission (verdict: Runtime Error):
S = int(input())
lst = []
while S > 0:
    lst.append(S%10)
    S //= 10 # 必須
if lst[0] == lst[1] or lst[1] == lst[2] or lst[2] == lst[3]:
  print("Bad")
else:
  print("Good")
  


Fixed submission:
S = int(input())
lst = []
while S > 0:
    lst.append(S%10)
    S //= 10 # 必須
while(len(lst) <= 4):
  lst.append(0)
  
if lst[0] == lst[1] or lst[1] == lst[2] or lst[2] == lst[3]:
  print("Bad")
else:
  print("Good")
Buggy python submission (verdict: Runtime Error):
X,A = (int(x) for x in input().split())

if x < A:
  print(0)
else:
  print(10)

Fixed submission:
X,A = (int(x) for x in input().split())
 
if X < A:
  print(0)
else:
  print(10)
Buggy python submission (verdict: Runtime Error):
X,A = (int(x) for x in input().split())
if X == 1:
  L = int(input())
  if L <= A:
    print(2)
  
else:
  L = list(map(int,input().split()))
  cnt = 0
  idx = 0
  ans = 0

  while(ans <= A):
    ans += L[idx]
    idx += 1
    cnt += 1

  print(cnt)

Fixed submission:
X,A = (int(x) for x in input().split())
L = list(map(int,input().split()))
cnt = 0
ans = 0
for i in range(X):
    ans += L[cnt]
    if(ans <= A):
        cnt += 1

print(cnt + 1)

Buggy python submission (verdict: Runtime Error):
X,A = (int(x) for x in input().split())
L = list(map(int,input().split()))
cnt = 0
idx = 0
ans = 0
while(ans <= A):
  ans += L[idx]
  idx += 1
  cnt += 1
  
print(cnt)

Fixed submission:
X,A = (int(x) for x in input().split())
L = list(map(int,input().split()))
cnt = 0
ans = 0
for i in range(X):
    ans += L[cnt]
    if(ans <= A):
        cnt += 1

print(cnt + 1)
Buggy python submission (verdict: Runtime Error):
import collections
N = int(input())
if N == 1:
  print(1)
elif N == 2:
  print(1)
else:
  ball = [tuple(map(int, input().split())) for _ in range(N)]
  ball = ball.sorted()
  diff = [tuple((ball[i][0] - ball[j][0], ball[i][1] - ball[j][1])) for i in range(N) for j in range(i + 1, N)]
  c = collections.Counter(diff)
  ans = c.most_common()[0][1]
  print(N - ans)


Fixed submission:
import collections
N = int(input())
if N == 1:
  print(1)
elif N == 2:
  print(1)
else:
  ball = [tuple(map(int, input().split())) for _ in range(N)]
  ball.sort(key=lambda x:(x[0], x[1]))
  diff = [tuple((ball[i][0] - ball[j][0], ball[i][1] - ball[j][1])) for i in range(N) for j in range(i + 1, N)]
  c = collections.Counter(diff)
  ans = c.most_common()[0][1]
  print(N - ans)

Buggy python submission (verdict: Runtime Error):
import collections
N = int(input())
if N == 1:
  print(1)
else if  N == 2:
  print(1)
else:
  ball = [tuple(map(int, input().split())) for _ in range(N)]
  ball.sort(key=lambda x:(x[0], x[1]))
  diff = [tuple((ball[i][0] - ball[i-1][0], ball[i][1] - ball[i-1][1])) for i in range(1,N)]
  c = collections.Counter(diff)
  ans = c.most_common()[0][1]
  print(N - ans)


Fixed submission:
import collections
N = int(input())
if N == 1:
  print(1)
elif N == 2:
  print(1)
else:
  ball = [tuple(map(int, input().split())) for _ in range(N)]
  ball.sort(key=lambda x:(x[0], x[1]))
  diff = [tuple((ball[i][0] - ball[j][0], ball[i][1] - ball[j][1])) for i in range(N) for j in range(i + 1, N)]
  c = collections.Counter(diff)
  ans = c.most_common()[0][1]
  print(N - ans)

Buggy python submission (verdict: Runtime Error):
import collections
N = int(input())
ball = [tuple(map(int, input().split())) for _ in range(N)]
ball.sort(key=lambda x:(x[0], x[1]))
diff = [tuple((ball[i][0] - ball[i-1][0], ball[i][1] - ball[i-1][1])) for i in range(1,N)]
c = collections.Counter(diff)
ans = c.most_common()[0][1]
print(N - ans)


Fixed submission:
import collections
N = int(input())
if N == 1:
  print(1)
elif N == 2:
  print(1)
else:
  ball = [tuple(map(int, input().split())) for _ in range(N)]
  ball.sort(key=lambda x:(x[0], x[1]))
  diff = [tuple((ball[i][0] - ball[j][0], ball[i][1] - ball[j][1])) for i in range(N) for j in range(i + 1, N)]
  c = collections.Counter(diff)
  ans = c.most_common()[0][1]
  print(N - ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = [int(x) for x in input().split()]
sort(l)

print(n,l)

Fixed submission:
n = int(input())
l = [int(x) for x in input().split()]

ans = 100000000000
for i in range(1,n):
  ans1 = sum(l[:i])
  ans2 = sum(l[i:])
  diff = abs(ans1 - ans2)
  if diff < ans:
    ans = diff
    
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
a=[]
for _ in range(M):
    a.append(int(input()))
    
kaidan = [1, 2]

for i in range(2, N):
  kaidan.append(kaidan[i-1]+ kaidan[i-2])

ans = 1

if a[0] - 1 > 0:
    ans *= kaidan[a[0] - 2]
  
for i in range(M-1):
  if((a[i] + 1) > (a[i+1] - 1)):
    ans *= 0
  elif((a[i] + 1) == (a[i+1] - 1)):
    ans *= 1
  else:
    ans *= (kaidan[a[i+1] - a[i] - 3])

if N - (a[M - 1] + 1) > 0:
    ans *= kaidan[N - (a[M - 1] + 2)]
print(ans%1000000007)
  

Fixed submission:
N,M = map(int,input().split())
a=[]
for _ in range(M):
    a.append(int(input()))
    
kaidan = [1, 2]

for i in range(2, N):
  kaidan.append(kaidan[i-1]+ kaidan[i-2])

if M == 0:
  ans = kaidan[N - 1]
else:
  ans = 1

  if a[0] - 1 > 0:
      ans *= kaidan[a[0] - 2]

  for i in range(M-1):
    if((a[i] + 1) > (a[i+1] - 1)):
      ans *= 0
    elif((a[i] + 1) == (a[i+1] - 1)):
      ans *= 1
    else:
      ans *= (kaidan[a[i+1] - a[i] - 3])

  if N - (a[M - 1] + 1) > 0:
      ans *= kaidan[N - (a[M - 1] + 2)]
      
print(ans%1000000007)

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
a=[]
for _ in range(M):
    a.append(int(input()))
    
kaidan = [1, 2]

for i in range(2, N):
  kaidan.append(kaidan[i-1]+ kaidan[i-2])

ans = 1

if a[0] - 1 > 0:
    ans *= kaidan[a[0] - 2]
  
for i in range(M-1):
  if((a[i] + 1) > (a[i+1] - 1)):
    ans *= 0
  else:
    ans *= (kaidan[a[i+1] - a[i] - 3])

if N - (a[M - 1] + 1) > 0:
    ans *= kaidan[N - (a[M - 1] + 2)]
print(ans%1000000007)
  

Fixed submission:
N,M = map(int,input().split())
a=[]
for _ in range(M):
    a.append(int(input()))
    
kaidan = [1, 2]

for i in range(2, N):
  kaidan.append(kaidan[i-1]+ kaidan[i-2])

if M == 0:
  ans = kaidan[N - 1]
else:
  ans = 1

  if a[0] - 1 > 0:
      ans *= kaidan[a[0] - 2]

  for i in range(M-1):
    if((a[i] + 1) > (a[i+1] - 1)):
      ans *= 0
    elif((a[i] + 1) == (a[i+1] - 1)):
      ans *= 1
    else:
      ans *= (kaidan[a[i+1] - a[i] - 3])

  if N - (a[M - 1] + 1) > 0:
      ans *= kaidan[N - (a[M - 1] + 2)]
      
print(ans%1000000007)
Buggy python submission (verdict: Runtime Error):
import fractions
N = int(input())
A = list(map(int, input().split()))
A.sort()

ans = 0
counter = 0
for i in range(N):
  ans += abs(A[i])
  if(A[i] < 0):
    counter = counter + 1
    
if(counter%2 == 1):
  if(abs(A[counter - 1]) >= A[counter]):
    ans -= A[counter]*2
  else:
    ans -= A[counter-1]*2
  
print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Amin = 10**9
ans = 0
counter = 0
for i in range(N):
  if(A[i] < 0):
    counter = counter + 1
  a = abs(A[i])
  ans += a
  Amin = min(a, Amin)
    
if(counter%2 == 1):
    ans -= 2*Amin
  
print(ans)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()
arr = []

if(s[0] == '0'):
  arr.append(0)
for i in range(n-1):
  if(s[i] != s[i+1]):
    arr.append(i+1)
arr.append(n)
if(s[-1] == '0'):
  arr.append(n)
    
width = 2*k + 1
len_arr = len(arr)

ans = arr[2*k]
left = 2
while True:
  if(left + width > len_arr):
    break
  tmp = arr[left + width - 1] - arr[left - 1]
  ans = max(ans, tmp)
  left += 2

print(ans)
    
  




Fixed submission:
n, k = map(int, input().split())
s = input()
arr = []

if(s[0] == '0'):
  arr.append(0)
for i in range(n-1):
  if(s[i] != s[i+1]):
    arr.append(i+1)
arr.append(n)
if(s[-1] == '0'):
  arr.append(n)
    
width = 2*k + 1
len_arr = len(arr)

if(2*k >= len_arr):
  ans = arr[-1]
else:
  ans = arr[2*k]
  left = 2
  while True:
    if(left + width > len_arr):
      break
    tmp = arr[left + width - 1] - arr[left - 1]
    ans = max(ans, tmp)
    left += 2
print(ans)