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

Fixed submission:
H, W = map(int, input().split())
data = [list(map(str, input())) for _ in range(H)]


def g(m):
    if data[0][0] == '.':
        a = 0
    else:
        a = 1

    for i in range(1, m, 1):
        if data[0][i] == '.':
            continue
        elif data[0][i] == '#' and data[0][i - 1] == '.':
            a += 1
        else:
            continue
    return a


def h(n):
    if data[0][0] == '.':
        a = 0
    else:
        a = 1

    for i in range(1, n, 1):
        if data[i][0] == '.':
            continue
        elif data[i][0] == '#' and data[i - 1][0] == '.':
            a += 1
        else:
            continue
    return a

A = [0] + [g(i) for i in range(1,W+1)]
B = [0] + [h(i) for i in range(1,H+1)]
C = [[0]*(W+1) for i in range(H+1)]

for n in range(1,H+1):
    for m in range(1,W+1):
        if n == 1:
            C[n][m] = A[m]
        elif m == 1:
            C[n][m] = B[n]
        else:
            if data[n - 1][m - 1] == '.':
                C[n][m] = min(C[n - 1][m], C[n][m - 1])
            elif data[n - 2][m - 1] == '.':
                if data[n - 1][m - 2] == '.':
                    C[n][m] = min(C[n - 1][m] + 1, C[n][m - 1] + 1)
                else:
                    C[n][m] =  min(C[n - 1][m] + 1, C[n][m - 1])
            else:
                if data[n - 1][m - 2] == '.':
                    C[n][m] = min(C[n - 1][m], C[n][m - 1] + 1)
                else:
                    C[n][m] = min(C[n - 1][m], C[n][m - 1])


print(C[H][W])

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
A = list(map(int,input()))
B = []
M = math.ceil(math.log(N,2)) 

for i in range(N):
  a = 0
  for j in range(1,M+1,1):
    a += math.floor((N-1)/(2**j))-math.floor((i)/(2**j))-math.floor((N-1-i)/(2**j))
  if a == 0:
    B.append(1)
  else:
    B.append(0)
b = 0
for i in range(N):
  b += B[i]*A[i]
if b % 2 == 1:
  print(1)
else:
  for i in range(N):
    if A[i] == 2:
      print(0)
      break
  else:
    c = 0
    for i in range(N):
      A[i] = (A[1]-1)//2
      c += B[i]*A[i]
    if c % 2 == 1:
      print(2)
    else:
      print(0)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
A = list(map(int,input()))
B = []
M = math.ceil(math.log(N,2)) 

for i in range(N):
  a = 0
  for j in range(1,M+1,1):
    a += math.floor((N-1)/(2**j))-math.floor((i)/(2**j))-math.floor((N-1-i)/(2**j))
  if a == 0:
    B.append(1)
  else:
    B.append(0)
    
b = 0
for i in range(N):
  b += B[i]*A[i]
if b % 2 == 1:
  print(1)
else:
  for i in range(N):
    if A[i] == 2:
      print(0)
      break
  else:
    for i in range(N):
      A[i] = (A[1]-1)//2
    for i in range(N):
      a = 0
      C = []
      for j in range(1,M+1,1):
        a += math.floor((N-1)/(2**j))-math.floor((i)/(2**j))-math.floor((N-1-i)/(2**j))
      if a == 0:
        C.append(1)
      else:
        C.append(0)
    
    for i in range(N):
      b += C[i]*A[i]
    if b % 2 == 1:
      print(2)
    else:
      print(0)
Problem p02736 (python)

Fixed submission:
import math

N = int(input())
A = list(map(int,input()))
B = []

for i in range(N):
  if N-1 == (i|N-1-i):
    B.append(1)
  else:
    B.append(0)
    
b = 0
for i in range(N):
  b += B[i]*A[i]
if b % 2 == 1:
  print(1)
else:
  for i in range(N):
    if A[i] == 2:
      print(0)
      break
  else:
    c = 0
    for i in range(N):
      A[i] = (A[i]-1)//2
      c += B[i]*A[i]
    if c % 2 == 1:
      print(2)
    else:
      print(0)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
A = list(map(int,input()))
B = []
M = math.ceil(math.log(N,2)) 

for i in range(N):
  a = 0
  for j in range(1,M+1,1):
    a += math.floor((N-1)/(2**j))-math.floor((i)/(2**j))-math.floor((N-1-i)/(2**j))
  if a == 0:
    B.append(1)
  else:
    B.append(0)
    
b = 0
for i in range(N):
  b += B[i]*A[i]
if b % 2 == 1:
  print(1)
else:
  for i in range(N):
    if A[i] == 2:
      print(0)
      break
  else:
    for i in range(N):
      A[i] = (A[1]-1)//2
    for i in range(N):
      a = 0
      C = []
      for j in range(1,M+1,1):
        a += math.floor((N-1)/(2**j))-math.floor((i)/(2**j))-math.floor((N-1-i)/(2**j))
      if a == 0:
        C.append(1)
      else:
        C.append(0)
    
    for i in range(N):
      b += C[i]*A[i]
    if b % 2 == 1:
      print(2)
    else:
      print(0)

Buggy submission (verdict: Runtime Error):
import math

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

if N == 2:
  print(abs(A[0]-A[1]))

elif (N+sum(A)) % 2 == 1:
  print(1)
else:
  for i in range(N):
    if A[i] == 2:
      print(0)
      break
    else:
      B = []
      C = []
      M = math.ceil(math.log(N,A)) 
      for i in range(N-1):
        B.append(abs(A[i]-A[i+1]))
        a = 0
        for j in range(1,M+1,1):
          a += math.floor((N-2)/(2**j))-math.floor((i)/(2**j))-math.floor((N-2-i)/(2**j))
        if a == 0:
          C.append(1)
        else:
          C.append(0)
      b = 0
      for i in range(N-1):
        b += B[i]*C[i]
      if b % 4 == 0:
        print(0)
      else:
        print(2)
Problem p02753 (python)

Fixed submission:
S = input()
if S[0] == S[1] and S[1] == S[2]:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
Q = N//(A + B)
if N - Q * (A + B) > A:
  print(Q * A + A)
else:
  print(Q * A + N - Q * (A + B))

Buggy submission (verdict: Runtime Error):
S = input()
if S[0] == S[1] and S[1] == S[2]:
  print('NO")
else:
        print('Yes')
Problem p02759 (python)

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

Buggy submission (verdict: Runtime Error):
N = input()
if N % 2 == 0:
  print(N/2)
else:
  print((N+1)/2)

Buggy submission (verdict: Runtime Error):
N == input()
if N % 2 == 0:
  print(N/2)
else:
  print((N+1)/2)
Problem p02835 (python)

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

if A+B+C <= 21:
  print('win')
else:
  print('bust')

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

if A[0]+A[1]+A[2] <= 21:
  print('win')
else:
  print('bust')
Problem p02891 (python)

Fixed submission:
S = list(input())
s = len(S)
K = int(input())
A = []
j = 1

for i in range(0,s-1,1):
  if S[i] == S[i+1]:
    j += 1
  else:
    A.append(j)
    j = 1
A.append(j)

a = len(A)

b = 0
for i in range(0,a,1):
  b += A[i]//2
  
x = b*K

if a == 1:
  x = (s*K)//2
elif S[s-1] == S[0] and A[a-1] % 2 == 1 and A[0] % 2 == 1:
  x += K-1

print(x)

Buggy submission (verdict: Runtime Error):
S = list(input())
s = len(S)
K = int(input())
A = []
j = 1

for i in range(0,s-1,1):
  if S[i] == S[i+1]:
    j += 1
  else:
    A.append(j)
    j = 1
A.append(j)

a = len(A)

b = 0
for i in range(0,a,1):
  b += A[i]//2
  
x = b*K

if S[s-1] == S[0] and A[a-1] % 2 == 1 and A[1] % 2 == 1:
  x += K-1

print(x)

Buggy submission (verdict: Runtime Error):
S = list(input())
s = len(S)
K = int(input())
A = []
j = 1

for i in range(0,s-1,1):
  if S[i] == S[i+1]:
    j += 1
  else:
    A.append(j)
    j = 1
A.append(j)

a = len(A)

b = 0
for i in range(0,a,1):
  b += A[i]//2
  
x = b*K

if S[s-1] == S[0] and A[a-1] % 2 == 1 and A[1] % 2 == 1:
  x += K-1

print(b)
print(x)

Buggy submission (verdict: Runtime Error):
S = list(input())
s = len(S)
K = int(input())
A = []
j = 1

for i in range(0,s-1,1):
  if S[i] == S[i+1]:
    j += 1
  else:
    A.append(j)
    j = 1
A.append(j)

a = len(A)

b = 0
for i in range(a):
  b += i//2
  
x = b*K

if S[s-1] == S[0] and A[a-1] % 2 == 1 and A[1] % 2 == 1:
  x += K-1
  
print(x)
Problem p03104 (python)

Fixed submission:
import sys

def S(): return sys.stdin.readline().rstrip()

A,B = map(int,S().split())

def f(n):  # 0からnまでのxor
    res = 0
    for i in range(41):  # 2**iの位
        if i == 0:
            res += ((n+1)//2) % 2
        else:
            a = n - ((n >> (i+1)) << (i+1))
            if a < 2**i or a % 2 == 1:
                continue
            else:
                res += 1 << i
    return res

print(f(B) ^ f(A-1))

Buggy submission (verdict: Runtime Error):
import sys

def S(): return sys.stdin.readline().rstrip()

A,B = map(int,S().split())

def f(n):  # 0からnまでのxor
    res = 0
    while n % 4 != 3:
        res ^= n
        n -= 1

print(f(B) ^ f(A-1))
Problem p03365 (python)

Fixed submission:
import sys
def I(): return int(sys.stdin.readline().rstrip())


N = I()
mod = 10**9+7


fac = [1]*(N+1)
for i in range(1,N+1):
    fac[i] = (fac[i-1]*i) % mod

fac_inverse = [1]*(N+1)
for i in range(1,N+1):
    fac_inverse[i] = pow(fac[i],mod-2,mod)


def nCr(n,r):
    if n < r:
        return 0
    return (fac[n]*fac_inverse[r]*fac_inverse[n-r]) % mod


A = [0]*(N+1)  # Ai = i回以下マシンを稼働することで、全て黒く塗られるような順列の個数
for i in range(N+1):
    A[i] = (fac[i]*fac[N-1-i]*nCr(i-1,N-1-i)) % mod

ans = 0
for i in range(1,N):
    ans += i*(A[i]-A[i-1])
    ans %= mod

print(ans)

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N = I()
mod = 10**9+7

if N == 2:
    print(1)
    exit()
elif N == 3:
    print(4)
    exit()

kaijou = [1]
for i in range(1,N+1):
    kaijou.append((kaijou[-1]*i) % mod)

kaijou_inverse = [1]
for i in range(1,N+1):
    kaijou_inverse[i] = pow(kaijou[i],mod-2,mod)

def nCr(n,r):
    if n < r:
        return 0
    return (kaijou_inverse[n]*kaijou_inverse[r]*kaijou_inverse[n-r]) % mod

ans = 0
for i in range(1,N):
    ans += i*kaijou[i]*kaijou[N-i-i]*nCr(i-1,N-1-i)
    ans %= mod

print(ans)
Problem p03618 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


A = LS2()
N = len(A)

from collections import defaultdict

d = defaultdict(int)
for i in range(N):
    d[A[i]] += 1


ans = 0
for key in d.keys():
    ans += d[key]*(N-d[key])

ans //= 2
ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N,K = MI()
S = LI2()

A = []
a = 1
for i in range(1,N):
    if S[i-1] == S[i]:
        a += 1
    else:
        A.append(a)
        a = 1
A.append(a)

l = len(A)
if l <= 2*K-1:
    print(N)
    exit()

if S[0] == 1:
    A = [1]+A
if S[-1] == 1:
    A = A+[1]

A = [0]+A
l = len(A)

from itertools import accumulate

A = list(accumulate(A))
ans = 0
for i in range(l//2-K+1):
    if i == 0:
        ans = max(ans,A[2*(K+i)]-A[2*i])
    elif i == l//2-K:
        ans = max(ans,A[2*(K+i)-1]-A[2*i-1])
    else:
        ans = max(ans,A[2*(K+i)]-A[2*i-1])

print(ans)
Problem p02577 (python)

Fixed submission:
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
    # combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    n = input()
    res = 0
    for i in range(len(n)):
        res += int(n[i])
    if res%9==0:
        print("Yes")
    else:
        print("No")
    return

if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
n = int(input())
if n%9==0:
  print("Yes")
else:
  prinrt("No")
Problem p03077 (python)

Fixed submission:
N = int(input())
ABCDE = [int(input()) for i in range(5)]
mi = min(ABCDE)
if N%mi!=0:
    ans = N//mi+5
else:
    ans = N//mi+4
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ABCDE = [int(input()) for i in range(5)]
ans = N//mi+5
print(ans)
Problem p02597 (python)

Fixed submission:
n = int(input())
c = input()
l = 0
j = 0
a = [0]*n
b = [0]*n
for i in range(n):
  if(c[i]=='W'):
    a[l] =i+1
    l +=1
l = 0
for i in range(n-1,0,-1):
  if(c[i]=='R'):
    b[j] = i+1
    j +=1
j = 0
while(a[l] < b[l] and not(a[l]==0 or b[l] == 0)):
      a[l]=0
      b[l]=0
      l+=1
      j+=1
print(j)

Buggy submission (verdict: Runtime Error):
n = int(input())
c = input()
l = 0
j = 0
a = [0]*n
b = [0]*n
for i in range(n):
  if(c[i]=='W'):
    a[l] =i+1
    l +=1
l = 0
for i in range(n-1,0,-1):
  if(c[i]=='R'):
    b[j] = i+1
    j +=1
j = 0
while(a[l] < b[l]):
      a[l]=0
      b[l]=0
      l+=1
      j+=1
if(a[l+1]==0):
  while(b[l+1]>0):
    j +=1
else:
  while(a[l+1]>0):
    j +=1
print(j)
Problem p02659 (python)

Fixed submission:
import numpy as np
import scipy as sp
import math
 
a, b = map(str, input().split())
a = int(a)
b = int(float(b) * 100.001)
ans = int(a * b // 100)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import scipy as sp
import math
 
x, y = input().split()
a = int(x)
b = math.floor(y*100)
c = b/100
print(math.floor(a*c))
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" or S = "BBB"):
  print("No")
else:
  print("Yes")
Problem p02987 (python)

Fixed submission:
s = input()
if((s[0]==s[1] and s[2]==s[3] and s[0]!=s[2]) or (s[0]==s[2] and s[1] ==s[3] and s[0]!=s[1])
   or (s[0]==s[3] and s[1]==s[2] and s[0]!=s[1])):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = input()
if((s[0]==s[1] and s[2]==s[3] and s[0]!=s[2]) or (s[0]==s[2] and s[1] ==s[3] and s[0]!=s[1])
   and (s[0]===s[3] and s[1]==s[2] and s[0]!=s[1])):
  print("Yes")
else:
  print("No")
Problem p03041 (python)

Fixed submission:
n,k = map(int,input().split())
S = list(input())
if(S[k-1]=="A"):
  S[k-1]="a"
elif(S[k-1]=="B"):
  S[k-1]="b"
else:
  S[k-1]="c"
for i in range(n):
  print(S[i],end='')

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
S = list(input())
if(S[k-1]=="A"):
  S[k-1]="a"
elif(S[k-1]=="B"):
  S[k-1]="b"
else:
  S[K-1]="c"
for i in range(n):
  print(S[i],end='')
Problem p02829 (python)

Fixed submission:
n =int(input())
m = int(input())
print(6-n-m)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
print(6-n-m)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
print(6-n-m)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
print(6-n-m)
Problem p02550 (python)

Fixed submission:
import bisect
from collections import deque
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
# mod = 10 ** 9 + 7
mod = 998244353

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]



def main():
    N, X, M = read_values()
    F = [-1] * (M + 1)

    A = X
    t = 0
    while F[A] < 0:
        F[A] = t
        A = pow(A, 2, M)
        t += 1
    
    if t == 1:
        print(X * N)
        return
    d = (N - F[A]) // (t - F[A])
    r = ((N - F[A]) % (t - F[A])) + F[A]

    K = 0
    for _ in range(F[A], t):
        K += A
        A = pow(A, 2, M)
    
    K *= d

    A = X
    for _ in range(r):
        K += A
        A = pow(A, 2, M)

    print(K)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import bisect
from collections import deque
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
# mod = 10 ** 9 + 7
mod = 998244353

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]



def main():
    N, X, M = read_values()
    F = [-1] * M

    A = X
    t = 0
    while F[A] < 0:
        F[A] = t
        A = pow(A, 2, M)
        t += 1
    
    if t == 1:
        print(X * N)
    else:
        d = (N - F[A]) // (t - F[A])
        r = (N - F[A]) % (t - F[A]) + F[A]

    K = 0
    for i in range(F[A], t):
        K += A
        A = pow(A, 2, M)
    
    K *= d

    A = X
    for _ in range(r):
        K += A
        A = pow(A, 2, M)

    print(K)


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

Fixed submission:
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N, K = read_values()
    A = read_list()

    D = {}
    L = []

    l = 1
    r = max(A) + 1

    while l != r:
        m = (l + r) // 2 
        k = 0

        for a in A:
            k += (a - 1) // m 
        if k > K:
            l = m + 1
        else:
            r = m

    print(r)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N, K = read_values()
    A = read_list()

    D = {}
    L = []

    l = 0
    r = max(A) + 1

    while l != r:
        m = (l + r) // 2 
        k = 0

        for a in A:
            k += (a - 1) // m 
        if k > K:
            l = m + 1
        else:
            r = m

    print(r)


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

Fixed submission:
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    S = input().strip()
    T = input().strip()
    
    res = 0
    for s, t in zip(S, T):
        if s != t:
            res += 1

    print(res)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
print(sum([1 if s, t else 0 for s, t in zip(input(), input())]))
Problem p02754 (python)

Fixed submission:
N, A, B = map(int, input().split())
print(N // (A + B) * A + min(A, N % (A + B)))

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
print(N // (A + B) * A + min(A, N % (A + B))
Problem p02831 (python)

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


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


import fractions
def main():
    A, B = read_values()
    print(int(A * B / fractions.gcd(A, B)))


if __name__ == "__main__":
    main()

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


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


import math
def main():
    A, B = read_values()
    print(int(A * B / math.gcd(A, B)))



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

Fixed submission:
import heapq as hq

def f():
    # N = int(input())
    N, M = map(int, input().split())
    A = sorted(list(map(int, input().split())))

    H = []
    for m in range(M):
        B, C = map(int, input().split())
        hq.heappush(H, (-C, B))

    index = 0
    res = sum(A)
    for n in range(M):
        c, b = hq.heappop(H)
        c *= -1

        for _ in range(b):
            if A[index] < c:
                res += (c - A[index])
                index += 1
                if index == N:
                    return res
            else:
                return res
    return res

print(f())

Buggy submission (verdict: Runtime Error):
import heapq as hq

def f():
    # N = int(input())
    N, M = map(int, input().split())
    A = sorted(list(map(int, input().split())))

    H = []
    for m in range(M):
        B, C = map(int, input().split())
        hq.heappush(H, (-C, B))

    index = 0
    res = sum(A)
    for n in range(M):
        c, b = hq.heappop(H)
        c *= -1

        for _ in range(b):
            if A[index] < c:
                res += (c - A[index])
                index += 1
            else:
                return res
    return res

print(f())
Problem p03104 (python)

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

res = 0
if A % 2:
    res ^= A
    A += 1

if B % 2 == 0:
    res ^= B
    B -= 1

K = (B - A + 1) // 2
res ^= K % 2
print(res)

Buggy submission (verdict: Runtime Error):
import math

A, B = map(int, input().split())

# 右からi bit(0-index)について、何番目にいるかをかんがえる
# 0: 0 ~ 2^i - 1
# k: 2^(ki) ~ 2^((k + 1)i) - 1
# k_A = int(log(2^i)(A))
# 間で変換される回数は、K = k_B - k_A 回
# K: 偶数→ 0、奇数→1

b = (B - A + 1) // 2
if A % 2 + B % 2 == 0:
    b = max(0, b - 1)
res = str(b % 2)

k_a = A
k_b = B
for i in range(1, int(math.log2(B)) + 1):
    k_a //= 2
    k_b //= 2
    num_bit = 0
    if k_a % 2:
        num_bit += 2 ** i - A % (2 ** i)
    if k_b % 2:
        num_bit += B % (2 ** i) + 1

    res = str(num_bit % 2) + res

print(int(res, 2))