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

Fixed submission:
s=input()
k=int(input())
n=len(s)
ans=[]
for i in range(n):
    for j in range(i+1,i+k+1):
        ans.append(s[i:j])
ans=list(set(ans))
ans.sort()
if "" in ans:
    ans.pop(0)
print(ans[k-1])

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())
ans=[]
n=len(s)
for i in range(n):
    for j in range(n):
        ans.append(s[i:j+1])
ans=list(set(ans))
ans.sort()
if "" in ans:
    ans.pop(0)
if n==1:
    print(s)
else:
    print(ans[k])
Problem p03399 (python)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
print(min(a,b)+min(c,d))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=[]
a.sort()
cnt=0
for i in range(n):
    v=a[i]
    a[i]=0
    a.sort()
    for j in range(1,n):
        cnt+=a[j]-a[j-1]
    ans.append(cnt+(max(a)-min(a)))
    cnt=0
    a[i]=v
for i in ans:
    print(i)
Problem p03434 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
v=sum(a)
alice_count=0
for i in range(n):
    if i%2==0:
        alice_count+=a[i]
bob_count=v-alice_count
print(alice_count-bob_count)

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	cin >>n;
	int a[110];
	for(int i=0;i<n;++i)cin >>a[i];
	sort(a,a+n,greater<int>());
	int alic=0;
	int bob=0;
	for(int i=0;i<n;++i){
		if(i%2==0){
			alic+=a[i];
		}
		else{
			bob+=a[i];
		}
	}
	cout <<alic-bob<<endl;
}
Problem p03471 (python)

Fixed submission:
def test():
    n,y=map(int,input().split())
    a,b,c=10000,5000,1000
    for i in range(n+1):
        for j in range(n+1):
            ans=a*i+b*j
            if y<ans:
                break
            if (y-ans)%c==0:
                k=(y-ans)//c
                if i+j+k==n:
                    return i,j,k
    return -1,-1,-1
one,two,three=test()
print(one,two,three)

Buggy submission (verdict: Runtime Error):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,y;
    cin>>n>>y;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            int z=y-(10000*i+5000*j);
            if(z%1000==0){
                z/=1000;
                if(0<=z && i+j+z==n){
                    cout<<i<<" "<<j<<" "<<z<<endl;
                    return 0;
                }
            }
        }
    }
   cout<<-1<<" "<<-1<<" "<<-1<<endl;
    return 0;
}
Problem p03495 (python)

Fixed submission:
from collections import Counter
n,k=map(int,input().split())
a=list(map(int,input().split()))
counter=Counter(a)
ans=[]
for i in counter.values():
    ans.append(i)
ans.sort()
ans.reverse()
v=sum(ans[0:k])
print(n-v)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n,k=map(int,input().split())
cnt=list(sorted(Counter(map(int,input().split().values()))))
num=len(cnt)
ans=0
for v in cnt:
    if num<=k:
        break
    ans+=v
    num-=1
print(ans)
Problem p03545 (python)

Fixed submission:
a=list(map(int,input()))
if a[0]+a[1]+a[2]+a[3]==7:
    print(str(a[0])+"+"+str(a[1])+"+"+str(a[2])+"+"+str(a[3])+"=7")
    exit()
elif a[0]+a[1]+a[2]-a[3]==7:
    print(str(a[0])+"+"+str(a[1])+"+"+str(a[2])+"-"+str(a[3])+"=7")
    exit()
elif a[0]+a[1]-a[2]+a[3]==7:
    print(str(a[0])+"+"+str(a[1])+"-"+str(a[2])+"+"+str(a[3])+"=7")
    exit()
elif a[0]+a[1]-a[2]-a[3]==7:
    print(str(a[0])+"+"+str(a[1])+"-"+str(a[2])+"-"+str(a[3])+"=7")
    exit()
elif  a[0]-a[1]+a[2]+a[3]==7:
    print(str(a[0])+"-"+str(a[1])+"+"+str(a[2])+"+"+str(a[3])+"=7")
    exit()
elif a[0]-a[1]+a[2]-a[3]==7:
    print(str(a[0])+"-"+str(a[1])+"+"+str(a[2])+"-"+str(a[3])+"=7")
    exit()
elif a[0]-a[1]-a[2]+a[3]==7:
    print(str(a[0])+"-"+str(a[1])+"-"+str(a[2])+"+"+str(a[3])+"=7")
    exit()
elif a[0]-a[1]-a[2]-a[3]==7:
    print(str(a[0])+"-"+str(a[1])+"-"+str(a[2])+"-"+str(a[3])+"=7")
    exit()

Buggy submission (verdict: Runtime Error):
ans=list(input())
a=int(ans[0])
b=int(ans[1])
c=int(ans[2])
d=int(ans[3])
    pass=int(ans[3])
if b+c+d+e==7:
    print(str(a)+"+"str(b)+"+"+str(c)+"+"+str(d)=="7")
elif a+b+c-d==7:
    print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif a+b-c+d==7:
    print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a+b-c-d==7:
    print(str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
elif a-b+c+d==7:
    print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a-b+c-d==7:
    print(str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif a-b-c+d==7:
    print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a-b-c-d==7:
    print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
Problem p03565 (python)

Fixed submission:
s=list(input())
t=list(input())
sl=len(s)
tl=len(t)
for k in range(sl-tl,-1,-1):
    judge=True
    for i in range(tl):
        if s[i+k]==t[i] or s[i+k]=="?":
            pass
        else:
            judge=False
            break
    if judge:
        for i in range(tl):
            s[i+k]=t[i]
        for i in range(sl):
            if s[i]=="?":
                s[i]="a"
        print("".join(s))
        exit()
print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
s=list(input())
t=list(input())
sl=len(s)
tl=len(t)
for k in range(sl-tl+2):
    judge=True
    for i in range(tl):
        if s[i+k]==t[i] or s[i+k]=="?":
            pass
        else:
            judge=False
            break
    if judge:
        for i in range(tl):
            s[i+k]=t[i]
        for i in range(sl):
            if s[i]=="?":
                s[i]="a"
        print("".join(s))
        exit()
print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
s=list(input())
t=list(input())
sl=len(s)
tl=len(t)
for i in range(sl-tl,-1,-1):
    j=0
    while j<tl:
        if s[j+1]==t[j] or s[j+i]=="?":
            j+=1
        else:
            break
    if j==tl:
        for i in range(tl):
            s[i+k]=t[k]
        for j in range(sl):
            if s[j]=="?":
                s[j]="a"
        print("".join(s))
        exit()
print("UNRESTORABLE")
Problem p03599 (python)

Fixed submission:
a,b,c,d,e,f = map(int, input().split())

sugar = []
for i in range(f):
    for j in range(f):
        y = i*c + j*d
        if y <= f:
            sugar.append(y)

water = []
for i in range(0, f//100+1):
    for j in range(0, f//100+1):
        x = i*a*100 + j*b*100
        if x <= f:
            water.append(x)
max_concentration = 0
ans1, ans2 = 0, 0
for x in water:
    for y in sugar:
        if x == 0 and y == 0:
            continue
        elif e * (x // 100) < y:
            continue
        elif x + y > f:
            continue
        else:
            concentration = (100 * y) / (x+y)
            if max_concentration <= concentration:
                max_concentration = concentration
                ans1 = x+y
                ans2 = y
print("{} {}".format(ans1, ans2))

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,f=map(int,input().split())
water=[]
suguar=[]
for i in range((f+1)//100):
    for j in range((f+1)//100):
        x=100*i*a+100*j*b
        if 1<=x<=f:
            water.append(x)
for i in range(f+1):
    for j in range(f+1):
        y=c*i+d*j
        if y<=f:
            suguar.append(y)
ans=0
for i in water:
    for j in suguar:
        total=i+j
        if total<=f:
            if j<=i//100*e:
                con=100*j/(i+j)
                if ans<con:
                    ans=con
                    ans_2=total
                    ans_3=j
print(ans_2,ans_3)

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,f=map(int,input().split())
water=[]
sugar=[]
ans,ans_2,con=0,0,0
for i in range(f//100+1):#f//100+1によりTLEを解消
    for j in range(f//100+1):
        x=100*a*i+100*j*b
        if x<=f:
            water.append(x)
for i in range(f):
    for j in range(f):
        y=c*i+d*j
        if y<=f:
            sugar.append(y)
sugar=list(set(sugar))
for i in water:
    for j in sugar:
        if i+j<=f:
            f j<=(i//100)*e:
                now=(100*j)/(i+j)
                if con<=now:
                    ans=i+j
                    ans_2=j
                    con=now
print(ans,ans_2)
Problem p03624 (python)

Fixed submission:
s=list(set(input()))
test=["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"]
test.sort()
s.sort()
if len(s)==len(test):
    print("None")
    exit()

i=0
while True:
    if len(s)<=i:
        print(test[i])
        break
        
    if test[i]!=s[i]:
        print(test[i])
        break
    i+=1

Buggy submission (verdict: Runtime Error):
s=list(set(input()))
test=["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"]
test.sort()
s.sort()
if len(s)==len(test):
    print("None")
    exit()
i=0
while True:
    if test[i]!=s[i]:
        print(test[i])
        break
    i+=1

Buggy submission (verdict: Runtime Error):
s=list(set(input()))
test=["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"]
test.sort()
s.sort()
if len(s)==len(test):
    print("None")
    exit()
i=0
while True:
    if test[i]!=s[i]:
        print(test[i])
        break
    i+=1
Problem p03625 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
data=Counter(a)
two_i=[]
four_i=[]
for i,j in data.items():
    if 4<=j:
        four_i.append(i)
    elif 2<=j:
        two_i.append(i)
two_i.sort()
four_i.sort()
two_i.reverse()
four_i.reverse()
if len(four_i)==0:
    four_i.append(0)
if len(two_i)<=1:
    two_i.append(0)
    two_i.append(0)
four_area=four_i[0]*four_i[0]
two_area=two_i[0]*two_i[1]
mix_area=two_i[0]*four_i[0]
print(max(four_area,two_area,mix_area))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
data=Counter(a)
two=[]
four=[]
for i,j in data.items():
    if 2<=j<=3:
        two.append(i)
    elif 4<=j:
        four.append(i)
if len(four)==0:
    four.append(0)
    four.append(0)
    four[1]=0
elif len(two)==0:
    two.append(0)
    two.append(0)
print(max(four[0]*four[0],four[0]*four[1],two[0]*two[1],two[0]*four[0]))

Buggy submission (verdict: Runtime Error):
def test():
    n=int(input())
    a=list(map(int,input().split()))
    a.sort()
    a.reverse()
    s=list(set(a))
    s.sort()
    s.reverse()
    ans=[]
    v=0
    for i in s:
        if 4<=a.count(i):
            return i*i
        elif 2<=a.count(i)<=3:
            ans.append(i)
            return ans[0]*ans[1]
    return 0
t=test()
print(t)

Buggy submission (verdict: Runtime Error):
def test():
    n=int(input())
    a=list(map(int,input().split()))
    a.sort()
    a.reverse()
    s=list(set(a))
    s.sort()
    s.reverse()
    ans=[]
    v=0
    for i in s:
        if 4<=a.count(i):
            v="i"
        elif 2<=a.count(i)<=3:
            ans.append(i)
        if v or 2<=len(ans):
            return max(int(v)*int(v),ans[0]*ans[1])
    return 0
t=test()
print(t)
Problem p03679 (python)

Fixed submission:
x,a,b=map(int,input().split())
pass_day=b-a
if b<=a:
    print("delicious")
else:
    if pass_day<=x:
        print("safe")
    else:
        print("dangerous")

Buggy submission (verdict: Runtime Error):
x,a,b=map(int,input().split())
if b<=a:
    print("delicious")
else:
    pass=b-a
    if pass<=x:
        print("safe")
    else:
        print("dangerous")
Problem p03681 (python)

Fixed submission:
import math
mod=10**9+7
n,m=map(int,input().split())
ans=0
if abs(n-m)==0:
    ans=math.factorial(n)*math.factorial(m)*2
elif abs(n-m)==1:
    ans=math.factorial(n)*math.factorial(m)
else:
    ans=0
ans=ans%mod
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
mod=10**9+7
sn=1
for i in range(n+1):
    sn*=i
for j in range(m+1):
    sm*=j
if 2<=abs(n-m):
    print(0)
elif abs(n-m)==1:
    print(sn*sm)
elif n==m:
    print(2*sn*sm)
Problem p03697 (python)

Fixed submission:
a,b=map(int,input().split())
if 10<=a+b:
    print("error")
else:
    print(a+b)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=[]
for i in range(n):
    s.append(int(input()))
total=sum(s)
s.sort()
if total%10!=0:
    print(total)
else:
    for i in s:
        if i%10!=0:
            total-=i
            if total%10!=0:
                break
if total%10==0:
    print(0)
else:
    print(total)
Problem p03713 (python)

Fixed submission:
h,w=map(int,input().split())
import math
if h%3==0 or w%3==0:
    print(0)
    exit()
w_i=w//2
ans=[]
for i in range(1,h):
    sa=i*w
    sb=(h-i)*w_i
    sc=(h-i)*(w-w_i)
    ans.append(max(sa,sb,sc)-min(sa,sb,sc))
v=min(ans)
ans_3=[]
for l in range(1,h):
    h_half=(h-l)//2
    sa=w*l
    sb=w*h_half
    sc=w*((h-l)-h_half)
    ans_3.append(max(sa,sb,sc)-min(sa,sb,sc))
v_3=min(ans_3)
ans_i=[]
h_i=h//2
for j in range(1,w):
    sa=j*h
    sb=(w-j)*(h_i)
    sc=(w-j)*(h-h_i)
    ans_i.append(max(sa,sb,sc)-min(sa,sb,sc))
v_i=min(ans_i)
ans_2=[]
for k in range(1,w):
    w_half=(w-k)//2
    sa=h*k
    sb=h*w_half
    sc=h*((w-k)-w_half)
    ans_2.append(max(sa,sb,sc)-min(sa,sb,sc))
v_2=min(ans_2)
print(min(v,v_i,v_2,v_3))
#86 5

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
ans=[]
ans_2=[]
ans_3=[]
ans_4=[]
for i in range(1,w-1):
    a=h*i
    res=w-i
    if res%2==0:
        b=h*(res//2)
        c=h*(res//2)
    else:
        b=h*(res//2)
        c=h*(res//2+1)
    ans.append(max(a,b,c)-min(a,b,c))
for i in range(1,h-1):
    a_2=i*w
    res_2=h-i
    if res_2%2==0:
        b_2=w*(res_2//2)
        c_2=w*(res_2//2)
    else:
        b_2=w*(res_2//2)
        c_2=w*(res_2//2+1)
    ans_2.append(max(a_2,b_2,c_2)-min(a_2,b_2,c_2))
for i in range(1,w-1):
    a_3=i*h
    res_3=w-i
    if h%2==0:
        b_3=res_3*(h//2)
        c_3=res_3*(h//2)
    else:
        b_3=res_3*(h//2)
        c_3=res_3*(h//2+1)
    ans_3.append(max(a_3,b_3,c_3)-min(a_3,b_3,c_3))
for i in range(1,h-1):
    a_4=w*i
    res_4=h-i
    if w%2==0:
        b_4=res_4*(w//2)
        c_4=res_4*(w//2)
    else:
        b_4=res_4*(w//2)
        c_4=res_4*(w//2+1)
    ans_4.append(max(a_4,b_4,c_4)-min(a_4,b_4,c_4))
if len(ans)==0:
    v=float("inf")
else:
    v=min(ans)
if len(ans_2)==0:
    x=float("inf")
else:
    x=min(ans_2)
if len(ans_3)==0:
    y=float("inf")
else:
    y=min(ans_3)
if len(ans_4)==0:
    z=float("inf")
else:
    z=min(ans_4)
if min(v,x,y,z)==inf:
    print(1)
else:
    print(min(v,x,y,z))

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
ans=[]
ans_2=[]
ans_3=[]
ans_4=[]
for i in range(1,w-1):
    a=h*i
    res=w-i
    if res%2==0:
        b=h*(res//2)
        c=b*(res//2)
    else:
        b=h*(res//2)
        c=h*(res//2+1)
    ans.append(max(a,b,c)-min(a,b,c))
for i in range(1,h-1):
    a_2=i*w
    res_2=h-i
    if res_2%2==0:
        b_2=w*(res_2//2)
        c_2=w*(res_2//2)
    else:
        b_2=w*(res_2//2)
        c_2=w*(res_2//2+1)
    ans_2.append(max(a_2,b_2,c_2)-min(a_2,b_2,c_2))
for i in range(1,w-1):
    a_3=i*h
    res_3=w-i
    if h%2==0:
        b_3=res_3*(h//2)
        c_3=res_3*(h//2)
    else:
        b_3=res_3*(h//2)
        c_3=res_3*(h//2+1)
    ans_3.append(max(a_3,b_3,c_3)-min(a_3,b_3,c_3))
for i in range(1,h-1):
    a_4=w*i
    res_4=h-i
    if w%2==0:
        b_4=res_4*(w//2)
        c_4=res_4*(w//2)
    else:
        b_4=res_4*(w//2)
        c_4=res_4*(w//2+1)
    ans_4.append(max(a_4,b_4,c_4)-min(a_4,b_4,c_4))
v=min(ans)
x=min(ans_2)
y=min(ans_3)
z=min(ans_4)
print(min(v,x,y,z))
Problem p03720 (python)

Fixed submission:
n,m=map(int,input().split())
line=[tuple(map(int,input().split()))for i in range(m)]
ans=[0]*n
for i in range(m):
    ans[line[i][0]-1]+=1
    ans[line[i][1]-1]+=1
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
line=[tuple(map(int,input().split()))for i in range(m)]
ans=[]
for i in range(m):
    ans.append(line[i][0])
    ans.append(line[i][1])
from collections import Counter
data=Counter(ans)
data=sorted(data.items())
for i in range(n):
    print(data[i][1])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
line=[tuple(map(int,input().split()))for i in range(m)]
from collections import Counter
ans=[]
for i in range(m):
    ans.append(line[i][0])
    ans.append(line[i][1])
data=Counter(ans)
data=sorted(data.items())
for i in range(n):
    print(data[i][1])
Problem p03721 (python)

Fixed submission:
n,k=map(int,input().split())
num=[list(map(int,input().split()))for _ in range(n)]
p=0
num.sort()
for i in range(n):
    p+=num[i][1]
    if k<=p:
        ans=num[i][0]
        break
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
ans=[]
ans_i=[]
num=""
for i in range(n):
    a,b=map(int,input().split())
    ans.append(str(a)*b)
for j in ans:
    num+=j
ans_i=list(num)
print(ans_i[k-1])
Problem p03731 (python)

Fixed submission:
n,t=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(1,n):
    ans+=min(t,a[i]-a[i-1])
ans+=t
print(ans)

Buggy submission (verdict: Runtime Error):
n,t=map(int,input().split())
a=list(map(int,input().split()))
ans=int(0)
for i in range(0,n):
    if n==i-1:
        ans+=t
        break
    ans+=min(t,a[i+1]-a[i])
print(ans)
Problem p03807 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
even_cnt=0
odd_cnt=0
for i in a:
    if i%2==0:
        even_cnt+=1
    else:
        odd_cnt+=1
if 1<=odd_cnt:
    even_cnt+=odd_cnt//2
    odd_cnt=odd_cnt%2
    even_cnt=even_cnt%2
    if even_cnt==1 and odd_cnt==1:
        print("NO")
    else:
        print("YES")
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
even_cnt=0
odd_cnt=0
for i in a:
    if i%2==0:
        even_cnt+=1
    else:
        odd_cnt+=1
if 1<=odd_cnt:
    even_cnt+=odd_cnt//2　#奇数から偶数になったもの数
    odd_cnt=odd_cnt%2 
    even_cnt=even_cnt%2
    if even_cnt==1 and odd_cnt==1:
        print("NO")
    else:
        print("YES")
else:
    print("YES")

#考察
#奇数の和も偶数の和も偶数なので、奇数の数を減らせばよい。
Problem p03815 (python)

Fixed submission:
x=int(input())
ans=0
ans+=(x//11)*2
if x%11==0:
    print(ans)
elif x%11<=6:
    print(ans+1)
else:
    print(ans+2)

Buggy submission (verdict: Runtime Error):
x=int(input())
ans=0
ans+=(x//)*2
if x%11==0:
    print(ans)
elif x%11<=6:
    print(ans+1)
else:
    print(ans+2)
Problem p03828 (python)

Fixed submission:
n=int(input())
import math
fac=math.factorial(n)
mod=10**9+7
ans=[0]*(n+1)
ans[0]=ans[1]=1
i=2
while i*i<=n:
    j=2
    while i*j<=n and ans[i]==0:
        ans[i*j]=1
        j+=1
    i+=1
v=[]
for i in range(n+1):
    if ans[i]==0:
        v.append(i)
total=1
count=0
for i in v:
    while fac%i==0:
        count+=1
        fac//=i
    total*=count+1
    count=0
print(total%mod)

Buggy submission (verdict: Runtime Error):
n=int(input())
mod=10**9+7
import math
import sympy
v=math.factorial(n)
print(sympy.divisor_count(v)%mod)
Problem p03998 (python)

Fixed submission:
sa=list(input())
sb=list(input())
sc=list(input())
owner="a"
while True:
    if owner=="a":
        if len(sa):
            owner=sa[0]
            del sa[0]
        else:
            break
    elif owner=="b":
        if len(sb):
            owner=sb[0]
            del sb[0]
        else:
            break
    else:
        if len(sc):
            owner=sc[0]
            del sc[0]
        else:
            break
if owner=="a":
    print("A")
elif owner=="b":
    print("B")
else:
    print("C")

Buggy submission (verdict: Runtime Error):
a=list(input())
b=list(input())
c=list(input())
next=a[0]
del a[0]
while True:
    if len(a)==0 and next=="a":
        print("A")
        break
    if len(b)==0 and next=="b":
        print("B")
        break
    if len(c)==0 and next=="c":
        print("C")
        break
    if next=="a":
        next=a[0]
        del a[0]
    if next=="b":
        next=b[0]
        del b[0]
    if next=="c":
        next=c[0]
        del c[0]

Buggy submission (verdict: Runtime Error):
a=list(input())
b=list(input())
c=list(input())
next=a[0]
del a[0]
while True:
    if next=="a":
        next=a[0]
        del a[0]
    if next=="b":
        next=b[0]
        del b[0]
    if next=="c":
        next=c[0]
        del c[0]
    if len(a)==0 and next=="a":
        print("A")
        break
    if len(b)==0 and next=="b":
        print("B")
        break
    if len(c)==0 and next=="c":
        print("C")
        break

Buggy submission (verdict: Runtime Error):
a=list(input())
b=list(input())
c=list(input())
next=a[0]
del a[0]
while True:
    if next=="a":
        next=a[0]
        del a[0]
    if next=="b":
        next=b[0]
        del b[0]
    if next=="c":
        next=c[0]
        del c[0]
    if len(a)==0 and next=="a":
        print("A")
        break
    if len(b)==0 and next=="b":
        print("B")
        break
    if len(c)==0 and next=="c":
        print("C")
        break

Buggy submission (verdict: Runtime Error):
sa=list(input())
sb=list(input())
sc=list(input())
owner="a"
while True:
    if owner=="a":
        if len(A):
            owner=A[0]
            del A[0]
        else:
            break
    elif owner=="b":
        if len(B):
            owner=B[0]
            del B[0]
        else:
            break
    else:
        if len(C):
            owner=C[0]
            del C[0]
        else:
            break
if owner=="a":
    print("A")
elif owner=="b":
    print("B")
else:
    print("C")
Problem p03999 (python)

Fixed submission:
s=input()
count=0
for i in range(2**(len(s)-1)):
    t=""
    for j in s:
        t+=j
        if i%2==1:
            t+="+"
        i//=2
    count+=eval(t)
print(count)

Buggy submission (verdict: Runtime Error):
s=input()
count=0
for i in range(1<<len(s)-1):
    t=""
    for j s:
        if i%2==1:
            t+="+"
        i//=2
    count+=eval(t)
print(count)

Buggy submission (verdict: Runtime Error):
def main():
    s=input()
    n=len(s)
    sum=0
    for i in range(1<<(n-1)):
        ans=0
        t=""
        for j in range(n-1):
            if 1&j<<i:
                t+=s[ans:j+1]
                ans+=j+1
                t+="+"
        t+=s[ans:]
        sum+=eval(t)
    print(sum)
if __name__ =="__main__":
    main()

Buggy submission (verdict: Runtime Error):
from itertools import combinations
s=input()
ans=0
for i in range(len(s)):
    for j in combinations(range(1,len(s)),i):
        c=0
        s_i=s
        for k in j:
            s_i=s_i[:k+c]+"+"+s_i[j+c:]
            c+=1
        ans+=eval(s_i)
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import product
s=input()
ans=0
t=["","+"]
for i in product(range(2),repeat=len(s)-1):
    v=s[0]
    for j in range(1,len(s)):
        v+=t[i[j-1]+s[j]]
    ans+=eval(v)
print(ans)
Problem p04001 (python)

Fixed submission:
s=input()
n=len(s)
ans=0
for i in range(1<<n-1):
    ins=s[0]
    for j in range(n-1):
        if i&(1<<j):
            ins+="+"+s[j+1]
        else:
            ins+=s[j+1]
    ans+=eval(ins)
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)
ans=0
for i in range(1<<n-1):#+を入れるかどうか
    num=s[0]
    for j in range(n-1):#+を入れるかどうか
        if i&(1<<j):#bitで考える,iと1<<jが同じ数字であれば実行
            num+="+"+s[j+1]
        else:
            num+=s[j+1]
    ans+=eval(ins)
print(ans)
Problem p04031 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ave=round(sum(a)/n)
a=[(x-ave)**2 for x in a]
print(sum(a))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for i in range(n)]
s=sum(a)
ans=round(s/n)
count=0
for i in range(n):
    count+=(a[i]-ans)**2
print(count)
Problem p04045 (python)

Fixed submission:
n,k=map(int,input().split())
d=list(input().split())
ans=n
p=0
for i in range(10*n+1):
    s=str(ans)
    for j in range(len(str(s))):
        if s[j] in d:
            break
    else:
        break
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
d=list(input().split())
for i in range(n,100001):
    set_i=set(list(str(i)))
    for j in set_i:
        if s in d:
            break
    else:
        print(i)
        break