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

Fixed submission:
from collections import Counter
from sys import exit

n=int(input())
s=input()

l=list(Counter(s).values())
if len(l)<3:
	print("0")
	exit()
	
res=l[0]*l[1]*l[2]

for i in range(1,n//2+1):
	for j in range(n):
		if j+i*2>n-1:
			break
		a=j
		b=j+i
		c=b+i
		if s[a]!=s[b] and s[b]!=s[c] and s[c]!=s[a]:
			res-=1
			
print(res)

Buggy submission (verdict: Runtime Error):
from collections import Counter

n=int(input())
s=input()

l=list(Counter(s).values())
res=l[0]*l[1]*l[2]

dis=0
chk=0

while chk==0:
	dis+=1
	for i in range(n):
		if dis*2>n-1:
			chk=1
			break
		if i+dis*2>n-1:
			break
		j=i+dis
		k=i+dis*2
		if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
			res-=1
			
print(res)
Problem p02768 (python)

Fixed submission:
mod=10**9+7

n,a,b=map(int,input().split())
res=pow(2,n,mod)
res=(res-1)%mod

ncb=1
for i in range(1,b+1):
	ncb*=(n-i+1)*pow(i,mod-2,mod)
	ncb%=mod
	if i==a:
		nca=ncb
		
print((res-nca-ncb)%mod)

Buggy submission (verdict: Runtime Error):
mod=10**9+7

n,a,b=map(int,input().split())
res=pow(2,n,mod)
res=(res-1)%mod

up=1
down=1
for i in range(1,b+1):
	up*=(n-i+1)
	up%mod
	down*=i
	if i==a:
		upa=up
		downa=down

nca=upa%mod
nca*=pow(downa,mod-2,mod)
nca%=mod
ncb=(up%mod)
ncb=*pow(down,mod-2,mod)
ncb%=mod
print((res-nca-ncb)%mod)

Buggy submission (verdict: Runtime Error):
mod=10**9+7

class Combination:
	def __init__(self,size):
		self.size = size + 2
		self.fact = [1, 1] + [0] * size
		self.factInv = [1, 1] + [0] * size
		self.inv = [0, 1] + [0] * size
		
		for i in range(2, self.size):
			self.fact[i] = self.fact[i - 1] * i % mod
			self.inv[i] = -self.inv[mod % i] * (mod//i) % mod
			self.factInv[i] = self.factInv[i - 1] * self.inv[i] % mod
			
	def npk(self,n,k):
		if n < k or n < 0 or k < 0:
			return 0
		return self.fact[n] * self.factInv[n - k] % mod
		
	def nck(self,n,k):
		if n < k or n < 0 or k < 0:
			return 0
		return self.fact[n] * (self.factInv[k] * self.factInv[n - k] % mod) % mod
		
	def nhk(self,n,k):
		return self.nck(n + k - 1, n - 1)
		
n,a,b=map(int,input().split())

ca=Combination(n+a)
cb=Combination(n+b)
nca=ca.nck(n,a)
ncb=cb.nck(n,b)

print(((2**n-1)%mod-nca-ncb)%mod)
Problem p02772 (python)

Fixed submission:
import sys
n = int(input())
A = list(map(int,input().split()))

for a in A:
	if a%2 == 0:
		if a%3 != 0 and a%5 != 0:
			print("DENIED")
			sys.exit()

print("APPROVED")

Buggy submission (verdict: Runtime Error):
from sys import exit
n = int(input())
A = list(map(int,input().split()))

for a in A:
	if a%2 == 0:
		if a%3 != 0 and a%5 != 0:
			print("DENIED")
			sys.exit()

print("APPROVED")
Problem p02789 (python)

Fixed submission:
n,m=map(int,input().split())
print("Yes") if n==m else print("No")

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
print(Yes) if n==m else print(No)
Problem p02801 (python)

Fixed submission:
c=input()
print(chr(ord(c)+1))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
for i in range(m):
	p,s=input().split()
	if p in a:
		continue
	if s=="AC":
		a.append(p)
print(len(a))
Problem p02802 (python)

Fixed submission:
n,m=map(int,input().split())
a=[-1]*n
for i in range(m):
	p,s=input().split()
	p=int(p)-1
	if s=="AC" and a[p]<0:
		a[p] = a[p]*(-1)
	if s=="WA" and a[p]<0:
		a[p] -= 1
ac=0
wa=0
for i in range(n):
	if a[i] > 0:
		ac += 1
		wa += a[i] - 1

print(ac,wa)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[-1]*(10**5)
for i in range(n):
	p,s=input().split()
	p=int(p)
	if s=="AC" and a[p]<0:
		a[p] = a[p]*(-1)
	if s=="WA" and a[p]<0:
		a[p] -= 1
ac=0
wa=0
for i in range(n):
	if a[i] > 0:
		ac += 1
		wa += a[i] - 1

print(ac,wa)
Problem p02898 (python)

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

res = 0
 
for i in h:
	if i >= k:
		res = res + 1
print(res)

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

res=0

for i in h:
	if i>=k:
       res = res + 1
       
print(res)
Problem p02910 (python)

Fixed submission:
s = input()
 
for i in range(len(s)):
	if i%2==1 and s[i]=='R':
		print('No')
		exit()
	elif i%2==0 and s[i]=='L':
		print('No')
		exit()
 
print('Yes')

Buggy submission (verdict: Runtime Error):
s = input()
 
for i in range(len(s))
	if i%2==0 and s[i]=='R':
    	print('No')
    	exit()
    elif i%2==1 and s[i]=='L':
    	print('No')
    	exit()
 
print('Yes')

Buggy submission (verdict: Runtime Error):
s = input()
 
for i in range(len(s))
	if i%2==0 and s(i)=='R':
    print('No')
    exit()
    elif i%2==1 and s(i)=='L':
    print('No')
    exit()

print('Yes')

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

for i in range(len(s))
	if i%2==0 and s(i)=='R':
    print('No')
    exit
    elif i%2==1 and s(i)=='L':
    print('No')
    exit
print('Yes')
Problem p02923 (python)

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

res=0
cnt=0
for i in range(n-1):
	if H[i]>=H[i+1]:
		cnt += 1
	else:
		cnt = 0
	res=max(res,cnt)
print(res)

Buggy submission (verdict: Runtime Error):
import math

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

b = b - a
a = a - 1
print(1+math.ceil(b/a))
Problem p02945 (python)

Fixed submission:
a, b = map(int,input().split())
x=a+b
y=a-b
z=a*b
list=[x,y,z]
print(max(list))

Buggy submission (verdict: Runtime Error):
import collections
n=int(input())
s=collections.Counter(["".join(sorted(input())) for _ in range(n)])
v=list(s.values())
res=0
for u in v:
	if u!=1:
		res += u*(u-1)//2
print(res)

Buggy submission (verdict: Runtime Error):
P=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101]
n=int(input())
A=[1]*n

for i in range(n):
	s=input()
	for j in range(10):
		A[i] *= P[ord(s[j])-97]

res=0
for i in range(n):
	for j in range(i+1,n):
		if A[i]==A[j]:
			res += 1
print(res)

Buggy submission (verdict: Runtime Error):
a, b = map(int,input().split())
print(max[a+b,a-b,a*b])
Problem p02947 (python)

Fixed submission:
P=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101]
n=int(input())
A=[1]*n

for i in range(n):
	s=input()
	for j in range(10):
		A[i] *= P[ord(s[j])-97]

res=0
A.sort()
cnt=0

for i in range(n-1):
		if A[i]==A[i+1]:
			cnt += 1
		else:
			res += cnt*(cnt+1)//2
			cnt=0
if cnt != 0:
	res += cnt*(cnt+1)//2
print(res)

Buggy submission (verdict: Runtime Error):
P=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101]
n=int(input())
A=[1]*n

for i in range(n):
	s=input()
	for j in range(10):
		A[i] *= P[ord(s[j])]

res=0
for i in range(n):
	for j in range(i+1,n):
		if A[i]==A[j]:
			res += 1
print(res)
Problem p02952 (python)

Fixed submission:
N = int(input())
n = len(str(N))
 
if n==1:
	print(N)
else:
	M = [9,0]*(n//2)			#list[9,0]がn//2個繋がっている
	M.pop()						#pop()でlistの最後尾を削除
	M = map(str,M)				#joinの際には文字列しか使えないのでstrを使用
	M = int(''.join(M))			#join(M)=90909みたいな。それを数字化
	if n%2==0:
		print(M)
	else:
		M = M + N - 10**(n-1) + 1
		print(M)

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

if n==1:
	print(N)
else:
	M = [9,0]*(n//2)			#list[9,0]がn//2個繋がっている
    M.pop()						#pop()でlistの最後尾を削除
    M = map(str,M)				#joinの際には文字列しか使えないのでstrを使用
    M = int(''.join(M))			#join(M)=90909みたいな。それを数字化
    if n%2==0:
		print(M)
	else:
		M = M + N - 10**n + 1
        print(M)
Problem p03029 (python)

Fixed submission:
a,p=map(int,input().split())
print((a*3+p)//2)

Buggy submission (verdict: Runtime Error):
a,p=map(int,input().split())
print((a*3+p)//2
Problem p03145 (python)

Fixed submission:
a,b,c=map(int,input().split())	#map(int　でinputの中身をint性質にしている
print(b*a//2)					#//はint表示、/はreal表示。多分

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())	!map(int　でinputの中身をint性質にしている
print(b*a//2)					!//はint表示、/はreal表示。多分
Problem p03238 (python)

Fixed submission:
n=int(input())
if n==1:
	print("Hello World")
else:
	a=int(input())
	b=int(input())
	print(a+b)

Buggy submission (verdict: Runtime Error):
n=int(input()
if n==1:
	print("Hello World")
else:
	a=int(input())
	b=int(input())
	print(a+b)
Problem p03239 (python)

Fixed submission:
N,T=map(int,input().split())
res=1001

for _ in range(N):
	c,t=map(int,input().split())
	if t<=T:
		res=min(res,c)

if res==1001:
	print("TLE")
else:
	print(res)

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

for _ in range(N):
	c,t=map(int,input().split())
	if t<=T:
		res=min(res,c)

if res=1001:
	print("TLE")
else:
	print(res)
Problem p03240 (python)

Fixed submission:
from sys import exit

def ht(cx,cy,x,y,h):
	return h+abs(x-cx)+abs(y-cy)

n=int(input())			#高々100なのでほとんどが高さ0っていう状況はない
xyh=[0]*n

for i in range(n):
	x,y,h=map(int,input().split())
	xyh[i]=[x,y,h]
xyh.sort(key=lambda x:x[2],reverse=True)			#h=0を選択してしまうことを避ける

for cx in range(101):
	for cy in range(101):
		H=ht(cx,cy,xyh[0][0],xyh[0][1],xyh[0][2])
		for i in range(1,n):
			if max(H-abs(xyh[i][0]-cx)-abs(xyh[i][1]-cy),0)!=xyh[i][2]:			#H=ht(このfor文で選択した座標)にすると、高さ0の場合に合わなくなる
				break
			
		else:			#直前のifが行われなければ、という意味。forの外における
			print(cx,cy,H)
			exit()

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

n=int(input())
x=[0]*n
y=[0]*n
h=[0]*n

for i in range(n):
	xx,yy,hh=map(int,input().split())
	x[i]=xx
	y[i]=yy
	h[i]=hh
	
hres=0

if n==1:
	print(xx,yy,hh)
	exit()
else:
	for cx in range(101):
		for cy in range(101):
			cnt=0
			h2=h[0]+abs(x[0]-cx)+abs(y[0]-cy)
			for i in range(1,n):
				h1=h[i]+abs(x[i]-cx)+abs(y[i]-cy)
				if h2!=h1:
					cnt=1
			if cnt==0 and h1>hres:
				hres=h1
				xres=cx
				yres=cy
				
print(xres,yres,hres)
Problem p03273 (python)

Fixed submission:
h,w=map(int,input().split())
a=[]
for _ in range(h):
	b=[]
	s=input()
	for i in range(w):
		b.append(s[i])
	a.append(b)
	
#タテのチェック
for i in range(w):
	tmp=0
	for j in range(h):
		if a[j][i]=="#":
			tmp=1
	if tmp==0:
		for j in range(h):
			a[j][i]="0"

#ヨコのチェック
for i in range(h):
	if not "#" in a[i][:]:
		a[i][:]=[0]*w

for i in range(h):
	tmpl=[]
	for j in range(w):
		if not a[i][j]=="0":
			tmpl.append(a[i][j])
	if "#" in tmpl or "." in tmpl:
		print("".join(tmpl))		#listを詰めて表示

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
a=[list(input().split()) for _ in range(h)]

#タテのチェック
for i in range(w):
	tmp=0
	for j in range(h):
		if a[j][i]=="#":
			tmp=1
	if tmp==0:
		for j in range(h):
			a[j][i]="0"

#ヨコのチェック
for i in range(h):
	if not "#" in a[i][:]:
		a[i][:]=[0]*w

for i in range(h):
	tmpl=[]
	for j in range(w):
		if not a[i][j]=="0":
			tmpl.append(a[i][j])
	if "#" in tmpl or "." in tmpl:
		print("".join(tmpl))		#listを詰めて表示

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
a=[list(input().split()) for _ in range(h)]

#タテのチェック
for i in range(w):
	tmp=0
	for j in range(h):
		if a[j][i]=="#":
			tmp=1
	if tmp==0:
		for j in range(h):
			a[j][i]="0"

#ヨコのチェック
for i in range(h):
	if not "#" in a[i][:]:
		a[i][:]=[0]*w

for i in range(h):
	tmpl=[]
	for j in range(w):
		if not a[i][j]=="0":
			tmpl.append(a[i][j])
	if "#" in tmpl or "." in tmpl:
		print(" ".join(tmpl))

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
a=[list(input().split()) for _ in range(h)]

#タテのチェック
for i in range(w):
	tmp=0
	for j in range(h):
		if a[j][i]=="#":
			tmp=1
	if tmp==0:
		for j in range(h):
			a[j][i]="0"

#ヨコのチェック
for i in range(h):
	if not "#" in a[i][:]:
		a[i][:]=[0]*w

for i in range(h):
	tmpl=[]
	for j in range(w):
		if not a[i][j]=="0":
			tmpl.append(a[i][j])
	if "#" in tmpl or "." in tmpl:
		print(" ".join(tmpl))
Problem p02684 (python)

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
dic = {}
for key, a in zip(range(1, n+1), a):
    dic[key] = a
 
log = [-1]*(n+1)
next = dic[1]
step = 1
log[next] = step
k -= 1
while k:
    next = dic[next]
    step += 1
    k -= 1
    if log[next] != -1:
        k %= log[next] - step
    else:
        log[next] = step
print(next)

Buggy submission (verdict: Runtime Error):
dic = {}
for key, a in zip(range(1, n+1), list(map(int,input().split()))):
    dic[key] = a
 
keynum = 0
log = [-1]*(n+1)
next = dic[1]
step = 1
log[next] = step
k -= 1
while k:
    next = dic[next]
    step += 1
    k -= 1
    if log[next] != -1:
        k %= log[next] - step
    else:
        log[next] = step
print(next)
Problem p02694 (python)

Fixed submission:
money = 100
x = int(input())
count = 0
while money < x:
    money = int(money * 1.01)
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
x = int(input())
count = 0
while money < x:
    money = int(money * 1.01)
    count += 1
print(count)
Problem p02995 (python)

Fixed submission:
import fractions

a,b,c,d = map(int,input().split())
tn = b-a+1

cn = (b//c)-(a-1)//c
dn = (b//d)-(a-1)//d
cd = (c*d)//fractions.gcd(c, d)
cdn = (b//cd)-(a-1)//cd

print(tn-cn-dn+cdn)

Buggy submission (verdict: Runtime Error):
import math

a,b,c,d = map(int,input().split())
tn = b-a+1


cn = (b//c)-(a-1)//c
dn = (b//d)-(a-1)//d
#最少公倍数
cd = (c*d)//math.gcd(c, d)
cdn = (b//cd)-(a-1)//cd

print(int(tn-cn-dn+cdn))

Buggy submission (verdict: Runtime Error):
import math

a,b,c,d = map(int,input().split())
tn = b-a+1


cn = (b//c)-(a-1)//c
dn = (b//d)-(a-1)//d
#最少公倍数
cd = (c*d)//math.gcd(c, d)
cdn = (b//cd)-(a-1)//cd

print(tn-cn-dn+cdn)

Buggy submission (verdict: Runtime Error):
import math

a,b,c,d = map(int,input().split())
tn = b-a+1


cn = b//c-(a-1)//c
dn = b//d-(a-1)//d
#最少公倍数
cd = (c*d)//math.gcd(c, d)
cdn = b//cd-(a-1)//cd

print(tn-cn-dn+cdn)

Buggy submission (verdict: Runtime Error):
import math

a,b,c,d = map(int,input().split())
tn = b-a+1

cn = (b//c)-(a-1)//c
dn = (b//d)-(a-1)//d
cd = (c*d)//math.gcd(c, d)
cdn = (b//cd)-(a-1)//cd

print(tn-cn-dn+cdn)

Buggy submission (verdict: Runtime Error):
import math

a,b,c,d = map(int,input().split())
tn = b-a+1

cn = (b//c)-((a-1)//c)
dn = (b//d)-((a-1)//d)
cd = (c * d) // math.gcd(c, d)
cdn = (b//cd)-((a-1)//cd)

print(tn-cn-dn+cdn)

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())
tn = b-a+1


cn = (b//c)-((a-1)//c)
dn = (b//d)-((a-1)//d)

cd = lcm(c,d)
cdn = (b//cd)-((a-1)//cd)

print(tn-cn-dn+cdn)

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())
tn = b-a+1


cn = (b//c)-((a-1)//c)
dn = (b//d)-((a-1)//d)

cd = lcm(c,d)
cdn = (b//cd)-((a-1)//cd)



print(tn,cn,dn,cdn)
print(tn-cn-dn+cdn)
Problem p03284 (python)

Fixed submission:
n,k = map(int,input().split())
if n % k == 0 :
  print(0)
else:
  print(1)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
if n%k = 0 :
  print(0)
else:
  print(1)
Problem p03323 (python)

Fixed submission:
a,b = map(int,input().split())
if a > 8 or b > 8:
    print(":(")
else:
    print("Yay!")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input())
if a > 8 or b > 8:
    print(":(")
else:
    print("Yay!")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a > 8 or b > 8:
    print(":(")
else:
    print("Yay!")
Problem p03386 (python)

Fixed submission:
a,b,k = map(int,input().split())
ans = []
if 2*k <= b-a+1:
    for i in range(k):
        ans.append(a+i)
        ans.append(b-i)
    ans = list(set(ans))
    ans = sorted(ans)
    for i in ans:
        print(i)
else:
    for i in range(a,b+1):
        print(i)

Buggy submission (verdict: Runtime Error):
a,b,k = map(int,input().split())
n = list(range(a,b+1))
n.sort
if 2*k >= len(n):
    for i in n:
        print(i)
else:
    a = []
    a.extend(n[:k])
    a.extend(n[-k:])
    a.sort
    for i in a:
        print(i)

Buggy submission (verdict: Runtime Error):
a,b,k = map(int,input().split())
n = list(range(a,b+1))
n.sort
if 2*k >= len(n):
    for i in n:
        print(i)
else:
    a = []
    a.extend(n[:k])
    a.extend(n[-k:])
    for i in a:
        print(i)

Buggy submission (verdict: Runtime Error):
a,b,k = map(int,input().split())
n = list(range(a,b+1))
n.sort
if 2*k >= len(n):
    for i in n:
        print(i)
else:
    a = []
    a.extend(n[:k])
    a.extend(n[-k:])
    for i in a:
        print(i)
Problem p03471 (python)

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

for i in range(N+1):
    for j in range(N-i+1):
        if Y-10000*i-5000*j == 1000*(N-i-j):
            print(i,j,N-i-j)
            break
    else:
        continue
    break
else:
    print(-1,-1,-1)

Buggy submission (verdict: Runtime Error):
def Otoshidama():
    N,Y = input().split()
    N = int(N)
    Y = int(Y)
    for i in range(N+1):
        for j in range(N-i+1):
            for k in range(N-i-j+1):
                ans = 10000*i + 5000*j + 1000*k
                if Y == ans:
                    return(i,j,k)
    return(-1,-1,-1)

One,Two,Three = Otoshidama()
print(One,Two,Th
Problem p03485 (python)

Fixed submission:
a,b = map(int,input().split())
y = (a + b)/ 2
import math
print(math.ceil(y))

Buggy submission (verdict: Runtime Error):
s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
if s < t:
    print("yes")
else:
    print("No")
Problem p03486 (python)

Fixed submission:
s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
if s < t:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = list(input())
t = list(input())
N = len(s)
M = len(t)
s.sort()
t.reverse()
if N < M and s == t[:N]:
    print("Yes")
else:
    for i in range(N):
        if s[i] < t[i]:
            print("Yes")
            break
    else:
        print("No")
Problem p03493 (python)

Fixed submission:
x = list(input())
print(x.count("1"))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split()]
num = 0
while True:
    for i in n:
        if a[i] % 2 == 1:
          return ans
        else:
            a[i] = a[i] / 2
        num += 1
Problem p03555 (python)

Fixed submission:
a=input()
b=input()
if a[0]==b[2] and a[1]==b[1] and a[2]==b[0]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
if (a[0]==b[2] and a[1]==b[a] and a[2]==b[0]):
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
if a[0]==b[2] and a[1]==b[a] and a[2]==b[0]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
if a[0]==b[2] and a[1]==b[a] and a[2]==b[0]:
  print("Yes")
else:
  print("No")
Problem p03563 (python)

Fixed submission:
R =int(input())
G =int(input())
print(2*G-R)

Buggy submission (verdict: Runtime Error):
R =int(input())
G =int(input())
print(2G-R)
Problem p03610 (python)

Fixed submission:
s=input()
outp=""
for i in range(0,len(s),2):
    outp+=s[i]
print(outp)

Buggy submission (verdict: Runtime Error):
s=input()
outp=""
for i in range(len(s),2):
    outp+=s[i]
print(outp)
Problem p03644 (python)

Fixed submission:
n = int(input())
k = 0
while 2**k <= n:
    k += 1
print(2**(k-1))

Buggy submission (verdict: Runtime Error):
n = int(input())
k = 0
while 2**k <= n:
    k += 1:
print(2**(k-1))
Problem p03672 (python)

Fixed submission:
s = input()
for i in range(len(s)):
    s = s[:-1]
    if len(s)%2 == 0:
        if s[:int(len(s)/2)] == s[int(len(s)/2):]:
            print(len(s))
            break

Buggy submission (verdict: Runtime Error):
s = input()
for i in range(len(s)):
    s = s[:-1]
    if len(s)%2 == 0:
        if s[:len(s)/2] == s[len(s)/2:]:
            print(len(s))
            break
Problem p04044 (python)

Fixed submission:
n,l = input().split()
n = int(n)
s = []
for i in range(n):
    s.append(input())
s.sort()
print("".join(s))

Buggy submission (verdict: Runtime Error):
n,l = input().split()
n = int(n)
s = []
for i in range(n):
    s.append(input())
s.sort()
print(s[0]+s[1]+s[2])

Buggy submission (verdict: Runtime Error):
n,l = map(int,input().split())
s = []
for i in range(n):
    s.append(input())
s.sort()
print(s[0]+s[1]+s[2])
Problem p02684 (python)

Fixed submission:
cin = open(0).read().strip().split('\n')

n,k = map(int, cin[0].split(' '))
a = list(map(int, cin[1].split(' ')))

history = [1]
for i in range(n):
    history.append(a[history[i]-1])

if n >= k:
    print(history[k])
else:
    times = [-1] * n
    for i in range(n):
        if times[history[i]-1] == -1:
            times[history[i]-1] = i
        else:
            cycle = i-times[history[i]-1]
            pre = times[history[i]-1]
            mod = (k-pre)%cycle
            print(history[pre+mod])
            break

Buggy submission (verdict: Runtime Error):
cin = open(0).read().strip().split('\n')

n,k = map(int, cin[0].split(' '))
a = list(map(int, cin[1].split(' ')))

history = [1]
for i in range(n):
    history.append(a[history[i]-1])

if n >= k:
    print(a[k])
else:
    times = [0] + [-1] * (n-1)
    for i in range(n):
        if times[a[i]-1] == -1:
            times[a[i]-1] = i+1
        else:
            cycle = i-times[a[i]-1]
            pre = times[a[i]-1]
            mod = (k-pre)%cycle
            print(history[pre+mod])
            break
Problem p02813 (python)

Fixed submission:
cin = open(0).read().strip().split('\n')
n = int(cin[0])
p = list(map(int, cin[1].split(' ')))
q = list(map(int, cin[2].split(' ')))

import itertools

a = 0
b = 0
for idx, case in enumerate(itertools.permutations(range(1, n+1))):
    if case == tuple(p):
        a = idx+1
    if case == tuple(q):
        b = idx+1

print(abs(a-b))

Buggy submission (verdict: Runtime Error):
cin = open(0).read().strip().split('\n')
n = int(cin[0])
p = list(map(int, cin[1].split(' ')))
q = list(map(int, cin[2].split(' ')))

a = 0
b = 0
for idx, case in enumerate(itertools.permutations(range(1, n+1))):
    if case == tuple(p):
        a = idx+1
    if case == tuple(q):
        b = idx+1
print(abs(a-b))
Problem p02844 (python)

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

import itertools

d = list()
for d1, d2, d3 in itertools.product(range(10), range(10), range(10)):
    d.append(str(d1) + str(d2) + str(d3))

ret = 0
for di in d:
    ls = list(s)
    try:
        idx1 = ls.index(di[0])
        idx2 = ls[idx1+1:].index(di[1])
        idx3 = ls[idx1+1:][idx2+1:].index(di[2])
        ret += 1
    except:
        continue

print(ret)

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

import itertools

d = list()
for d1, d2, d3 in itertools.product(range(10), range(10), range(10)):
    d.append(f'{d1}{d2}{d3}')

ret = 0
for di in d:
    ls = list(s)
    try:
        idx1 = ls.index(di[0])
        idx2 = ls[idx1+1:].index(di[1])
        idx3 = ls[idx1+1:][idx2+1:].index(di[2])
        ret += 1
    except:
        continue

print(ret)
Problem p03752 (python)

Fixed submission:
cin = open(0).read().strip().split('\n')
n, k = map(int, cin[0].split(' '))
a = list(map(int, cin[1].split(' ')))

ret = float('inf')
for idx in range(2**(n)):
    colors = 0
    res = 0
    left = 0
    for i in range(n):
        if (idx>>i) & 1:
            colors += 1
            res += max(left+1 - a[i] , 0)
            left += 1
        # else:
        #     colors += 1 if left < a[i] else 0

        left = max(a[i], left)

    if colors >= k:
        ret = min(ret, res)

print(ret)

Buggy submission (verdict: Runtime Error):
cin = open(0).read().strip().split('\n')
n, k = map(int, cin[0].split(' '))
a = list(map(int, cin[1].split(' ')))

ret = 0
target = [a[0]+i for i in range(1, k)]
for idx in range(2**(n-1)):
    cnt = 0
    tmp = 0
    for i in range(n):
        if (idx>>i) & 1:
            tmp += target[cnt] - a[i+1] if target[cnt] > a[i+1] else 0
            cnt += 1

        if cnt == len(target):
            if ret == 0:
                ret = tmp
            else:
                ret = min(ret, tmp)
            break

print(f'{ret}\n')