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

Fixed submission:
import sys
import numpy as np

input = sys.stdin.readline

n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = np.zeros(n, dtype=int)
h = np.array(h)

for i in range(1,n):
    start = max(0, i-k)
    dp[i] = min(dp[start: i] + np.abs(h[i] - h[start: i]))

print(dp[n-1])

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np

input = sys.stdin.readline

n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = dp.zeros(n, dtype=int)
h = np.array(h)

for i in range(1,n):
    start = max(0, i-k)
    dp[i] = min(dp[start: i] + np.abs(h[i] - h[start: i]))

print(dp[n-1])

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

#aとbで小さい方を返す
def chmin(a,b):
    if a > b:
        return b
    else:
        return a

f_inf = float('inf')

dp = [f_inf] * (10**5+10)

dp[0] = 0

def rec(i):
    if dp[i] < f_inf:
        return dp[i]

    if i == 0:
        return 0

    res = f_inf
    res = chmin(res, rec(i-1) + abs(h[i] - h[i-1]))
    if i > 1:
        res = chmin(res, rec(i-2) + abs(h[i] - h[i-2]))

    dp[i] = res
    return res

ans = res(n-1)
print(ans)
Problem p03434 (python)

Fixed submission:
n = int(input())
nums = [int(i) for i in input().split()]

nums.sort(reverse=True)
print(sum(nums[0::2]) - sum(nums[1::2]))

Buggy submission (verdict: Runtime Error):
n = int(input())
nums = [int(i) for i in input().split()]

nums.sort_values(reverse=True)
print(sum(nums[0::2]) - sum(nums[1::2]))
Problem p03455 (python)

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

if (a * b) % 2 == 0:
    print("Even")
else:
    print("Odd")

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

if (a * b) % 2 == 0
    print("Even")
else:
    print("Odd")

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

if a * b % 2 == 0
    print("Even")
else:
    print("Odd")

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

if a * b % 2 = 0
    print("Even")
else:
    print("Odd")
Problem p03470 (python)

Fixed submission:
nums = [int(input()) for _ in range(int(input()))]
print(len(set(nums)))

Buggy submission (verdict: Runtime Error):
n = int(input())
nums = [int(input()) for _ in range(int(input()))]
print(len(set(nums)))
Problem p02953 (python)

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

for i in range(N - 2, -1, -1):
    if arr[i] > arr[i + 1]:
        arr[i] -= 1
        if arr[i] > arr[i + 1]:
            print('No')
            break
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
import sys

if __name__ == "__main__":
    N = int(input())
    input_str = input()
    H_str = input_str.split(' ')
    H = []
    for str in H_str:
        H.append(int(str))

    for i in range(len(H) - 1):
        if i != len(H) - 2:
            if H[i + 1] - H[i] <= -2:
                print('No')
                sys.exit(0)
            elif H[i + 1] - H[i] == -1:
                H[i] -= 1
        else:
            if H[i + 1] - H[i] <= -2:
                print('No')
                sys.exit(0)
            if H[i + 2] - H[i + 1] <= -1:
                print('No')
                sys.exit(0)

    print('Yes')

Buggy submission (verdict: Runtime Error):
import sys

if __name__ == "__main__":
    N = int(input())
    input_str = input()
    H_str = input_str.split(' ')
    H = []
    for str in H_str:
        H.append(int(str))

    for i in range(len(H) - 3):
        print(H)
        if H[i + 1] - H[i] > 1 and H[i + 2] - H[i + 1] < 0 and H[i + 3] - H[i + 2] < 0:
            print('No')
            sys.exit(0)

    print('Yes')

Buggy submission (verdict: Runtime Error):
import sys

if __name__ == "__main__":
    N = int(input())
    input_str = input()
    H_str = input_str.split(' ')
    H = []
    for str in H_str:
        H.append(int(str))

    for i in range(len(H) - 3):
        print(H)
        if H[i + 1] - H[i] > 1 and H[i + 2] - H[i + 1] < 0 and H[i + 3] - H[i + 2] < 0:
            print('No')
            sys.exit(0)

    print('Yes')
Problem p02981 (python)

Fixed submission:
#input
N, A, B = map(int, input().split())
 
#output
if N*A > B:
  print(B)
else:
  print(N*A)

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

#output
if N*A > B:
  print(B)
elif:
  print(N*A)
Problem p03240 (python)

Fixed submission:
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
xyh.sort(key=lambda val: val[2])
 
for cx in range(101):
    for cy in range(101):
        check = True
        H = xyh[-1][2] + abs(xyh[-1][0] - cx) + abs(xyh[-1][1] - cy)
        for x in xyh[:-1]:
            if x[2] != max(H - abs(x[0] - cx) - abs(x[1] - cy), 0):
                check = False
                break
        if check:
            print(cx, cy, H)
            exit()

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())

x = [0]*n
y = [0]*n
h = [0]*n
H = [0]*n

for i in range(n):
  x[i], y[i], h[i] = map(int, input().split())
  
for cx in range(101):
  for cy in range(101):
    for i in range(n):
      H[i] = max(h[i] + abs(x[i]-cx) + abs(y[i]-cy), 0)
    c = collections.Counter(H)
    if len(c) == 1 && H[0] >= max(h):
      print(cx, cy, H[0])
      exit()
Problem p03290 (python)

Fixed submission:
d, g = map(int, input().split())
p = [0]*d
c = [0]*d
for i in range(d):
  p[i], c[i] = map(int, input().split())
 
ans = 10**6

for i in range(2**d):
  cnt = 0
  sum = 0
  k = -1
  for j in range(d):
    if (i >> j) & 1:
      sum += (j+1)*100*p[j]+c[j]
      cnt += p[j]
    else:
      k = j
  if sum < g:
    s1 = 100 * (k + 1)
    need = (g - sum + s1 - 1) // s1
    if need >= p[k]:
      continue
    cnt += need
  ans = min(ans, cnt)
print(ans)

Buggy submission (verdict: Runtime Error):
d, g = map(int, input().split())
p = [0]*d
c = [0]*d
for i in range(d):
  p[i], c[i] = map(int, input().split())

ans = 10**6

for i in range(2**d):
  cnt = 0
  sum = 0
  k = -1
  for j in range(d):
    if (i >> j) & 1:
      sum += (j+1)*100*p[j]+c[j]
      cnt += p[j]
    else:
      k = j
  if sum < g:
        s1 = 100 * (k + 1)
        need = (g - sum + s1 - 1) // s1
 
        if need >= p[k]:
            continue
 
        cnt += need
 
    ans = min(ans, cnt)
 
print(ans)
Problem p04030 (python)

Fixed submission:
str = input()
ans = ''
for i in str:
  if i is '0':
    ans += '0'
  elif i is '1':
    ans += '1'
  elif i is 'B':
    ans = ans[:-1]
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
s_list = list(s)
ans = ''
for i in s_list:
  if(s_list[i] != 'B'):
    ans += s_list[i]
  else:
    ans = ans[:-1]
print(ans)
Problem p03006 (python)

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

n = int(input())
xy = [list(map(int, input().split())) for i in range(n)]
if len(xy) == 1:
    print(1)
    exit()

xy.sort()
xy = xy[::-1]
aaa = []
for i in range(len(xy)-1):
    for j in range(i+1, len(xy)):
        a, b = xy[i]
        c, d = xy[j]
        aaa.append(str(a-c)+str(b-d))

# import itertools
#
# # itertools.permutations(xy, 2)
#
# aaa = []
# for i in list(itertools.combinations(xy, 2)):
#     a, b, c, d = sum(i, [])
#     aaa.append([str(a-c)+str(b-d)])
#     # print(a,b,c,d)
# # print(aaa)
# aaa = sum(aaa, [])
# print(aaa)
import collections
bbb = collections.Counter(aaa)
# print(bbb.most_common())
print(n-bbb.most_common()[0][1])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = int(input())
xy = [list(map(int, input().split())) for i in range(n)]

xy.sort()
xy = xy[::-1]
aaa = []
for i in range(len(xy)-1):
    for j in range(i+1, len(xy)):
        a, b = xy[i]
        c, d = xy[j]
        aaa.append(str(a-c)+str(b-d))

# import itertools
#
# # itertools.permutations(xy, 2)
#
# aaa = []
# for i in list(itertools.combinations(xy, 2)):
#     a, b, c, d = sum(i, [])
#     aaa.append([str(a-c)+str(b-d)])
#     # print(a,b,c,d)
# # print(aaa)
# aaa = sum(aaa, [])
# print(aaa)
import collections
bbb = collections.Counter(aaa)
# print(bbb.most_common())
print(n-bbb.most_common()[0][1])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = int(input())
xy = [list(map(int, input().split())) for i in range(n)]

xy.sort()
xy = xy[::-1]

import itertools

# itertools.permutations(xy, 2)

aaa = []
for i in list(itertools.combinations(xy, 2)):
    a, b, c, d = sum(i, [])
    aaa.append([str(a-c)+str(b-d)])
    # print(a,b,c,d)
# print(aaa)
aaa = sum(aaa, [])
import collections
bbb = collections.Counter(aaa)
# print(bbb.most_common())
print(n-bbb.most_common()[0][1])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = int(input())
xy = [list(map(int, input().split())) for i in range(n)]

xy.sort()
xy = xy[::-1]

import itertools

# itertools.permutations(xy, 2)

aaa = []
for i in list(itertools.combinations(xy, 2)):
    a, b, c, d = sum(i, [])
    aaa.append([str(a-c)+str(b-d)])
    # print(a,b,c,d)
# print(aaa)
aaa = sum(aaa, [])
import collections
bbb = collections.Counter(aaa)
# print(bbb.most_common())
print(n-bbb.most_common()[0][1])
Problem p03047 (python)

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

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

print(n-k+1)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

r, g, b, n = map(int, input().split())

count = 0

for i in range(n//r+1):
    for j in range((n-i*r)//g+1):
        if (n - i*r - j*g) % b == 0:
            count += 1

# やってはいけないやつ
# for i in range(0, n+1):
#     for j in range(0, n+1):
#         for k in range(0, n+1):
#             if r*i + g*j + b*k == n:
#                 count += 1

print(count)
Problem p03076 (python)

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

li = [int(input()) for i in range(5)]

li2 = list()

for i in li:
    if i % 10 != 0:
        i = (i // 10 + 1) * 10
    li2.append(i)

# li3 = [i for i in li if i % 10 != 0]

li4 = [int(str(i)[-1]) for i in li if i % 10 != 0]

# print(li3, li4)

if not li4:
    print(sum(li))
else:
    print(sum(li2) - 10 + min(li4))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

li = [int(input()) for i in range(5)]

li2 = list()

for i in li:
    if i % 10 != 0:
        i = (i // 10 + 1) * 10
    li2.append(i)

# li3 = [i for i in li if i % 10 != 0]

li4 = [int(str(i)[-1]) for i in li if i % 10 != 0]

# print(li3, li4)


print(sum(li2) - 10 + min(li4))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

li = [int(input()) for i in range(5)]

li2 = list()

for i in li:
    if i % 10 != 0:
        i = (i // 10 + 1) * 10
    li2.append(i)

# li3 = [i for i in li if i % 10 != 0]

li4 = [int(str(i)[-1]) for i in li if i % 10 != 0]

# print(li3, li4)


print(sum(li2) - min(li4))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

li = [int(input()) for i in range(5)]

li2 = list()

for i in li:
    if i % 10 != 0:
        i = (i // 10 + 1) * 10
    li2.append(i)

li3 = [int(str(i)[-1]) for i in li if i % 10 != 0]

print(sum(li2) - min(li3))
Problem p03086 (python)

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

import re

s = input()

result = re.sub(r'[^ATGC]', ',', s).split(',')

print(max([len(i) for i in result]))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import re

s = input()

result = re.findall(r'[ATGC]+', s)

print(len(max(result)))
Problem p03351 (python)

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

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

if abs(c - a) <= d or (abs(b - a) <= d and abs(c - b) <= d):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

x = int(input())
xx = list(reversed(range(1,x+1)))
xxx = set()

for i in range(1, 32):
    for j in range(2, 11):
        if i**j <= 1000:
            xxx.add(i**j)

for i in xx:
    if i in xxx:
        print(i)
        break
Problem p03386 (python)

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

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

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

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

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

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

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

bb = []

bb.append(aa[0:k])
bb.append(aa[len(aa)-k:])
bb = sum(bb,[])
bb = sorted(list(set(bb)))
for i in bb:
    print(i)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

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

aa = ''.join(map(str, (list(range(a, b+1)))))

cc = aa[0:k]
dd = aa[len(aa)-k:]

cc = [int(i) for i in cc]
dd = [int(i) for i in dd]

ee = set()

for i in cc+dd:
    ee.add(i)

ee = sorted(list(ee))

for i in ee:
    print(i)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

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

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

ans = set()
for i in range(len(aa)):
    if i <= k-1 or i >= len(aa)-k:
        ans.add(aa[i])

for i in sorted(list(ans)):
    print(i)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

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

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

bb = []

bb.append(aa[0:k])
bb.append(aa[len(aa)-k:])
bb = sum(bb,[])
bb = sorted(list(set(bb)))
for i in bb:
    print(i)
Problem p03495 (python)

Fixed submission:
#読み込み
N, K = map(int, input().split())
A = list(map(int, input().split()))
#処理回数
reduce_type = len(set(A)) - K
#削除する数の選定
A_dict = {str(i):0 for i in set(A)}
for a in A:
  A_dict[str(a)] += 1
del A
list_del_num = sorted(list(A_dict.values()))[:reduce_type]
#計算
ans = sum(list_del_num)
print(ans)

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

A_dict = {str(i):0 for i in set(A)}
for a in A:
  A_dict[str(a)] += 1

def get_A_key_from_value(dic, value):
  keys = [i for i, j in dic.items() if j == value]
  if len(keys) != 1:
    keys = keys[0]
  return keys[0]
  
ans = 0
while True:
  if len(A_dict) <= K:
    break
  ans += min(A_dict.values())
  del A_dict[get_A_key_from_value(A_dict,min(A_dict.values()))]
print(ans)
Problem p02975 (python)

Fixed submission:
if __name__ == '__main__':
    n = int(input())
    l = list(map(int, input().split()))
    num = l[0]
    for i in range(1, n):
        num = num ^ l[i]
    if num == 0:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
l = []
n = 0


def abc(inp, rest, dic, idx):
    if len(rest) == 0:
        if l[dic[n - 1]] ^ l[dic[1]] == l[dic[0]]:
            return True
        else:
            return False
    for i in rest:
        if l[i] ^ l[dic[idx - 1]] == inp:
            cur_rest = rest[:]
            cur_rest.remove(i)
            cur_dic = dic.copy()
            cur_dic[idx + 1] = i
            if abc(l[i], cur_rest, cur_dic, idx + 1):
                return True
    return False


if __name__ == '__main__':
    n = int(input())
    l = list(map(int, input().split()))
    rest = [i for i in range(0, n)]
    dic = {}
    rest.remove(0)
    dic[1] = 0
    for i in range(1, n):
        cur_rest = rest[:]
        cur_rest.remove(i)
        cur_dic = dic.copy()
        cur_dic[0] = i
        if abc(l[0], cur_rest, cur_dic, 1):
            print("Yes")
            exit()
    print("No")

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    n, = map(int, input())
    a = list(map(int, input().split()))
    flag = True
    for i in range(0, n):
        b = i - 1
        c = i + 1
        if b < 0:
            b = n - 1
        if c >= n:
            c = 0
        if a[b] ^ a[c] != a[i]:
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")
Problem p02971 (python)

Fixed submission:
N=int(input())
l=list()
for i in range(N):
    l.append(int(input()))
a=sorted(l)
m1=a[-1]
m2=a[-2]
for k in range(N):
    if(m1==l[k]):
        print(m2)
    else:
        print(m1)

Buggy submission (verdict: Runtime Error):
N=int(input())
l=list()
for i in range(N):
    l.append(int(input()))

num=list()
M=max(l)
for k in range(N):
    if(k[i]==M):
        num=l[:k]+l[k+1:]
        print(max(num))
    else:
        print(M)
Problem p02995 (python)

Fixed submission:
import fractions

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

sum1=(A-1)//C
sum2=B//C
sum3=sum2-sum1
sum1=(A-1)//D
sum2=B//D
sum4=sum2-sum1
num=(C*D)//fractions.gcd(C,D)
sum1=(A-1)//num
sum2=B//num
sum5=sum2-sum1
sum=sum3+sum4-sum5
sum=B-A+1-sum


print(sum)

Buggy submission (verdict: Runtime Error):
import math
A,B,C,D=map(int,input().split())

sum1=(A-1)//C
sum2=B//C
sum3=sum2-sum1
sum1=(A-1)//D
sum2=B//D
sum4=sum2-sum1
num=(C*D)//math.gcd(C,D)
sum1=(A-1)//num
sum2=B//num
sum5=sum2-sum1
sum=sum3+sum4-sum5
sum=B-A+1-sum


print(sum)
Problem p03059 (python)

Fixed submission:
a,b,t=map(int,input().split())
x=0
num=0
c=a
for i in range(21):
    x=c
    c=a*(i+2)
    #print(x)
    if(x>t):
        break
    num+=b

print(num)

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

A[0]=A[0]-1
A[1]=A[1]-1
sum=0

for a in A:
    if a>0:
        sum+=a

print(sum)

Buggy submission (verdict: Runtime Error):
import fractions

def main():
    N=int(input())
    num=list(map(int,input().split()))
    gcd=0
    gcd_list_front=[]
    gcd_list_back=[]
    gcd_list_front.append(num[0])
    gcd_list_back.append(num[-1])

    for  i in range(1,N-1):
        gcd_list_front.append(fractions.gcd(gcd_list_front[i-1],num[i]))
        gcd_list_back.append(fractions.gcd(gcd_list_back[i-1],num[-i-1]))
    gcd_list_back.reverse()

    gcd=max(gcd_list_back[0],gcd_list_front[-1])
    for i in range(0,N-2):
       temp_gcd=fractions.gcd(gcd_list_front[i],gcd_list_back[i+1])
       if temp_gcd>gcd:
           gcd=temp_gcd
    print(gcd)


if  __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
import fractions

def main():
    N=int(input())
    num=list(map(int,input().split()))
    gcd=0
    gcd_list_front=[]
    gcd_list_back=[]
    gcd_list_front.append(num[0])
    gcd_list_back.append(num[-1])

    for  i in range(1,N-1):
        gcd_list_front.append(fractions.gcd(gcd_list_front[i-1],num[i]))
        gcd_list_back.append(fractions.gcd(gcd_list_back[i-1],num[-i-1]))
    gcd_list_back.reverse()

    gcd=max(gcd_list_back[0],gcd_list_front[-1])
    for i in range(0,N-2):
       temp_gcd=fractions.gcd(gcd_list_front[i],gcd_list_back[i+1])
       if temp_gcd>gcd:
           gcd=temp_gcd
    print(gcd)


if  __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
import fractions

def main():
    N=int(input())
    num=list(map(int,input().split()))
    gcd=0
    gcd_list_front=[]
    gcd_list_back=[]
    gcd_list_front.append(num[0])
    gcd_list_back.append(num[-1])

    for  i in range(l,N-1):
        gcd_list_front.append(fractions.gcd(gcd_list_front[i-1],num[i]))
        gcd_list_back.append(fractions.gcd(gcd_list_back[i-1],num[-i-1]))
   gcd_list_back.reverse()

   gcd=max(gcd_list_back[0],gcd_list_front[-1])
   for i in range(0,N-2):
       temp_gcd=fractions.gcd(gcd_list_front[i],gcd_list_back[i+1])
       if temp_gcd>gcd:
           gcd=temp_gcd
    print(gcd)


if  __name__="__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math

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

L=[0,0]
for ai in A:
    #L.append(gcd(L[-1],ai))
    L.append(math.gcd(L[-1],ai))
    print(L)

R=[0,0]
for ai in A[::-1]:
    #R.append(gcd(R[-1],ai))
    R.append(math.gcd(L[-1],ai))
    print(R)

print(max(math.gcd(l,r) for l,r in zip(L,reversed(R))))
Problem p03060 (python)

Fixed submission:
n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
d=[]
max=0
num=0
for i in range(n):
            d.append(v[i]-c[i])
"""
for i in range(n-1):
    num=d[i]

    for k in range(n-i-1):
        if(num+d[i+1+k]>max):
            max=num+d[i+1+k]
"""
d.sort()
d.reverse()
for i in range(n):
    num=max+d[i]
    if num>max:
        max=num

print(max)

Buggy submission (verdict: Runtime Error):
n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
num=0
for i in range(n):
            if(v[i]-c[i]>0):
                num+=v[i]-d[i]
print(num)
Problem p03061 (python)

Fixed submission:
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)
N=int(input())
A=list(map(int,input().split()))

L=[0,0]
for ai in A:
    L.append(gcd(L[-1],ai))
    #print(L)

R=[0,0]
for ai in A[::-1]:
    R.append(gcd(R[-1],ai))
    #print(R)

print(max(gcd(l,r) for l,r in zip(L,reversed(R))))

Buggy submission (verdict: Runtime Error):
#import math
import fraction

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

L=[0,0]
for ai in A:
    #L.append(gcd(L[-1],ai))
    L.append(fraction.gcd(L[-1],ai))
    print(L)

R=[0,0]
for ai in A[::-1]:
    #R.append(gcd(R[-1],ai))
    R.append(fraction.gcd(L[-1],ai))
    print(R)

print(max(fraction.gcd(l,r) for l,r in zip(L,reversed(R))))

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)
N=int(input())
A=list(map(int,input().split()))

L=[0,0]
for ai in A:
    L.append(gcd(L[-1],ai))
    print(L)

R=[0,0]
for ai in A[::-1]:
    R.append(gcd(R[-1],ai))
    print(R)

print(max(gcd(l,r) for l,r in zip(L,reversed(R))))
Problem p03062 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
l=[abs(i)  for i in A]
cnt=0
for i in A:
    if(i<0):
        cnt+=1
if cnt%2==0:
    print(sum(l))
else:
    print(sum(l)-2*min(l))

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
l=(abs(i)  for i in A)
cnt=0
for i in A:
    if(i<0):
        cnt+=1
if cnt%2==0:
    print(sum(l))
else:
    print(sum(l)-2*min(l))
Problem p03071 (python)

Fixed submission:
a,b=map(int,input().split())
#a,b=(input().split())
c=max(a,b)
d=min(a,b)
if  c>d:
    print(2*c-1)

else:
    print(c+d)

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

l=[0]
curr='1'

for c in S:
    if c !=curr:
        l.append(1)
        curr=c
    else:
        l[-1]+=1
if curr=='0':
    l.append(0)

n_group=len(1)
sum_=0
k =min(k,n_group)

for i in range(k):
    sum_+=l[2*i]+l[2*i+1]
sum_ +=l[2*k]
max_=sum_

for i in range(k,n_group):
    sum_ -=l[2*i-2*k]+l[2*i+1-2*k]
    sum_ +=l[2*i+1]+l[2*i+2]
    max_ =max(max_,sum_)

print(max_)

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())

if(A>B):
    print(2*A-1)
elif(A==B):
    print(A*2)
elif(B>A):
    print(B*2-1)
Problem p03074 (python)

Fixed submission:
N, K = map(int, input().split())
S = input()
 
l = [0]
curr = '1'
 
#0と1の塊を探索
for c in S:
    if c != curr:
        l.append(1)
        curr = c
    else:
        l[-1] += 1
if curr == '0':
    l.append(0)
 
n_group = len(l) // 2
sum_ = 0
k = min(K, n_group)
 
#初期値として左端から1の塊を算出
for i in range(k):
    sum_ += l[2 * i] + l[2 * i + 1]
sum_ += l[2 * k]
max_ = sum_
 
#左端から0の塊を１つずつ取り替えて、最大値を算出
for i in range(k, n_group):
    sum_ -= l[2 * i - 2 * K] + l[2 * i + 1 - 2 * K]
    sum_ += l[2 * i + 1] + l[2 * i + 2]
    max_ = max(max_, sum_)
 
print(max_)

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

l=[0]
curr='1'

for c is S:
    if c !=curr:
        l.append(1)
        curr=c
    else:
        l[-1]+=1
if curr=='0':
    l.append(0)

n_group=len(1)
sum_=0
k =min(k,n_group)

for i in range(k):
    sum_+=l[2*i]+l[2*i+1]
sum_ +=l[2*k]
max_=sum_

for i in range(k,n_group):
    sum_ -=l[2*i-2*k]+l[2*i+1-2*k]
    sum_ +=l[2*i+1]+l[2*i+2]
    max_ =max(max_,sum_)

print(max_)
Problem p03085 (python)

Fixed submission:
b=input()

if(b=="A"):
    print("T")
elif(b=="T"):
    print("A")
elif(b=="G"):
    print("C")
else:
    print("G")

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

if(b="A"):
    print("T")
else:
    print("G")