Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):

n,q = map(int, input().split())
s = input()
a = [0 for i in range(q)]
for k in range(q):
    i,j = map(int, input().split())
    a[k] = [i,j]
for nums in a:
    check = s[nums[0]-1:nums[1]]
    count = 0
    for i in range(len(check)-1):
        if check[i]+check[i+1] == "AC":
            count += 1
    print(count)

Fixed submission:
def get_ac_count(S):
    buf = None
    temp = []
    count = 0
    for c in S:
        if c == "A":
            buf = "A"
        elif buf == "A" and c == "C":
            buf = None
            count += 1
        elif buf == "A":
            buf = None
        temp.append(count)
    return temp
N, Q = map(int, input().split())
S = input()
ac_count = get_ac_count(S)
for i in range(Q):
    l,r = map(int, input().split())
    print(ac_count[r-1]-ac_count[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int, input().split())
s = input()
a = [0 for i in range(q)]
for k in range(q):
    i,j = map(int, input().split())
    a[k] = [i,j]
for nums in a:
    print(s[nums[0]-1:nums[1]].count("AC"))

Fixed submission:
def get_ac_count(S):
    buf = None
    temp = []
    count = 0
    for c in S:
        if c == "A":
            buf = "A"
        elif buf == "A" and c == "C":
            buf = None
            count += 1
        elif buf == "A":
            buf = None
        temp.append(count)
    return temp
N, Q = map(int, input().split())
S = input()
ac_count = get_ac_count(S)
for i in range(Q):
    l,r = map(int, input().split())
    print(ac_count[r-1]-ac_count[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int, input().split())
s = input()
a = [0 for i in range(q)]
for k in range(q):
    i,j = map(int, input().split())
    print(s[i-1:j].count("AC"))

Fixed submission:
def get_ac_count(S):
    buf = None
    temp = []
    count = 0
    for c in S:
        if c == "A":
            buf = "A"
        elif buf == "A" and c == "C":
            buf = None
            count += 1
        elif buf == "A":
            buf = None
        temp.append(count)
    return temp
N, Q = map(int, input().split())
S = input()
ac_count = get_ac_count(S)
for i in range(Q):
    l,r = map(int, input().split())
    print(ac_count[r-1]-ac_count[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int, input().split())
s = input()
for i in range(q):
    i,j = map(int, input().split())
    print(s[i-1:j].count("AC"))

Fixed submission:
def get_ac_count(S):
    buf = None
    temp = []
    count = 0
    for c in S:
        if c == "A":
            buf = "A"
        elif buf == "A" and c == "C":
            buf = None
            count += 1
        elif buf == "A":
            buf = None
        temp.append(count)
    return temp
N, Q = map(int, input().split())
S = input()
ac_count = get_ac_count(S)
for i in range(Q):
    l,r = map(int, input().split())
    print(ac_count[r-1]-ac_count[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())
ans = a
for i in range(a+1,b+1):
    ans ^= i
print(ans)


Fixed submission:
a, b = map(int, input().split())
def xor(i):
    if i%4==0:
        m = i
    elif i%4==1:
        m = 1
    elif i%4==2:
        m = 1 ^ i
    else:
        m=0
    return m
print(xor(a-1) ^ xor(b))

Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())
ans = a
for i in range(a+1,b+1):
    ans = ans ^ i
print(ans)


Fixed submission:
a, b = map(int, input().split())
def xor(i):
    if i%4==0:
        m = i
    elif i%4==1:
        m = 1
    elif i%4==2:
        m = 1 ^ i
    else:
        m=0
    return m
print(xor(a-1) ^ xor(b))
Buggy python submission (verdict: Runtime Error):
from sympy import gcd
a, b, k = map(int, input().split())
c = gcd(a,b)
count = 0
for i in range(1,c+1):
    if c%i == 0:
        count += 1
    if count == k:
        ans = i
        break
print(ans)


Fixed submission:
a, b, k = map(int, input().split())
count = 0
ans = min(a,b)
while count != k:
    if a%ans == b %ans == 0:
        count += 1
    ans -= 1
print(ans+1)

Buggy python submission (verdict: Runtime Error):
import math
a, b, k = map(int, input().split())
c = math.gcd(a,b)
count = 0
for i in range(1,c+1):
    if c%i == 0:
        count += 1
    if count == k:
        ans = i
        break
print(ans)


Fixed submission:
a, b, k = map(int, input().split())
count = 0
ans = min(a,b)
while count != k:
    if a%ans == b %ans == 0:
        count += 1
    ans -= 1
print(ans+1)
Buggy python submission (verdict: Runtime Error):
s = input()
a = 0
for i in s:
  a += i
print(2 * min(a, len(s)-a))

Fixed submission:
S = input()
print(2*min(S.count("1"),S.count("0")))
Buggy python submission (verdict: Runtime Error):
N,A,B,C = map(int, input().split())
l = [int(input()) for _ in range(N)]
INF = 10**9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a-A)+abs(b-B)+abs(c-C) > 0 else INF
    ret0 = dfs(cur+1, a, b, c)
    ret1 = dfs(cur+1,a+l[cur],b,c) +10
    ret2 = dfs(cur+1,a,b+l[cur],c)+10
    ret3 = dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)
print(dfs(0,0,0,0))

Fixed submission:
N,A,B,C = map(int, input().split())
l = [int(input()) for _ in range(N)]
INF = 10**9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c) > 0 else INF
    ret0 = dfs(cur+1, a, b, c)
    ret1 = dfs(cur+1,a+l[cur],b,c) +10
    ret2 = dfs(cur+1,a,b+l[cur],c)+10
    ret3 = dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)
print(dfs(0,0,0,0))
Buggy python submission (verdict: Runtime Error):
X Y = map(int, input().split())
print(X + Y//2)

Fixed submission:
X,Y = map(int, input().split())
print(X + Y//2)
Buggy python submission (verdict: Runtime Error):
n = map(int, input().split())
n.sort()
print(n[2]*10 + n[1] + n[0])

Fixed submission:
n = [int(i) for i in input().split()]
n.sort()
print(n[2]*10 + n[1] + n[0])
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

#values
INF = 10**9

#input
N,X = map(int, input().split())
x_list = [int(i) for i in input().split()]

d_list = [abs(X-i) for i in x_list]
print(gcd(*d_list))

Fixed submission:
from functools import reduce

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

def gcd(*numbers):
    return reduce(gcd_two, numbers)

#values
INF = 10**9

#input
N,X = map(int, input().split())
x_list = [int(i) for i in input().split()]

d_list = [abs(X-i) for i in x_list]
print(gcd(*d_list))
Buggy python submission (verdict: Runtime Error):
INF = 10**9

N, K = map(int, input().split())
x_list = [int(i) for i in input().split()]
for i in range(N):
    if x_list[i] >= 0:
        T = i
        break
else:
    print(abs(x_list[-K])
    exit()
min_take_time = INF
for i in range(K+1):
    if T-K+i < 0 or T+i>N:
        continue
    if x_list[T-K+i] *  x_list[T+i-1] <= 0:
        take_time = min(abs(x_list[T-K+i]), abs(x_list[T+i-1])) * 2 + max(abs(x_list[T-K+i]), abs(x_list[T+i-1]))
    else:
        take_time = max(abs(x_list[T-K+i]), abs(x_list[T+i-1]))
    min_take_time = min(min_take_time, take_time)


print(min_take_time)

Fixed submission:
INF = 10**9

N, K = map(int, input().split())
x_list = [int(i) for i in input().split()]
for i in range(N):
    if x_list[i] >= 0:
        T = i
        break
else:
    print(abs(x_list[-K]))
    exit()
min_take_time = INF
for i in range(K+1):
    if T-K+i < 0 or T+i>N:
        continue
    if x_list[T-K+i] *  x_list[T+i-1] <= 0:
        take_time = min(abs(x_list[T-K+i]), abs(x_list[T+i-1])) * 2 + max(abs(x_list[T-K+i]), abs(x_list[T+i-1]))
    else:
        take_time = max(abs(x_list[T-K+i]), abs(x_list[T+i-1]))
    min_take_time = min(min_take_time, take_time)


print(min_take_time)

Buggy python submission (verdict: Runtime Error):
INF = 10**9

N, K = map(int, input().split())
x_list = [int(i) for i in input().split()]
for i in range(N):
    if x_list[i] >= 0:
        T = i
        break
min_take_time = INF
for i in range(K+1):
    if T-K+i < 0 or T+i>N:
        continue
    if x_list[T-K+i] *  x_list[T+i-1] <= 0:
        take_time = min(abs(x_list[T-K+i]), abs(x_list[T+i-1])) * 2 + max(abs(x_list[T-K+i]), abs(x_list[T+i-1]))
    else:
        take_time = max(abs(x_list[T-K+i]), abs(x_list[T+i-1]))
    min_take_time = min(min_take_time, take_time)


print(min_take_time)

Fixed submission:
INF = 10**9

N, K = map(int, input().split())
x_list = [int(i) for i in input().split()]
for i in range(N):
    if x_list[i] >= 0:
        T = i
        break
else:
    print(abs(x_list[-K]))
    exit()
min_take_time = INF
for i in range(K+1):
    if T-K+i < 0 or T+i>N:
        continue
    if x_list[T-K+i] *  x_list[T+i-1] <= 0:
        take_time = min(abs(x_list[T-K+i]), abs(x_list[T+i-1])) * 2 + max(abs(x_list[T-K+i]), abs(x_list[T+i-1]))
    else:
        take_time = max(abs(x_list[T-K+i]), abs(x_list[T+i-1]))
    min_take_time = min(min_take_time, take_time)


print(min_take_time)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a_list = [int(i) for i in input().split()]
d_list = [0 for i in range(N)]
for i in range(N):
    d_list[i] = a_list[i] - (i+1)
ans = 2 * (10 ** 5) * 10 ** 9
for b in range(min(d_list), max(d_list)+1):
    c = 0
    for i in range(N):
        c += abs(a_list[i] - (b + i + 1))
    ans = min(c, ans)
print(ans)


Fixed submission:
N = int(input())
a_list = [int(i) for i in input().split()]
b_list = [0 for i in range(N)]
for i in range(N):
    b_list[i] = a_list[i] - (i + 1)
b_list.sort()
b1,b2 = b_list[N//2-1], b_list[N//2]
c1,c2 = 0,0
for i in range(N):
    c1 += abs(a_list[i] - (b1 + i + 1))
for i in range(N):
    c2 += abs(a_list[i] - (b2 + i + 1))
print(min(c1,c2))
Buggy python submission (verdict: Runtime Error):
N = input()
S = 0
for i in N:
    S += int(i)
print("Yes" if N % S == 0 else "No")


Fixed submission:
N = input()
S = 0
for i in N:
    S += int(i)
print("Yes" if int(N) % S == 0 else "No")
Buggy python submission (verdict: Runtime Error):
N,K = map(int, input().split())
input()
judge = (N-1)%(K-1) == 0
if judge:
    print(int((N-1)/(K-1))
else:
    print(int((N-1)//(K-1)+1)


Fixed submission:
N,K = map(int, input().split())
input()
judge = (N-1)%(K-1) == 0
if judge:
    print(int((N-1)/(K-1)))
else:
    print(int((N-1)//(K-1)+1))
Buggy python submission (verdict: Runtime Error):
N = int(input())
l = [int(i) for i in input().split()]
count = 0
total = 1
for i in l:
    total *= i
while total%2==0:
    total /= 2
    count += 1
print(count)


Fixed submission:
N = int(input())
l = [int(i) for i in input().split()]
count = 0
for i in l:
    while i % 2 == 0:
        i /= 2
        count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
N, D = map(int, input().split())

X = [0] * N
Y = [0] * N

for i in range(N):
    X[i], Y[i] = map(int, input.split())

count = 0

for i in range(N):
    if(D**2 >= X[i]**2 + Y[i]**2):
        count += 1

print(count)




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

X = [0] * N
Y = [0] * N

for i in range(N):
    X[i], Y[i] = map(int, input().split())

count = 0

for i in range(N):
    if(D**2 >= X[i]**2 + Y[i]**2):
        count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split('1 2'))

input_cal = []
input_cal.append(a + b)
input_cal.append(a - b)
input_cal.append(a * b)
print(max(input_cal))


Fixed submission:

a, b = map(int, input().split())

input_cal = [a + b, a - b, a * b]
print(max(input_cal))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = 0
for i in range(1, n+1):
    ii = str(i)
    for j in range(int(ii[0]), n+1, 10):
        jj = str(j)
        if ii[0] == jj[-1] and ii[-1] == jj[0]:
            s+=1
print(s)

Fixed submission:
n = int(input())
cif = [[0]*10 for i in range(10)]

for i in range(1, n+1):
    s = str(i)
    f = int(s[0])
    r = int(s[-1])
    cif[f][r] += 1
res = 0

for i in range(10):
    for j in range(10):
        res += cif[i][j]*cif[j][i]
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = 0
for i in range(1, n+1):
    for j in range(1, n+1):
        ii = str(i)
        jj = str(j)
        if ii[0] == jj[-1] and ii[-1] == jj[0]:
            s+=1
print(s)

Fixed submission:
n = int(input())
cif = [[0]*10 for i in range(10)]

for i in range(1, n+1):
    s = str(i)
    f = int(s[0])
    r = int(s[-1])
    cif[f][r] += 1
res = 0

for i in range(10):
    for j in range(10):
        res += cif[i][j]*cif[j][i]
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

s = sum(a)
for i in range(int(input())):
    b, c = map(int, input().split())
    for j in range(n):
        if a[j] == b:
            s -= b
            a[j] = c
            s += c
    print(s)

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

s = sum(a)
nums = {}
for i in range(n):
    if a[i] in nums:
        nums[a[i]] += 1
    else:
        nums[a[i]] = 1

for i in range(int(input())):
    b, c = map(int, input().split())
    if b in nums:
        s -= nums[b]*b
        s += nums[b]*c
        if c in nums:
            nums[c] += nums[b]
        else:
            nums[c] = nums[b]
        nums[b] = 0
    print(s)
Buggy python submission (verdict: Time Limit Exceeded):
import math
a,b = (int(x) for x in input().split())
saidai = 1
c = []
def yakusuu(x,y):
    return(y,x % y)

def cont(z):
    n = 0
    while True:
        if n - int(z ** (1/2)) + 1 == 0:
            c.append(z)
            break
                
        for j in range(2,int(z ** (1/2)) + 1):
            if z % j == 0:
                z = z // j
                c.append(j)
                n = 0
                break
        else:
            n = n + 1

saidai = math.gcd(a,b)


cont(saidai)
if max(c) == 1:
   print(1)
   exit()
print(len(set(c)) + 1)


Fixed submission:
import math
a,b = (int(x) for x in input().split())
saidai = 1

def yakusuu(x,y):
    return(y,x % y)

def cont(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

saidai = math.gcd(a,b)


d = cont(saidai)
if d[0] == [1,1]:
    print(1)
    exit()
print(len(d) + 1)

Buggy python submission (verdict: Time Limit Exceeded):
a,b = (int(x) for x in input().split())
saidai = 1
c = []
def yakusuu(x,y):
    return(y,x % y)

def cont(z):
    n = 0
    while True:
        if n - int(z ** (1/2)) + 1 == 0:
            c.append(z)
            break
                
        for j in range(2,int(z ** (1/2)) + 1):
            if z % j == 0:
                z = z // j
                c.append(j)
                n = 0
                break
        else:
            n = n + 1

if a > b:
   while True:
      if a % b == 0:
         saidai = b
         break
      a,b = yakusuu(a,b)

else:
   while True:
     if b % a == 0:
       saidai = a
       break
     b,a = yakusuu(b,a)


cont(saidai)
if max(c) == 1:
   print(1)
   exit()
print(len(set(c)) + 1)

Fixed submission:
import math
a,b = (int(x) for x in input().split())
saidai = 1

def yakusuu(x,y):
    return(y,x % y)

def cont(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

saidai = math.gcd(a,b)


d = cont(saidai)
if d[0] == [1,1]:
    print(1)
    exit()
print(len(d) + 1)
Buggy python submission (verdict: Runtime Error):
n,d=[int(i) for i in input().strip().split(" ")]
ans=0
for _ in range(n):
  x,y=[int(i) for i in input().strip().split(" ")]
  if x*x+y*y==d*d:
    ans+=1
print(ans)

Fixed submission:
n=int(input())
if n>=30:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n,d=[int(i) for i in input().strip().split(" ")]
ans=0
for _ in range(n):
  x,y=[int(i) for i in input().strip().split(" ")]
  if x*x+y*y=d*d:
    ans+=1
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 24 12:23:05 2020

@author: vivek
"""

n,d=[int(i) for i in input().strip().split(" ")]
ans=0
for _ in range(n):
  x,y=[int(i) for i in input().strip().split(" ")]
  if x*x+y*y<=d*d:
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
arr=[int(i) for i in input().strip().split(" ")]
arr=sorted(arr)
arr=arr[::-1]
newArr=[arr[0]]
ans=0
for i in range(1,n//2):
    newArr.append(arr[i])
    newArr.append(arr[i])
for i in range(n-1):
    ans+=newArr[i]
print(ans)


Fixed submission:
n=int(input())
arr=[int(i) for i in input().strip().split(" ")]
arr=sorted(arr)
arr=arr[::-1]
# newArr=[arr[0]]
ans=0
# for i in range(1,n//2):
#     newArr.append(arr[i])
#     newArr.append(arr[i])
for i in range(1,n):
    # print()
    ans+=arr[i//2]
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
arr=[int(i) for i in input().strip().split(" ")]
arr=sorted(arr)
arr=arr[::-1]
newArr=[arr[0]]
ans=0
for i in arr[1:]:
    newArr.append(arr[i])
    newArr.append(arr[i])
for i in range(n-1):
    ans+=newArr[i]
print(ans)



Fixed submission:
n=int(input())
arr=[int(i) for i in input().strip().split(" ")]
arr=sorted(arr)
arr=arr[::-1]
# newArr=[arr[0]]
ans=0
# for i in range(1,n//2):
#     newArr.append(arr[i])
#     newArr.append(arr[i])
for i in range(1,n):
    # print()
    ans+=arr[i//2]
print(ans)
Buggy python submission (verdict: Runtime Error):
n,k=[int(i) for i in input().strip().split(" ")]
arr=[int(i) for i in input().strip().split(" ")]
arrs=sorted(arr)
print(arrs)
ans=0
for i in range(k):
    ans+=arrs[k]
print(ans)

Fixed submission:
n,k=[int(i) for i in input().strip().split(" ")]
arr=[int(i) for i in input().strip().split(" ")] 
ans=0
arr=sorted(arr)
for i in range(k):
    ans+=arr[i]
print(ans)

Buggy python submission (verdict: Runtime Error):
n,k=[int(i) for i in input().strip().split(" ")]
arr=[int(i) for i in input().strip().split(" ")]
arr=sorted(arr)
ans=0
for i in range(k):
    ans+=arr[k]
print(ans)

Fixed submission:
n,k=[int(i) for i in input().strip().split(" ")]
arr=[int(i) for i in input().strip().split(" ")] 
ans=0
arr=sorted(arr)
for i in range(k):
    ans+=arr[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
arr=[int(i) for i in input().strip().split(" ")]
t=int(input())
dic={}
sum_array=0
for i in arr:
    dic[i]=dic.get(i,0)+1
    sum_array+=i
    

for _ in range(t):
    a,b=[int(i) for i in input().split(" ")]
    if b in dic:
        dic[b]+=dic[a]
    else:
        dic[b]=dic[a]
    
    sum_array+=dic[a]*(b-a)
    print(sum_array)
    dic[a]=0

Fixed submission:
n=int(input())
arr=[int(i) for i in input().strip().split(" ")]
t=int(input())
dic={}
sum_array=0
for i in arr:
    dic[i]=dic.get(i,0)+1
    sum_array+=i
    

for _ in range(t):
    a,b=[int(i) for i in input().split(" ")]
    if a not in dic:
        print(sum_array)
        continue
    if b in dic:
        dic[b]+=dic[a]
    else:
        dic[b]=dic[a]
    
    sum_array+=dic[a]*(b-a)
    print(sum_array)
    dic[a]=0

Buggy python submission (verdict: Runtime Error):
n=int(input())
arr=[int(i) for i in input().strip().split(" ")]
t=int(input())
dic={}
sum_array=0
for i in arr:
    dic[i]=dic.get(i,0)+1
    sum_array+=i
    

for _ in range(t):
    a,b=[int(i) for i in input().split(" ")]
    if b in dic:
        dic[b]+=dic[a]
    else:
        dic[b]=dic[a]
    
    sum_array+=dic[a]*(b-a)
    print(dic,sum_array)
    dic[a]=0

Fixed submission:
n=int(input())
arr=[int(i) for i in input().strip().split(" ")]
t=int(input())
dic={}
sum_array=0
for i in arr:
    dic[i]=dic.get(i,0)+1
    sum_array+=i
    

for _ in range(t):
    a,b=[int(i) for i in input().split(" ")]
    if a not in dic:
        print(sum_array)
        continue
    if b in dic:
        dic[b]+=dic[a]
    else:
        dic[b]=dic[a]
    
    sum_array+=dic[a]*(b-a)
    print(sum_array)
    dic[a]=0

Buggy python submission (verdict: Runtime Error):
def sum_dic(dic):
    ans=0
    for i in dic:
        ans+=dic[i]*i
    return ans

n=int(input())
arr=[int(i) for i in input().strip().split(" ")]
t=int(input())
dic={}
for i in arr:
    dic[i]=dic.get(i,0)+1
    

for _ in range(t):
    a,b=[int(i) for i in input().split(" ")]
    if b in dic:
        dic[b]+=dic[a]
    else:
        dic[b]=dic[a]
    dic[a]=0
    print(sum_dic(dic))

Fixed submission:
n=int(input())
arr=[int(i) for i in input().strip().split(" ")]
t=int(input())
dic={}
sum_array=0
for i in arr:
    dic[i]=dic.get(i,0)+1
    sum_array+=i
    

for _ in range(t):
    a,b=[int(i) for i in input().split(" ")]
    if a not in dic:
        print(sum_array)
        continue
    if b in dic:
        dic[b]+=dic[a]
    else:
        dic[b]=dic[a]
    
    sum_array+=dic[a]*(b-a)
    print(sum_array)
    dic[a]=0
Buggy python submission (verdict: Runtime Error):
# arr=input().strip().split(' ')
x,n=[int(i) for i in input().strip().split(' ')]
arr=[int(i) for i in input().strip().split(' ')]
# neg,pos=[],[]
# for i in arr:
# 	if x-i >0 :
# 		pos.append(x-i)
# 	else:
# 		neg.append(i-x)
# pos=sorted(pos)
# neg=sorted(neg)
diff=[]
for i in arr:
    
	diff.append(x-i)
i=-1
j=0
while i in diff:
	i=i-1
while j in diff:
	j=j+1
if abs(i)<abs(j):
    print(x-i)
else:
    print(x-j)
# print(x+)

Fixed submission:
# arr=input().strip().split(' ')
def aa():
    x,n=[int(i) for i in input().strip().split(' ')]
    if n==0:
        print(x)
        return 
    arr=[int(i) for i in input().strip().split(' ')]
    # neg,pos=[],[]
    # for i in arr:
    # 	if x-i >0 :
    # 		pos.append(x-i)
    # 	else:
    # 		neg.append(i-x)
    # pos=sorted(pos)
    # neg=sorted(neg)
    
    diff=[]
    for i in arr:

        diff.append(x-i)
    i=-1
    j=0
    while i in diff:
        i=i-1
    while j in diff:
        j=j+1
    if abs(i)<abs(j):
        print(x-i)
    else:
        print(x-j)
    # print(x+)
aa()

Buggy python submission (verdict: Runtime Error):
# arr=input().strip().split(' ')
x,n=[int(i) for i in input().strip().split(' ')]
arr=[int(i) for i in input().strip().split(' ')]
# neg,pos=[],[]
# for i in arr:
# 	if x-i >0 :
# 		pos.append(x-i)
# 	else:
# 		neg.append(i-x)
# pos=sorted(pos)
# neg=sorted(neg)
diff=[]
for i in arr:
	diff.append(x-i)
i=-1
j=1
while i in diff:
	i=i-1
while j in diff:
	j=j+1
print(min(x+i,x+j))

Fixed submission:
# arr=input().strip().split(' ')
def aa():
    x,n=[int(i) for i in input().strip().split(' ')]
    if n==0:
        print(x)
        return 
    arr=[int(i) for i in input().strip().split(' ')]
    # neg,pos=[],[]
    # for i in arr:
    # 	if x-i >0 :
    # 		pos.append(x-i)
    # 	else:
    # 		neg.append(i-x)
    # pos=sorted(pos)
    # neg=sorted(neg)
    
    diff=[]
    for i in arr:

        diff.append(x-i)
    i=-1
    j=0
    while i in diff:
        i=i-1
    while j in diff:
        j=j+1
    if abs(i)<abs(j):
        print(x-i)
    else:
        print(x-j)
    # print(x+)
aa()
Buggy python submission (verdict: Runtime Error):
def partpall(s,n):
	if s!=s[::-1]:
		return False
	else:
		return True

def pall(s,n):
	if s!=s[::-1]:
		return False
	return partpall(s[n//2 +1 :],n) and partpall(s[:n//2 ],n)


# s=input("enter:")
s="akakaka"
# print("sucess",s,s[::-1])
# revStr=s[::-1]
#n=len(s)
# print(n)
if pall(s,n):
	print("Yes")
else:
	print("No")

Fixed submission:
def partpall(s,n):
	if s!=s[::-1]:
		return False
	else:
		return True

def pall(s,n):
	if s!=s[::-1]:
		return False
	return partpall(s[n//2 +1 :],n) and partpall(s[:n//2 ],n)


# s=input("enter:")
s=input()
# print("sucess",s,s[::-1])
# revStr=s[::-1]
n=len(s)
# print(n)
if pall(s,n):
	print("Yes")
else:
	print("No")