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

Fixed submission:
N,M = (int(x) for x in input().split())
H   = [int(x) for x in input().split()]
Way = [[] for I in range(N)]
for T in range(0,M):
    A,B = (int(x) for x in input().split())
    Way[A-1].append(B)
    Way[B-1].append(A)
    
Count = 0
for TT in range(0,N): 
    if all(H[TT]>Ele for Ele in [H[I-1] for I in Way[TT]]):
        Count = Count+1
print(Count)

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M = (int(x) for x in input().split())
H   = np.array([int(x) for x in input().split()])
Way = np.zeros((N,N),dtype=bool)
for T in range(0,M):
    A,B = (int(x) for x in input().split())
    Way[A-1,B-1] = True
    Way[B-1,A-1] = True
    
Count = 0
#for TT in range(0,N): 
#    TrueIndex = [n for n,v in enumerate(Way[TT,:]) if v==True]
#    if np.all(H[TT]>H[TrueIndex]):
#        Count = Count+1
print(Count)

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M = (int(x) for x in input().split())
H   = np.array([int(x) for x in input().split()])
Way = np.zeros((N,N),dtype=bool)
for T in range(0,M):
    A,B = (int(x) for x in input().split())
    Way[A-1,B-1] = True
    Way[B-1,A-1] = True
    
Count = 0
for TT in range(0,N):
    TrueIndex = np.where(Way[TT,:]==True)
    if np.all(H[TT]>H[TrueIndex]):
        Count = Count+1
print(Count)

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M = (int(x) for x in input().split())
H   = np.array([int(x) for x in input().split()])
Way = np.zeros((N,N),dtype=bool)
for T in range(0,M):
    A,B = (int(x) for x in input().split())
    Way[A-1,B-1] = True
    Way[B-1,A-1] = True
    
Count = 0
for TT in range(0,N):
    TrueIndex = [Index for Index,Name in enumerate(Way[TT,:]) if Name==True]
    if np.all(H[TT]>H[TrueIndex]):
        Count = Count+1
print(Count)

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M = (int(x) for x in input().split())
H   = np.array([int(x) for x in input().split()])
Way = np.zeros((N,N),dtype=bool)
for T in range(0,M):
    A,B = (int(x) for x in input().split())
    Way[A-1,B-1] = True
    Way[B-1,A-1] = True
    
Count = 0
for TT in range(0,N):
    TrueIndex = [n for n,v in enumerate(Way[TT,:]) if v==True]
    if np.all(H[TT]>H[TrueIndex]):
        Count = Count+1
print(Count)

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M = (int(x) for x in input().split())
H   = np.array([int(x) for x in input().split()])
Way = np.zeros((N,N),dtype=bool)
for T in range(0,M):
    A,B = (int(x) for x in input().split())
    Way[A-1,B-1] = True
    Way[B-1,A-1] = True
    
Count = 0
for TT in range(0,N):
    TrueIndex = [n for n,v in enumerate(Way[TT,:]) if v==True]
    if all(H[TT]>H[TrueIndex]):
        Count = Count+1
print(Count)
Problem p03077 (python)

Fixed submission:
import math
N = int(input())
Cap = [int(input()) for X in range(0,5)]
print(int(math.ceil(N/min(Cap))+4))

Buggy submission (verdict: Runtime Error):
N = int(input())
Cap = [int(input()) for X in range(0,5)]
print(int(math.ceil(N/min(Cap))+4))

Buggy submission (verdict: Runtime Error):
N = int(input())
Cap = [int(input()) for X in range(0,5)]
Str = math.ceil(N/Cap[0])
for T in range(0,len(Cap)-1):
    Str += math.ceil(Cap[T]/Cap[T+1])
print(Str)
Problem p03207 (python)

Fixed submission:
N = int(input())
P = [int(input()) for X in range(0,N)]
P[P.index(max(P))] = max(P)//2
print(sum(P))

Buggy submission (verdict: Runtime Error):
N = int(input())
P = sorted([int(input()) for X in range(0,N)])
P[-1] = P[-1]//2
print(sum(SP))
Problem p02659 (python)

Fixed submission:
from decimal import Decimal,ROUND_FLOOR
a,b=map(str,input().split())
c=Decimal(a)*Decimal(b)
print(Decimal(str(c)).quantize(Decimal('0'),rounding=ROUND_FLOOR))

Buggy submission (verdict: Runtime Error):
import decimal
a,b=map(str,input().split())
c=decimal.Decimal(a)*decimal.Decimal(b)
print(decimal.Decimal(str(c)).quantize(decimal.Decimal('0'),rounding=ROUND_FLOOR))
Problem p02711 (python)

Fixed submission:
n=int(input())
if n%10==7:
    print('Yes')
elif 70<=n%100 and n%100<=79:
    print('Yes')
elif 700<=n and n<=799:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
count=0
n=int(input())
l=list(map(str,input()))
i=0
while i<=n-3:
    j=i+1
    while i+1<=j and j<=n-2:
        if l[i]==l[j]:
            j+=1
        else:
            k=j+1
            while j+1<=k and k<=n-1 and k-j!=j-i:
                if l[i]!=l[j] and l[j]!=l[k]:
                    count+=1
                    k+=1
                else:
                    k+=1
            j+=1
    i+=1
print(count)
Problem p02685 (python)

Fixed submission:
class Combination:
    def __init__(self, n, mod):
        self.fact = [1]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * i % mod)
        self.inv_fact = [0] * (n + 1)
        self.inv_fact[n] = pow(self.fact[n], mod - 2, mod)
        for i in reversed(range(n)):
            self.inv_fact[i] = self.inv_fact[i + 1] * (i + 1) % mod
        self.mod = mod

    def factorial(self, k):

        return self.fact[k]

    def inverse_factorial(self, k):
        return self.inv_fact[k]

    def permutation(self, k, r):
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r]) % self.mod

    def combination(self, k, r):
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.mod

    def combination_large(self, k, r):
        if k < r:
            return 0
        res = 1
        for l in range(r):
            res *= (k - l)
            res %= self.mod
        return (res * self.inv_fact[r]) % self.mod

n, m, k = map(int, input().split())
mod = 998244353
cmb = Combination(10**6, mod)

ans = 0
for i in range(k+1):
    ans += m*cmb.combination(n-1, i)*pow(m-1, n-1-i, mod)
    ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
def comb(n,k):
  if n<k:
    return 0
  if n<0 or k<0:
    return 0
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod

n,m,k=map(int,input().split())
mod=998244353
fac=[1]*n
finv=[1]*n
inv=[0]*n
inv[1]=1
for i in range(2,n):
  fac[i]=fac[i-1]*i%mod
  inv[i]=mod-inv[mod%i]*(mod//i)%mod
  finv[i]=finv[i-1]*inv[i]%mod

ans=0
for i in range(k+1):
  ans+=m*comb(n-1,i)*pow(m-1,n-1-i,mod)
  ans%=mod
print(ans)
Problem p02833 (python)

Fixed submission:
# ABC148 E
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
import math
n=ni()

if n==0:
    print(0)
    exit()

if n%2==1:
    print(0)
    exit()

five=math.floor(math.log(n,5))
ans=0

# for i in range(five):
for j in range(five):
    t=n//(5**(five-j))
    ans+=t//2
print(ans)

Buggy submission (verdict: Runtime Error):
# ABC148 E
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
import math
n=ni()

if n==0:
    print(0)

if n%2==1:
    print(0)
    exit()

five=math.floor(math.log(n,5))
ans=0

# for i in range(five):
for j in range(five):
    t=n//(5**(five-j))
    ans+=t//2
print(ans)

Buggy submission (verdict: Runtime Error):
# ABC148 E
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
import math
n=ni()

if n%2==1:
    print(0)
    exit()

five=math.floor(math.log(n,5))
ans=0

# for i in range(five):
for j in range(five):
    t=n//(5**(five-j))
    ans+=t//2
print(ans)
Problem p02863 (python)

Fixed submission:
# E - All-you-can-eat
n,t=map(int,input().split())
a,b=[],[]
for i in range(n):
    aa,bb=map(int,input().split())
    a.append(aa)
    b.append(bb)

dp1=[[0]*t for _ in range(n+1)] # 前から
dp2=[[0]*t for _ in range(n+1)] # 後ろから
arev=a[::-1]
brev=b[::-1]

for i in range(1,n+1):
    for j in range(t):
        if j-a[i-1]>=0:
            dp1[i][j]=max(dp1[i-1][j-a[i-1]]+b[i-1],dp1[i-1][j])
        else:
            dp1[i][j]=dp1[i-1][j]

for i in range(1,n+1):
    for j in range(t):
        if j-arev[i-1]>=0:
            dp2[i][j]=max(dp2[i-1][j-arev[i-1]]+brev[i-1],dp2[i-1][j])
        else:
            dp2[i][j]=dp2[i-1][j]

ans=-1
for i in range(1,n+1):
    for j in range(t):
        ans=max(ans,dp1[i-1][j]+dp2[n-i][t-1-j]+b[i-1])
print(ans)

Buggy submission (verdict: Runtime Error):
# E - All-you-can-eat
n,t=map(int,input().split())
a,b=[],[]
for i in range(n):
    aa,bb=map(int,input().split())
    a.append(aa)
    b.append(bb)

dp=[[0]*(2*t+1) for i in range(n+1)]

for i in range(n):
    for j in range(1,2*t+1):
        # if j-a[i]>=0:
        #     dp[i+1][j]=max(dp[i+1][j],dp[i][j-a[i]]+b[i])
        # dp[i+1][j]=max(dp[i+1][j],dp[i][j])
        if j-a[i]>=0:
            dp[i+1][j]=max(dp[i+1][j],dp[i][j-a[i]]+b[i])
        dp[i+1][j]=max(dp[i+1][j],dp[i][j])
# print(dp)
# print(dp[10][124])
a_max=max(a)
ans=0
if t+a_max-1>2*t:
    print(dp[n][sum(a)])
    exit()

for i in range(t-a_max-1,t+a_max-2):
    ans=max(dp[n][i],ans)

print(ans)
Problem p02891 (python)

Fixed submission:
S = input()
K = int(input())

if len(S) == 1:
    print(K//2)
    exit()
L = []
LS = []
ans = 0
streak = 1
s = ''

for i in range(len(S)-1):
    if i == 0:
        s = S[0]
        streak = 1
    
    if s == '':
        if S[i+1:i+2] == S[i:i+1]:
            s = S[i:i+1]
            streak += 1
    else:
        if S[i+1:i+2] == s:
            streak += 1
        else:
            L.append(streak)
            LS.append(s)
            s = ''
            streak = 1
    
    if i == len(S)-2:
        L.append(streak)
        LS.append(S[-1])
        # if streak == len(S):
        #     ans = K*(len(S)//2)
        #     print(ans)
        #     exit()

# print(LS)
# print(L)
if streak == len(S):
    ans = (len(S)*K)//2
    # print(len(S))
    print(ans)
    exit()

if LS[0] != LS[-1]:
    for l in L:
        # if l >=2:
        ans += l//2
    ans = K*ans
elif LS[0] == LS[-1]:
    for i in range(1,len(L)-1):
        ans += L[i]//2
    ans = K*ans + L[0]//2 + (K-1)*((L[0]+L[-1])//2) + L[-1]//2
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())

L = []
LS = []
ans = 0
streak = 1
s = ''

for i in range(len(S)-1):
    if i == 0:
        s = S[0]
        streak = 1
    
    if s == '':
        if S[i+1:i+2] == S[i:i+1]:
            s = S[i:i+1]
            streak += 1
    else:
        if S[i+1:i+2] == s:
            streak += 1
        else:
            L.append(streak)
            LS.append(s)
            s = ''
            streak = 1
    
    if i == len(S)-2:
        if streak >= 2:
            L.append(streak)
            LS.append(s)
        if streak == len(S):
            ans = K*(len(S)//2)
            print(ans)
            exit()

if LS[0] != LS[-1]:
    for l in L:
        if i >=2:
            ans += l//2
    ans *= K
elif LS[0] == LS[-1]:
    for i in range(1,len(L)-1):
        ans += L[i]//2
    ans = K*ans + L[0]//2 + (K-1)*(L[0]+L[-1])//2 + L[-1]//2
print(ans)
Problem p03038 (python)

Fixed submission:
# ABC127 D-Integer Cards
from operator import itemgetter
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]

A.sort()
BC.sort(key=itemgetter(1),reverse=True)
# print(A)
# print('sort',BC)
c = 0
for i in range(M):
    for j in range(BC[i][0]):
        if A[c] < BC[i][1]:
            A[c] = BC[i][1]
        else:
            print(sum(A))
            exit()
        c += 1
        if c == N:
            print(sum(A))
            exit()
# for i in range(M):
#     x = 0
#     while x < BC[i][0]:
#         A.sort()
#         print(i,A)
#         if BC[i][1] > A[0]:
#             A[0] = BC[i][1]
#         x += 1 
print(sum(A))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
bc=[list(map(int,input().split())) for i in range(m)]
a.sort()
bc.sort(key=lambda x: x[1],reverse=True)
# print(a)
# print(bc)
i=0
for b,c in bc:
  tb=b
  while tb>0:
    if a[i]>=c:
      break
    a[i]=c
    tb-=1
    i+=1
  if a[i]>=c or n==i:
    break
print(sum(a))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
bc=[list(map(int,input().split())) for i in range(m)]
a.sort()
bc.sort(key=lambda x: x[1],reverse=True)
# print(a)
# print(bc)
i=0
for b,c in bc:
  tb=b
  while tb>0:
    if a[i]>=c:
      break
    a[i]=c
    tb-=1
    i+=1
  if a[i]>=c:
    break
print(sum(a))
Problem p03104 (python)

Fixed submission:
# ABC121 D - XOR World
from math import log2,ceil
a,b=map(int,input().split())
if a==0 and b==0:
    print(0)
    exit()
if a==0:
    pass
elif a>=2:
    na=int(ceil(log2(a)))
nb=int(ceil(log2(b)))
l=[0]*(nb+1)

if a>=2:
    a-=1
    for i in range(na+1):
        q=a//(2**(i+1))
        r=a%(2**(i+1))
        r-=2**i
        if r<0:
            r=0
        elif r>=0:
            r+=1
        l[i]-=q*2**i+r

for i in range(nb+1):
    q=b//(2**(i+1))
    r=b%(2**(i+1))
    r-=2**i
    if r<0:
        r=0
    elif r>=0:
        r+=1
    l[i]+=q*2**i+r

for i in range(len(l)):
    l[i]=l[i]%2

ans=0
for i in range(len(l)):
    ans+=l[i]*2**i
print(ans)

Buggy submission (verdict: Runtime Error):
# ABC121 D - XOR World
from math import log2,ceil
a,b=map(int,input().split())
if a==0:
    pass
elif a>=2:
    na=int(ceil(log2(a)))
nb=int(ceil(log2(b)))
l=[0]*(nb+1)

if a>=2:
    a-=1
    for i in range(na+1):
        q=a//(2**(i+1))
        r=a%(2**(i+1))
        r-=2**i
        if r<0:
            r=0
        elif r>=0:
            r+=1
        l[i]-=q*2**i+r

for i in range(nb+1):
    q=b//(2**(i+1))
    r=b%(2**(i+1))
    r-=2**i
    if r<0:
        r=0
    elif r>=0:
        r+=1
    l[i]+=q*2**i+r

for i in range(len(l)):
    l[i]=l[i]%2

ans=0
for i in range(len(l)):
    ans+=l[i]*2**i
print(ans)
Problem p03127 (python)

Fixed submission:
# ABC118 C - Monsters Battle Royale
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
ans = 10**10

for i in range(n-1):
    t = gcd(a[i],a[i+1])
    ans = min(ans,t)
print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
# def lcm(x,y):
#   return (x*y)//gcd(x,y)

n=int(input())
a=list(map(int,input().split()))
ans=10**18
t=0
for i in range(1,n):
  if i==1:
    t=gcd(a[i-1],a[i])
    continue
  t=gcd(t,a[i])
  ans=min(t,ans)
print(ans)
Problem p03221 (python)

Fixed submission:
n, m = map(int, input().split())
py = []
for _ in range(m):
  py.append(list(map(int,input().split())) + [0])

sortPy = sorted(py, key = lambda x : (x[0], x[1]))
 
d = {}
for i, (p, y, n) in enumerate(sortPy):
  if p in d:
    d[p] += 1
  else:
    d[p] = 1
  sortPy[i][2] = d[p]

for p, y, n in py:
  print(str(p).zfill(6) + str(n).zfill(6))

Buggy submission (verdict: Runtime Error):
# ID
n,m=map(int,input().split())
s=[[] for _ in range(m)]
for i in range(m):
    p,y=map(int,input().split())
    s[p-1].append([y,i,''])

for i in range(len(s)):
    s[i].sort()

ans=[]
for i,ss in enumerate(s):
    for j,sss in enumerate(ss):
        if ss:
            if sss:
                id_no=''
                id_no+='0'*(6-len(str(i+1)))+str(i+1)
                id_no+='0'*(6-len(str(j+1)))+str(j+1)
                s[i][j][2]=id_no

for i,ss in enumerate(s):
    for j,sss in enumerate(ss):
        ans.append(s[i][j])
ans.sort(key=lambda x:x[1])
for aa in ans:
    print(aa[2])

Buggy submission (verdict: Runtime Error):
# ID
n,m=map(int,input().split())
s=[[] for _ in range(m)]
for i in range(m):
    p,y=map(int,input().split())
    s[p-1].append([y,i])

for i in range(len(s)):
    s[i].sort()

ans=[]
for i,ss in enumerate(s):
    for j,sss in enumerate(ss):
        if ss:
            if sss:
                id_no=''
                id_no+='0'*(6-len(str(i+1)))+str(i+1)
                id_no+='0'*(6-len(str(j+1)))+str(j+1)
                s[i][j].append(id_no)

for i,ss in enumerate(s):
    for j,sss in enumerate(ss):
        ans.append(s[i][j])
ans.sort(key=lambda x:x[1])
for aa in ans:
    print(aa[2])

Buggy submission (verdict: Runtime Error):
# ID
n,m=map(int,input().split())
s=[[] for _ in range(m)]
for i in range(m):
    p,y=map(int,input().split())
    s[p-1].append([y,i])

for i in range(len(s)):
    s[i].sort()

ans=[]
for i,ss in enumerate(s):
    for j,sss in enumerate(ss):
        id_no=''
        id_no+='0'*(6-len(str(i+1)))+str(i+1)
        id_no+='0'*(6-len(str(j+1)))+str(j+1)
        s[i][j].append(id_no)

for i,ss in enumerate(s):
    for j,sss in enumerate(ss):
        ans.append(s[i][j])
ans.sort(key=lambda x:x[1])
for aa in ans:
    print(aa[2])

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().readline().split())
py = []
for _ in range(m):
  py.append(list(map(int,input().split())) + [0])

sortPy = sorted(py, key = lambda x : (x[0], x[1]))
 
d = {}
for i, (p, y, n) in enumerate(sortPy):
  if p in d:
    d[p] += 1
  else:
    d[p] = 1
  sortPy[i][2] = d[p]
 
for p, y, n in py:
  print(str(p).zfill(6) + str(n).zfill(6))

Buggy submission (verdict: Runtime Error):
n, m = map(int, stdin.readline().split())
py = []
for _ in range(m):
  py.append(list(map(int, stdin.readline().split())) + [0])

sortPy = sorted(py, key = lambda x : (x[0], x[1]))
 
d = {}
for i, (p, y, n) in enumerate(sortPy):
  if p in d:
    d[p] += 1
  else:
    d[p] = 1
  sortPy[i][2] = d[p]

for p, y, n in py:
  print(str(p).zfill(6) + str(n).zfill(6))
Problem p03242 (python)

Fixed submission:
n = input()
print(n.replace("9","a").replace("1","9").replace("a","1"))

Buggy submission (verdict: Runtime Error):
n = int(input())
print(replace("9","a").replace("1","9").replace("a","9"))
Problem p03634 (python)

Fixed submission:
# ABC070 D - Transit Tree Path
import heapq
def dijkstra_heap(s):
    """
    始点sから各頂点への最短距離を返す

    Parameters
    ----------
    s : int
        視点とする頂点

    Returns
    -------
    d ：list
    始点sから各頂点への最短距離
    """
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #未使用の頂点の中から最小の距離のものを探す
        if not used[minedge[0]]:
            continue
        v = minedge[0]
        d[v] = minedge[1]
        used[v] = False
        for e in edge[v]:
            if used[e[0]]:
                heapq.heappush(edgelist,[e[0],e[1]+d[v]])
    return d

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

q,k=map(int,input().split())
k-=1
dist=dijkstra_heap(k)
for i in range(q):
    x,y=map(int,input().split())
    x-=1
    y-=1
    print(dist[x]+dist[y])

Buggy submission (verdict: Runtime Error):
def dfs(cur,par,d):
    dist[cur]=d
    for nx,nx_dist in G[cur]:
        if nx==par:continue
        dfs(nx,cur,d+nx_dist)

n=int(input())
G=[[] for i in range(n)]
dist=[0]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    G[a-1].append([b-1,c])
    G[b-1].append([a-1,c])
q,k=map(int,input().split())
k-=1
dfs(k,-1,0)
for i in range(q):
    x,y=map(int,input().split())
    x-=1
    y-=1
    print(dist[x]+dist[y])
Problem p03806 (python)

Fixed submission:
n,ma,mb = map(int,input().split())
a = []
b = []
c = []
for i in range(n):
    aa,bb,cc = map(int,input().split())
    a.append(aa)
    b.append(bb)
    c.append(cc)

inf = 10**18
dp = [[[inf]*(411) for j in range(411)] for i in range(n+1)]
for i in range(n+1):
    dp[i][0][0] = 0
for i in range(n):
    for j in range(400):
        for k in range(400):
            if dp[i][j][k] == inf:continue
            dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k])
            dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i])

ans = 10**18
for j in range(1,401):
    for k in range(1,401):
        if ma*k == mb*j:
            ans = min(ans,dp[n][j][k]) 
if ans == 10**18:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
print(oteagedesita)
Problem p03104 (python)

Fixed submission:
a,b=map(int,input().split())
if a%2==0 and b%2==0:
  if (b-a)%4==0:
    print(b)
  else:
    print(b^1)
elif a%2==0:
  if (b-a)%4==1:
    print(1)
  else:
    print(0)
elif b%2==0:
  if (b-a)%4==1:
    print(a^b)
  else:
    print(a^b^1)
else:
  if (b-a)%4==0:
    print(a)
  else:
    print(a^1)

Buggy submission (verdict: Runtime Error):
a,b=list(map(int,input().split()))
if a%2==0&&b%2==0:
  if (b-a)%4==0:
    print(b)
  else:
    print(b^1)
elif a%2==0:
  if (b-a)%4==1:
    print(0)
  else:
    print(1)
elif b%2==0:
  if (b-a)%4==1:
    print(a^b^1)
  else:
    print(a^b)
else:
  if (b-a)%4==0:
    print(a)
  else:
    print(a^1)
Problem p02550 (python)

Fixed submission:
n,x,m=map(int,input().split())
p=[0]*(m+1)
a=x
t=0
s=0
for i in range(2*m):
    if p[a]==1:
        p[a]=2
        break
    else:
        p[a]=1
        a=a**2%m
a=x
S=0
for i in range(2*m):
    if p[a]==1:
        s+=1
        S+=a
        a=a**2%m
    else:
        s+=1
        S+=a
        break
T=0
A=0
for i in range(2*m):
    a=a**2%m
    t+=1
    T+=a
    if p[a]==2:
        A=a
        break
a = x
if n <= s:
    ans=0
    for i in range(n):
        ans+=a
        a=a**2%m
    print(ans)
else:
    ans=S
    a=A
    n-=s
    ans+=(n//t)*T
    n=n%t
    for i in range(n):
        a=a**2%m
        ans+=a
    print(ans)

Buggy submission (verdict: Runtime Error):
n,x,m = map(int,input().split())
mod = m
num = []
ans = 0
cnt = 0
ch = x

#ループの始まりを特定
while True:
    if ch not in num:
        num.append(ch)
    else:
        st = ch #ループの開始している配列の初めの数字
        break
    ch *= ch
    ch %= mod

#ループの始まりの配列の添え字を特定
for i in range(len(num)):
    if num[i] == st:
        stnum = i #ループ開始の最初の配列のの番号
        break
else:
    stnum = len(num) - 1


if 0 in num:
    ans = sum(num[:n])
else:
    if (len(num)-stnum) != 0:
        rest = (n-stnum)%(len(num)-stnum) #余り
        qu = (n-stnum)//(len(num)-stnum)  #商
    else:
        rest = n
        qu = 0
    if n <= stnum + 1:
        ans = sum(num[:n])
    else:
        ans = sum(num[:stnum]) + sum(num[stnum:stnum+rest]) + sum(num[stnum:])*sho
print(ans)

Buggy submission (verdict: Runtime Error):
n,x,m = map(int,input().split())
st = x
ans = 0
mod = m
num = []
for i in range(n):
    ch = st
    if st in num:
        break
    ans += ch
    st *= st
    st %= mod
    if i != 0 and i != 1:
        num.append(ch)
le = len(num)
if len(num) == 0:
    z = 0
else:
    z  = n//le
rest = (n-1)%le
if 0 in num:
    print(sum(num[:n]) + x + x**2%mod)
else:
    print(z*sum(num) + sum(num[:rest-1]) + x + x**2%mod)

Buggy submission (verdict: Runtime Error):
n,x,m = map(int,input().split())
st = x
ans = 0
mod = m
num = []
for i in range(n):
    ch = st
    if st in num:
        break
    ans += ch
    st *= st
    st %= mod
    if i != 0 and i != 1:
        num.append(ch)
le = len(num)
z  = n//le
rest = (n-1)%le
if 0 in num:
    print(sum(num[:n]) + x + x**2%mod)
else:
    print(z*sum(num) + sum(num[:rest-1]) + x + x**2%mod)
Problem p02595 (python)

Fixed submission:
n , d = map(int,input().split())
import math

ans = 0
cnt = 0
for i in range(n):
    a,b = map(int,input().split())
    if math.sqrt(a**2 + b**2) <= d:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
front = 0
rear = sum(a)
ans = 10**100
for i in range(n-1):
    front += a[i]
    rear -= a[i]
    ans = min(ans,abs(front - rear))
print(ans)
Problem p03834 (python)

Fixed submission:
s=str(input())
for i in range(len(s)):
    if s[i]==",":
        s=s[:i]+" "+s[i+1:]
print(s)

Buggy submission (verdict: Runtime Error):
s=str(input())
for i in s:
    if s[i]==",":
        s=s[:i]+" "+s[i+1:]
print(s)