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

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

loopcount=0
tmpPoint=1
vis={1:0}
for i in range(N):
    Next=A[tmpPoint-1]
    if Next in vis:
        startat=i
        #print(startat)
        #print(tmpPoint)
        #print(vis)
        #print(Next)
        #print(vis[Next]+1)
        loopcount=i - vis[Next]+1
        break
    vis[Next]=i+1
    tmpPoint=Next

if loopcount==0:
    print(tmpPoint)
    exit()
if startat+loopcount < K:
    nokori=(K-startat) % loopcount
    K=startat+nokori

tmpPoint=1
for i in range(K):
    Next=A[tmpPoint-1]
    tmpPoint=Next
print(tmpPoint)

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

loopcount=0
tmpPoint=1
vis={1:0}
for i in range(N):
    Next=A[tmpPoint-1]
    if Next in vis:
        startat=i
        #print(startat)
        #print(tmpPoint)
        #print(vis)
        #print(Next)
        #print(vis[Next]+1)
        loopcount=i - vis[Next]+1
        break
    vis[Next]=i+1
    tmpPoint=Next

if loopcount==0:
    print(tmpPoint)
    exit()
if startat+nokori < K:
    nokori=(K-startat) % loopcount

tmpPoint=1
for i in range(startat+nokori):
    Next=A[tmpPoint-1]
    tmpPoint=Next
print(tmpPoint)

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

loopcount=0
tmpPoint=1
vis={1:0}
for i in range(N):
    Next=A[tmpPoint-1]
    if Next in vis:
        startat=i
        #print(startat)
        #print(tmpPoint)
        #print(vis)
        #print(Next)
        #print(vis[Next]+1)
        loopcount=i - vis[Next]+1
        break
    vis[Next]=i+1
    tmpPoint=Next

if loopcount==0:
    print(tmpPoint)
    exit()
if startat+loopcount < K:
    nokori=(K-startat) % loopcount

tmpPoint=1
for i in range(startat+nokori):
    Next=A[tmpPoint-1]
    tmpPoint=Next
print(tmpPoint)
Problem p02718 (python)

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

list.sort(A,reverse=True)

sumnum = sum(A)
if A[M-1] >= (sumnum/(4*M)):
    print("Yes")
else:
    print("No")

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

list.sort(A,reverse=True)

sumnum = sum(A)

if A[M] > (sumnum/(4*M)):
    print("Yes")
else:
    print("No")
Problem p02765 (python)

Fixed submission:
a,b=map(int, input().split())
x = b if a>10 else b+((10-a)*100)
print(x)

Buggy submission (verdict: Runtime Error):
a,b=map(int, input().split())
print a>10?b:b+800
Problem p03260 (python)

Fixed submission:
T = [int(a) for a in input().split()]
if (T[0]*T[1])%2 == 0:
  	print("No")
else:
	print("Yes")

Buggy submission (verdict: Runtime Error):
T = [int(a) for a in input().split()]
if (T[0]*T[1])%2 == 0:
  	print("No")
else
	print("Yes")
Problem p02608 (python)

Fixed submission:
import numpy as np
#import functools
#import operator
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm
#import collections as C #most_common
#import math
#import sympy

N = int(input())
#N,K,d= map(int,input().split())
#A = list(map(int,input().split()))
#S = str(input())
#T = str(input())

num=np.zeros(10**4+1)
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if ans < 10**4+1:
                num[ans]+=1


for i in range(N):
    print(int(num[i+1]))

Buggy submission (verdict: Runtime Error):

N = int(input())
#N,K,d= map(int,input().split())
#A = list(map(int,input().split()))
#S = str(input())
#T = str(input())

num=np.zeros(10**4+1)
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if ans < 10**4+1:
                num[ans]+=1


for i in range(N):
    print(int(num[i+1]))
Problem p02618 (python)

Fixed submission:
#import math
import numpy as np
#import torch
#import torch.nn as nn
#import matplotlib.pyplot as plt
#from decimal import Decimal
#import itertools
#import collections

D=int(input())
#N,M,K = map(int,input().split())
#B,W = map(int,input().split())
#T=int(input())
C = list(map(int,input().split()))
#S=str(input())
c=np.zeros(365)
l=np.zeros([26,365])
T=[]
for i in range(D):
    S = list(map(int,input().split()))
    t=max(S)
    T.append(S.index(t))
    #for i in range(26):
    #    n=
for s in T:
    print(s+1)

Buggy submission (verdict: Runtime Error):
#import math
import numpy as np
#import torch
#import torch.nn as nn
#import matplotlib.pyplot as plt
#from decimal import Decimal
#import itertools
#import collections

D=int(input())
#N,M,K = map(int,input().split())
#B,W = map(int,input().split())
#T=int(input())
C = list(map(int,input().split()))
#S=str(input())
c=np.zeros(365)
l=np.zeros([26,365])
T=[]
for i in range(D):
    S = map(int,input().split())
    t=max(S)
    T.append(S.index(t))
    #for i in range(26):
    #    n=
for s in T:
    print(s)
Problem p02646 (python)

Fixed submission:
#import math
#import numpy as np
#import torch
#import torch.nn as nn
#import matplotlib.pyplot as plt
#from decimal import Decimal

#N=int(input())
A,V = map(int,input().split())
B,W = map(int,input().split())
T=int(input())
#A = list(map(int,input().split()))
#S=str(input())

if V<=W:
    print('NO')
else:
    L=abs(A-B)
    if L/(V-W)<=T:
        print('YES')
    else:
        print('NO')

Buggy submission (verdict: Runtime Error):
#import math
#import numpy as np
#import torch
#import torch.nn as nn
#import matplotlib.pyplot as plt
#from decimal import Decimal

#N=int(input())
A,V = map(int,input().split())
B,W = map(int,input().split())
T=int(input())
#A = list(map(int,input().split()))
#S=str(input())

if V<=W:
    print('NO')
else:
    L=abs(A-B)
    if L%(V-W)==0:
        if L/(V-W)<=T:
            print('YES')
        else:
            print('NO')
    else:
        while T>0:
            T-=1
            L=L+V+W
            if L/(V-W)<=T:
                print('YES')
                exit()
            if V*T<L:
                ptint('NO')
                exit()

        print('NO')
Problem p02683 (python)

Fixed submission:
from itertools import combinations
import numpy as np
#S= str(input())
#T= str(input())
N,M,X = map(int,input().split())
#N = int(input())
#A = list(map(int,input().split()))
a=[]
ans=[]
for j in range(N):

    A = list(map(int,input().split()))
    a.append(A)

for i in range(1,N+1):
    for l in list(combinations(a,i)):
        s=np.zeros(M+1)
        for k in l:
            k=np.array(k)
            s=s+k
        #print(s)

        if min(s[1:])>=X:
            ans.append(s[0])
if len(ans)==0:
    print(-1)
else:
    print(int(min(ans)))

Buggy submission (verdict: Runtime Error):
from itertools import combinations
import numpy as np
#S= str(input())
#T= str(input())
N,M,X = map(int,input().split())
#N = int(input())
#A = list(map(int,input().split()))
a=[]
c=[]
ans=[]
for j in range(N):

    A = list(map(int,input().split()))
    c.append(A)
    a.append(A)

for i in range(1,N+1):
    for l in list(combinations(a,i)):
        s=np.zeros(M+1)
        for k in l:
            k=np.array(k)
            s=s+k
        #print(s)
        
        if min(s)>=X:
            ans.append(s[0])
print(int(min(ans)))
Problem p02684 (python)

Fixed submission:
#N=int(input())
N,K = map(int,input().split())
#N=int(input())
A = list(map(int,input().split()))
#S=str(input())

now=1
flag=[-1]*(N)

for i in range(K):
    if flag[now-1]==-1:
        flag[now-1]=i
        now = A[now-1]
    else:
        loop = i - flag[now-1]
        zan=(K-(i-loop))%loop
        ans = flag.index(i-loop+zan)+1
        print(ans)
        exit()

print(now)

Buggy submission (verdict: Runtime Error):
#N=int(input())
N,K = map(int,input().split())
#N=int(input())
A = list(map(int,input().split()))
#S=str(input())

now=1
flag=[-1]*(N)

for i in range(N):
    if flag[now-1]==-1:
        flag[now-1]=i
        now = A[now-1]
    else:
        loop = i+1 - flag[now-1]
        zan=(K-(i-loop))%loop
        ans = flag.index(flag[now-1]+zan)+1
        print(ans)
        exit()

print(now)
Problem p02922 (python)

Fixed submission:
a = [int(i) for i in input().split()]
ans=0
num=0

while True:
    if a[1]==1:
        break
    if (a[0]-1)*num+a[0] >= a[1]:
        ans = num+1
        break
    num += 1
print(ans)

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

for i in range 100:
  C = A*i - i
  if C >= B:
    break
print(i)

Buggy submission (verdict: Runtime Error):
a = [int(i) for i in input().split()]
ans=0
num=0
while True:
  	if a[1]==1:
      break
    if (a[0]-1)*num+a[0] >= a[1]:
        ans = num+1
        break
    num += 1
print(ans)
Problem p02995 (python)

Fixed submission:
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
abcd = input().split(" ")
a = int(abcd[0])
b = int(abcd[1])
c = int(abcd[2])
d = int(abcd[3])
cd = lcm(c, d)
print(b-a-(b//c-((a-1)//c + 1))-(b//d - ((a-1)//d + 1))+(b//cd-((a-1)//cd + 1)))

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d = [int(i) for i in input().split()]

l= (c * d) // math.gcd(c, d)

s=(b-a-(b//c-((a-1)//c + 1))-(b//d - ((a-1)//d + 1))+(b//cd-((a-1)//cd + 1)))
print(s)

Buggy submission (verdict: Runtime Error):
import math
A,B,C,D = [int(i) for i in input().split()]

l= (C * D) // math.gcd(C, D)

s=B - A + 1 - (((B//C - (A-1)//C))+(B//D - (A-1)//D)-(B//l)-((A-1)//l))
print(s)

Buggy submission (verdict: Runtime Error):
import math
A,B,C,D = [int(i) for i in input().split()]

l= (C * D) // math.gcd(C, D)

s=B - A + 1 - ((B//C - (A-1)//C)+(B//D - (A-1)//D)-(B//l))
print(s)

Buggy submission (verdict: Runtime Error):
import math
A,B,C,D = [int(i) for i in input().split()]

l= C * D // math.gcd(C, D)

s=B - A + 1 - ((B//C - (A-1)//C)+(B//D - (A-1)//D)-(B//l))
print(s)

Buggy submission (verdict: Runtime Error):
import math
A,B,C,D = [int(i) for i in input().split()]

l= C * D / math.gcd(C, D)

s=B - A + 1 - ((B//C - (A-1)//C)+(B//D - (A-1)//D)-(B//l))
print(int(s))

Buggy submission (verdict: Runtime Error):
A,B,C,D = [int(i) for i in input().split()]
import math
l= C * D / math.gcd(C, D)

s=B - A + 1 - ((B//C - (A-1)//C)+(B//D - (A-1)//D)-(B//l))
print(int(s))

Buggy submission (verdict: Runtime Error):
A,B,C,D = [int(i) for i in input().split()]
import math
l= C * D / math.gcd(C, D)

s=B - A + 1 - ((B//C - (A-1)//C)+(B//D - (A-1)//D)-(B//l))
print(s)
Problem p03029 (python)

Fixed submission:
s,t = map(int,input().split())
f=(s*3+t)//2
print(f)

Buggy submission (verdict: Runtime Error):
A,P=input().split()
print((3*A+2)//2)
Problem p03037 (python)

Fixed submission:
#import numpy as np
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with

#A = int(input())
N,M= map(int,input().split())
#A = list(map(int,input().split()))
#B = list(map(int,input().split()))
#S= str(input())
p=1
left=1
right=N
for m in range(M):
    l,r = map(int,input().split())
    if left<=l and l<=right:
        left=l
    if left<=r and r<=right:
        right=r

    if right<l or r<left:
        p=0

if not p:
    print(p)
    exit()
print(right-left+1)

Buggy submission (verdict: Runtime Error):
#import numpy as np
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with

#A = int(input())
N,M= map(int,input().split())
#A = list(map(int,input().split()))
#B = list(map(int,input().split()))
#S= str(input())
left=1
right=N
for m in range(M):
    l,r = map(int,input().split())
    if left<=l and l<=right:
        left=l
    if left<=r and r<=right:
        right=r

    if right<l or r<left:
        p=0

if not p:
    print(p)
    exit()
print(right-left+1)
Problem p03080 (python)

Fixed submission:
N=int(input())
s=str(input())
r=[]
b=[]
for i in range(N):

  if s[i]=='R':
    r.append(s[i])
  else:
    b.append(s[i])
if len(r) > len(b):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N=int(input())
s=input().split()
r=[]
b=[]
for i in s:
  if i=='R':
    r.append(i)
  else:
    b.append(i)
if len(a) > len(b):
  print('Yes')
else:
  print('No')
Problem p03086 (python)

Fixed submission:
S= str(input())
#N,K = map(int,input().split())
#N = int(input())
#V = list(map(int,input().split()))
C=[]
c=0
for i in range(len(S)):
    if S[i]=='A' or S[i]=='T' or S[i]=='C' or S[i]=='G':
        c+=1
    else:
        C.append(c)
        c=0
C.append(c)
print(max(C))

Buggy submission (verdict: Runtime Error):
S= str(input())
#N,K = map(int,input().split())
#N = int(input())
#V = list(map(int,input().split()))
C=[]
c=0
for i in range(len(S)):
    if S[i]=='A' or S[i]=='T' or S[i]=='C' or S[i]=='G':
        c+=1
    else:
        C.append(c)
        c=0

print(max(C))
Problem p03680 (python)

Fixed submission:
#import numpy as np
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm


N = int(input())
#H1,M1,H2,M2,K= map(int,input().split())
#A = list(map(int,input().split()))
#B = list(map(int,input().split()))
#S= str(input())
l=[]
for i in range(N):
    B = int(input())
    l.append(B)

now=0
next=1
c=0
while c<10**6:
    now=next
    if now==2:
        print(c)
        exit()
    next=l[now-1]
    c+=1

print(-1)

Buggy submission (verdict: Runtime Error):
#import numpy as np
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm


N = int(input())
#H1,M1,H2,M2,K= map(int,input().split())
#A = list(map(int,input().split()))
#B = list(map(int,input().split()))
#S= str(input())
l=[]
for i in range(N):
    B = int(input())
    l.append(B)

now=0
next=1
c=0
while c<10**6
Problem p04030 (python)

Fixed submission:
s=str(input())
x=''
list=[]
for i in range(len(s)):
    if s[i]=='1':
        list.append('1')
    elif s[i]=='0':
        list.append('0')
    elif s[i]=='B' and len(list)!=0:
        del list[len(list)-1]

for i in range(len(list)):
    x += list[i]

print(x)

Buggy submission (verdict: Runtime Error):
s=str(input())
x=''
list=[]
for i in range(len(s)):
    if s[i]=='1':
        list.append('1')
    elif s[i]=='0':
        list.append('0')
    elif s[i]=='B' and len(list)!=0:
        del list[i-1]

for i in range(len(list)):
    x += list[i]

print(x)

Buggy submission (verdict: Runtime Error):
s=str(input())
x=''
list=[]
for i in range(len(s)):
    if s[i]=='1':
        list.append('1')
    elif s[i]=='0':
        list.append('0')
    elif s[i]=='B' and len(list)!=0:
        del list[i-1]
    print(list)
for i in range(len(list)):
    x += list[i]

print(x)

Buggy submission (verdict: Runtime Error):
s=str(input())
x=''
list=[]
for i in range(len(s)):
    if s[i]=='1':
        list.append('1')
    elif s[i]=='0':
        list.append('0')
    elif s[i]=='B' and len(list)!=0:
        del list[i-1]
    print(list)
for i in range(len(list)):
    x += list[i]

print(x)
Problem p02616 (python)

Fixed submission:
mod = 10**9+7
N, K = map(int,input().split())
A = sorted(list(map(int,input().split())))

pi = 1
ni = 0
ans = 1
i = 0
while i < K-1:
  if A[ni]*A[ni+1] > A[-pi]*A[-pi-1]:
    ans = ans*A[ni]*A[ni+1]%mod
    ni += 2
    i += 2
    
  else:
    ans = ans*A[-pi]%mod
    pi += 1
    i += 1
    
if i == K-1:
  ans = ans*A[-pi]%mod
  
if A[-1]<0 and K%2==1:
  ans = 1
  for i in A[N-K:]:
    ans = ans*i%mod

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
import sys

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

mod = 10 ** 9 + 7
num = 0
Ans = 1

while num < K-1:
    non_minus = A[-1] * A[-2]
    minus = A[0] * A[1]
    if non_minus > minus:
        Ans = Ans * A.pop() % mod
        num += 1
    else:
        Ans = Ans * A.popleft() * A.popleft() % mod
        num += 2

if num == K - 1:
    Ans = Ans * A[-1] % mod
    
if A[-1] < 0 and K % 2 == 1:
    Ans = 1
    for i in range(K):
        Ans = Ans * A[i] % mod

print(Ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
import sys

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

mod = 10 ** 9 + 7
num = 0
Ans = 1

while num < K-1:
    non_minus = A[-1] * A[-2]
    minus = A[0] * A[1]
    if non_minus > minus:
        Ans = Ans * A.pop() % mod
        num += 1
    else:
        Ans = Ans * A.popleft() * A.popleft() % mod
        num += 2

if num == K - 1:
    Ans = Ans * A[-1] % mod
    
if A[-1] < 0 and K % 2 == 1:
    for i in range(K):
        Ans = Ans * A[i] % mod
    print(Ans)
    sys.exit()

print(Ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
import sys

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

mod = 10 ** 9 + 7
num = 0
Ans = 1

if A[-1] < 0 and K % 2 == 1:
    for i in range(K):
        Ans = Ans * A[i] % mod
    print(Ans)
    sys.exit()

while num < K:
    non_minus = A[-1] * A[-2]
    minus = A[0] * A[1]
    if num == K-1 or non_minus > minus:
        Ans = Ans * A.pop() % mod
        num += 1
    else:
        Ans = Ans * A.popleft() * A.popleft() % mod
        num += 2

print(Ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
import sys

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

mod = 10 ** 9 + 7
num = 0
Ans = 1

if A[-1] < 0 and K % 2 == 1:
    for i in range(K):
        Ans = Ans * A[i] % mod
    print(Ans)
    sys.exit()

while num < K:
    non_minus = A[-1] * A[-2]
    minus = A[0] * A[1]
    if num == K-1 or non_minus > minus:
        Ans = Ans * A.pop() % mod
        num += 1
    else:
        Ans = Ans * A.popleft() * A.popleft() % mod
        num += 2

print(Ans)
Problem p02714 (python)

Fixed submission:
import collections
import math

N = int(input())
S = list(input())

if 'R' in S and 'G'in S and 'B' in S:
    count = collections.Counter(S)
    c_value = list(count.values())
    con = c_value[0]*c_value[1]*c_value[2]
else:
    con = 0

for i in range(N):
    for j in range(i+1, int(math.ceil((N+i)/2))):
        if S[i] != S[j]:
            if S[i] != S[j + (j - i)] and S[j] != S[j + (j - i)]:
                con -= 1

print(con)

Buggy submission (verdict: Runtime Error):
import collections
import math

N = int(input())
S = list(input())

count = collections.Counter(S)
c_value = list(count.values())
con = c_value[0]*c_value[1]*c_value[2]

for i in range(N):
    for j in range(i+1, int(math.ceil((N+i)/2))):
        if S[i] != S[j]:
            if S[i] != S[j + (j - i)] and S[j] != S[j + (j - i)]:
                con -= 1

print(con)
Problem p02801 (python)

Fixed submission:
C = input()

L = list('abcdefghijklmnopqrstuvwxyz')

for i in range(26):
    if C == L[i]:
        print(L[i + 1])
        break

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

A = [[0] * 2 for i in range(M)]

for i in range(M):
    A[i][0], A[i][1] = input().split()


AC = [0] * M
WA = [0] * M

for j in range(M)[::-1]:
    if A[j][1] == 'AC' and (A[j][0] in AC) is False:
        AC[j] = A[j][0]
    elif A[j][1] == 'WA' and (A[j][0] in AC) is True:
        WA[j] = A[j][0]

print(len(AC) - AC.count(0), len(WA) - WA.count(0))
Problem p02812 (python)

Fixed submission:
N = int(input())
S = list(input())

count = 0

if N >= 3:
    for i in range(N - 1):
        if (i + 2) < N and S[i] == 'A' and S[i + 1] == 'B' and S[i + 2] == 'C':
           count += 1
    print(count)
else:
    print(0)

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

count = 0

if N >= 3:
    for i in range(N - 1):
        if S[i] == 'A' and S[i + 1] == 'B' and S[i + 2] == 'C':
           count += 1
    print(count)
else:
    print(0)

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

count = 0
for i in range(N - 1):
    if S[i] == 'A' and S[i + 1] == 'B' and S[i + 2] == 'C':
        count += 1

print(count)

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

count = 0
for i in range(N - 1):
    if S[i] == 'A' and S[i + 1] == 'B' and S[i + 2] == 'C':
        count += 1

print(count)
Problem p02899 (python)

Fixed submission:
import numpy as np

N = int(input())
Stu = list(input().split())
Stu2 = [int(i) for i in Stu]

x = np.argsort(Stu2)
for i in range(N):
    Stu[i] = x[i] + 1

print(' '.join(map(str, Stu)))

Buggy submission (verdict: Runtime Error):
mport numpy as np

N = int(input())
Stu = list(input().split())
Stu2 = [int(i) for i in Stu]
print(Stu2)

x = np.argsort(Stu2)
print(x)
for i in range(N):
    Stu[i] = x[i] + 1

print(' '.join(map(str, Stu)))
Problem p02995 (python)

Fixed submission:
import math
import fractions

A, B, C, D = map(int, input().split())
lcm = C * D // fractions.gcd(C, D)

count = 0
if A % C == 0:
    div_C = B // C - A // C + 1
else:
    div_C = B // C - A // C

if A % D == 0:
    div_D = B // D - A // D + 1
else:
    div_D = B // D - A // D

if A % lcm == 0:    
    div_C_D = B // lcm - A // lcm + 1
else:
    div_C_D = B // lcm - A // lcm

print(B - A + 1 - div_C - div_D + div_C_D)

Buggy submission (verdict: Runtime Error):
import math

A, B, C, D = map(int, input().split())
lcm = C * D // math.gcd(C, D)

count = 0
div_C = B // C - math.ceil(A / C) + 1
div_D = B // D - math.ceil(A / D) + 1
div_C_D = B // lcm - math.ceil(A / lcm) + 1


print(B - A + 1 - div_C - div_D + div_C_D)
Problem p03087 (python)

Fixed submission:
N, Q = map(int, input().split())
S = input()
query = [input().split() for i in range(Q)]
AC = [0 for i in range(N+1)]

for i in range(N):
    AC[i+1] = AC[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
    L, R = int(query[i][0]), int(query[i][1])
    print(AC[R-1] - AC[L-1])

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
query = [input().split() for i in range(Q)]
AC = [0 for i in range(N)]

for i in range(N):
    if S[i] == 'A' and S[i+1] == 'C':
        AC[i] = 1

for i in range(Q):
    L, R = int(query[i][0]), int(query[i][1])
    if S[R-1] == 'A':
        print(sum(AC[L-1:R-1]))
    else:
        print(sum(AC[L-1:R]))
Problem p03386 (python)

Fixed submission:
A, B, K = map(int, input().split())
candidate1 = [i for i in range(A, A+K) if i <= B]
candidate2 = [i+1 for i in range(B-K, B) if i+1 >= A]

ans = list(sorted(list(set(candidate1+candidate2))))
ans = [str(ans[i]) for i in range(len(ans))]

print('\n'.join(ans))

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
candidate1 = [i for i in range(A, A+K) if i <= B]
candidate2 = [i+1 for i in range(B-K, B) if i+1 >= A]

ans = list(sorted(list(set(candidate1+candidate2))))
ans = [str(ans[i]) for i in range(len(candidate2) + len(candidate1))]

print('\n'.join(ans))
Problem p03486 (python)

Fixed submission:
s = sorted(list(input()))
t = sorted(list(input()), reverse = True)

Alpha = ['0', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 
         'u', 'v', 'w', 'x', 'y', 'z']

while len(s) != len(t):
    if len(s) > len(t):
        t.append('0')
    else:
        s.append('0')

for i in range(len(s)+1):
    if i == len(s):
        print('No')
    elif Alpha.index(s[i]) < Alpha.index(t[i]):
        print('Yes')
        break
    elif Alpha.index(s[i]) > Alpha.index(t[i]):
        print('No')
        break
    else:
        continue

Buggy submission (verdict: Runtime Error):
s = sorted(list(input()))
t = sorted(list(input()), reverse = True)

Alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 
         'u', 'v', 'w', 'x', 'y', 'z']

for i in range(len(s)+1):
    if i == len(s):
        if len(t) > len(s):
            print('Yes')
        else:
            print('No')
    elif Alpha.index(s[i]) < Alpha.index(t[i]):
        print('Yes')
        break
    elif Alpha.index(s[i]) > Alpha.index(t[i]):
        print('No')
        break
    else:
        continue