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

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

N = int(input())
e = [[] for _ in range(N+1)]
for _ in range(N-1):
  u, v, w = map(int, input().split())
  e[u].append((v,w))
  e[v].append((u,w))

col = [-1 for _ in range(N+1)]
def dfs(x, c):
    col[x] = c
    for v, w in e[x]:
        if col[v] == -1:
            dfs(v, (c+w%2)%2)

dfs(1, 0)

for c in col[1:]:
    print(c)

Buggy submission (verdict: Runtime Error):
N = int(input())
e = [[] for _ in range(2*N+1)]
for _ in range(N-1):
  u, v, w = map(int, input().split())
  e[u].append((v,w))
  e[v].append((u,w))
col = [-1 for _ in range(2*N+1)]
def dfs(x, c):
    col[x] = c
    for v, w in e[x]:
        if col[v] == -1:
            dfs(v, (c+w%2)%2)
dfs(1, 0)
for c in col[1:N+1]:
    print(c)

Buggy submission (verdict: Runtime Error):
N = int(input())
e = [[] for _ in range(2*N)]
for _ in range(N-1):
  u, v, w = map(int, input().split())
  e[u].append((v,w))
  e[v].append((u,w))

col = [-1 for _ in range(2*N)]
def dfs(x, c):
    col[x] = c
    for v, w in e[x]:
        if col[v] == -1:
            dfs(v, (c+w%2)%2)

dfs(1, 0)

for c in col[1:]:
    print(c)

Buggy submission (verdict: Runtime Error):
N = int(input())
e = [[] for _ in range(N+1)]
for _ in range(N-1):
  u, v, w = map(int, input().split())
  e[u].append((v,w))
  e[v].append((u,w))

col = [-1 for _ in range(N+1)]
def dfs(x, c):
    col[x] = c
    for v, w in e[x]:
        if col[v] == -1:
            dfs(v, (c+w%2)%2)

dfs(1, 0)

for c in col[1:]:
    print(c)

Buggy submission (verdict: Runtime Error):
N = int(input())
e = [[] for _ in range(N+1)]
for _ in range(N-1):
  u, v, w = map(int, input().split())
  e[u].append((v,w))
  e[v].append((u,w))

col = [-1 for _ in range(N+1)]
def dfs(x, c):
    col[x] = c
    for v, w in e[x]:
        if col[v] == -1:
            dfs(v, c+w%2)

dfs(1, 0)

for c in col[1:]:
    print(c)
Problem p03148 (python)

Fixed submission:
from heapq import heappush, heappop

N, K = map(int, input().split())
h = []
for i in range(N):
  t, d = map(int, input().split())
  heappush(h, (-d, t))

# initial
res = 0
sum = 0
q = []
used = {}
for i in range(K):
  (d, t) = heappop(h)
  if t not in used:
    used[t] = 1
  else:
    heappush(q, (-d, t))
  sum += -d
res = len(used)*len(used)+sum

# swap minimum
while q and h:
  (d, t) = heappop(h)
  if t not in used:
    used[t] = 1
    m, _ = heappop(q)
    sum = sum - m - d
  res = max(res, len(used)*len(used) + sum)
  
print(res)

Buggy submission (verdict: Runtime Error):
from heapq import heappush, heappop

N, K = map(int, input().split())
h = []
for i in range(N):
  t, d = map(int, input().split())
  heappush(h, (-d, t))

# initial
res = 0
sum = 0
q = []
used = {}
for i in range(K):
  (d, t) = heappop(h)
  if t not in used:
    used[t] = 1
  else:
    heappush(q, (-d, t))
  sum += -d
res = len(used)*len(used)+sum

# swap minimum
while q:
  (d, t) = heappop(h)
  if t not in used:
    used[t] = 1
    m, _ = heappop(q)
    sum = sum - m - d
  res = max(res, len(used)*len(used) + sum)
  
print(res)
Problem p03194 (python)

Fixed submission:
N, P = map(int, input().split())
if N >= 40:
  print(1)
else:
  m = int(P**(1/N))+1
  while True:
    if P % m == 0:
      x = m**N
      if P % x == 0:
        break
    m -= 1
  print(m)

Buggy submission (verdict: Runtime Error):
N, P = map(int, input().split())
Y = [i for i in range(1,int(P**(1/N))+1) if P % i == 0]
m = int(P**(1/N))
while True:
  if P % m == 0:
    x = m**N
    if P % x == 0:
      if P / x in Y:
        break
  m -= 1
print(m)

Buggy submission (verdict: Runtime Error):
N, P = map(int, input().split())
Y = [i for i in range(1,int(P**(1/N))+1) if P % i == 0]
m = int(P**(1/N))
while True:
  if P % m == 0:
    x = m**N
    if P % x == 0 and P / x in Y:
      break
  m -= 1
print(m)
Problem p02658 (python)

Fixed submission:
n = int(input())
b = input()
a = [int(i) for i in b.split()]

ans = 1
for i in range(n):
    if a[i] == 0 : 
        ans = 0
        break

if ans :
    for i in range(n):
        ans *= a[i];
        if ans > 1000000000000000000 :
            ans = -1
            break
        
print(ans)

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

ans = 1
for i in range(n):
    if a[i] == 0 : 
        ans = 0
        break

if ans :
    for i in range(n):
        ans = ans * a[i];
        if ans > 1000000000000000000 :
            ans = -1
            break
        
print(ans)
Problem p02658 (python)

Fixed submission:

n=int(input())
l1=list(map(int,input().split()))
p=1
k=0
if 0 in l1:
  print("0")
  exit()
for i in range(n):
  p*=l1[i]
  if p>10**18:
    k=1
    break
if k==1:
  print("-1")
else:
  print(p)

Buggy submission (verdict: Runtime Error):
331import math
l1=list(map(int,input().split()))
a=math.prod(l1)
if a>10**18:
  print("-1")
else:
  print(a)

Buggy submission (verdict: Runtime Error):
import prod
l1=list(map(int,input().split()))
a=math.prod(l1)
if a>=10**18:
  print("-1")
esle:
  print(a)
Problem p03161 (python)

Fixed submission:
import math
 
def solve(a,n,k):
  dp = [0]*(n)
  dp[0]=0
  inf = 10**9
  for i in range(1,n):
    dp[i]=inf
    r=max(0,i-k)
    dp[i]=min([abs(a[i]-a[j])+dp[j] for j in range(r,i)])
 
  #print(dp)
  return dp[-1]
n,k=map(int,input().split())
a=list(map(int,input().split()))
print(solve(a,n,k))

Buggy submission (verdict: Runtime Error):
import math

def solve(a,n,k):
  dp = [0]*(n)
  dp[0]=0
  inf = 10**9
  for i in range(1,n):
    dp[i]=inf
    r=max(0,i-k)
    dp[i]=min([abs(a[i]-a[j])+dp[j] for j in range(r,i)])

  #print(dp)
  return dp[-1]
n,k=map(int,input().split())
a=list(map(int,input().split()))
print(solve(a,n,k))
DP[i]=min([abs(h[i]-h[j])+DP[j] for j in range(r,i)])
Problem p02730 (python)

Fixed submission:
S = input()
N = len(S)

flag = True

for i in range(int(len(S)/2)):
  if S[i]!=S[-1-i]:
    flag = False
    break

if flag==True:
  right = int((N-1) / 2)
  subS = S[0:right]
  for i in range(int(len(subS)/2)):
    if subS[i]!=subS[-1-i]:
      flag = False
      break

if flag==True:
  left = int((N+3) / 2)
  subS = S[left-1:N]
  for i in range(int(len(subS)/2)):
    if subS[i]!=subS[-1-i]:
      flag = False
      break

if flag:
  print("Yes")
else:
  print("No")

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

flag = True

for i in range(int(len(S)/2)):
  if S[i]!=S[-1-i]:
    flag = False
    breakat

if flag==True:
  right = int((N-1) / 2)
  subS = S[0:right]
  for i in range(int(len(subS)/2)):
    if subS[i]!=subS[-1-i]:
      flag = False
      break

if flag==True:
  left = int((N+3) / 2)
  subS = S[left-1:N]
  for i in range(int(len(subS)/2)):
    if subS[i]!=subS[-1-i]:
      flag = False

if flag:
  print("Yes")
else:
  print("No")
Problem p02744 (python)

Fixed submission:
N = int(input())
def DFS(s, mx):
    if len(s) == N:
        print(s)
        return
    c = 'a'
    while c <= chr(ord(mx)+1):
        t = s + c
        DFS(t, chr(max(ord(c), ord(mx))))
        c = chr(ord(c) + 1)
DFS("", chr(ord('a')-1))

Buggy submission (verdict: Runtime Error):
N = input()
def DFS(s, mx):
    if len(s) == N:
        print(s)
        return
    c = 'a'
    while c <= chr(ord(mx)+1):
        t = s + c
        DFS(t, chr(max(ord(c), ord(mx))))
        c = chr(ord(c) + 1)
DFS("", chr(ord('a')-1))

Buggy submission (verdict: Runtime Error):
def DFS(s, mx):
    if len(s) == N:
        print(s)
        return
    c = 'a'
    while c <= chr(ord(mx)+1):
        t = s + c
        DFS(t, chr(max(ord(c), ord(mx))))
        c = chr(ord(c) + 1)
DFS("", chr(ord('a')-1))
Problem p03469 (python)

Fixed submission:
S=str(input())
print(S[0:3],end='')
print(8,end='')
print(S[4:],end='')

Buggy submission (verdict: Runtime Error):
S=str(input())
print(S[0:3],end='')
print(8,end='')
print(S[4:],end='')
Problem p03361 (python)

Fixed submission:


h, w = map(int,input().split())
# In[]
s = [list(input()) for _ in range(h)]
dx = [0,1,0,-1]
dy = [1,0,-1,0]

count = 0

for y in range(h):
    for x in range(w):
        cnt = 0
        for k in range(4):
            ny = y + dy[k]
            nx = x + dx[k]
            if nx < 0 or nx>=w or ny < 0 or ny >=h:
                continue
            if s[y][x] == '.':
                cnt +=1
                continue
            if s[y][x] == '#':
                if s[ny][nx] == '#':
                    cnt += 1
        if cnt == 0:
            print('No')
            exit()

                        
print('Yes')

Buggy submission (verdict: Runtime Error):
# In[]
s = [list(input()) for _ in range(h)]
dx = [0,1,0,-1]
dy = [1,0,-1,0]

count = 0

for y in range(h):
    for x in range(w):
        cnt = 0
        for k in range(4):
            ny = y + dy[k]
            nx = x + dx[k]
            if nx < 0 or nx>=w or ny < 0 or ny >=h:
                continue
            if s[y][x] == '#':
                if s[ny][nx] == '#':
                    cnt += 1
        if cnt == 0:
            print('No')
            exit()

                        
print('Yes')
Problem p03471 (python)

Fixed submission:

n , t = map(int,input().split())
for i in range(n+1):
    for j in range(n+1-i):
        k = n - i- j

        #for k in range(n+1-i-j):#このfor分は不要、i,jで決まるから
        if 10000 * i + 5000 * j + 1000 * k == t:

            print('{} {} {}'.format(i, j ,k))
            exit(0)
print('{} {} {}'.format(-1 ,-1,-1))

Buggy submission (verdict: Runtime Error):
count = 0
n , t = map(int,input().split())
for i in range(n+1):
    for j in range(n+1-i):
        k = t - i- j
        #for k in range(n+1-i-j):#このfor分は不要、i,jで決まるから
            if 10000 * i + 5000 * j + 1000 * k == t:
                x,y,z = i, j, k
                print('{} {} {}'.format(x, y ,z))
                count += 1
if count == 0:
    print('{} {} {}'.format(-1 ,-1,-1))
Problem p03624 (python)

Fixed submission:
s = input()
g1 = set("abcdefghijklmnopqrstuvwxyz")
g2 = set(s)
a = g1 -g2
if a == set():
    print('None')
    

else:
    print(sorted(list(a))[0])

Buggy submission (verdict: Runtime Error):
s = input()
g1 = set("abcdefghijklmnopqrstuvwxyz")
g2 = set(s)
a = g1 -g2
print(sorted(list(a))[0])
Problem p03720 (python)

Fixed submission:

n,m = map(int, input().split())
xy = [map(int,input().split()) for _ in range(m)]
x,y = [list(i) for i in zip(*xy)]
l = x + y


d = {}#辞書同士の追加はupdate

for i in range(1,n+1):
    d[i] =0
for i in l:
    if i not in d:
        d[i] = 0
    d[i] += 1

for j in range(1,n+1):
    print(d[j])

Buggy submission (verdict: Runtime Error):

n,m = map(int, input().split())
xy = [map(int,input().split()) for _ in range(m)]
x,y = [list(i) for i in zip(*xy)]
l = x + y


d = {}#辞書同士の追加はupdate

for i in n:
    d[i] =0
for i in l:
    if i not in d:
        d[i] = 0
    d[i] += 1

for j in range(1,n+1):
    print(d[j])

Buggy submission (verdict: Runtime Error):

n,m = map(int, input().split())
xy = [map(int,input().split()) for _ in range(m)]
x,y = [list(i) for i in zip(*xy)]
l = x + y


d = {}
for i in l:
    if i not in d:
        d[i] = 0
    d[i] += 1

for j in range(1,n+1):
    print(d[j])

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
xy = [map(int,input().split()) for _ in range(m)]
x,y = [list(i) for i in zip(*xy)]
l = x + y

print(l)

d = {}
for i in l:
    if i not in d:
        d[i] = 0
    d[i] += 1

for j in range(1,n+1):
    print(d[j])
Problem p04044 (python)

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

s = [input() for _ in range(n)]
i = sorted(s)
print(''.join(i))

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

s = [input() for _ in range(n)]
i = sorted(s)
print(''.join(i)
Problem p02732 (python)

Fixed submission:
from math import factorial
def comb(n):
    if n == 1 or n == 0:
        return 0
    return int(n * (n-1) / 2 )

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

count = {}
ans = 0

for i in range(n):
    count.setdefault(a[i], 0)
    count[a[i]] += 1

for v in count.values():
    ans += comb(v)


for i in range(n):
    v = count[a[i]]
    print(ans - comb(v) + comb(v-1))

Buggy submission (verdict: Runtime Error):
from math import factorial
def comb(n,r=2):
    if n == 1 or n == 0:
        return 0
    return int(factorial(n) / factorial(r) / factorial(n - r))

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

count = {}
ans = 0

for i in range(n):
    count.setdefault(a[i], 0)
    count[a[i]] += 1

for v in count.values():
    ans += comb(v)


for i in range(n):
    v = count[a[i]]
    print(ans - comb(v) + comb(v-1))

Buggy submission (verdict: Runtime Error):
from math import factorial
def comb(n,r=2):
    if n == 1:
        return 0
    return int(factorial(n) / factorial(r) / factorial(n - r))

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

count = {}
ans = 0

for i in range(n):
    count.setdefault(a[i], 0)
    count[a[i]] += 1

for v in count.values():
    ans += comb(v)


for i in range(n):
    v = count[a[i]]
    print(ans - comb(v) + comb(v-1))
Problem p02802 (python)

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

check = {}
error = {}

ans_ac = 0
ans_wa = 0

for i in range(m):
    p,s = map(str, input().split())
    p = int(p)
    if p in check:
        pass
    else:
        if s == "WA":
            if p in error:
                error[p] += 1
            else:
                error[p] = 1
        else:
            if p in check:
                check[p] += 1
            else:
                check[p] = 1
            if p in error:
                ans_wa += error[p]
            ans_ac += 1
print(str(ans_ac) + " " + str(ans_wa) )

Buggy submission (verdict: Runtime Error):

check = {}
error = {}

ans_ac = 0
ans_wa = 0

for i in range(m):
    p,s = map(str, input().split())
    p = int(p)
    if p in check:
        pass
    else:
        if s == "WA":
            if p in error:
                error[p] += 1
            else:
                error[p] = 1
        else:
            if p in check:
                check[p] += 1
            else:
                check[p] = 1
            if p in error:
                ans_wa += error[p]
            ans_ac += 1
print(str(ans_ac) + " " + str(ans_wa) )
Problem p02947 (python)

Fixed submission:
import math

n = int(input())

check = {}
ans = 0

for _ in range(n):
    word = sorted(input())
    new_word = ''.join(list(word))
    check.setdefault(new_word, 0)
    check[new_word] += 1

for k in check:
    if check[k] >= 2:
        ans += int(math.factorial(check[k])/(math.factorial(check[k]-2)*2))

print(ans)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())

check = {}
ans = 0

for _ in range(n):
    word = sorted(input())
    new_word = ''.join(list(sorted(word)))
    check.setdefault(new_word, 0)
    check[new_word] += 1

for k in check:
    if check[k] >= 2:
        ans += int(math.factorial(check[k])/2)

print(ans)
Problem p02958 (python)

Fixed submission:
N = int(input())
s = list(map(int, input().split()))
new_s = sorted(s)
count = 0

for i in range(N):
    if s[i]-new_s[i]!=0:
        count += 1

if count>2:
    print('NO')
else:
    print('YES')

Buggy submission (verdict: Runtime Error):
N = int(input())
s = list(map(int, input().split())
new_s = sorted(s)
count = 0

for i in range(N):
    if s[i]-new_s[i]!=0:
        count += 1

if count>2:
    print('NO')
else:
    print('YES')
Problem p02981 (python)

Fixed submission:
x,y,z = map(int,input().split())
x = int(x)
y = int(y)
z = int(z)
if x*y < z:
  print(x*y)
else:
  print(z)

Buggy submission (verdict: Runtime Error):
x,y,z = map(int,input().stlip())
x = int(x)
y = int(y)
z = int(z)
if x*y > z:
  print(x*y)
else:
  print(z)

Buggy submission (verdict: Runtime Error):
x,y,z = map(int,input().stlip())
x = int(x)
y = int(y)
z = int(z)
if x＊y > z:
  print(x＊y)
else:
  print(z)

Buggy submission (verdict: Runtime Error):
x,y,z = input().split()
x = int(x)
y = int(y)
z = int(z)
if x＊y > z:
  print(x＊y)
else:
  print(z)

Buggy submission (verdict: Runtime Error):
x,y,z = input().stlip()
x = int(x)
y = int(y)
z = int(z)
if x＊y > z:
  print(x＊y)
else:
  print(z)
Problem p02995 (python)

Fixed submission:
from fractions import gcd
a, b, c, d = map(int, input().split())

p = (c * d) // gcd(c, d)

a_under = a-1

ans = (b - b//c - b//d + b//p) - (a_under - a_under//c - a_under//d + a_under//p)

print(ans)

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

p = math.floor((c * d) / math.gcd(c, d))

a_under = a-1

ans = (b - math.floor(b/c) - math.floor(b/d) + math.floor(b/p)) - (a_under - math.floor(a_under/c) - math.floor(a_under/d) + math.floor(a_under/p))

print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

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

ans = 0
p = lcm(c, d)

a_under = a-1

ans = (b - math.floor(b/c) - math.floor(b/d) + math.floor(b/p)) - (a_under - math.floor(a_under/c) - math.floor(a_under/d) + math.floor(a_under/p))

print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

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

ans = 0
p = lcm(c, d)

print(p)

a_under = a-1

ans = (b - math.floor(b/c) - math.floor(b/d) + math.floor(b/p)) - (a_under - math.floor(a_under/c) - math.floor(a_under/d) + math.floor(a_under/p))

print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

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

ans = 0
p = lcm(c, d)

print(p)

a_under = a-1

ans = (b - math.floor(b/c) - math.floor(b/d) + math.floor(b/p)) - (a_under - math.floor(a_under/c) - math.floor(a_under/d) + math.floor(a_under/p))

print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

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

ans = 0
p = lcm(c, d)

print(p)

a_under = a-1

ans = (b - b // c - b // d + b // p) - (a_under - a_under // c - a_under // d + a_under//p)

print(ans)
Problem p02683 (python)

Fixed submission:
n,m,x = map(int, input().split())
ca = []
for i in range(n):
    ca.append(list(map(int, input().split())))

c = []
a = []
for i in range(len(ca)):
    c.append(ca[i][0])
    a.append(ca[i])
    del a[i][0]

ans = 12345678
for i in range(2 ** n):
    cost = 0
    level = [0] * m
    for j in range(n):
        if((i>>j)&1):
            cost += c[j]
            for k in range(m):
                level[k] += a[j][k]
    flag = True
    for k in range(m):
        if(level[k] < x):
            flag = False
    if(flag):
        ans = min(ans,cost)
if(ans == 12345678):
    print(-1)
else:
    print(ans)

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

c = []
a = []
for i in range(len(ca)):
    c.append(ca[i][0])
    a.append(ca[i])
    del a[i][0]

ans = 12345678
for i in range(2 ** n):
    cost = 0
    level = [0] * m
    for j in range(n):
        if(i>>j&1):
            cost += c[j]
            for k in range(m):
                level[k] += a[j][k]
    flag = True
    for k in range(m):
        if(level[k] < x):
            flag = False
    if(flag):
        ans = min(ans,cost)
if(ans == 12345678):
    print(-1)
else:
    print(ans)
Problem p02705 (python)

Fixed submission:
import math

r = int(input())
print(2*math.pi*r)

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

num = [0] * n
for i in a:
    num[i-1] += 1
print(*num)

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

num = [0] * n
for i in range(0,n):
    num[i-1] += 1
print(num)

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

num = [0] * (len(a)+1)
for i in range(0,n):
    for j in range(len(a)):
        if a[j] == i+1:
            num[i] += 1
            if num[i] == a[j]:
                continue
    print(num[i])

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

jj = sum(j)

if i[0]-jj < 0:
    print(-1)
else:
    print(i[0]-jj)
Problem p02713 (python)

Fixed submission:
import math
from functools import reduce
 
def aaa(*numbers):
    return reduce(math.gcd, numbers)
 
num = int(input())
list = []
for i in range(1,num+1):
    for j in range(1,num+1):
        for k in range(1,num+1):
            list.append(aaa(i,j,k))
print(sum(list))

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

def gcd(*numbers):
    return reduce(math.gcd, numbers)

num = int(input())
list = []
for i in range(1,num):
  for j in range(i,num):
    for k in range(j,num):
      list.add(gcd(i,j,k))
print(sum(list))
Problem p02658 (python)

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

for i in range(n):
    l*=a[i]
    if l>10**18:
        break
if min(a)==0:
    print(0)
elif l>10**18:
    print(-1)
else:
    print(l)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
l=1
for i in range(n):
    l*=a[i]
    if j>10**18:
        break
if l>10**18:
    print(-1)
else:
    print(l)
Problem p02719 (python)

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

if N > K:
    x = N%K
else:
    x = K-N

while  N > x :
    N = x

    if N > K:
        x = N-K

    else:
        x = K-N

print(N)

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())
x = N%K
print(min(x,k-x))
Problem p02742 (python)

Fixed submission:
H, W = map(int,input().split())

if H==1 or W==1:
    print(1)
else:
    print((H*W+1)//2)

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

if (H==1 or W==1):
    print(0)
else:
    if (h!=0 and w !=0):
        print((2*(H//2)+1)*(W//2) + H//2+1)

    if (h==0 and w == 0):
        print((2*(H//2))*(W//2))

    if (h!=0 and w == 0):
        print((2*(H//2)+1)*(W//2))

    if (h ==0 and w !=0):
        print((2*(H//2))*(W//2) + H//2)
Problem p02748 (python)

Fixed submission:
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

min = min(a)+min(b)

for i in range(M):
    c =list(map(int,input().split()))
    s = a[c[0]-1]+b[c[1]-1]-c[2]
    min = (s if s < min else min)

print(min)

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

min = min(a)+min(b)

for i in range(M):
    c =list(map(int,input().split()))
    s = a[c[0]-1]+b[c[1]-1]-c[2]
    min = min(s,min)

print(min)
Problem p02765 (python)

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

print( R if N >=10 else R+100*(10-N))

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

MaxX = max(X)
MinX = min(X)

ListP = []

for i in range(MinX, MaxX):
    P = 0
    for j in range(N):
        P += (X[j]-i)**2
    
    ListP.append(P)

print(min(ListP))
Problem p02767 (python)

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

a = min(X)
b = max(X)

ans = []

for i in range(a,b+1):
  S = 0
  for j in range(N):
    S += (X[j]-i)**2

  ans.append(S)
  
print(min(ans))

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

MaxX = max(X)
MinX = min(X)

ListP = []

for i in range(MinX, MaxX):
    P = 0
    for j in range(N):
        P += (X[j]-i)**2
    
    ListP.append(P)

print(min(ListP))
Problem p02789 (python)

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

if a == b :
  print("Yes")
else:
  print("No")

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

for i in range(N):
  if min(list[:i+1]) >= list[i]:
    a += 1
    
print(a)
Problem p02922 (python)

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

print((B-1-1)//(A-1)+1)

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

def main():
    print(B//A+ (1 if B%A > 0 else 0)

if __name__ == '__main__':
    main()