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

Fixed submission:
# python template for atcoder1
from functools import reduce
from math import log2
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def floor(x, y):
    return int((-x)//y*(-1))


def floorlog(x):
    if x > 0:
        return floor(log2(x), 1)
    else:
        return 0


def XXor(X, A):
    #    print("x,a->", X, A)
    return X ^ A


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


def xorSum(X):
    ret = 0
    for a in A:
        ret += XXor(X, a)
    return ret


def solve():

    ans = 0
    ans_x = 0
    for x in range(K+1):
        tmp = xorSum(x)
        if tmp > ans:
            ans = tmp
            ans_x = x
    # print("ans_x->", ans_x)

    return ans


def solve2():
    ans = 0
    for i in reversed(range(0, 40)):
        b = sum([(a >> i) % 2 for a in A])*2 < N
        if b and ans+(1 << i) <= K:
            ans += (1 << i)
        else:
            continue
    return xorSum(ans)


print(solve2())

Buggy submission (verdict: Runtime Error):
# python template for atcoder1
from functools import reduce
from math import log2
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def floor(x, y):
    return int((-x)//y*(-1))


def floorlog(x):
    if x > 0:
        return floor(log2(x), 1)
    else:
        return 0


def XXor(X, A):
    #    print("x,a->", X, A)
    return X ^ A


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


def xorSum(X):
    ret = 0
    for a in A:
        ret += XXor(X, a)
    return ret


def solve():

    ans = 0
    ans_x = 0
    for x in range(K+1):
        tmp = xorSum(x)
        if tmp > ans:
            ans = tmp
            ans_x = x
    # print("ans_x->", ans_x)

    return ans


def solve2():
    a = sorted(A, reverse=True)
    ans = reduce(XXor, a)
    k_log = floorlog(K)
    a_log = floorlog(a[0])
    if k_log == a_log:
        ans = ans
    else:
        a.ppend(K)
        ans = reduce(XXor, a)

    return xorSum(ans)


# print("1---->", solve())
# print("2----->", solve2())
print(solve2())
Problem p03148 (python)

Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, K = map(int, input().split())
sushis = [list(map(int, input().split())) for _ in range(N)]

sushis = sorted(sushis, key=lambda x: (x[1], x[0]), reverse=True)

p = 0


def calcPoint(selected_sushis):
    p = 0
    vari = set()
    for i, v in selected_sushis:
        vari.add(i)
        p += v
    p += len(vari)**2
    return p, vari


selected = sushis[:K]
unSelected = sushis[K:]

p, vari = calcPoint(selected)
cand = [p]

va = len(vari)
v = [0]*(N+1)
for i, _ in selected:
    v[i] += 1

can_del = []
for i, d in reversed(selected):
    if v[i] >= 2:
        v[i] -= 1
        can_del.append(d)

can_in = []
for i, d in unSelected:
    if not i in vari:
        vari.add(i)
        can_in.append(d)

#print("del->", can_del, can_in)
for od, nd in zip(can_del, can_in):
    nextp = p-od+nd-(va)**2+(va+1)**2
    p = nextp
    cand.append(p)
    va += 1
print(max(cand))

Buggy submission (verdict: Runtime Error):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, K = map(int, input().split())
sushis = [list(map(int, input().split())) for _ in range(N)]

sushis = sorted(sushis, key=lambda x: (x[1], x[0]), reverse=True)

p = 0


def calcPoint(selected_sushis):
    p = 0
    vari = set()
    for i, v in selected_sushis:
        vari.add(i)
        p += v
    p += len(vari)**2
    return p, vari


selected = sushis[:K]
unSelected = sushis[K:]

p, vari = calcPoint(selected)
cand = [p]

va = len(vari)
v = [0]*(N+1)
for i, _ in selected:
    v[i] += 1

can_del = []
for i, v in reversed(selected):
    if vari[i] > 2:
        vari[i] -= 1
        can_del.append(v)

can_in = []
for i, v in unSelected:
    if not i in vari:
        vari.add(i)
        can_in.append(v)

for od, nd in zip(can_del, can_in):
    nextp = p-od+nd-(vari)**2+(vari+1)**2
    cand.append(nextp)
    vari += 1
print(max(cand))
Problem p03157 (python)

Fixed submission:
# https://atcoder.jp/contests/aising2019/submissions/3986315
# 解説のように 連結成分を求めてから、bfsする
import sys
sys.setrecursionlimit(2 * 10 ** 5)

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

ans = 0

dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]

un_reached = [[True for i in range(W)] for j in range(H)]


def isIn(x, y):
    return 0 <= x < H and 0 <= y < W


def dfs(x, y):
    un_reached[x][y] = False
    if s[x][y] == '#':
        cc[1] += 1
    else:
        cc[0] += 1

    for i in range(4):
        nx = x+dx[i]
        ny = y+dy[i]
        if isIn(nx, ny) and s[nx][ny] != s[x][y] and un_reached[nx][ny]:
            dfs(nx, ny)


for i in range(H):
    for j in range(W):
        if un_reached[i][j]:
            cc = [0 for _ in range(2)]
            dfs(i, j)
            ans += cc[1]*cc[0]
print(ans)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/aising2019/submissions/3986315
# 解説のように 連結成分を求めてから、bfsする

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

ans = 0

dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]

un_reached = [[True for i in range(W)] for j in range(H)]


def isIn(x, y):
    return 0 <= x < H and 0 <= y < W


def dfs(x, y):
    un_reached[x][y] = False
    if s[x][y] == '#':
        cc[1] += 1
    else:
        cc[0] += 1

    for i in range(4):
        nx = x+dx[i]
        ny = y+dy[i]
        if isIn(nx, ny) and s[nx][ny] != s[x][y] and un_reached[nx][ny]:
            dfs(nx, ny)


for i in range(H):
    for j in range(W):
        if un_reached[i][j]:
            cc = [0 for _ in range(2)]
            dfs(i, j)
            ans += cc[1]*cc[0]
print(ans)

Buggy submission (verdict: Runtime Error):
import copy
H, W = (list)(map(int, input().split()))
grid = [[lin for lin in input()] for _ in range(H)]

mat = [['&'] * (W+2) for _ in range(H+2)]
for row in range(1, H+1):
    for col in range(1, W+1):
        mat[row][col] = grid[row-1][col-1]


def search(x, row, col, mat):
    ran = [-1, 1]
    ret = []
    for i in ran:
        if mat[row+i][col] == x:
            ret.append([row+i, col])
        if mat[row][col+i] == x:
            ret.append([row, col+i])

    return ret


def bfs(row, col, mat):
    ret = 0
    mat[row][col] = '&'

    res = search('.', row, col, mat)

    ret += len(res)
    for cand in res:
        mat[cand[0]][cand[1]] = '&'

    for cand in res:
        res2 = search('#', cand[0], cand[1], mat)
        for cand2 in res2:
            res3 = bfs(cand2[0], cand2[1], mat)
            ret += res3
    return ret


ans = 0

for row in range(1, H+1):
    for col in range(1, W+1):
        if mat[row][col] == '#':
            mat_copy = copy.deepcopy(mat)
            ans += bfs(row, col, mat_copy)

print(ans)
Problem p03164 (python)

Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, W = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(N)]


def solve():
    MaxV = 10**3*N+1
    dp = [[float('inf')]*MaxV for _ in range(N+1)]
    dp[0][0] = 0

    for i in range(1, N+1):
        for v in range(MaxV):
            if items[i-1][1] <= v:
                dp[i][v] = min(dp[i-1][v], dp[i-1]
                               [v-items[i-1][1]]+items[i-1][0])
            else:
                dp[i][v] = dp[i-1][v]
    ans = 0
    for i, v in enumerate(dp[N]):
        if v <= W:
            ans = i

    print(ans)


solve()

Buggy submission (verdict: Runtime Error):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, W = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(N)]


def solve():
    dp = [[0]*(W+1) for _ in range(N+1)]

    # init
    # update
    for i in range(1, N+1):
        for w in range(W+1):
            if w-items[i-1][0] >= 0:
                dp[i][w] = max(dp[i-1][w], dp[i-1]
                               [w-items[i-1][0]]+items[i-1][1])
            else:
                dp[i][w] = dp[i-1][w]

    print(max(dp[N]))


def solve2():
    dp = [0]*(W+1)
    for i in range(N):
        for w in reversed(range(W+1)):  # revにしないと、更新済みの値を使って更新しちゃう
            if w-items[i][0] >= 0:
                dp[w] = max(dp[w], dp[w-items[i][0]]+items[i][1])
    print(dp[-1])


solve2()
Problem p03197 (python)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]

if all(v % 2 == 0 for v in A):
    print("second")
else:
    print("first")

Buggy submission (verdict: Runtime Error):
N=int(input())
L=list(map(int,input().split()))
if al(l%2==0 for l in L):
  print("second")
else:
  print("first")
Problem p03219 (python)

Fixed submission:
x,y = list(map(int,input().split()))
print(int(x+y/2))

Buggy submission (verdict: Runtime Error):
#M num of prefecture
#N num of city
N, M = map(int,input().split())
#P pref
#Y year
P=[]
Y=[]
cities=[]
for i in range(M):
    try:
        s = input()
        p,y = s.split()
        city=(p,y)
        cities.append(city) 
        P.append(p)
        Y.append(y)
    except:
        break

sort_city=sorted(cities,key=lambda x:(x[0],x[1]))
prefs = sorted(set(P))

address=[]
res=[]
for i in range(len(sort_city)): 
    address=str(sort_city[i][0]).rjust(6,'0')+str(i+1).rjust(6,'0')
    res.append((sort_city[i],address))

print(res[1][0])
for i in range(len(cities)):
    for j in range(len(res)):
        if cities[i] == res[j][0]:
            print(res[j][1])

Buggy submission (verdict: Runtime Error):
x,y = list(map(int,input().split())
print(x+y/2)
Problem p03239 (python)

Fixed submission:
n,t=list(map(int,input().split()))
l=[]
for i in range(n):
    l.append(tuple(map(int,input().split())))

l=sorted(l,key=lambda x:x[0])
for i in l:
    if i[1]<=t:
        print(i[0])
        exit()
print('TLE')

Buggy submission (verdict: Runtime Error):
n,t=list(map(int,input().split()))
l=[]
for i in range(n):
    l.append(tuple(map(int,input().split())))

l=sorted(l,key=lambda x:x[0])
for i in l:
    if i[1]<=t:
        print(i[0])
        exit(1)
print('TLE')
Problem p03240 (python)

Fixed submission:
n = (int)(input())

x = []
y = []
h = []

for _ in range(n):
    a, b, c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)

f = False
for i in range(0, 100+1):
    for j in range(0, 100+1):
        for k in range(n):
            if h[k] != 0:
                ch = h[k] + abs(i-x[k]) + abs(j-y[k])
                break
        if all(max(ch-abs(i-x[k]) - abs(j-y[k]), 0) == h[k] for k in range(n)):
            print(i, j, ch)
            exit()

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

x = []
y = []
h = []

for _ in range(n):
    a, b, c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)

for i in range(0, 100+1):
    for j in range(0, 100+1):
        tmp = [h[k] + abs(x[k]-i) + abs(y[k]-j) for k in range(n)]
        tmp.remove(0)
        if tmp.count(tmp[0]) == len(tmp) and len(set(tmp)) == 1:
            print(i, j, (lambda x: x if x >= 0 else 0)(tmp[0]))
            exit()

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

x = []
y = []
h = []

for _ in range(n):
    a, b, c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)

for i in range(0, 100+1):
    for j in range(0, 100+1):
        tmp = [h[k] + abs(x[k]-i) + abs(y[k]-j) for k in range(n)]
        tmp.rempe(0)
        if tmp.count(tmp[0]) == len(tmp) and len(set(tmp)) == 1:
            print(i, j, (lambda x: x if x >= 0 else 0)(tmp[0]))
            exit()
Problem p03241 (python)

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

upper = m//n
ans = 0
for i in range(1, upper+1):
    if m % i == 0:
        ans = i
        if (m // i) > i and (m // i) <= upper:
            ans = m // i
            break

print(ans)

Buggy submission (verdict: Runtime Error):
import math
n,m=list(map(int,input().split()))
lim=(int)(2*m/((n-1)*(n)))
for i in reversed(range(1,lim+2)):
    a=m%i
    b=m/i
    if a==0 and b>=n:
        x=(int)(n/3+1)
        for j in range(1,x):
            for k in range(1,x):
                for l in range(1,x):
                    if j+k+l==n:
                        print(j*2)
                        exit()

Buggy submission (verdict: Runtime Error):
import math
n,m=list(map(int,input().split()))
lim=(int)(2*m/((n-1)*(n)))
for i in reversed(range(1,lim+2)):
    a=m%i
    b=m/i
    print(i,a,b,n)
    if a==0 and b>=n:
        for j in range(1,(int)(n/3+1)):
            if(math.factorial(b-2)
                    /(math.factorial(n-j-1)*math.factorial(b-n+j-1))>0):
                print(j*i)
                exit()
Problem p03251 (python)

Fixed submission:
n,m,x,y=list(map(int,input().split()))
l_x=list(map(int,input().split()))
l_y=list(map(int,input().split()))
x_max=max(l_x)
y_min=min(l_y)
for i in range(x_max+1,y_min+1):
    if x<i<=y:
        print('No War')
        exit()
print('War')

Buggy submission (verdict: Runtime Error):
n,m,x,y=list(map(int,input().split()))
l_x=list(map(int,input().split()))
l_y=list(map(int,input().split()))
x_max=max(l_x)
y_max=min(l_y)
for i in range(x_max+1,y_min):
    if x<i<=y:
        print('No War')
        exit()
print('War')
Problem p03264 (python)

Fixed submission:
n=(int)(input())
if n%2==0:
    print((n//2)**2)
else:
    print((n//2)*(n//2+1))

Buggy submission (verdict: Runtime Error):
n = (int)(input())
l_o = [v for v in range(1,n+1,2)]
l_e = [v for v in range(2,n+1,2)]
return (len(l_o)*len(l_e))
Problem p03266 (python)

Fixed submission:
n, k = map(int, input().split())
print(sum([1 if v % k == 0 else 0 for v in range(1, n+1)])**3 +
      sum([1 if v % k == k/2 else 0 for v in range(1, n+1)])**3)

Buggy submission (verdict: Runtime Error):
import collections
n,k=list(map(int,input().split()))
l_n=[(v+1)%k for v in range(n)]
c = collections.Counter(l_n)
m = len(c)
ret=0
if k%2==0:
    for i in range(0,m,k/2):
        for j in range(0,m,k/2):
            if (i+j)%k==0:
                for r in range(0,r,k/2):
                    if(i+r)%k==0 and(r+j)%k==0:
                        ret+=c[i]*c[j]*c[r]
else:
    for i in range(0,m,k):
        for j in range(0,m,k):
            if (i+j)%k==0:
                for r in range(0,m,k):
                    if (i+r)%k ==0 and (r+j)%k==0:
                        ret+=c[i]*c[j]*c[r]
print(ret)
Problem p03282 (python)

Fixed submission:
s = input()
k = (int)(input())

c = 0
for ch in s:
  if not ch == '1':
    break
  c += 1
n = s[c] if c < len(s) else None
a = n if n and c < k else s[0]
print(a)

Buggy submission (verdict: Runtime Error):
s = input()
k = (int)(input())

c = 0
for ch in s:
  if not ch == '1':
    break
  c += 1
n = s[c] if c < len(s) else None
a = n if n and c < k else S[0]
print(a)

Buggy submission (verdict: Runtime Error):
s = input()
k = (int)(input())

c = 0
for ch in s:
  if not ch == '1':
    break
  c += 1
n = s[c] if c < len(S) else None
a = n if n and c < K else S[0]
print(a)

Buggy submission (verdict: Runtime Error):
s = input()
k = (int)(input())

c = 0
for c in s:
  if not c == '1':
    break
  c += 1
n = s[c] if c < len(S) else None
a = n if n and c < K else S[0]
print(a)

Buggy submission (verdict: Runtime Error):
s = input()
K = (int)(input())
k = K
for n in s:
  if n != '1':
    print(n)
    exit(1)
print('1')

Buggy submission (verdict: Runtime Error):
s = input()
K = (int)(input())
k = K
for n in s:
  if k == 0:
    break
  elif n == '1':
    k = k-1
  else:
    print(n)
    exit(1)
if k == 0:
  print(s[K-1])

Buggy submission (verdict: Runtime Error):
s = input()
k = (int)(input())

if k <= 5000000000000000:
  for n in s:
    if k == 0:
      print(n)
    elif n == '1':
      k = k-1
    else:
      print(n)

else:
  for n in s:
    if n == '1':
      k = k-1
    elif n == '2':
      if k >= 2ae0i0:
      else:
        print(n)
    else:
    print(n)
Problem p03287 (python)

Fixed submission:
from collections import Counter
N, M = (list)(map(int, input().split()))
A = (list)(map(int, input().split()))
A[0] %= M

for i in range(1, N):
    A[i] += A[i-1]
    A[i] %= M

ans = 0

C = Counter(A)
for num, val in C.items():
    if num == 0:
        ans += val
    if val >= 2:
        ans += val*(val-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
N, M = (list)(map(int, input().split()))
A = (list)(map(int, input().split()))
A[0] %= M

for i in range(1, N):
    A[i] += A[i-1]
    A[i] %= M

ans = 0

C = Counter(A)
for num, val in C:
    if num == 0:
        ans += val
    if val >= 2:
        ans += val*(val-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = (list)(map(int, input().split()))
A = (list)(map(int, input().split()))
Accum = [0]*(N+1)


def comb(n):
    if n >= 2:
        return n*(n-1)//2
    else:
        return 0


for i in range(N-1):
    Accum[i+1] = (Accum[i]+A[i+1]) % M

ans = 0
for i in range(M):
  	if i == 0:
      ans += Accum.count(i)
    else:
    	c = Accum.count(i)
    	ans += comb(c)
print(ans)
Problem p03290 (python)

Fixed submission:
d, g = map(int, input().split())
o, c = zip(*[map(int, input().split()) for _ in range(d)])

comp = [(i+1)*o[i]+c[i]//100 for i in range(d)]

G = g//100

# 大きい数（全問解く)
ans = sum(o)

for j in range(2**d):
    tmp = bin(j)
    ope = tmp[2:len(tmp)].zfill(d)

    now = 0  # 得点
    f = 1
    num = 0  # 問題数
    re = [[0, 0]]  # とかなかった問題の配列

    for i in range(d):
        if ope[i] == '1':
            now += comp[i]
            num += o[i]
        else:
            re.append([(i+1)*(o[i]-1), i+1])

        re.sort()
        re.reverse()

    if now < G:
        if now+re[0][0] < G:
            # 答えにならない
            now = sum(o)
            f = -1
        else:
            # 中途半端に解く問題数
            K = (G - now)//re[0][1]

            # 中途半端に解くときに、%==0ならちょうどgoalになるけど、それ以外の時は、ちょっとだけ点数が足りないから問題をもう一問解く
            if ((G-now) % re[0][1] > 0):
                K = K+1
            num += K
    if num < ans and f > 0:
        ans = num
print(ans)

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

comp = [(i+1)*o[i]+c[i]//100 for i in range(d)]

G = g//100

# 大きい数（全問解く)
ans = sum(o)

for j in range(2**d):
    tmp = bin(j)
    ope = tmp[2:len(tmp)].zfill(d)

    now = 0  # 得点
    f = 1
    num = 0  # 問題数
    re = [[0, 0]]  # とかなかった問題の配列

    for i in range(d):
        if ope[i] == '1':
            now += comp[i]
            num += o[i]
        else:
            re.append([(i+1)*(o[i]-1), i+1])

        re.sort()
        re.reverse()

    if now < G:
        if now+re[0][0] < G:
            # 答えにならない
            now = sum(p)
            f = -1
        else:
            # 中途半端に解く問題数
            K = (G - now)//re[0][1]

            # 中途半端に解くときに、%==0ならちょうどgoalになるけど、それ以外の時は、ちょっとだけ点数が足りないから問題をもう一問解く
            if (G % re[0][1] > 0):
                K = K+1
            num += K
    if num < ans and f > 0:
        ans = num
print(ans)

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

comp = [(i+1)*o[i]+c[i]//100 for i in range(d)]
print(o, c)
print(comp)

G = g//100

# 大きい数（全問解く)
ans = sum(o)

for j in range(2**d):
    tmp = bin(j)
    ope = tmp[2:len(tmp)].zfill(d)

    now = 0  # 得点
    f = 1
    num = 0  # 問題数
    re = [[0, 0]]  # とかなかった問題の配列

    for i in range(d):
        if ope[i] == '1':
            now += comp[i]
            num += o[i]
        else:
            re.append([(i+1)*(o[i]-1), i+1])

        re.sort()
        re.reverse()

    if now < G:
        if now+re[0][0] < G:
            # 答えにならない
            now = sum(p)
            f = -1
        else:
            # 中途半端に解く問題数
            K = (G - now)//re[0][1]

            # 中途半端に解くときに、%==0ならちょうどgoalになるけど、それ以外の時は、ちょっとだけ点数が足りないから問題をもう一問解く
            if (G % re[0][1] > 0):
                K = K+1
            num += K
    if num < ans and f > 0:
        ans = num
print(ans)
Problem p03292 (python)

Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

l = list(map(int, input().split()))

l = sorted(l, reverse=True)
print(sum(a-b for a, b in zip(l, l[1:])))

Buggy submission (verdict: Runtime Error):
from functools import reduce
n = (int)(input())
a = (list)(map(int, input().split()))


def calcMod(a, m):
  return sum([m % v for v in a])


def mul(a, b):
  return a*b


#print(calcMod(a, reduce(mul, a)-1))
print(sum(a)-n)
Problem p03294 (python)

Fixed submission:
from functools import reduce
n = (int)(input())
a = (list)(map(int, input().split()))


def gcd(a, b):
    # a>b
  while(b):
    c = a % b
    a = b
    b = c
  return a


def calcMod(a, m):
  return sum([m % v for v in a])


def lcm(a, b):
  return a*b/gcd(a, b)


def lcm_list(l):
  g = reduce(lcm, l)
  return g


def mul(a, b):
  return a*b


#print(calcMod(a, (int)(lcm_list(a)-1)))
print(calcMod(a, reduce(mul, a)-1))

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

# print(-(-(n-1)//(k-1)))
print((n+1 + (k - 2)) // (k-1))

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

# print(-(-(n-1)//(k-1)))
print((n + (k - 1)) // k)

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

# print(-(-(n-1)//(k-1)))
print((n + (k - 1)) / k)

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

# print(-(-(n-1)//(k-1)))
print((n + (k - 1)) / k

Buggy submission (verdict: Runtime Error):
from functools import reduce
n = (int)(input())
a = (list)(map(int, input().split()))


def calcMod(a, m):
  return sum([m % v for v in a])


def mul(a, b):
  return a*b


#print(calcMod(a, reduce(mul, a)-1))
print(sum(a)-N)

Buggy submission (verdict: Runtime Error):
from functools import reduce
n = (int)(input())
a = (list)(map(int, input().split()))
from functools import reduce
n = (int)(input())
a = (list)(map(int, input().split()))


def gcd(a, b):
    # a>b
  while(b):
    c = a % b
    a = b
    b = c
  return a


def calcMod(a, m):
  return sum([m % v for v in a])


def lcm(a, b):
  return a*b/gcd(a, b)


def lcm_list(l):
  g = reduce(lcm, l)
  return g


print(calcMod(a, (int)(lcm_list(a)-1)))
Problem p03304 (python)

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

if D == 0:
    print(1/N*(M-1))
else:
    print(2*(N-D)/N**2*(M-1))

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

if D == 0:
    print(1/N*(M-1))
else:
    print(2(N-D)/N**2*(M-1))

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

if D == 0:
    print(1/N*(M-1))
else:
    print(2(N-D)/N**2*(M-1))

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

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

if D == 0:
    print(1/N*(M-1))
else:
    print(2(N-D)/N**2*(M-1))
Problem p03316 (python)

Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)

N = input()
di = 0
for c in N:
    di += int(c)
if int(N) % di == 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)

N = input()
di = 0
for c in N:
    di += int(c)
if N % di == 0:
    print("Yes")
else:
    print("No")
Problem p03331 (python)

Fixed submission:
# python template for atcoder1
from math import log10
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

n = int(input())
ans = 0
l = log10(n)
if int(l) == l:
    ans = 10
else:
    while n > 0:
        ans += n % 10
        n //= 10
print(ans)

Buggy submission (verdict: Runtime Error):
from math import log10
n = int(input())
ans=0
l = log10(n)
if int(l)==l:
  ans=10
else:
  while n>0:
  ans+=n%10
  n//=10
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans=0
while n>0:
  n%10+=ans
  n//=10
print(ans)