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

Fixed submission:
n = int(input())
blue = []
red = []
score_list = []
for i in range(n):
    blue.append(input())
m = int(input())
for j in range(m):
    red.append(input())
for value in blue:
    score = 0
    for s in blue:
        if value == s:
            score += 1
    for t in red:
        if value == t:
            score -= 1
    if score not in score_list:
        score_list.append(score)
if max(score_list) < 0:
    print(0)
else:
    print(max(score_list))

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
blue = []
red = []
for i in range(n):
    blue.append(input())
m = int(input())
for j in range(m):
    red.append(input())

blue_dict = collections.Counter(blue)
red_dict = collections.Counter(red)
count_list = []
for b_key, b_value in blue_dict.items():
    for r_key, r_value in red_dict.items():
        if b_key == r_key:
            count_list.append(b_value - r_value)
print('出力 : {}'.format(max(count_list)))
Problem p03415 (python)

Fixed submission:
row1 = input()
row2 = input()
row3 = input()
print(row1[0]+row2[1]+row3[2])

Buggy submission (verdict: Runtime Error):
row1 = input().split()
row2 = input().split()
row3 = input().split()
print(row1[0]+row2[1]+row3[2])

Buggy submission (verdict: Runtime Error):
row1 = list(map(str, input().split()))
row2 = list(map(str, input().split()))
row3 = list(map(str, input().split()))
matrix = [row1, row2, row3]
print(matrix[0][0]+matrix[1][1]+matrix[2][2])

Buggy submission (verdict: Runtime Error):
row1 = list(map(str, input().split()))
row2 = list(map(str, input().split()))
row3 = list(map(str, input().split()))
matrix = [row1, row2, row2]
print(matrix[0][0]+matrix[1][1]+matrix[2][2])

Buggy submission (verdict: Runtime Error):
row1 = list(map(str, input().split()))
row2 = list(map(str, input().split()))
row3 = list(map(str, input().split()))
matrix = [row1, row2, row2]
print(matrix)
print(matrix[0][0]+matrix[1][1]+matrix[2][2])

Buggy submission (verdict: Runtime Error):
matrix = [[], [], []]
for row in matrix:
    for i in range(3):
        row.append(input())
print(matrix[0][0] + matrix[1][1] + matrix[2][2])

Buggy submission (verdict: Runtime Error):
matrix = [[], [], []]
for row in matrix:
    for i in range(3):
        row.append(input())
print(matrix)
print(matrix[0][0] + matrix[1][1] + matrix[2][2])
Problem p04043 (python)

Fixed submission:
a, b, c = map(int, input().split())
five = 0
seven = 0
check = [a, b, c]
for s in check:
    if s == 5:
        five += 1
    if s == 7:
        seven += 1
if five == 2 and seven == 1:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
five = 0
seven = 0
check = [A, b, C]
for s in check:
    if s == 5:
        five += 1
    if s == 7:
        seven += 1
if five == 2 and seven == 1:
    print('YES')
else:
    print('NO')
Problem p02789 (python)

Fixed submission:
n,m = map(int, input().split())
if n==m:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n,m = int(input().split())
if m==n:
  print("Yes")
else:
  print("No")
Problem p02993 (python)

Fixed submission:
s = input()
s_list = [i for i in s]
flag = True
for i in range(1,4):
  if s_list[i]==s_list[i-1]:
    print('Bad')
    flag = False
    break

if flag:
  print('Good')

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

#cとdの最大公約数を求める
first = [c,d%c]
first.sort()
if d%c==0:
  cd = c
elif first[0]==1:
  cd = 1
else:
  while first[0]>=2:
    first[1] = first[1]%first[0]
    first.sort()
    if first[0]==0:
      cd = first[1]
    elif first[0]==1:
      cd = 1
lcm = c*d/cd
      
zen = b-a+1
c_num = (b//c) -math.ceil(a/c)+1
d_num = (b//d) -math.ceil(a/d)+1
lcm_num = (b//lcm) - math.ceil(a/lcm)+1
ans = zen - c_num - d_num + lcm_num
print(ans)
Problem p03262 (python)

Fixed submission:
N, X = map(int, input().split())
cities = [int(i) for i in input().split()]
cities.sort()
dist = [int(abs(i-X)) for i in cities]
dist.sort()
 
if N==1:
    print(max(dist))
else:
    while len(dist)>0:
        m = min(dist)
        dist = [int(i%m) for i in dist]
        dist.sort()
        while len(dist)>0 and dist[0]==0:
            dist.remove(0)
        if len(dist)==0:
            break
        else:
            dist.append(m)
    print(m)

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
cities = [int(i) for i in input().split()]
cities.sort()
dist = [int(abs(i-X)) for i in cities]
dist.sort()
 
if N==1:
    print(max(dist))
else:
    while len(dist)>0:
        m = min(dist)
        dist = [int(i%m) for i in dist]
        dist.sort
        while len(dist)>0 and dist[0]==0:
            dist.remove(0)
        if len(dist)==0:
            break
        else:
            dist.append(m)
    print(m)

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
cities = [int(i) for i in input().split()]
cities.sort()
dist = [int(abs(i-X)) for i in cities]
dist.sort()

import math
if N==1:
    print(max(dist))
else:
    D = math.gcd(min(dist), max(dist))
    for i in reversed(range(1, D+1)): #最大公約数を1から順に考える
        for j in range(len(dist)): #全ての数を割ってみる
            if dist[j]%i != 0:
                flag = False
                break
            else:
                flag = True
        if flag:
            D = i
            break
    print(D)

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
cities = [int(i) for i in input().split()]
cities.sort()
dist = [int(abs(i-X)) for i in cities]
dist.sort()

import math
if N==1:
    print(max(dist))
else:
    D = math.gcd(min(dist), max(dist))
    for i in reversed(range(1, D+1)): #最大公約数を1から順に考える
        for j in range(len(dist)): #全ての数を割ってみる
            if dist[j]%i != 0:
                flag = False
                break
            else:
                flag = True
        if flag:
            D = i
            break
    print(D)
Problem p03493 (python)

Fixed submission:
print(list(input()).count("1"))

Buggy submission (verdict: Runtime Error):
a,b,c=map(int, input().split())
list = [a,b,c]
s = 0
for i in range (3):
	if list[i] == 1:
		s += 1
print(s)

Buggy submission (verdict: Runtime Error):
a,b,c=map(int, input().split())
list = [a,b,c]
s = 0
for i in range (3):
  if list[i] == 1:
    s += 1
print(s)
Problem p03564 (python)

Fixed submission:
N = int(input())
K = int(input())
c = 1
for i in range(N):
  c = min(c*2, c+K)
print(c)

Buggy submission (verdict: Runtime Error):
N = input()
K = input()
c = 1
for i in range(N):
  c = min(c*2, c+K)
print(c)
Problem p02755 (python)

Fixed submission:
a, b = map(int, input().split())
for i in range(b*10, (b+1)*10):
  if int(i*0.08) == a:
    print(i)
    break
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
#include <stdio.h>

int main() {
  int a, b, x=-1;
  scanf("%d %d", &a, &b);
  for(int i=b*10; i<(b+1)*10; ++i) {
    if ((int)(i*0.08) == a) {
      x = i;
      break;
    }
  }
  printf("%d", x);
  return 0;
}

Buggy submission (verdict: Runtime Error):
#include <stdio.h>

int main() {
  int a, b, x=-1;
  scanf("%d %d", &a, &b);
  for(int i=b*10; i<(b+1)*10; ++i) {
    if ((int)(i*0.08) == a) {
      x = i;
      break;
    }
  }
  printf("%d", x);
  return 0;
}
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
num = [None]*N
res = 0
for i in range(M):
    s, c = map(int, input().split())
    s -= 1
    if N > 1 and s == 0 and c == 0:
        res = -1
        break    
    if num[s] == None:
        num[s] = c
    elif num[s] != c:
        res = -1
        break

print(res) if res == -1 else print(*[e if e!=None else 0 if i != 0 or N == 1 else 1 for i, e in enumerate(num)], sep="")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
num = [None]*N
res = 0
for i in range(M):
    s, c = map(int, input().split())
    s -= 1
    if n > 1 and s == 0 and c == 0:
        res = -1
        break    
    if num[s] == None:
        num[s] = c
    elif num[s] != c:
        res = -1
        break

print(res) if res == -1 else print(0) if M == 0 else print(*[e if e!=None else 0 if i != 0 else 1 for i, e in enumerate(num)], sep="")
Problem p02865 (python)

Fixed submission:
n = int(input())

print(n//2-bool(not(n%2)))

Buggy submission (verdict: Runtime Error):
n = int(input())

print(n//2-not(n%2))
Problem p02886 (python)

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

print(sum(l[i]*x for i in range(len(l)-1) for x in l[i+1:]))

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

print(sum([l[i]*x for i in range(len(l)-1) for x in l[i+1:]))
Problem p02887 (python)

Fixed submission:
n = int(input())
s = input()
res = ""
x = ""
for l in s:
  if l != x:
    x = l
    res += x
  else: pass
print(len(res))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
res = ""
x = ""
for l in s:
  if i != x:
    x = l
    res += x
  else: pass
print(len(res))
Problem p02756 (python)

Fixed submission:
import collections

x = collections.deque(input())
n = int(input())
rev = False

for i in range(n):
    y = input().split()
    if len(y) == 1:
      rev = not rev
    elif rev:
      if int(y[1]) == 2:
          x.appendleft(y[2])
      else:
          x.append(y[2])
    else:
      if int(y[1]) == 2:
          x.append(y[2])
      else:
          x.appendleft(y[2])

if rev:
  x.reverse()

print("".join(x))

Buggy submission (verdict: Runtime Error):
import collections

x = collections.deque(input())
n = int(input())

for i in range(n):
    y = input()
    if len(y) == 1:
      x.reverse()
    else:
      if int(y[1]) == 2:
          x.append(y[2])
      else:
          x.appendleft(y[2])

print("".join(x))
Problem p02755 (python)

Fixed submission:
#!/usr/bin/env python
import sys

input = sys.stdin

def tax(pct8, pct10):
    pct8low_x10 = pct8 * 125
    if pct8low_x10 % 10 == 0:
        pct8low = pct8low_x10 // 10
    else:
        pct8low = pct8low_x10 // 10 + 1

    pct8high_x10 = (pct8 + 1) * 125

    if pct8high_x10 % 10 == 0:
        pct8high = pct8high_x10 // 10 - 1
    else:
        pct8high = pct8high_x10 // 10

    pct10low = pct10 * 10
    pct10high = (pct10 + 1) * 10 - 1

    if pct8high < pct10low or pct10high < pct8low:
        return -1
    else:
        return max(pct8low, pct10low)

#def test():
#    for i in range(1, 100+1):
#        for j in range(1, 100+1):
#            price = tax(i, j)
#            if price > 0:
#                if int(price *.08) != i or int(price * .1) != j:
#                    print(f"Wrong! tax({i},{j}) -> {price} but price*0.8={int(price*0.08)} and price*0.1={int(price*0.1)}")

pct8, pct10 = map(int, input.readline().split(" "))
print(tax(pct8, pct10))
#test()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
import sys

input = sys.stdin

def tax(pct8, pct10):
    pct8low_x10 = pct8 * 125
    if pct8low_x10 % 10 == 0:
        pct8low = pct8low_x10 // 10
    else:
        pct8low = pct8low_x10 // 10 + 1

    pct8high_x10 = (pct8 + 1) * 125

    if pct8high_x10 % 10 == 0:
        pct8high = pct8high_x10 // 10 - 1
    else:
        pct8high = pct8high_x10 // 10

    pct10low = pct10 * 10
    pct10high = (pct10 + 1) * 10 - 1

    if pct8high < pct10low or pct10high < pct8low:
        return -1
    else:
        return max(pct8low, pct10low)

def test():
    for i in range(1, 100+1):
        for j in range(1, 100+1):
            price = tax(i, j)
            if price > 0:
                if int(price *.08) != i or int(price * .1) != j:
                    print(f"Wrong! tax({i},{j}) -> {price} but price*0.8={int(price*0.08)} and price*0.1={int(price*0.1)}")

pct8, pct10 = map(int, input.readline().split(" "))
print(tax(pct8, pct10))
#test()
Problem p02760 (python)

Fixed submission:
import sys
rl = sys.stdin.readline

rows = 3
cols = 3
a11,a12,a13 = [int(x) for x in rl().split(' ')]
a21,a22,a23 = [int(x) for x in rl().split(' ')]
a31,a32,a33 = [int(x) for x in rl().split(' ')]

n = int(rl())
b = []

for i in range(n):
    b.append(int(rl()))

#####################

card = [a11,a12,a13,a21,a22,a23,a31,a32,a33]

for num in b:
    for i in range(len(card)):
        if card[i] == num:
            card[i] = 0


def check(card):
    for y in range(rows):
        if all([card[y*rows+x] == 0 for x in range(cols)]):
            return True

    # col
    for x in range(cols):
        if all([card[y*rows+x] == 0 for y in range(rows)]):
            return True

    # diagonal
    if all([card[xy*rows+xy] == 0 for xy in range(rows)]):
            return True

    if all([card[xy*rows+cols-1-xy] == 0 for xy in range(rows)]):
            return True

    return False


if check(card):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import sys
rl = sys.stdin.readline

rows = 3
cols = 3
a11,a12,a13 = [int(x) for x in rl().split(' ')]
a11,a12,a13 = [int(x) for x in rl().split(' ')]
a31,a32,a33 = [int(x) for x in rl().split(' ')]

n = int(rl())
b = []

for i in range(n):
    b.append(int(rl()))

#####################

card = [a11,a12,a13,a1,a22,a23,a31,a32,a33]

for num in b:
    for i in range(len(card)):
        if card[i] == num:
            card[i] = 0

def check(card):
    for y in range(rows):
        if all([card[y*rows+x] == 0 for x in range(cols)]):
            return True

    # col
    for x in range(cols):
        if all([card[y*rows+x] == 0 for y in range(rows)]):
            return True

    # diagonal
    if all([card[xy*rows+xy] == 0 for xy in range(rows)]):
            return True

    if all([card[xy*rows+cols-1-xy] == 0 for xy in range(rows)]):
            return True

    return False

if check(card):
    print("Yes")
else:
    print("No")
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
sc = []
for i in range(M):
    s,c = map(int, input().split())
    sc.append([s,c])

ans = 0
sc_dic = {}
min_s = N+1
for i in sc:
    min_s = min(min_s, i[0])
    if i[0] in sc_dic:
        if i[1] != sc_dic[i[0]]:
            ans = -1
            break
        break
    else:
        ans += 10**(N-i[0])*i[1]
        sc_dic[i[0]] = i[1]

if ans != -1:
        
    if min_s == N+1:
        if N == 1:
            ans = 0
        else:
            ans = 10**(N-1)
        sc_dic[1]=1

    if 1 not in sc_dic:
        ans += 10**(N-1)
        sc_dic[1] = 1
        min_s = 1

    if sc_dic[1] == 0 and N!=1:
        ans = -1

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc = []
for i in range(M):
    s,c = map(int, input().split())
    sc.append([s,c])

ans = 0
sc_dic = {}
for i in sc:
    if i[0] in sc_dic:
        if i[1] != sc_dic[i[0]]:
            ans = -1
    else:
        ans += 10**(N-i[0])*i[1]
        sc_dic[i[0]] = i[1]

if sc_dic[1] == 0:
    ans = -1
print(ans)
Problem p03125 (python)

Fixed submission:
A, B = (int(i) for i in input().split())  
if B%A == 0:
  print(A + B)
else:
  print(B - A)

Buggy submission (verdict: Runtime Error):
A,B = input().split()
if B%A == 0:
  print(A + B)
else:
  print(A - B)
Problem p03160 (python)

Fixed submission:
N = int(input())
h = [i for i in map(int, input().split())]

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

Buggy submission (verdict: Runtime Error):
N = int(input())
h = [i for i in map(int, input().split())]

def dp(i):
    if i==0:
        return 0
    elif i==1:
        return abs(h[1]-h[0])
    else:
        return min(dp(i-1)+abs(h[i]-h[i-1]), dp(i-2)+abs(h[i]-h[i-2]))

print(dp(N-1))
Problem p03557 (python)

Fixed submission:
import bisect

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

A.sort()
C.sort()
#ある一つのBについて、それ以下のAの個数とそれ以上のCの個数を二分探索で求める
ans = 0
for i in range(N):
    lw_a = bisect.bisect_left(A, B[i])
    up_c = N - bisect.bisect_right(C, B[i])
    ans += lw_a * up_c
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

def sunuke(ai, bi, ci, ans):

    if ai > N-1:
        print(ans)
    elif bi > N-1:
        sunuke(ai+1, 0, 0, ans)
    elif ci > N-1:
        sunuke(ai, bi+1, 0, ans)

    elif A[ai] >= B[bi]:
        sunuke(ai,bi+1,ci, ans)
    elif B[bi] >= C[ci]:
        sunuke(ai, bi, ci+1, ans)
    else:
        sunuke(ai, bi, ci+1, ans+1)

ans = 0
sunuke(0,0,0, ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

print(N,A,B,C)
def sunuke(ai, bi, ci, ans):

    if ai > N-1:
        print(ans)
    elif bi > N-1:
        sunuke(ai+1, 0, 0, ans)
    elif ci > N-1:
        sunuke(ai, bi+1, 0, ans)

    elif A[ai] >= B[bi]:
        sunuke(ai,bi+1,ci, ans)
    elif B[bi] >= C[ci]:
        sunuke(ai, bi, ci+1, ans)
    else:
        ans += 1
        sunuke(ai, bi, ci+1, ans)

ans = 0
sunuke(0,0,0, ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

def sunuke(ai, bi, ci, ans):

    if ai > N-1:
        print(ans)
    elif bi > N-1:
        sunuke(ai+1, 0, 0, ans)
    elif ci > N-1:
        sunuke(ai, bi+1, 0, ans)

    elif A[ai] >= B[bi]:
        sunuke(ai,bi+1,ci, ans)
    elif B[bi] >= C[ci]:
        sunuke(ai, bi, ci+1, ans)
    else:
        ans += 1
        sunuke(ai, bi, ci+1, ans)

ans = 0
sunuke(0,0,0, ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

def sunuke(ai, bi, ci):
    global ans

    if ai > N-1:
        print(ans)
    elif bi > N-1:
        sunuke(ai+1, 0, 0)
    elif ci > N-1:
        sunuke(ai, bi+1, 0)

    elif A[ai] >= B[bi]:
        sunuke(ai,bi+1,ci)
    elif B[bi] >= C[ci]:
        sunuke(ai, bi, ci+1)
    else:
        ans += 1
        sunuke(ai, bi, ci+1)

ans = 0
sunuke(0,0,0)
Problem p04001 (python)

Fixed submission:
s = str(input())
s_list = []
for i in range(len(s)):
  s_list.append(s[i])

#print(s_list)
L = len(s_list)

sum_a = 0
if L == 1:
  print(int(s))
else:
  for k in range(2**(L-1)):
    plus_list = [0]*(L-1)
    p = list(bin(k)[2:])
    for l in range(len(p)):
      plus_list[L-len(p)+l-1] = int(p[l])

    #print("p_list:",plus_list)
    #print("p:",p)
    num_list = []
    start = 0
    for i in range(len(plus_list)):
      if plus_list[i]:
        num_list.append(s_list[start:i+1])
        start = i+1
    num_list.append(s_list[start:])
    ans = 0
    for i in num_list:
      s = ''
      for j in i:
        s = s+j
      ans += int(s)
    sum_a += ans
    #print("num_list:",num_list)
    #print("ans:",ans)
  print(sum_a)

Buggy submission (verdict: Runtime Error):
s = str(input())
s_list = []
for i in range(len(s)):
  s_list.append(s[i])

#print(s_list)
L = len(s_list)

sum_a = 0
for k in range(2**(L-1)):
  plus_list = [0]*(L-1)
  p = list(bin(k)[2:])
  for l in range(len(p)):
    plus_list[L-len(p)+l-1] = int(p[l])
  
  #print("p_list:",plus_list)
  #print("p:",p)
  num_list = []
  start = 0
  for i in range(len(plus_list)):
    if plus_list[i]:
      num_list.append(s_list[start:i+1])
      start = i+1
  num_list.append(s_list[start:])
  ans = 0
  for i in num_list:
    s = ''
    for j in i:
      s = s+j
    ans += int(s)
  sum_a += ans
  #print("num_list:",num_list)
  #print("ans:",ans)
print(sum_a)
Problem p02811 (python)

Fixed submission:
import sys
input = sys.stdin.readline

k, x = [int(x) for x in input().rstrip().split()]
print('Yes' if k * 500 >= x else 'No')

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n, m = [int(x) for x in input().rstrip().split()]
a = [int(x)//2 for x in input().rstrip().split()]
a = list(set(a))

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


gcd = a[0]
product = 1
for x in a:
    gcd = find_gcd(gcd, x)
    product *= x

lcm = product // gcd

for x in a:
    if (lcm // x) % 2 == 0:
        print(0)
        sys.exit(0)

print((m // lcm + 1) // 2)
Problem p02814 (python)

Fixed submission:
import sys
import fractions
from functools import reduce
input = sys.stdin.readline
n, m = [int(x) for x in input().strip().split()]
a = [int(x)//2 for x in input().strip().split()]
a = list(set(a))

def lcm_base(x, y): return x * y // fractions.gcd(x, y)
lcm = reduce(lcm_base, a, 1)


for x in a:
    if (lcm // x) % 2 == 0:
        print(0)
        break
else:
    print((m // lcm + 1) // 2)

Buggy submission (verdict: Runtime Error):
import sys
import math
input = sys.stdin.readline

n, m = [int(x) for x in input().rstrip().split()]
a = [int(x)//2 for x in input().rstrip().split()]
a = list(set(a))

gcd = a[0]
product = 1
for x in a:
    gcd = math.gcd(gcd, x)
    product *= x

lcm = product // gcd

for x in a:
    if (lcm // x) % 2 == 0:
        print(0)
        sys.exit(0)

print((m // lcm + 1) // 2)

Buggy submission (verdict: Runtime Error):
import sys
import math
input = sys.stdin.readline

n, m = [int(x) for x in input().rstrip().split()]
a = [int(x)//2 for x in input().rstrip().split()]
a = list(dict.fromkeys(a))

gcd = a[0]
product = 1
for x in a:
    gcd = math.gcd(gcd, x)
    product *= x

lcm = product // gcd

for x in a:
    if (lcm // x) % 2 == 0:
        print(0)
        sys.exit(0)

print((m // lcm + 1) // 2)
Problem p02947 (python)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from collections import defaultdict
import math

N = int(input())
H = defaultdict(int)

for i in range(N):
    s = "".join(sorted(input()))
    H[s] += 1

ret = 0
for v in H.values():
    if v >= 2:
        ret += math.factorial(v) // (math.factorial(v - 2) * math.factorial(2))
print(ret)

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

from collections import defaultdict
import math

N = int(input())
H = defaultdict(int)

for i in range(N):
    s = "".join(sorted(input()))
    H[s] += 1

ret = 0
for v in H.values():
    ret += math.factorial(v) // (math.factorial(v - 2) * math.factorial(2))
print(ret)
Problem p03280 (python)

Fixed submission:
def main():
    A, B = map(int, input().split())
    print(A*B-(A+B)+1)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    S = [int(s) for s in list(input())]
    K = int(input())
    for i in S:
        if i != 1:
            print(i)
            break


if __name__ == "__main__":
    main()
Problem p02995 (python)

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

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

under_c = (A - 1) // C
under_d = (A - 1) // D
under_cd = (A - 1) // lcm_cd

top_c = B // C
top_d = B // D
top_cd = B // lcm_cd

ans = (B -
       (A - 1)) - (top_c - under_c) - (top_d - under_d) + (top_cd - under_cd)

print(ans)

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

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

under_c = (A - 1) // C
under_d = (A - 1) // D
under_cd = (A - 1) // lcm_cd

top_c = B // C
top_d = B // D
top_cd = B // lcm_cd

ans = (B -
       (A - 1)) - (top_c - under_c) - (top_d - under_d) + (top_cd - under_cd)

print(ans)
Problem p03006 (python)

Fixed submission:
from collections import Counter as c
N = int(input())
XY = [tuple(map(int, input().split())) for _ in range(N)]
XY.sort(key=lambda xy: (xy[0], xy[1]))
if N == 1 or N == 2:
    print(1)
    exit()

inclination = []
for i in range(0, N-1):
    for j in range(i+1, N):
        inclination.append((XY[j][0] - XY[i][0], XY[j][1] - XY[i][1]))

print(N - sorted(list(c(inclination).items()), key=lambda x: x[1])[-1][1])

Buggy submission (verdict: Runtime Error):
from collections import Counter as c
N = int(input())
XY = [tuple(map(int, input().split())) for _ in range(N)]
XY.sort(key=lambda xy: xy[0])

inclination = []
for i in range(1, N):
    inclination.append((XY[i][0] - XY[i-1][0], XY[i][1] - XY[i-1][1]))

ans = N - sorted(list(c(inclination).items()), key=lambda x: x[1])[-1][1]
print(ans)