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

Fixed submission:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator

from fractions import gcd


inf = float('inf')


# globals
N, X = 0, 0
C = []


def set_inputs():
    global N, X, C
    N, X = get_li()
    C = get_li()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    ans = reduce(gcd, filter(lambda x: x != 0, map(lambda x: abs(x-X), C)))
    print(ans)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator

from fraction import gcd


inf = float('inf')


# globals
N, X = 0, 0
C = []


def set_inputs():
    global N, X, C
    N, X = get_li()
    C = get_li()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    ans = reduce(gcd, filter(lambda x: x != 0, map(lambda x: abs(x-X), C)))
    print(ans)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()
Problem p03485 (python)

Fixed submission:
a, b = map(int, input().strip().split())
print((a + b + 2 -1) // 2)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().stirp().split())
print((a + b + 2 -1) // 2)
Problem p03477 (python)

Fixed submission:
a,b,c,d = map(int,input().split())
if a+b>c+d:
  print("Left")
elif a+b==c+d:
  print("Balanced")
else:
  print("Right")

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
if a+b>c+d:
  print("Left")
elif a+b=c+d:
  print("Balanced")
else:
  print("Right")
Problem p03495 (python)

Fixed submission:
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
hash = [0 for i in range(n+1)]

if len(set(a))<=k:
  print(0)
  exit()
else:
  ans=0
  for i in a:
    hash[i]+=1
  hash.sort()
  L=hash
  #何種類減らすかカウントするx
  x = len(set(a)) - k
  j=0
  m=0
  while m!=x:
    if L[j]==0:
      j+=1
      continue
    else:
      ans+=L[j]
      j+=1
      m+=1
  print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
hash = [0 for i in range(n+1)]
#dic = {a[i]:count}
if len(set(a))<=k:
  print(0)
  exit()
else:
  ans=0
  for i in a:
    hash[i]+=1
  L = list(set(hash))
  x = len(set(a)) - k
  for i in range(x+1):
    ans+=L[i]
  print(ans)
Problem p03693 (python)

Fixed submission:
r,g,b = map(int,input().split())
print("YES" if (100*r+10*g+b)%4==0 else("NO"))

Buggy submission (verdict: Runtime Error):
r,g,b = map(int,input().split())
print("YES" if (100*r+10*g+b)%4=0 else("NO")

Buggy submission (verdict: Runtime Error):
r,g,b = map(int,input().split())
print("YES" if 100*r+10*g+b%4=0 else("NO")
Problem p03711 (python)

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

B = (4,6,9,11)
C = (1,3,5,7,8,10,12)
if x==y==2:
  print("Yes")
elif x in B and y in B:
  print("Yes")
elif x in C and y in C:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
x,y = map(int,input().split())
A = (2)
B = (4,6,9,11)
C = (1,3,5,7,8,10,12)
if x in A and y in B:
  print("Yes")
else if x in B and y in B:
  print("Yes")
else if x in C and y in C:
  print("Yes")
else:
  print("No")
Problem p03739 (python)

Fixed submission:
import copy
n = int(input())
a = [int(i) for i in input().split()]
b=a.copy()
s0p = a[0]
s0n = b[0]
countp = 0
countn = 0

if a.count(0)==n:
  print(2*n-1)
  exit()

if s0p<=0:
  s0p+=(abs(a[0])+1)
  countp+=(abs(a[0])+1)
  
if s0n>=0:
  s0n-=(abs(b[0])+1)
  countn+=(abs(b[0])+1)

for i in range(1,n):
  s1 = s0p+a[i]
  if s0p*s1>=0:
    if s1>0:
      a[i]-=(abs(s1)+1)
      countp+=(abs(s1)+1)
    elif s1<0:
      a[i]+=(abs(s1)+1)
      countp+=(abs(s1)+1)
    elif s1==0:
      if s0p>0:
        a[i]-=1
        countp+=1
      elif s0p<0:
        a[i]+=1
        countp+=1
  s0p += a[i]

for i in range(1,n):
  s1 = s0n+b[i]
  if s0n*s1>=0:
    if s1>0:
      b[i]-=(abs(s1)+1)
      countn+=(abs(s1)+1)
    elif s1<0:
      b[i]+=(abs(s1)+1)
      countn+=(abs(s1)+1)
    elif s1==0:
      if s0n>0:
        b[i]-=1
        countn+=1
      elif s0n<0:
        b[i]+=1
        countn+=1
  s0n += b[i]
  
print(countp if countp<=countn else(countn))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]
s0 = a[0]
count=0

i=0
while a[i]!=0and i!=n-1:i++
if a[i]>0:
  s0+=1
  count+=1
else:
  s0-=1
  count+=1
  

  for i in range(1,n):
  s1 = s0+a[i]
  if s0*s1>=0:
    if s1>0:
      a[i]-=(abs(s1)+1)
      count+=(abs(s1)+1)
    elif s1<0:
      a[i]+=(abs(s1)+1)
      count+=(abs(s1)+1)
    elif s1==0:
      if s0>0:
        a[i]-=1
        count+=1
      elif s0<0:
        a[i]+=1
        count+=1
  s0 += a[i]
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]
s0 = a[0]
count=0

i=0
while a[i]!=0:i++
if a[i]>0:
  s0+=1
  count+=1
else:
  s0-=1
  count+=1
  

  for i in range(1,n):
  s1 = s0+a[i]
  if s0*s1>=0:
    if s1>0:
      a[i]-=(abs(s1)+1)
      count+=(abs(s1)+1)
    elif s1<0:
      a[i]+=(abs(s1)+1)
      count+=(abs(s1)+1)
    elif s1==0:
      if s0>0:
        a[i]-=1
        count+=1
      elif s0<0:
        a[i]+=1
        count+=1
  s0 += a[i]
print(count)
Problem p03760 (python)

Fixed submission:
O = input()
E = input()
str = ""
i = 0
while True:
  str += O[i]
  str += E[i]
  i+=1
  if len(E)-1<i:break
if len(O)-len(E)==1:
  str+=O[-1]
print(str)

Buggy submission (verdict: Runtime Error):
O = input()
E = input()
str = ""
i = 0
while True:
  str = str + O[i]
  if len(E)-1<i:
    exit(1)
  str = str + E[i]
  i+=1
  
print(str)

Buggy submission (verdict: Runtime Error):
O = input()
E = input()
str = ""
i = 0
while True:
  str = str + O[i]
  if len(E)-1<i:
    break
  str = str + E[i]
  i+=1
  
print(str)
Problem p03777 (python)

Fixed submission:
a,b = input().split()
if a=="H"and b=="H":
  print("H")
elif a=="H" and b=="D":
  print("D")
elif a=="D" and b=="H":
  print("D")
elif a=="D" and b=="D":
  print("H")

Buggy submission (verdict: Runtime Error):
a,b = input().split()
if a=="H"and b=="H":
  print("H")
elif a=="H" and b=="D":
  print("D")
elif a=="D" and b=="H":
  print("D")
elif a=="D" and b=="D":
  print(")
Problem p03813 (python)

Fixed submission:
print("ABC" if int(input())<1200 else("ARC"))

Buggy submission (verdict: Runtime Error):
print(“ABC” if int(input())<1200 else(“ARC”))

Buggy submission (verdict: Runtime Error):
print(“ABC” if int(input())<1200 else(“ARC”))

Buggy submission (verdict: Runtime Error):
print(“ABC” if int(input()) <=1200 else(“ARC”))
Problem p03962 (python)

Fixed submission:
s = input().split()
count = 0
flag = False
for i in range(len(s)):
    for j in range(i+1,len(s)):
        if s[i] == s[j]:
            count-=1
    count+=1
if count == 0:
    count = 1
print(count)

Buggy submission (verdict: Runtime Error):
s=input().split()
print(len(set(s))
Problem p04011 (python)

Fixed submission:
w = [input() for i in range(4)]
N = int(w[0])
K = int(w[1])
X = int(w[2])
Y = int(w[3])

paid = 0
for i in range(1,N+1):
    if i < K+1:
        paid += X
    else:
        paid += Y

print(paid)

Buggy submission (verdict: Runtime Error):
w = input()
for i in range(len(w)):
    if w.count(w[i])%2 == 1:
        print("No")
        exit(1)

print("Yes")

Buggy submission (verdict: Runtime Error):
w = input()
for i in set(w):
    if w.count(i)%2 == 1:
        print("No")
        exit(1)

print("Yes")

Buggy submission (verdict: Runtime Error):
w = input()
for i in set(w):
    if w.count(i)%2 == 1:
        print("No")
        exit(-1)

print("Yes")

Buggy submission (verdict: Runtime Error):
w = input()
for i in set(w):
    if w.count(i)%2 == 1:
#print("No")


print("Yes")
Problem p04012 (python)

Fixed submission:
w = input()
only = list(set(w))
count = 0
can = True
for i in only:
    if w.count(i) % 2 != 0:
        can = False
        break
if can:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
w = input()
for i in set(w):
    if w.count(i)%2 == 1:
        print("No")
        exit(1)

print("Yes")

Buggy submission (verdict: Runtime Error):
w = input()
for i in set(w):
    if w.count(i)%2 == 1:
        print("No")
        exit(1)

print("Yes")

Buggy submission (verdict: Runtime Error):
w = input()
for i in range(len(w)):
    if w.count(w[i])%2 == 1:
        print("No")
        exit(1)

print("Yes")
Problem p04030 (python)

Fixed submission:
s = input()
str = ""
count = 0
for i in range(len(s)):
    #print("count",count)
    if s[i] == "0":
        str += s[i]
        count += 1
    elif s[i] == "1":
        str += s[i]
        count += 1
    elif s[i] == "B":
        if count > 0:
            str = str[:-1]
            count -= 1
#print("str",str)


print(str)

Buggy submission (verdict: Runtime Error):
s = input()
str = ""
count = 0
for i in range(len(s)):
    #print("str",str)
    if s[i] == "0":
        str += s[i]
        count += 1
    elif s[i] == "1":
        str += s[i]
        count += 1
    elif s[i] == "B":
        if count > 0:
            str = str.rstrip(str[count-1])
            count -= 1


print(str)
Problem p02995 (python)

Fixed submission:
import fractions

A, B, C, D = [int(i) for i in input().split()]

lcm_CD = (C*D)//fractions.gcd(C, D)

C_bot = C * -(-A//C) 
C_top = C * (B//C) 
D_bot = D * -(-A//D)
D_top = D * (B//D)
CD_bot = lcm_CD * -(-A//(lcm_CD ))
CD_top = lcm_CD  * (B//(lcm_CD ))

num_A_B = B - A + 1
num_divC = (C_top - C_bot)//C + 1
num_divD = (D_top - D_bot)//D + 1
num_divCD = (CD_top - CD_bot)//(lcm_CD ) + 1
ans = num_A_B - num_divC - num_divD + num_divCD


print(int(ans))

Buggy submission (verdict: Runtime Error):
import math

A, B, C, D = [int(i) for i in input().split()]

lcm_CD = (C*D)//math.gcd(C, D)

C_bot = C * -(-A//C) 
C_top = C * (B//C) 
D_bot = D * -(-A//D)
D_top = D * (B//D)
CD_bot = lcm_CD * -(-A//(lcm_CD ))
CD_top = lcm_CD  * (B//(lcm_CD ))

num_A_B = B - A + 1
num_divC = (C_top - C_bot)//C + 1
num_divD = (D_top - D_bot)//D + 1
num_divCD = (CD_top - CD_bot)//(lcm_CD ) + 1
ans = num_A_B - num_divC - num_divD + num_divCD


print(int(ans))
Problem p03030 (python)

Fixed submission:
list_SP = []
N = int(input())

for i in range(N):
  S, P = input().split()
  list_SP.append([S, 100 - int(P), i+1])
  
  
sorted_listSP = sorted(list_SP)
for data in sorted_listSP:
  print(data[2])

Buggy submission (verdict: Runtime Error):
list_SP = []
N = int(input())

for i in range(N):
  S, P = input().split()
  list_SP.append([S, 100 - int(P), i+1])
  
  
sorted_listSP = sorted(list_SP)
print(sorted_listSP[2])
Problem p02969 (python)

Fixed submission:
r = int(input())
print(3*(r**2))

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left
n = int(input())
A=[int(input()) for _ in range(n)]
row = [A[0]]
for a in A[1:]:
    if a<=row[-1]:
        row.append(a)
    else:
        row[len(row) - bisect_left(row[::-1],a)] = a
print(len(row))
Problem p02973 (python)

Fixed submission:
from bisect import bisect_left
from collections import deque
n = int(input())
A=[int(input()) for _ in range(n)]
q=deque()
for a in A:
    i=bisect_left(q,a)
    if not i:
        q.appendleft(a)
    else:
        q[i-1]=a
print(len(q))

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left
from collections import deque
n = int(input())
A=[int(input()) for _ in range(n)]
q=deque()
for a in A:
    i=bisect_left(l,a)
    if not i:
        q.appendleft(a)
    else:
        q[i-1]=a
print(len(q))
Problem p03014 (python)

Fixed submission:
from itertools import takewhile

H, W = map(int, input().split())
S = [input() for _ in range(H)]

x = [[0 for _ in range(W)] for _ in range(H)]
y = [[0 for _ in range(W)] for _ in range(H)]

for i, j in ((i, j) for i in range(H) for j in range(W) if S[i][j] == '.'):
    if x[i][j] == 0:
        w = len(list(takewhile(lambda k: S[i][k] == '.', range(j, W))))
        for k in range(j, j + w):
            x[i][k] = w
    if y[i][j] == 0:
        h = len(list(takewhile(lambda k: S[k][j] == '.', range(i, H))))
        for l in range(i, i + h):
            y[l][j] = h

ans = max(
    x[i][j] + y[i][j] - 1
    for i in range(H)
    for j in range(W)
)
# 出力
print(ans)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
S = [input() for _ in range(H)]

x = [[0 for _ in range(W)] for _ in range(H)]
y = [[0 for _ in range(W)] for _ in range(H)]

for i, j in ((i, j) for i in range(H) for j in range(W) if S[i][j] == '.'):
    if x[i][j] == 0:
        w = len(list(takewhile(lambda k: S[i][k] == '.', range(j, W))))
        for k in range(j, j + w):
            x[i][k] = w
    if y[i][j] == 0:
        h = len(list(takewhile(lambda k: S[k][j] == '.', range(i, H))))
        for l in range(i, i + h):
            y[l][j] = h

ans = max(
    x[i][j] + y[i][j] - 1
    for i in range(H)
    for j in range(W)
)
# 出力
print(ans)
Problem p03061 (python)

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

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

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

for i in range(1,N):
    X[i]=gcd(X[i-1],A[i-1])
for i in range(N-1)[::-1]:
    Y[i]=gcd(Y[i+1],A[i+1])

Z = [0]*N
for i in range(N):
    Z[i]=gcd(X[i],Y[i])
print(max(Z))

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

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

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

for i in range(1,N):
    X[i]=gcd(X[i-1],A[i-1])
for i in range(N-1)[::-1]:
    Y[i]=gcd(Y[i+1],A[i+1])

Z = [0]*n
for i in range(N):
    Z[i]=gcd(X[i],Y[i])
print(max(Z))
Problem p03111 (python)

Fixed submission:
N,A,B,C = map(int, input().split())
l = [int(input()) for i 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 submission (verdict: Runtime Error):
N,A,B,C = map(int, input().split())
l = [int(i) for i in input()]
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))
Problem p03128 (python)

Fixed submission:
N,M = map(int, input().split())
am = list(map(int, input().split()))
c = [0,2,5,5,4,5,6,3,7,6]
f = [-1]*10010
f[0]=0
for i in range(1,N+1):
    for x in am:
        if i-c[x] >= 0:
            f[i] = max(f[i], f[i-c[x]]*10 +x)
            
print(f[N])

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
am = list(map(int, input().split()))
c = [0,2,5,5,4,5,6,3,7,6]
f = [-1]*10010
f[0]=0
for i in range(1,N+1):
    for x in am:
        if i-c[x] >= 0:
            f[i] = max(f[i], f[i-c[x]]*10 +x)
            
print(f[n])

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
am = list(map(int, input().split()))
c = [0,2,5,5,4,5,6,3,7,6]
f = [-1]*10010
f[0]=0
for i in range(1,n+1):
    for x in am:
        if i-c[x] >= 0:
            f[i] = max(f[i], f[i-c[x]]*10 +x)
            
print(f[n])

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
am = list(map(int, input().split()))
c = [0,2,5,5,4,5,6,3,7,6]
f = [-1]*10010
f[0]=0
for i in range(1,n+1):
    for x in a:
        if i-c[x] >= 0:
            f[i] = max(f[i], f[i-c[x]]*10 +x)
            
print(f[n])
Problem p03146 (python)

Fixed submission:
s = int(input())
lst = []

while s not in lst:
    lst.append(s)
    s = s/2 if s%2==0 else 3*s + 1
    
print(len(lst) + 1)

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

s = int(input())
a = [s]
def f_even(n):
    return n//2
def f_odd(n):
    return 3*n + 1
for i in range(100):
    if a[i]%2 == 0:
        a.append(f_even(a[i]))
    else:
        a.append(f_odd(a[i]))
    tmp = Counter(a).most_common()[0]
    if tmp[1] > 1:
        print(i+2)
        return
Problem p03147 (python)

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

ans = 0

while sum(hn) > 0:
    ans+= 1
    flag = False
    for i in range(n):
        if hn[i] > 0:
            hn[i] -= 1
            flag = True
        elif flag is True:
            break

print(ans)

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

ans = 0

while sum(hn) > 0:
    ans+= 1
    flag = False
    for i in range(n):
        if hn[i] > 0:
            hn[i] -= 1
            flag = True
        else:
            break

print(ans)
Problem p03165 (python)

Fixed submission:
S = input()
T = input()
 
# dp[i][j] := Sのi文字目, Tのj文字目まで見た場合のLCS
dp = [[0] * (len(T) + 1) for i in range(len(S) + 1)]
 
for i in range(1, len(S) + 1):
    for j in range(1, len(T) + 1):
        if S[i - 1] == T[j - 1]:
            dp[i][j] = dp[i - 1][j - 1] + 1
        else:
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
 
ans = ''
i, j = len(S), len(T)
while i > 0 and j > 0:
    if S[i - 1] == T[j - 1]:
        ans += S[i - 1]
        i, j = i - 1, j - 1
    elif dp[i][j - 1] > dp[i - 1][j]:
        j -= 1
    else:
        i -= 1
 
print(ans[::-1])

Buggy submission (verdict: Runtime Error):
s = input()
t= input()
# s = "abracadabra"
# t = "avadakedavra"

dp=[[0]*len(t) for i in range(len(s))]
for i in range(len(s)):
    for j in range(len(t)):
        if s[i-1] == t[j-1]:
            dp[i][j] = dp[i-1][j-1] + 1
        else:
            dp[i][j] = max(dp[i][j-1], dp[i-1][j])
            
i, j, dp_len = len(s),len(t), dp[-1][-1]
ans = ""

while dp_len:
#     print("現在精査している文字は{}と{}です。もとのsは{}で、tは{}です。sの長さは{}, tの長さは{}です".format(s[i-1],t[j-1],s[:i-1], t[:j-1], i,j))
    if s[i-1] == t[j-1]:
        ans += s[i-1]
        i -= 1
        j -= 1
        dp_len -= 1
#         print("一致")
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
    else:
        j -= 1
        
# print(dp)
print(ans[::-1])

Buggy submission (verdict: Runtime Error):
s = input()
t= input()
dp=[[0]*len(s) for i in range(len(t))]
for i in range(len(t)):
    for j in range(len(s)):
        if t[i] == s[j]:
            dp[i][j] = dp[i-1][j-1] + 1
        else:
            dp[i][j] = max(dp[i][j-1], dp[i-1][j])
i, j = len(s),len(t)
ans = ""
while i>0 and j > 0:
    if s[i-1] == t[j-1]:
        ans += s[i-1]
        i -= 1
        j -= 1
    elif dp[j][i] > dp[j-1][i]:
        j -= 1
    else:
        i -= 1
print(ans[::-1])
Problem p03244 (python)

Fixed submission:
import collections
 
def counter_top(c, exclude):
  for a in c.most_common():
    if a[0] != exclude:
      return a
  return (object(), 0)
 
def conv_seq(seq, exclude=None):
  c = collections.Counter(seq)
  mc = counter_top(c, exclude)
  return sum(c.values()) - mc[1], mc[0]
 
input()
vals = list(map(int, input().split()))
s1, a = conv_seq(vals[::2])
s2, b = conv_seq(vals[1::2])
if a != b:
  print(s1 + s2)
else:
  s1_new, _ = conv_seq(vals[::2], exclude=b)
  s2_new, _ = conv_seq(vals[1::2], exclude=a)
  print(min(s1_new + s2, s1 + s2_new))

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

n = int(input())
vn = list(map(int,input().split()))
vn_odd = [vn[i] for i in range(n) if i%2==1]
vn_even = [vn[i] for i in range(n) if i%2==0]
odd_freq = Counter(vn_odd).most_common(2)
even_freq = Counter(vn_even).most_common(2)

ans = 0

if odd_freq[0][0] != even_freq[0][0]:
    ans += n - odd_freq[0][1] - even_freq[0][1]
else:
    ans += n - max(odd_freq[0][1]+even_freq[1][1], odd_freq[1][1]+even_freq[0][1])
            
print(ans)

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

n = int(input())
vn = list(map(int,input().split()))
vn_odd = [vn[i] for i in range(n) if i%2==1]
vn_even = [vn[i] for i in range(n) if i%2==0]
odd_freq = Counter(vn_odd).most_common(2)
even_freq = Counter(vn_even).most_common(2)

ans = 0

if odd_freq[0][0] != even_freq[0][0]:
    ans += n - odd_freq[0][1] - even_freq[0][1]
else:
    if odd_freq[0][1] > even_freq[0][1]:
        ans += n - odd_freq[0][1] - even_freq[1][1]
    elif odd_freq[0][1] < even_freq[0][1]:
        ans += n - odd_freq[1][1] - even_freq[0][1]
    else:
        if odd_freq[1][1] >= even_freq[1][1]:
            ans += n - odd_freq[1][1] - even_freq[0][1]
        else:
            ans += n - odd_freq[0][1] - even_freq[1][1]

            
print(ans)
Problem p03262 (python)

Fixed submission:
from functools import reduce
import fractions

N,X = map(int,input().split())
xn = list(map(int,input().split()))

distance = [abs(X-xn[i]) for i in range(N)]
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
print(gcd_list(distance))

Buggy submission (verdict: Runtime Error):
from functools import reduce
import fractions

N,X = map(int,input().split())
xn = list(map(int,input().split()))
xn.append(X)
xn.sort()
distance = [xn[i]-xn[i-1] for i in range(1,N)]
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
print(gcd_list(distance))

Buggy submission (verdict: Runtime Error):
from functools import reduce
import fractions

N,X = map(int,input().split())
xn = list(map(int,input().split()))
xn.sort()
distance = [xn[i]-xn[i-1] for i in range(1,N)]
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
print(gcd_list(distance))
Problem p03287 (python)

Fixed submission:
N, M = map(int, input().split())
*A, = map(int, input().split())
C = {0: 1}
ans = 0
s = 0
for a in A:
    s = (s + a) % M
    ans += C.get(s, 0)
    C[s] = C.get(s, 0) + 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
*A, = map(int, input().split())
C = {0: 1}
ans = 0
s = 0
for a in A:
    s = (s + a) % M
    ans += C.get(s, 0)
    C[s] = C.get(s, 0) + 1
    print("C is {}, ans is {}".format(C,ans))
print(ans)
Problem p04029 (python)

Fixed submission:
n =int(input())
sum=0
for i in range(n):
  sum+=(i+1)
print(sum)

Buggy submission (verdict: Runtime Error):
=int(input())
sum=0
for i in range(n):
  sum+=(i+1)
print(sum)
Problem p04043 (python)

Fixed submission:
a=list(map(int,input().split()))
if a.count(5)==2 and a.count(7)==1:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
N,L = map(int,input().split())
S = []
ans = ""
for i in range(N):
  S.append(input())
sorted(S)
for i in range(len(S)):
  ans += S[i]
print(ans)