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

Fixed submission:
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
b = [0, 1]
c = []
ans = 1

for _ in range(n):
    b.append(b[-1] + b[-2])

if m == 0:
    ans = b[n + 1]
else:
    c.append(a[0])
    for i in range(m - 1):
        c.append(a[i + 1] - a[i] - 1)
    c.append(n - a[m - 1])

    for i in c:
        ans *= b[i]

print(ans % 1000000007)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
b = [0, 1]
c = []
ans = 1

for _ in range(n):
    b.append(b[-1] + b[-2])

c.append(a[0])
for i in range(m - 1):
    c.append(a[i + 1] - a[i] - 1)
c.append(n - a[m - 1])

for i in c:
    ans *= b[i]

print(ans % 1000000007)
Problem p03038 (python)

Fixed submission:
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
l = sorted([list(map(int, input().split())) for _ in range(m)], key=lambda x:x[1], reverse=True)

res = 0
pos_1 = 0
pos_2 = 0
for _ in range(n):
    if pos_2 == m or a[pos_1] > l[pos_2][1]:
        res += a[pos_1]
        pos_1 += 1
    else:
        res += l[pos_2][1]
        l[pos_2][0] -= 1
        if l[pos_2][0] == 0:
            pos_2 += 1

print(res)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
b = [0] * m
c = [0] * m
ans = 0
flag = False
for i in range(m):
    b[i], c[i] = map(int, input().split())

for _ in range(n):
    ans += max(a[-1], max(c))
    if flag == False:
        cnt = b[c.index(max(c))]
    if a[-1] > max(c):
        a.pop()
    else:
        flag = True
        cnt -= 1
        if cnt == 0:
            del b[c.index(max(c))]
            del c[c.index(max(c))]
            flag = False
            

print(ans)
Problem p03137 (python)

Fixed submission:
n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))
dif = []
pos = []
ans = 0

if n >= m:
    print(0)
elif n == 1:
    print(x[-1] - x[0])
else:
    for i in range(m - 1):
        dif.append([x[i + 1] - x[i], i])

    dif.sort(reverse = True)

    for i in range(n - 1):
        pos.append(dif[i][1])

    pos.sort()

    ans += x[pos[0]] - x[0]
    for i in range(n - 2):
        ans += x[pos[i + 1]] - x[pos[i] + 1]
    ans += x[m - 1] - x[pos[-1] + 1]

    print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))
dif = []
pos = []
ans = 0

if n >= m:
    print(0)
else:
    for i in range(m - 1):
        dif.append([x[i + 1] - x[i], i])

    dif.sort(reverse = True)

    for i in range(n - 1):
        pos.append(dif[i][1])

    pos.sort()

    ans += x[pos[0]] - x[0]
    if n > 1:
        for i in range(n - 2):
            ans += x[pos[i + 1]] - x[pos[i] + 1]
    ans += x[m - 1] - x[pos[-1] + 1]

    print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))
dif = []
pos = []
ans = 0

if n >= m:
    print(0)
else:
    for i in range(m - 1):
        dif.append([x[i + 1] - x[i], i])

    dif.sort(reverse = True)

    for i in range(n - 1):
        pos.append(dif[i][1])

    pos.sort()

    ans += x[pos[0]] - x[0]
    for i in range(n - 2):
        ans += x[pos[i + 1]] - x[pos[i] + 1]
    ans += x[m - 1] - x[pos[-1] + 1]

    print(ans)

Buggy submission (verdict: Runtime Error):
import sys

n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))
dif = []
pos = []
ans = 0

if n >= m:
    print(0)
    sys.exit(1)

for i in range(m - 1):
    dif.append([x[i + 1] - x[i], i])

dif.sort(reverse = True)

for i in range(n - 1):
    pos.append(dif[i][1])

pos.sort()

ans += x[pos[0]] - x[0]
for i in range(n - 2):
    ans += x[pos[i + 1]] - x[pos[i] + 1]
ans += x[m - 1] - x[pos[-1] + 1]

print(ans)
Problem p03208 (python)

Fixed submission:
n, k = map(int, input().split())
h = sorted([int(input()) for _ in range(n)])
ans = 1000000000

for i in range(n - k + 1):
    ans = min(ans, h[i + k - 1] - h[i])

print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = sorted([int(input()) for _ in range(n)])
ans = 1000000000

for i in range(n - k + 1):
    ans = min(ans, h[i + k - 11] - h[i])

print(ans)
Problem p03242 (python)

Fixed submission:
n = input()
m = []

for i in range(len(n)):
    if n[i] == "1":
        m.append(9)
    else:
        m.append(1)
for i in m:
    print(i, end = '')

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

for i in range(len(n)):
    if n[i] == '1':
        n[i] = '9'
    else:
        n[i] = '1'

print(n)
Problem p03634 (python)

Fixed submission:
from heapq import heappush, heappop

def dijkstra(s):
    '''
    始点sから各頂点への最短距離を求める
    '''
    d = [float("inf")] * n
    d[s] = 0
    used = [False] * n
    used[s] = True
    edgelist = []

    for e in edge[s]:
        heappush(edgelist, e)

    while edgelist:
        cost, v = heappop(edgelist)
        if used[v]:
            continue
        d[v] = cost
        used[v] = True
        for e in edge[v]:
            if not used[e[1]]:
                heappush(edgelist, [e[0] + d[v], e[1]])

    return d


n = int(input())

edge = [[] for _ in range(n)]
for _ in range(n-1):
    a, b, c = map(int, input().split())
    edge[a-1].append([c, b-1])
    edge[b-1].append([c, a-1])

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

dist = dijkstra(k-1)

res = [0] * q
for i in range(q):
    x, y = map(int, input().split())
    res[i] = dist[x-1] + dist[y-1]

for v in res:
    print(v)

Buggy submission (verdict: Runtime Error):
def dfs(v, p, d):
    dist[v] = d
    for c, cost in edge[v]:
        if c == p:
            continue
        dfs(c, v, d + cost)


n = int(input())

edge = [[] for _ in range(n)]
for _ in range(n-1):
    a, b, c = map(int, input().split())
    edge[a-1].append([b-1, c])
    edge[b-1].append([a-1, c])

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

dist = [0] * n
dfs(k-1, -1, 0)

res = [0] * q
for i in range(q):
    x, y = map(int, input().split())
    res[i] = dist[x-1] + dist[y-1]

for v in res:
    print(v)
Problem p02659 (python)

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

print((a*b)//100)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
b = 100*b
print((a*b)//100)
Problem p02793 (python)

Fixed submission:
import math

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

def gcd(x,y):
    return x if y == 0 else gcd(y,x%y)

def lcm(x,y):
    return (x*y)//gcd(x,y)

now_lcm = a[0]
for i in range(n):
    now_lcm = lcm(now_lcm,a[i])

ans = 0
for e in a:
    ans += now_lcm//e

print(int(ans%(10**9+7)))

Buggy submission (verdict: Runtime Error):
import math

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

def gcd(x,y):
    return x if y == 0 else gcd(y,x%y)

def lcm(x,y):
    return (x*y)//gcd(x,y)

now_lcm = a[0]
for i in range(n-1):
    now_lcm = lcm(now_lcm,a[i+1])

mod = 1e9+7
ans = 0
for e in a:
    ans = ((ans%mod) + ((now_lcm//e)%mod))%mod

print(int(ans))
Problem p02831 (python)

Fixed submission:
def gcd(x,y):
  return x if y==0 else gcd(y,x%y)

def lcm(x,y):
  return (x*y)//gcd(x,y)

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

print(lcm(a,b))

Buggy submission (verdict: Runtime Error):
def gcd(x,y):
  return x if y=0 else gcd(y,x%y)

def lcm(x,y):
  return (x*y)/gcd(x,y)

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

print(lcm(a,b))
Problem p02860 (python)

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

n //= 2
if s[:n] == s[n:]:
  print("Yes")
else:
  print("No")

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

n /= 2
if s[:n] == s[n:]:
  print("Yes")
else:
  print("No")

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

n /= 2;
if s[:n] == s[n:]:
  print("Yes")
else:
  print("No")
Problem p02897 (python)

Fixed submission:
n = int(input())

d = n//2
print((n-d)/n)

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

d = n//2
print((n-d)/d)
Problem p02935 (python)

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

arr.sort()

prev = arr[0]

for i in range(n-1):
  prev = (prev+arr[i+1])/2
  
print(prev)

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

arr.sort()

prev = arr[0]

for i in range(n-1)
  prev = (prev+arr[i+1])/2
  
print(prev)
Problem p02550 (python)

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

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

ls = []
s = set([])

a = X
s.add(a)
ls.append(a)
ind = -1
new_ls = []

while True:
    a = pow(a, 2, M)

    if a in s:
        ind = ls.index(a)
        break
    elif len(ls) == N:
        break
    else:
        s.add(a)
        ls.append(a)

if ind != -1:
    new_ls = ls[ind:len(ls)]

ans = sum(ls)

if len(new_ls) != 0:
    ans += sum(new_ls) * (max(0, (N - len(ls))) // len(new_ls))

    tmp = max(0, (N - len(ls))) % len(new_ls)

    if tmp != 0:
        for i in range(tmp):
            ans += new_ls[i % len(new_ls)]

print(ans)

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

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

ls = []
s = set([])

a = X
s.add(a)
ls.append(a)

while True:
    a = pow(a, 2, M)

    if a in s:
        ind = ls.index(a)
        break
    elif len(ls) == N:
        break
    else:
        s.add(a)
        ls.append(a)

new_ls = ls[ind:len(ls)]

ans = sum(ls)

if len(new_ls) != 0:
    ans += sum(new_ls) * (max(0, (N - len(ls))) // len(new_ls))

    tmp = max(0, (N - len(ls))) % len(new_ls)

    if tmp != 0:
        for i in range(tmp):
            ans += new_ls[i % len(new_ls)]

print(ans)

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

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

ls = []
s = set([])

a = X
s.add(a)
ls.append(a)

while True:
    a = pow(a, 2, M)

    if a in s:
        ind = ls.index(a)
        break
    elif len(ls) == N:
        break
    else:
        s.add(a)
        ls.append(a)

new_ls = ls[ind:len(ls)]

ans = sum(new_ls) * (max(0, (N - len(ls))) // len(new_ls)) + sum(ls)

tmp = max(0, (N - len(ls))) % len(new_ls)

if tmp != 0:
    for i in range(tmp):
        ans += new_ls[i % len(new_ls)]

print(ans)
Problem p02951 (python)

Fixed submission:
A, B, C = map(int, input().split())
if A - B >= C:
    print(0)
else:
    print(C - A + B)

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if A - B >= C:
　　print(0)
else:
　　print(C - A + B)
Problem p03045 (python)

Fixed submission:
import sys

# 再帰上限の変更(デフォルトは1000)
# 大きくしすぎるとREするらしい
sys.setrecursionlimit(10 ** 9)

N, M = map(int, input().split())
XYZ = [list(map(int, input().split())) for i in range(M)]

# XがわかればYがわかるので、あるAiがわかったときどこまでわかるか?をグラフにしてDFSで探索

graph = [[]for i in range(N + 1)]

seen = [0] * (N + 1)

for X, Y, Z in XYZ:
    graph[X].append(Y)
    graph[Y].append(X)


def dfs(a):
    if seen[a] == 1:
        return
    else:
        seen[a] = 1
        for i in graph[a]:
            dfs(i)


ans = 0

for i in range(1, N + 1):
    if seen[i] == 1:
        continue
    else:
        dfs(i)
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import sys

# 再帰上限の変更(デフォルトは1000)
sys.setrecursionlimit(10 ** 20)

N, M = map(int, input().split())
XYZ = [list(map(int, input().split())) for i in range(M)]

# XがわかればYがわかるので、あるAiがわかったときどこまでわかるか?をグラフにしてDFSで探索

graph = [[]for i in range(N + 1)]

seen = [0] * (N + 1)

for X, Y, Z in XYZ:
    graph[X].append(Y)
    graph[Y].append(X)


def dfs(a):
    if seen[a] == 1:
        return
    else:
        seen[a] = 1
        for i in graph[a]:
            dfs(i)


ans = 0

for i in range(1, N + 1):
    if seen[i] == 1:
        continue
    else:
        dfs(i)
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import sys

# 再帰上限の変更(デフォルトは1000)
sys.setrecursionlimit(10 ** 100)

N, M = map(int, input().split())
XYZ = [list(map(int, input().split())) for i in range(M)]

# XがわかればYがわかるので、あるAiがわかったときどこまでわかるか?をグラフにしてDFSで探索

graph = [[]for i in range(N + 1)]

seen = [0] * (N + 1)

for X, Y, Z in XYZ:
    graph[X].append(Y)
    graph[Y].append(X)


def dfs(a):
    if seen[a] == 1:
        return
    else:
        seen[a] = 1
        for i in graph[a]:
            dfs(i)


ans = 0

for i in range(1, N + 1):
    if seen[i] == 1:
        continue
    else:
        dfs(i)
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
from sys import setrecursionlimit

# 再帰上限の変更(デフォルトは1000)
setrecursionlimit(10 ** 100)

N, M = map(int, input().split())
XYZ = [list(map(int, input().split())) for i in range(M)]

# XがわかればYがわかるので、あるAiがわかったときどこまでわかるか?をグラフにしてDFSで探索

graph = [[]for i in range(N + 1)]

seen = [0] * (N + 1)

for X, Y, Z in XYZ:
    graph[X].append(Y)
    graph[Y].append(X)


def dfs(a):
    if seen[a] == 1:
        return
    else:
        seen[a] = 1
        for i in graph[a]:
            dfs(i)


ans = 0

for i in range(1, N + 1):
    if seen[i] == 1:
        continue
    else:
        dfs(i)
        ans += 1

print(ans)

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

graph = [[]for i in range(N + 1)]

seen = [0] * (N + 1)

for X, Y, Z in XYZ:
    graph[X].append(Y)
    graph[Y].append(X)


def dfs(a):
    if seen[a] == 1:
        return
    else:
        seen[a] = 1
        for i in graph[a]:
            dfs(i)


ans = 0

for i in range(1, N + 1):
    if seen[i] == 1:
        continue
    else:
        dfs(i)
        ans += 1

print(ans)
Problem p02547 (python)

Fixed submission:
n = int(input())
count = 0
ans = 'No'
for i in range(n):
  a,b = map(int, input().split())
  if a == b:
    count += 1
  else:
    count = 0
  if count >= 3:
    ans = 'Yes'
    break
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
count = 0
ans = 0
for i in range(n):
  a,b = map(int, input().split())
  if  a == b:
    count += 1
  else:
    count = 0
  if count >= 3:
    ans = 1
    break
if ans = 1:
  print('Yes')
else:
  print('No')
Problem p02693 (python)

Fixed submission:
k = int(input())
a,b = map(int, input().split())
flag = 0
for i in range(a,b+1):
  if i % k == 0:
    flag = 1
    break
if flag == 1:
  print('OK')
else:
  print('NG')

Buggy submission (verdict: Runtime Error):
k = int(input())
a,b = map(int, input().split())
flag = 0
for i in range(a,b+1):
  if i % k == 0:
    flag = 1
    break
if flag = 1:
  print('OK')
else:
  print('NG')
Problem p02793 (python)

Fixed submission:
import fractions

mod = 10**9 + 7;

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

l = 1
for i in A:
  l = l * i // fractions.gcd(l, i)

sum = 0
for i in A:
  sum += l // i

print(sum % mod)

Buggy submission (verdict: Runtime Error):
import fractions

mod = 1e9 + 7;

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

l = 1
for i in A:
  l = l * i // fractions.gcd(l, i)

sum = 0
for i in A:
  sum += l // i

print(sum % mod)

Buggy submission (verdict: Runtime Error):
import fractions

mod = 1e9 + 7;

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

l = 1
for i in A:
  l = l * i // fractions.gcd(l, i)

sum = 0
for i in A:
  sum += l // i

print(int(sum % mod))

Buggy submission (verdict: Runtime Error):
import fractions

mod = 1e9 + 7;

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

l = A[0]
for i in range(1, N):
  l = l * A[i] // fractions.gcd(l, A[i])

sum = 0
for i in A:
  sum += l / i

print(int(sum % mod))

Buggy submission (verdict: Runtime Error):
import fractions

mod = 1e9 + 7;

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

l = A[0]
for i in range(1, N):
  l = l * A[i] // fractions.gcd(l, A[i])

sum = 0
for i in A:
  sum += l / i
  sum %= mod

print(int(sum))

Buggy submission (verdict: Runtime Error):
mod = 1e9 + 7;

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

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

l = A[0]
ll = l
for i in range(1, N):
  l = l * A[i] // gcd(l, A[i])
  if ll > l:
    break
  ll = l

sum = 0
for i in A:
  sum += l / i
  sum %= mod

print(int(sum))

Buggy submission (verdict: Runtime Error):
mod = 1e9 + 7;

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

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

l = A[0]
for i in range(1, N):
  l = l * A[i] // gcd(l, A[i])

sum = 0
for i in A:
  sum += l / i
  sum %= mod

print(int(sum))
Problem p03291 (python)

Fixed submission:
MOD = 10**9 + 7
p3 = [1]

S = input()
n = len(S)

a = []
c = []
q = []
for i in range(n):
  p3.append(int(p3[i] * 3 % MOD))
  if S[i] == 'A':
    a.append(1)
  else:
    a.append(0)
  if S[i] == 'C':
    c.append(1)
  else:
    c.append(0)
  if S[i] == '?':
    q.append(1)
  else:
    q.append(0)

for i in range(1, n):
  a[i] += a[i - 1]
  c[i] += c[i - 1]
  q[i] += q[i - 1]

count = 0
for i in range(1, n - 1):
  if S[i] == 'B' or S[i] == '?':
    bq = 0 if S[i] == 'B' else 1
    count += a[i - 1] * (c[n - 1] - c[i]) * p3[q[n - 1] - bq]
    count += q[i - 1] * (c[n - 1] - c[i]) * p3[q[n - 1] - 1 - bq]
    count += a[i - 1] * (q[n - 1] - q[i]) * p3[q[n - 1] - 1 - bq]
    count += q[i - 1] * (q[n - 1] - q[i]) * p3[q[n - 1] - 2 - bq]

print(int(count % MOD))

Buggy submission (verdict: Runtime Error):
MOD = 1e9 + 7
p3 = [1]

S = input()
n = len(S)

a = []
c = []
q = []
for i in range(n):
  p3.append(int(p3[i] * 3))
  if S[i] == 'A':
    a.append(1)
  else:
    a.append(0)
  if S[i] == 'C':
    c.append(1)
  else:
    c.append(0)
  if S[i] == '?':
    q.append(1)
  else:
    q.append(0)

for i in range(1, n):
  a[i] += a[i - 1]
  c[i] += c[i - 1]
  q[i] += q[i - 1]

count = 0
for i in range(1, n - 1):
  if S[i] == 'B' or S[i] == '?':
    bq = 0 if S[i] == 'B' else 1
    count += a[i - 1] * (c[n - 1] - c[i]) * p3[q[n - 1] - bq]
    count %= MOD
    count += q[i - 1] * (c[n - 1] - c[i]) * p3[q[n - 1] - 1 - bq]
    count %= MOD
    count += a[i - 1] * (q[n - 1] - q[i]) * p3[q[n - 1] - 1 - bq]
    count %= MOD
    count += q[i - 1] * (q[n - 1] - q[i]) * p3[q[n - 1] - 2 - bq]
    count %= MOD
    

print(int(count))
Problem p02578 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = []
c = 0
for i in range(1,n):
    c = max(c,a[i-1])
    s = c-a[i]
    if s >= 0:
        b.append(s) 
print(sum(b))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = []
c = 0
for i in range(1,n):
    s = a[i-1]-a[i]
    if s >= 0:
        s = s+c 
        b.append(s)
        c = max(c,s)
    else:
        c = 0
        b.append(c)
print(sum(b)
Problem p02594 (python)

Fixed submission:
x = int(input())
if x >= 30:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
x = input()
if x >= 30:
    print('Yes')
else:
    print('No')
Problem p02676 (python)

Fixed submission:
K = int(input())
S = input()
if len(S) <= K:
    print(S)
else:
    print(S[:K] + '...')

Buggy submission (verdict: Runtime Error):
K = int(input())
S = input()
if S(len) < K:
    print(S)
else:
    print(S[:K] + '...')
Problem p02729 (python)

Fixed submission:
n, m = list(map(int, input().split()))
# 偶数 ＋　奇数
print(n * (n - 1) // 2 + m * (m - 1) // 2  )

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split()))
# 偶数 ＋　奇数
print(n * (n - 1) // 2 + m * (m - 1) // 2  )
Problem p02753 (python)

Fixed submission:
s = input()
if s == 'AAA'or s == 'BBB':
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
s = input()
if s == 'AAA' and S == 'BBB':
    print('No')
else:
    print('Yes')
Problem p02819 (python)

Fixed submission:
x = int(input())
while True:
    for i in range(2,x):
        if x%i == 0:
            break
    else:
        print(x)
        break
    x+= 1

Buggy submission (verdict: Runtime Error):
from sympy import isprime
n = int(input())
if isprime(n) == True:
    print(n)
else:
    print(sympy.nextprime(n))

Buggy submission (verdict: Runtime Error):
x = int(input())
while True:
    for i in range(2,x):
        if x%i == 0
        break
    else:
        print(x)
        break
    x+=1
Problem p03042 (python)

Fixed submission:
s = input()
a = 1<= int(s[:2]) <=12
b = 1<= int(s[2:]) <=12
if a and b:
    print("AMBIGUOUS")
elif a:
    print('MMYY')
elif b:
    print('YYMM')
else:
    print('NA')

Buggy submission (verdict: Runtime Error):
s = input()
a = 1<= int(s[:2]) <=12
b = 1<= int(s[2:]) <=12
if a and b:
    print("AMBIGUOUS")
elif a:
    print('MMYY')
elif b:
    print('YYMM')
else:
    print('NA')
Problem p03345 (python)

Fixed submission:
a,b,c,k=map(int,input().split())
print((-1)**k*(a-b))

Buggy submission (verdict: Runtime Error):
print((-1)**k*(a-b))

Buggy submission (verdict: Runtime Error):
print((-1)**k*(a-b))
Problem p03723 (python)

Fixed submission:
a,b,c=map(int,input().split())
d=0
if a==b==c and a%2==0:
    print(-1)
else:
    while a%2==0 and b%2==0 and c%2==0:
        a,b,c=(b+c)//2,(a+c)//2,(a+b)//2
        d+=1
    print(d)

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if a==b==c and a%2==0:
    print(-1)
d=0
else:
    while a%2==0 and b%2==0 and c%2==0:
        a,b,c=(b+c),(a+c),(a+b)
        d+=1
print(d)
Problem p02595 (python)

Fixed submission:
import math

def dist(x,y):
  return math.sqrt(x**2+y**2)

n,d=map(int,input().split())
i=0
for _ in range(n):
  x,y=map(int,input().split())
  if dist(x,y)<=d:
    i+=1
    
print(i)

Buggy submission (verdict: Runtime Error):
import math
def dist(x,y):
  return math.sqrt(x**2+y**2)

n,d=map(int,input().split())
i=0
for _ in range(d):
  x,y=map(int,input().split())
  if dist(x,y)<=d:
    i+=1
print(i)
Problem p02598 (python)

Fixed submission:
n,k=map(int,input().split())
A=[int(i) for i in input().split()]


def f(i):
    if i<=0: return False
    if i>= 10**9: return True
    x = sum([(a-1)//i for a in A])
    if x<=k:
        return True
    else:
        return False
l=-1
r=10**9
while r-l>1:
    m = (l+r)//2
    if f(m):
        r=m
    else:
        l=m
    #print(l,m,r)
print(r)

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


def f(i):
    if i<0: return True
    if i>= 10**9: return False
    x = sum([(a-1)//i for a in A])
    if x<=k:
        return True
    else:
        return False
l=-1
r=10**9
while r-l>1:
    m = (l+r)//2
    if f(m):
        r=m
    else:
        l=m
    #print(l,m,r)
print(r)

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


def f(A,i):
    return sum([(a-1)//i for a in A])
l=-1
r=10**9+1
while r-l>1:
    m = (l+r)//2
    #print(m)
    x = f(A,m)
    if x<=k:
        r=m
    else:
        l=m
    #print(x,k,l,r,m)
print(m)
Problem p02685 (python)

Fixed submission:
class Combination():
    def __init__(self, n, mod):
        self.n = n
        self.mod = mod
        self.fact = self.make_fact(n)
        self.fact_inv = self.make_fact_inv(n)
    def make_fact(self, n):#0~nの階乗を求める
        res = [1]*(n+1)
        for i in range(1, n+1):
            res[i] = res[i-1]*i%self.mod
        return res
    def make_fact_inv(self, n):#0~nの階乗のmodに関する逆元を求める
        fact_inv = [1]*(n+1)
        fact_inv[n] = pow(self.fact[n], self.mod-2, self.mod)#フェルマーの小定理
        for i in range(n, 0, -1):
            fact_inv[i-1] = fact_inv[i]*i%self.mod
        return fact_inv
    def comb(self, m, k):
        return self.fact[m]*self.fact_inv[k]*self.fact_inv[m-k]%self.mod
    


lim=998244353
n,m,k=map(int,input().split())

#n,m,k = 60522, 114575, 7559
sum_ = 0
comb=Combination(n,lim)
for j in range(k+1):
    ans = m %lim
    #print(m-j-1,n,j)
    ans = (ans *pow(m-1,n-j-1,lim)) % lim
    ans = (ans * comb.comb(n-1,j)) % lim
    #print(ans)
    sum_ = (sum_+ans) % lim
print(sum_)

Buggy submission (verdict: Runtime Error):
lim=998244353
n,m,k=map(int,input().split())
def f(n,k):
    ans = m %lim
    ans = (ans *pow(m-1,n-k-1,lim)) % lim
    ans = (ans * comb(n-1,k,lim)) % lim
    return ans

#n,m,k = 60522, 114575, 7559
sum_ = 0
for j in range(k+1):
    ans = m %lim
    #print(m-j-1,n,j)
    ans = (ans *pow(m-1,n-j-1,lim)) % lim
    ans = (ans * comb(n-1,j,lim)) % lim
    #print(ans)
    sum_ = (sum_+ans) % lim
print(sum_)