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

Fixed submission:
import collections
n=int(input())
a=map(int,input().split())
b=list(collections.Counter(a).items())
lst=[]
Lst=[]
for i in range(len(b)):
  if b[i][1]>1:
    lst.append(int(b[i][0]))  
    if b[i][1]>3:
      Lst.append(int(b[i][0]))
if len(lst)<2 and len(Lst)==0:
  print(0)
else:
  if len(lst)==1:
    Lst.sort(reverse=True)
    print(Lst[0]**2)
  else:
    if len(Lst)>0:
      lst.sort(reverse=True)
      Lst.sort(reverse=True)
      print(max(lst[0]*lst[1],Lst[0]**2))     
    else:
      lst.sort(reverse=True)
      print(lst[0]*lst[1])

Buggy submission (verdict: Runtime Error):
import collections
n=int(input())
a=list(map(int,input().split()))
b=collections.Counter(a)
c=list(b.items())
d=[]
e=[]
for i in range(len(c)):
  if c[i][1]>3:
    d.append(int(c[i][0]))
  elif c[i][1]>1:
    e.append(int(c[i][0]))
d.sort(reverse=True)
e.sort(reverse=True)
if len(d)<1 and len(e)<2:
  print(0)
else:
  print(max((d[0])**2,e[0]*e[1]))

Buggy submission (verdict: Runtime Error):
import collections
n=int(input())
a=list(map(int,input().split()))
b=collections.Counter(a)
c=list(b.items())
d=[]
e=[]
for i in range(len(c)):
  if c[i][1]>3:
    d.append(int(c[i][0]))
  elif c[i][1]>1:
    e.append(int(c[i][0]))
d.sort(reverse=True)
e.sort(reverse=True)
if len(d)<1 and len(e)<2:
  print(0)
else:
  print(max(d[0]**2,e[0]*e[1]))

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
b=list(Counter(a).values())
lst=[]
for i in range(len(b)):
  if b[i]>1:
    c=Counter(a).keys()
    lst.append(int(c[i]))
Lst=list(set(lst.sort(reverse=True)))
if len(Lst)<2:
  print(0)
else:
  print(Lst[0]*Lst[1])

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
b=list(Counter(a).values())
lst=[]
for i in range(len(b)):
  if b[i]>1:
    c=Counter(a).keys()
    lst.append(int(c[i]))
Lst=list(set(lst.sort(reverse=True)))
if len(Lst)<2:
  print(0)
else:
  print(Lst[0]*Lst[1])

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
b=list(Counter(a).values())
lst=[]
for i in range(len(b)):
  if b[i]>1:
    lst.append(int(Counter(a).keys()[i]))
Lst=set(lst)
lst.sort(reverse=True)
Lst_2=set(lst)
if len(Lst)<2:
  print(0)
else:
  print(Lst_2[0]*Lst_2[1])

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
b=list(Counter(a).values())
lst=[]
for i in range(len(b)):
  if b[i]>1:
    lst.append(int(Counter(a).keys()[i]))
lst.sort(reverse=True)
if len(lst)<2:
  print(0)
else:
  print(lst[0]*lst[1])
Problem p03633 (python)

Fixed submission:
import fractions
n=int(input())
t=[]
for i in range(n):
  t.append(int(input()))
a=t[0]
for i in range(n-1):
  a=(a*t[i+1])//(fractions.gcd(a,t[i+1]))
print(a)

Buggy submission (verdict: Runtime Error):
import fractions
n=int(input())
t=[]
for i in range(n):
  t.append(int(input()))
a=t[0]
for i in range(n-1):
  a=fractions.gcd(a,a[i+1])
print(a)
Problem p03993 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(n):
    if a[a[i]-1]==i+1:
      cnt+=1
    else:
      cnt=cnt
print(cnt//2)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(n):
    if a[a[i]]==i+1:
      cnt+=1
      break
    else:
      cnt=cnt
print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(n):
    if a[a[i]]==i+1
      cnt+=1
      break
    else:
      cnt=cnt
print(cnt)
Problem p02718 (python)

Fixed submission:
#! env/bin/local python3
# -*- coding:utf-8 -*-

is_first = True
while True:
    try:
        if is_first:
            n, m  = [int(i) for i in input().split()]
            is_first = False
        else:
            arr = [int(i) for i in input().split()]
    except EOFError:
        break

total_vote = sum(arr)
sorted_arr = sorted(arr, reverse=True)

list_up_arr = sorted_arr[: m]

flag = True
for l in list_up_arr:
    if l < 1 / (4 * m) * total_vote:
        flag = False

print('Yes' if flag else 'No')

Buggy submission (verdict: Runtime Error):
#! env/bin/local python3
# -*- coding:utf-8 -*-

is_first = False
while True:
    try:
        if is_first:
            n, m  = (int(i) for i in input().split())
            is_first = False
        else:
            arr = (int(i) for i in input().split())
    except EOFError:
        break

total_vote = sum(arr)
sorted_arr = sorted(arr)

list_up_arr = sorted_arr[-1: -m]

flag = False
for l in list_up_arr:
    if l >= 1 / (4 * m):
        flag = True

print('Yes' if flag else 'No')
Problem p03546 (python)

Fixed submission:
#! env/bin/local python3
# -*- coding: utf-8 -*-

import numpy as np

inputs = []

while True:
    try:
        inputs.append([int(i) for i in input().split()])
    except EOFError:
        break

h, w = inputs[0]
c = inputs[1: 11]
a = inputs[11:]

number_of_edge = 10
number_of_node = 10

for k in range(number_of_node):
    for i in range(number_of_node):
        for j in range(number_of_node):
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])

target = []
for ca in a:
    target += ca

target = [ta for ta in target if np.abs(ta) != 1]
results = 0
for t in target:
    results += c[t][1]

print(results)

Buggy submission (verdict: Runtime Error):
#! env/bin/local python3
# -*- coding: utf-8 -*-

import numpy as np

inputs: list = []

while True:
    try:
        inputs.append([int(i) for i in input().split()])
    except EOFError:
        break

h, w = inputs[0]
c = inputs[1: 11]
a = inputs[11:]

number_of_edge = 10
number_of_node = 10

for k in range(number_of_node):
    for i in range(number_of_node):
        for j in range(number_of_node):
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])

target = []
for ca in a:
    target += ca
# delete -1
target = [ta for ta in target if np.abs(ta) != 1]
results = 0
for t in target:
    results += c[t][1]

print(results)
Problem p03109 (python)

Fixed submission:
s = input()
foo = s.split('/')
if int(foo[1]) <= 4 and int(foo[2]) <= 30:
  print('Heisei')
else:
  print('TBD')

Buggy submission (verdict: Runtime Error):
s = input()
foo = s.split('/')
if foo[1] <= 4 and foo[2] <= 30:
  print('Heisei')
else:
  print('TBD')
Problem p02705 (python)

Fixed submission:
import math
R = float(input())
print(2 * math.pi * R)

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

if N[0] != "7" and N[1] != "7" and N[2] != "7":
    print("No")
else:
    print("Yes")
Problem p02761 (python)

Fixed submission:
# coding: utf-8
import sys

N, M = map(int, input().split())

if M == 0:
    if N == 1:
        print(0)
        sys.exit()
    else:
        print(10 ** (N - 1))
        sys.exit()

num = [-1] * (N + 1)
fin = 0
for _ in range(M):
    s, c = map(int, input().split())
    if num[s] == -1:
        num[s] = c
    elif num[s] != c:
        fin = 1
        print(-1)
        break

if fin == 0:
    for i in range(1, N + 1):
        if i == 1:
            if num[i] == -1:
                print(1, end="")
            elif num[i] == 0 and N == 1:
                print(0)
            elif num[i] == 0:
                print(-1)
                break
            else:
                print(num[i], end="")
        else:
            if num[i] == -1:
                print(0, end="")
            else:
                print(num[i], end="")

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

N, M = map(int, input().split())

num = [-1] * (N + 1)
fin = 0
for _ in range(M):
    s, c = map(int, input().split())
    if num[s] == -1:
        num[s] = c
    elif num[s] != c:
        fin = 1
        print(-1)
        break
if N == 1 and sum[1] == 0:
    print(0)
    fin = 1
if fin == 0:
    for i in range(1, N + 1):
        if i == 1:
            if num[i] == -1:
                print(1, end="")
            elif num[i] == 0:
                print(-1)
                break
            else:
                print(num[i], end="")
        else:
            if num[i] == -1:
                print(0, end="")
            else:
                print(num[i], end="")
Problem p03469 (python)

Fixed submission:
# coding: utf-8

S = input()

S = S.replace("2017","2018")
print(S)

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

N, Y=(int(x) for x in input().split())

A = Y // 10000 #Yを越えない最大の10000円札の枚数
B = Y // 5000
C = Y // 1000

roop = 0
for i in range(A+1):
    if roop == 1:
        break
    for j in range(B+1):
        if i + j > N:
            break
        c = N - i - j #c:1000円札の枚数
        if 10*i + 5*j + c == Y//1000 and c >= 0:
            # a:10000円札、b:5000円札
            a = i
            b = j
            roop = 1
            break

if roop == 1:
    print("{0} {1} {2}".format(a, b, c))
else:
    a, b, c = -1, -1, -1
    print("{0} {1} {2}".format(a, b, c))
Problem p03493 (python)

Fixed submission:
# coding: utf-8

s = input()

sum = 0

if s[0] == "1":
    sum = sum + 1
if s[1] == "1":
    sum = sum + 1
if s[2] == "1":
    sum += 1

print(sum)

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

s = input()

sum = int(0)

if s[0] = 1:
    sum++
if s[1] = 1:
    sum++
if s[2] = 1:
    sum++

print(sum)
Problem p02583 (python)

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

ans = 0
for i in range(N):
  for j in range(i+1, N):
    for k in range(j+1, N):
      if L[i] != L[j] and L[j] != L[k] and L[i] != L[k]:
        if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[i] + L[k] > L[j]:
          ans += 1

print(ans)

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

ans = 0
for i in range(N):
  for j in range(i+1, N):
    for k in range(j+1, N):
      if L[i] != L[j] and L[j] != L[k] and L[i] != L[k]:
        if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[i] + L[k] > L[j]:
          ans += 1

print(ans)
Problem p02936 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def dfs(v, p):
    for u in link[v]:
        if u == p:
            continue
        ans[u] += ans[v]
        dfs(u, v)

N, Q = map(int, input().split())
link = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    link[a-1].append(b-1)
    link[b-1].append(a-1)

ans = [0] * N
for i in range(Q):
    p, x = map(int, input().split())
    ans[p-1] += x

dfs(0, -1)

print(*ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def main():
    N, Q = map(int, input().split())
    link = [[] * N]
    a = [None] * (N-1)
    b = [None] * (N-1)
    for i in range(N-1):
        a[i], b[i] = map(int, input().split())

    cost = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        cost[p-1] += x

    for i in range(N-1):
        link[a[i]-1].append([b[i]-1, cost[i]])
        link[b[i]-1].append([a[i]-1, cost[i]])

    def dfs(v, c, p):
        for nv in link[v]:
            if nv[0] == p:
                continue
            cost[nv[0]] = c + cost[nv[0]]
            dfs(nv[0], cost[nv[0]], v)
        return

    dfs(0, cost[0], -1)

    print(*cost)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N, Q = map(int, input().split())
link = [[] for _ in range(N)]
a = [0] * (N-1)
b = [0] * (N-1)
for i in range(N-1):
    a[i], b[i] = map(int, input().split())

cost = [0] * N
for i in range(Q):
    p, x = map(int, input().split())
    cost[p-1] += x

for i in range(N-1):
    link[a[i]-1].append([b[i]-1, cost[i]])
    link[b[i]-1].append([a[i]-1, cost[i]])

nums = [0] * N
def dfs(v, c, p):
    for nv in link[v]:
        if nv[0] == p:
            continue
        nums[nv[0]] += c + cost[nv[0]]
        dfs(nv[0], c + cost[nv[0]])
    return

nums[0] = cost[0]
dfs(0, cost[0], -1)

print(*nums)
Problem p02957 (python)

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

K = (A + B) / 2
if K == int(K):
    print(int(K))
else:
    print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
import copy

S = input()

dp = [0] * 13

dp[0] = 1

mod = 10 ** 9 + 7
mul = 1
for i in range(len(S)-1, -1, -1):
    # 二次元dpの代わり
    ndp = [0] * 13
    
    if S[i] == '?':
        for k in range(10):
            for j in range(13):
                # 次の桁の余りが加わった時に、そこへ前のdp[j]の値を入れる
                # ただし、0-9までの値をその桁が取る可能性があるので、
                #　それぞれの場合全てを加算する
                ndp[(k * mul + j) % 13] += dp[j]
                ndp[(k * mul + j) % 13] %= mod
    else:
        k = int(S[i])
        for j in range(13):
            # 次の桁の余りが加わった時に、そこへ前のdp[j]の値を入れる
            ndp[(k * mul + j) % 13] += dp[j]
            ndp[(k * mul + j) % 13] %= mod

    mul *= 10
    mul %= 13
    dp = copy.deepcopy(ndp)

# 13で割って5で余るものを出力
print(dp[5])
Problem p02981 (python)

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

print(min(N*A, B))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)

def perm(n, k):
    return fact[n] * ifact[n-k] % mod

def dfs(v, p):
    global ans
    for nv in link[v]:
        if nv == p:
            continue
        dfs(nv, v)
    # p = -1の時は根である。根も含めて塗り分け方を考えるので、
    # n = K、c = 子の数+根の数で塗り分け方を求める
    # 見るのが子の時はその上の頂点とその親が塗られているので、
    # n = K-2、c = 子の数となる
    if p == -1:
        n = K
    else:
        n = K - 2
    if p == -1:
        k = len(link[v]) + 1
    else:
        k = len(link[v]) - 1

    ans *= perm(n, k)
    ans %= mod

N, K = map(int, input().split())
link = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    link[a-1].append(b-1)
    link[b-1].append(a-1)

mod = 10 ** 9 + 7
ans = 1

fact = [0] * (10**5+1)
fact[0] = 1
fact[1] = 1
for i in range(2, 10**5+1):
    fact[i] = fact[i-1] * i
    fact[i] %= mod
ifact = [0] * (10**5+1)
for i in range(10**5+1):
    ifact[i] = pow(fact[i], mod-2, mod)
    ifact[i] %= mod

dfs(0, -1)

print(ans % mod)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())

a = R % 2019
b = L % 2019

if a > 2019 // 2:
    a = 2019 - a
if b > 2019 // 2:
    b = 2019 - b

print(a * (a+1) % 2019)
Problem p02994 (python)

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

sums = 0
for i in range(N):
  sums += L + i

ans = 10 ** 9
cnt = 10 ** 9
for i in range(N):
  num = L + i
  if cnt >= abs(num):
    cnt = abs(num)
    ans = sums - num

print(ans)

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

sums = 0
for i in range(N):
  sums += L + i

ans = 10 ** 9
for i in range(N):
  num = L + i
  if cnt >= abs(num):
    cnt = abs(num)
    ans = sums - num

print(ans)
Problem p03001 (python)

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

S = W * H / 2

flag = 0
if x == W / 2 and y == H / 2:
    flag = 1

print(S, flag)

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

S = W * H / 2

flag = 0
if x == W / 2 and y == H / 2:
    flag = 1

if 
print(S, flag)
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

def dfs(v, p, c):
    res[v] = c
    for next in link[v]:
        if next[0] == p:
            continue
        if next[1] % 2:
            dfs(next[0], v, 1-c)
        else:
            dfs(next[0], v, c)


N = int(input())
link = [[] * N for _ in range(N)]
res = [0] * N
for i in range(N-1):
    u, v, w = map(int, input().split())
    link[u-1].append([v-1, w])
    link[v-1].append([u-1, w])

dfs(0, -1, 1)

for i in range(N):
    print(res[i])

Buggy submission (verdict: Runtime Error):
def dfs(v, p, c):
    res[v] = c
    for next in link[v]:
        if next[0] == p:
            continue
        if c == next[1]:
            dfs(next[0], v, c)
        else:
            dfs(next[0], v, 1-c)


N = int(input())
link = [[] * N for _ in range(N)]
res = [0] * N
for i in range(N-1):
    u, v, w = map(int, input().split())
    link[u-1].append([v-1, w % 2])
    link[v-1].append([u-1, w % 2])
print(link)
dfs(0, -1, 1)

for i in range(N):
    print(res[i])

Buggy submission (verdict: Runtime Error):
def dfs(v, p, c):
    res[v] = c
    for next in link[v]:
        if next[0] == p:
            continue
        if next[1]:
            dfs(next[0], v, c)
        else:
            dfs(next[0], v, 1-c)


N = int(input())
link = [[] * N for _ in range(N)]
res = [0] * N
for i in range(N-1):
    u, v, w = map(int, input().split())
    link[u-1].append([v-1, w % 2])
    link[v-1].append([u-1, w % 2])

dfs(0, -1, 1)

for i in range(N):
    print(res[i])
Problem p03069 (python)

Fixed submission:
N = int(input())
S = input()
a = [0] * N
b = [0] * N
counter = []

if S[0] == '#':
    a[0] = 1
if S[N-1] == '.':
    b[N-1] = 1

for i in range(N-1):
    if S[i+1] == '#':
        a[i+1] = a[i] + 1
    else:
        a[i+1] = a[i]
    if S[N-i-2] =='.':
        b[N-i-2] = b[N-i-1] + 1
    else:
        b[N-i-2] = b[N-i-1]
counter.append(a[N-1])
counter.append(b[0])
for i in range(N-1):
    counter.append(a[i] + b[i+1])

print(min(counter))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
a = [0] * N
b = [0] * N
counter = []

if S[0] == '#':
    a[0] = 1
if S[N-1] == '.':
    b[N-1] = 1

for i in range(N-1):
    if S[i+1] == '#':
        a[i+1] = a[i] + 1
    else:
        a[i+1] = a[i]
    if S[N-i-2] =='.':
        b[N-i-2] = b[N-i-1] + 1
    else:
        b[N-i-2] = b[N-i-1]
        
for i in range(N-1):
    counter.append(a[i] + b[i+1])

print(min(counter))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
count = 0

for i in range(N-1):
    if S[i:i+2] = '#.':
        count += 1

print(count)
Problem p03160 (python)

Fixed submission:
INF = 105 * 10**7
dp = [INF] * 100010

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

dp[0] = 0

for i in range(1, N):
    dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

print(dp[N-1])

Buggy submission (verdict: Runtime Error):
def rec(i):
    if dp[i] < INF:
        return dp[i]
    if i == 0:
        return 0

    res = INF

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

    dp[i] = res
    return dp[i]

INF = 105 * 10**7
dp = [INF] * 100010

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

print(rec(N-1))
Problem p03244 (python)

Fixed submission:
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

va = v[::2]
vb = v[1::2]

va_ = Counter(va).most_common()
vb_ = Counter(vb).most_common()

if va_[0][0] == vb_[0][0]:
    if len(va_) == 1 or len(vb_) == 1:
        if len(va_) == 1 and len(vb_) == 1:
            print(len(v) // 2)
        elif len(va_) == 1:
            if va_[0][0] == vb_[0][0]:
                print(len(vb) - vb_[1][1])
            else:
                print(len(vb) - vb_[0][1])
        else:
            if va_[0][0] == vb_[0][0]:
                print(len(va) - va_[1][1])
            else:
                print(len(va) - va_[0][1])
        exit()
    if va_[0][1] + vb_[1][1] > va_[1][1] + vb_[0][1]:
        print(len(va) - va_[0][1] + len(vb) - vb_[1][1])
    else:
        print(len(va) - va_[1][1] + len(vb) - vb_[0][1])
else:
    print(len(va) - va_[0][1] + len(vb) - vb_[0][1])

Buggy submission (verdict: Runtime Error):
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

va = v[::2]
vb = v[1::2]

va_ = Counter(va).most_common(2)
vb_ = Counter(vb).most_common(2)

if va_[0][0] == vb_[0][0]:
    if va_[0][1] + vb_[1][1] > va_[1][1] + vb_[0][1]:
        print(len(va) - va_[0][1] + len(vb) - vb_[1][1])
    else:
        print(len(va) - va_[1][1] + len(vb) - vb_[0][1])
else:
    print(len(va) - va_[0][1] + len(vb) - vb_[0][1])
Problem p03262 (python)

Fixed submission:
N, X = map(int, input().split())
x = list(map(int, input().split()))
x = list(map(lambda x: abs(X - int(x)), x))

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
        
if len(x) < 2:
    print(x[0])
else:
    D = gcd(x[0], x[1])
    for i in range(2, N):
        D = gcd(D, x[i])

    print(D)

Buggy submission (verdict: Runtime Error):
import fractions
 
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()

dist = []
for i in range(N-1):
    dist.append(x[i+1] - x[i])
    
g = dist[0]

for i in range(N-2):
    g = fractions.gcd(g, dist[i+1])

print(g)

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
x = list(map(int, input().split()))
x = list(map(lambda x: abs(X - int(x)), x))
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

D = gcd(x[0], x[1])
for i in range(2, N):
    D = gcd(D, x[2])

print(D)
Problem p03274 (python)

Fixed submission:
N, K = map(int, input().split())
x = list(map(int, input().split()))
L = []

for i in range(N-K+1):
    L.append(abs(x[i]) + x[K+i-1] - x[i])
    L.append(abs(x[K+i-1]) + x[K+i-1] - x[i])
    
if N != 1:
    print(min(L))
else:
    print(abs(x[0]))

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

for i in range(N-K):
    L.append(abs(x[i]) + x[K+i-1] - x[i])
    L.append(abs(x[K+i-1]) + x[K+i-1] - x[i])
    
if N != 1:
    print(min(L))
else:
    print(abs(x[0]))
Problem p03284 (python)

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

if N % K:
    print(1)
else:
    print(0)

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

if N % K:
    print(1)
else:
    print(0)
Problem p03328 (python)

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

l = [1]
for i in range(2, 1000):
    l.append(l[i-2] + i)
    
diff = b - a

print(l[diff-1] - b)

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

l = [1]
for i in range(2, 999):
    l.append(l[i-2] + i)
    
diff = b - a

print(l[diff-1] - b)
Problem p03330 (python)

Fixed submission:
N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(lambda x: int(x)-1, input().split())) for _ in range(N)]

cost = [[0] * C for _ in range(3)]
for p in range(C):
    for i in range(N):
        for j in range(N):
            #グループごとにかかるコストの計算
            cost[(i+j)%3][p] += D[c[i][j]][p]

res = 10 ** 9
p = [0] * 3
for p[0] in range(C):
    for p[1] in range(C):
        if p[0] == p[1]:
            continue
        for p[2] in range(C):
            if p[2] == p[0] or p[1] == p[2]:
                continue
            tmp = 0
            for i in range(3):
                tmp += cost[i][p[i]]
            res = min(res, tmp)

print(res)

Buggy submission (verdict: Runtime Error):
N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(lambda x: int(x)-1, input().split())) for _ in range(N)]

cost = [[0] * 3 for _ in range(C)]
for p in range(C):
    for i in range(N):
        for j in range(N):
            #グループごとにかかるコストの計算
            cost[(i+j)%3][p] += D[c[i][j]][p]

res = 10 ** 9
p = [0] * 3
for p[0] in range(C):
    for p[1] in range(C):
        if p[0] == p[1]:
            continue
        for p[2] in range(C):
            if p[2] == p[0] or p[1] == p[2]:
                continue
            tmp = 0
            for i in range(3):
                tmp += cost[i][p[i]]
            res = min(res, tmp)

print(res)
Problem p03338 (python)

Fixed submission:
N = int(input())
S = input()
L = []
for i in range(1, N):
    a = set()
    b = set()
    for j in S[:i]:
        a.add(j)
    for k in S[i:]:
        b.add(k)
    count = len(a & b)
    L.append(count)

print(max(L))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
L = []
for i in range(1, N-1):
    a = set()
    b = set()
    for j in S[:i]:
        a.add(j)
    for k in S[i:]:
        b.add(k)
    count = len(a & b)
    L.append(count)

print(max(L))