Datasets:

Languages:
code
ArXiv:
Tags:
code
License:
Muennighoff commited on
Commit
075cf48
1 Parent(s): c036193
data/.DS_Store ADDED
Binary file (6.15 kB). View file
 
data/cpp/data/.DS_Store ADDED
Binary file (6.15 kB). View file
 
data/cpp/data/humaneval.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/cpp/data/humanevalbugs.json ADDED
@@ -0,0 +1 @@
 
 
1
+ [{"buggy_solution": " int i,j;\n \n for (i=0;i<numbers.size();i++)\n for (j=i+1;j<numbers.size();j++)\n if (abs(numbers[i]-numbers[j])<threshold)\n return true;\n\n return false;\n}\n\n"}, {"buggy_solution": " vector<string> all_parens;\n string current_paren;\n int level=0;\n char chr;\n int i;\n for (i=0;i<paren_string.length();i++)\n {\n chr=paren_string[i];\n if (chr=='(')\n {\n level+=1;\n current_paren+=chr;\n }\n if (chr==')')\n {\n level-=1;\n current_paren+=chr;\n if (level==0){\n all_parens.push_back(current_paren);\n current_paren=\"\";\n }\n }\n }\n return all_parens;\n}\n"}, {"buggy_solution": " return number-int(number);\n}\n"}, {"buggy_solution": " int num=0;\n for (int i=0;i<operations.size();i++)\n {\n num+=operations[i];\n if (num<0) return true;\n }\n return false;\n}\n"}, {"buggy_solution": " float sum=0;\n float avg,msum,mavg;\n int i=0;\n for (i=0;i<numbers.size();i++)\n sum+=numbers[i];\n avg=sum/numbers.size();\n msum=0;\n for (i=0;i<numbers.size();i++)\n msum+=abs(numbers[i]-avg);\n return msum/numbers.size();\n}\n"}, {"buggy_solution": " vector<int> out={};\n if (numbers.size()>0) out.push_back(numbers[0]);\n for (int i=1;i<numbers.size();i++)\n {\n out.push_back(delimeter);\n out.push_back(numbers[i]);\n\n }\n return out;\n}\n"}, {"buggy_solution": " vector<int> all_levels;\n string current_paren;\n int level=0,max_level=0;\n char chr;\n int i;\n for (i=0;i<paren_string.length();i++)\n {\n chr=paren_string[i];\n if (chr=='(')\n {\n level+=1;\n if (level>max_level) max_level=level;\n current_paren+=chr;\n }\n if (chr==')')\n {\n level-=1;\n current_paren+=chr;\n if (level==0){\n all_levels.push_back(max_level);\n current_paren=\"\";\n max_level=0;\n }\n }\n }\n return all_levels;\n}\n"}, {"buggy_solution": " vector<string> out;\n for (int i=0;i<strings.size();i++)\n {\n if (strings[i].find(substring)!=strings[i].npos)\n out.push_back(strings[i]);\n }\n return out;\n}\n"}, {"buggy_solution": " int sum=0,product=1;\n for (int i=0;i<numbers.size();i++)\n {\n sum+=numbers[i];\n product*=numbers[i];\n }\n return {sum,product};\n}\n"}, {"buggy_solution": " vector<int> out;\n int max=0;\n for (int i=0;i<numbers.size();i++)\n {\n if (numbers[i]>max) max=numbers[i];\n out.push_back(max);\n }\n return out;\n}\n"}, {"buggy_solution": " int i;\n for (i=0;i<str.length();i++)\n {\n string rstr=str.substr(i);\n if (is_palindrome(rstr))\n {\n string nstr;\n nstr=str.substr(0,i);\n string n2str(nstr.rbegin(),nstr.rend());\n return str+n2str;\n }\n }\n string n2str(str.rbegin(),str.rend());\n return str+n2str;\n}\n"}, {"buggy_solution": " string output=\"\";\n for (int i=0;(i<a.length() and i<b.length());i++)\n {\n if (i<a.length() and i<b.length())\n {\n if (a[i]== b[i]) \n {\n output+='0';\n } \n else output+='1';\n }\n else\n {\n if (i>=a.length()) \n {\n output+=b[i];\n }\n else output+=a[i];\n }\n }\n return output;\n}\n"}, {"buggy_solution": " string out;\n for (int i=0;i<strings.size();i++)\n {\n if (strings[i].length()>out.length()) out=strings[i];\n }\n return out;\n}\n"}, {"buggy_solution": " int out,m;\n while (true){\n if (a<b) \n {\n m=a;a=b;b=m;\n }\n a=a%b;\n if (a==0) return b;\n }\n}\n"}, {"buggy_solution": " vector<string> out;\n string current=\"\";\n for (int i=0;i<str.length();i++)\n {\n current=current+str[i];\n out.push_back(current);\n }\n return out;\n}\n"}, {"buggy_solution": " string out=\"0\";\n for (int i=1;i<=n;i++)\n out=out+\" \"+to_string(i);\n return out;\n}\n"}, {"buggy_solution": " vector<char> distinct={};\n transform(str.begin(),str.end(),str.begin(),::tolower);\n for (int i=0;i<str.size();i++)\n {\n bool isin=false;\n for (int j=0;j<distinct.size();j++)\n if (distinct[j]==str[i])\n isin=true;\n if (isin==false) distinct.push_back(str[i]);\n\n }\n return distinct.size();\n}\n"}, {"buggy_solution": " string current=\"\";\n vector<int> out={};\n if (music_string.length()>0)\n music_string=music_string+' ';\n for (int i=0;i<music_string.length();i++)\n {\n if (music_string[i]==' ')\n {\n if (current==\"o\") out.push_back(4);\n if (current==\"o|\") out.push_back(2);\n if (current==\".|\") out.push_back(1);\n current=\"\";\n }\n else current+=music_string[i];\n }\n return out;\n}\n"}, {"buggy_solution": " int out=0;\n if (str.length()==0) return 0;\n for (int i=0;i<=str.length()-substring.length();i++)\n if (str.substr(i,substring.length())==substring)\n out+=1;\n return out;\n}\n"}, {"buggy_solution": " map<string,int> tonum={{\"zero\",0},{\"one\",1},{\"two\",2},{\"three\",3},{\"four\",4},{\"five\",5},{\"six\",6},{\"seven\",7},{\"eight\",8},{\"nine\",9}};\n map<int,string> numto={{0,\"zero\"},{1,\"one\"},{2,\"two\"},{3,\"three\"},{4,\"four\"},{5,\"five\"},{6,\"six\"},{7,\"seven\"},{8,\"eight\"},{9,\"nine\"}};\n int count[10];\n for (int i=0;i<10;i++)\n count[i]=0;\n string out=\"\",current=\"\";\n if (numbers.length()>0) numbers=numbers+' ';\n for (int i=0;i<numbers.length();i++)\n if (numbers[i]==' ')\n {\n count[tonum[current]]+=1;\n current=\"\";\n }\n else current+=numbers[i];\n for (int i=0;i<10;i++)\n for (int j=0;j<count[i];j++)\n out=out+numto[i]+' ';\n if (out.length()>0) out.pop_back();\n return out;\n}\n"}, {"buggy_solution": " vector<float> out={};\n for (int i=0;i<numbers.size();i++)\n for (int j=i+1;j<numbers.size();j++)\n if (out.size()==0 or abs(numbers[i]-numbers[j])<abs(out[0]-out[1]))\n out={numbers[i],numbers[j]};\n if (out[0]>out[1])\n out={out[1],out[0]};\n return out;\n}\n"}, {"buggy_solution": " float min=100000,max=-100000;\n for (int i=0;i<numbers.size();i++)\n {\n if (numbers[i]<min) min=numbers[i];\n if (numbers[i]>max) max=numbers[i];\n }\n for (int i=0;i<numbers.size();i++)\n numbers[i]=(numbers[i]-min)/(max-min);\n return numbers;\n}\n"}, {"buggy_solution": " list_any::iterator it;\n boost::any anyone;\n vector<int> out;\n for (it=values.begin();it!=values.end();it++)\n {\n anyone=*it;\n if( anyone.type() == typeid(int) )\n out.push_back(boost::any_cast<int>(*it));\n }\n return out;\n}\n"}, {"buggy_solution": " return str.length();\n}\n"}, {"buggy_solution": " for (int i=2;i*i<=n;i++)\n if (n%i==0) return n/i;\n return 1;\n\n}\n"}, {"buggy_solution": " vector<int> out={};\n for (int i=2;i*i<=n;i++)\n if (n%i==0)\n {\n n=n/i;\n out.push_back(i);\n i-=1;\n }\n out.push_back(n);\n return out;\n}\n"}, {"buggy_solution": " vector<int> out={};\n vector<int> has1={};\n vector<int> has2={};\n for (int i=0;i<numbers.size();i++)\n {\n if (find(has2.begin(),has2.end(),numbers[i])!=has2.end()) continue;\n if (find(has1.begin(),has1.end(),numbers[i])!=has1.end())\n {\n\n has2.push_back(numbers[i]);\n }\n else has1.push_back(numbers[i]);\n }\n for (int i=0;i<numbers.size();i++)\n if (find(has2.begin(),has2.end(),numbers[i])==has2.end())\n out.push_back(numbers[i]);\n return out;\n\n\n}\n"}, {"buggy_solution": " string out=\"\";\n for (int i=0;i<str.length();i++)\n {\n char w=str[i];\n if (w>=97 and w<=122) {w-=32;}\n else\n if (w>=65 and w<=90){ w+=32;}\n out=out+w;\n }\n return out;\n}\n"}, {"buggy_solution": " string out=\"\";\n for (int i=0;i<strings.size();i++)\n out=out+strings[i];\n return out;\n}\n"}, {"buggy_solution": " vector<string> out={};\n for (int i=0;i<strings.size();i++)\n if (strings[i].substr(0,prefix.length())==prefix) out.push_back(strings[i]);\n return out;\n}\n"}, {"buggy_solution": " vector<float> out={};\n for (int i=0;i<l.size();i++)\n if (l[i]>0) out.push_back(l[i]);\n return out;\n}\n"}, {"buggy_solution": " if (n<2) return false;\n for (long long i=2;i*i<=n;i++)\n if (n%i==0) return false;\n return true;\n}\n"}, {"buggy_solution": " double ans=0;\n double value;\n value=poly(xs,ans);\n while (abs(value)>1e-6)\n {\n double driv=0;\n for (int i=1;i<xs.size();i++)\n {\n driv+=xs[i]*pow(ans,i-1)*i;\n }\n ans=ans-value/driv;\n value=poly(xs,ans);\n }\n return ans;\n\n}\n"}, {"buggy_solution": " vector<int> third={};\n int i;\n for (i=0;i*3<l.size();i++)\n third.push_back(l[i*3]);\n \n sort(third.begin(),third.end());\n\n vector<int> out={};\n for (i=0;i<l.size();i++)\n {\n if (i%3==0) {out.push_back(third[i/3]);}\n else out.push_back(l[i]);\n }\n return out;\n\n}\n"}, {"buggy_solution": " vector<int> out={};\n for (int i=0;i<l.size();i++)\n if (find(out.begin(),out.end(),l[i])==out.end())\n out.push_back(l[i]);\n sort(out.begin(),out.end());\n return out;\n}\n"}, {"buggy_solution": " float max=-10000;\n for (int i=0;i<l.size();i++)\n if (max<l[i]) max=l[i];\n return max;\n\n}\n"}, {"buggy_solution": " int count=0;\n for (int i=0;i<n;i++)\n if (i%11==0 or i%13==0)\n {\n int q=i;\n while (q>0)\n {\n if (q%10==7) count+=1;\n q=q/10;\n }\n } \n return count;\n}\n"}, {"buggy_solution": " vector<float> out={};\n vector<float> even={};\n for (int i=0;i*2<l.size();i++)\n even.push_back(l[i*2]);\n sort(even.begin(),even.end());\n for (int i=0;i<l.size();i++)\n {\n if (i%2==0) out.push_back(even[i/2]);\n if (i%2==1) out.push_back(l[i]);\n }\n return out;\n}\n"}, {"buggy_solution": " int l=s.length();\n int num=(l+2)/3;\n string x,output;\n int i;\n for (i=0;i*3<l;i++)\n {\n x=s.substr(i*3,3);\n if (x.length()==3) x=x[2]+x.substr(0,2);\n output=output+x;\n }\n return output;\n\n\n}\n"}, {"buggy_solution": " int f1,f2,m;\n f1=1;f2=2;\n int count=0;\n while (count<n)\n {\n f1=f1+f2;\n m=f1;f1=f2;f2=m;\n bool isprime=true;\n for (int w=2;w*w<=f1;w++)\n if (f1%w==0)\n {\n isprime=false; break;\n }\n if (isprime) count+=1;\n if (count==n) return f1;\n }\n\n}\n"}, {"buggy_solution": " for (int i=0;i<l.size();i++)\n for (int j=i+1;j<l.size();j++)\n for (int k=j+1;k<l.size();k++)\n if (l[i]+l[j]+l[k]==0) return true;\n return false;\n}\n"}, {"buggy_solution": " return n*n;\n}\n"}, {"buggy_solution": " for (int i=0;i<l.size();i++)\n l[i]+=1;\n return l;\n}\n"}, {"buggy_solution": " for (int i=0;i<l.size();i++)\n for (int j=i+1;j<l.size();j++)\n if (l[i]+l[j]==0) return true;\n return false;\n}\n"}, {"buggy_solution": " string out=\"\";\n while (x>0)\n {\n out=to_string(x%base)+out;\n x=x/base;\n }\n return out;\n}\n"}, {"buggy_solution": "return (a*h)*0.5;\n\n}\n"}, {"buggy_solution": " int f[100];\n f[0]=0;\n f[1]=0;\n f[2]=2;\n f[3]=0;\n for (int i=4;i<=n;i++)\n {\n f[i]=f[i-1]+f[i-2]+f[i-3]+f[i-4];\n }\n return f[n];\n}\n"}, {"buggy_solution": " sort(l.begin(),l.end());\n if (l.size()%2==1) return l[l.size()/2];\n return 0.5*(l[l.size()/2]+l[l.size()/2-1]);\n}\n"}, {"buggy_solution": " string pr(text.rbegin(),text.rend());\n return pr==text;\n}\n"}, {"buggy_solution": " int out=1;\n for (int i=0;i<n;i++)\n out=(out*2)%p;\n return out;\n}\n"}, {"buggy_solution": " string out;\n int i;\n for (i=0;i<s.length();i++)\n {\n int w=((int)s[i]+21-(int)'a')%26+(int)'a'; \n out=out+(char)w;\n }\n return out;\n}\n"}, {"buggy_solution": " string out=\"\";\n string vowels=\"AEIOUaeiou\";\n for (int i=0;i<text.length();i++)\n if (find(vowels.begin(),vowels.end(),text[i])==vowels.end())\n out=out+text[i];\n return out;\n\n}\n"}, {"buggy_solution": " for (int i=0;i<l.size();i++)\n if (l[i]>=t) return false;\n return true;\n}\n"}, {"buggy_solution": " return x+y;\n}\n"}, {"buggy_solution": " for (int i=0;i<s0.length();i++)\n if (find(s1.begin(),s1.end(),s0[i])==s1.end())\n return false;\n for (int i=0;i<s1.length();i++)\n if (find(s0.begin(),s0.end(),s1[i])==s0.end())\n return false;\n return true; \n}\n"}, {"buggy_solution": " int f[1000];\n f[0]=0;f[1]=1;\n for (int i=2;i<=n; i++)\n f[i]=f[i-1]+f[i-2];\n return f[n];\n}\n"}, {"buggy_solution": " int level=0;\n for (int i=0;i<brackets.length();i++)\n {\n if (brackets[i]=='<') level+=1;\n if (brackets[i]=='>') level-=1;\n if (level<0) return false;\n }\n if (level!=0) return false;\n return true;\n}\n"}, {"buggy_solution": " int incr,decr;\n incr=0;decr=0;\n for (int i=1;i<l.size();i++)\n {\n if (l[i]>l[i-1]) incr=1;\n if (l[i]<l[i-1]) decr=1;\n }\n if (incr+decr==2) return false;\n return true;\n}\n"}, {"buggy_solution": " vector<int> out={};\n for (int i=0;i<l1.size();i++)\n if (find(out.begin(),out.end(),l1[i])==out.end())\n if (find(l2.begin(),l2.end(),l1[i])!=l2.end())\n out.push_back(l1[i]);\n sort(out.begin(),out.end());\n return out;\n}\n"}, {"buggy_solution": " for (int i=2;i*i<=n;i++)\n while (n%i==0 and n>i) n=n/i;\n return n;\n}\n"}, {"buggy_solution": " return n*(n+1)/2;\n}\n"}, {"buggy_solution": " int level=0;\n for (int i=0;i<brackets.length();i++)\n {\n if (brackets[i]=='(') level+=1;\n if (brackets[i]==')') level-=1;\n if (level<0) return false;\n }\n if (level!=0) return false;\n return true;\n}\n"}, {"buggy_solution": " vector<float> out={};\n for (int i=1;i<xs.size();i++)\n out.push_back(i*xs[i]);\n return out;\n}\n"}, {"buggy_solution": " int ff[100];\n ff[0]=0;\n ff[1]=0;\n ff[2]=1;\n for (int i=3;i<=n;i++)\n ff[i]=ff[i-1]+ff[i-2]+ff[i-3];\n return ff[n];\n\n}\n"}, {"buggy_solution": " string vowels=\"aeiouAEIOU\";\n int count=0;\n for (int i=0;i<s.length();i++)\n if (find(vowels.begin(),vowels.end(),s[i])!=vowels.end())\n count+=1;\n if (s[s.length()-1]=='y' or s[s.length()-1]=='Y') count+=1;\n return count;\n}\n"}, {"buggy_solution": " string xs;\n xs=to_string(x);\n if (xs.length()<shift)\n {\n string s(xs.rbegin(),xs.rend());\n return s;\n }\n xs=xs.substr(xs.length()-shift)+xs.substr(0,xs.length()-shift);\n return xs;\n}\n"}, {"buggy_solution": " int sum=0;\n for (int i=0;i<s.length();i++)\n if (s[i]>=65 and s[i]<=90)\n sum+=s[i];\n return sum;\n}\n"}, {"buggy_solution": " string num1=\"\",num2=\"\";\n int is12;\n is12=0;\n for (int i=0;i<s.size();i++)\n \n if (s[i]>=48 and s[i]<=57)\n {\n if (is12==0) num1=num1+s[i];\n if (is12==1) num2=num2+s[i];\n }\n else\n if (is12==0 and num1.length()>0) is12=1;\n return n-atoi(num1.c_str())-atoi(num2.c_str());\n\n}\n"}, {"buggy_solution": " vector<int> out={};\n for (int i=0;i<arr.size();i++)\n if (arr[i]%2==0 and (out.size()==0 or arr[i]<out[0]))\n out={arr[i],i};\n return out;\n}\n"}, {"buggy_solution": " vector<vector<int>> freq={};\n int max=-1;\n for (int i=0;i<lst.size();i++)\n {\n bool has=false;\n for (int j=0;j<freq.size();j++)\n if (lst[i]==freq[j][0]) \n {\n freq[j][1]+=1;\n has=true;\n if (freq[j][1]>=freq[j][0] and freq[j][0]>max) max=freq[j][0];\n }\n if (not(has)) \n {\n freq.push_back({lst[i],1});\n if (max==-1 and lst[i]==1) max=1;\n }\n }\n return max;\n}\n"}, {"buggy_solution": " vector<int> out={};\n sort(lst.begin(),lst.end());\n int l=0,r=lst.size()-1;\n while (l<r)\n {\n out.push_back(lst[l]);\n l+=1;\n out.push_back(lst[r]);\n r-=1;\n }\n if (l==r) out.push_back(lst[l]);\n return out;\n\n}\n"}, {"buggy_solution": " if (a+b<=c or a+c<=b or b+c<=a) return -1;\n float h=(a+b+c)/2;\n float area;\n area=pow(h*(h-a)*(h-b)*(h-c),0.5);\n return area;\n}\n"}, {"buggy_solution": " int sum=0;\n for (int i=0;i<q.size();i++)\n {\n if (q[i]!=q[q.size()-1-i]) return false;\n sum+=q[i];\n }\n if (sum>w) return false;\n return true;\n}\n"}, {"buggy_solution": " int out=0;\n for (int i=0;i<arr.size()-1-i;i++)\n if (arr[i]!=arr[arr.size()-1-i])\n out+=1;\n return out;\n}\n"}, {"buggy_solution": " int num1,num2,i;\n num1=0;num2=0;\n for (i=0;i<lst1.size();i++)\n num1+=lst1[i].length();\n for (i=0;i<lst2.size();i++)\n num2+=lst2[i].length();\n if (num1>num2) return lst2;\n return lst1;\n}\n"}, {"buggy_solution": " int num=0;\n for (int i=2;i*i<=a;i++)\n while (a%i==0 and a>i)\n {\n a=a/i;\n num+=1;\n }\n if (num==2) return true;\n return false; \n}\n"}, {"buggy_solution": " int p=1,count=0;\n while (p<=x and count<100)\n {\n if (p==x) return true;\n p=p*n;count+=1;\n }\n return false;\n}\n"}, {"buggy_solution": " for (int i=0;i*i*i<=abs(a);i++)\n if (i*i*i==abs(a)) return true;\n return false;\n}\n"}, {"buggy_solution": " string key=\"2357BD\";\n int out=0;\n for (int i=0;i<num.length();i++)\n if (find(key.begin(),key.end(),num[i])!=key.end()) out+=1;\n return out;\n}\n"}, {"buggy_solution": " string out=\"\";\n if (decimal==0) return \"db0db\";\n while (decimal>0)\n {\n out=to_string(decimal%2)+out;\n decimal=decimal/2;\n }\n out=\"db\"+out+\"db\";\n return out;\n}\n"}, {"buggy_solution": " if (s.length()<3) return false;\n for (int i=2;i<s.length();i++)\n if (s[i]==s[i-1] or s[i]==s[i-2]) return false;\n return true;\n}\n"}, {"buggy_solution": " vector<string> out={};\n for (int i=0;i<grades.size();i++)\n {\n if (grades[i]>=3.9999) out.push_back(\"A+\");\n if (grades[i]>3.7001 and grades[i]<3.9999) out.push_back(\"A\");\n if (grades[i]>3.3001 and grades[i]<=3.7001) out.push_back(\"A-\");\n if (grades[i]>3.0001 and grades[i]<=3.3001) out.push_back(\"B+\");\n if (grades[i]>2.7001 and grades[i]<=3.0001) out.push_back(\"B\");\n if (grades[i]>2.3001 and grades[i]<=2.7001) out.push_back(\"B-\");\n if (grades[i]>2.0001 and grades[i]<=2.3001) out.push_back(\"C+\");\n if (grades[i]>1.7001 and grades[i]<=2.0001) out.push_back(\"C\");\n if (grades[i]>1.3001 and grades[i]<=1.7001) out.push_back(\"C-\");\n if (grades[i]>1.0001 and grades[i]<=1.3001) out.push_back(\"D+\");\n if (grades[i]>0.7001 and grades[i]<=1.0001) out.push_back(\"D\");\n if (grades[i]>0.0001 and grades[i]<=0.7001) out.push_back(\"D-\");\n if (grades[i]<=0.0001) out.push_back(\"E\");\n }\n return out;\n}\n"}, {"buggy_solution": " int l,i;\n l=str.length();\n if (l<2) return false;\n for (i=2;i*i<=l;i++)\n if (l%i==0) return false;\n return true;\n}\n"}, {"buggy_solution": " if (n<1) return 0;\n if (n==1) return 1;\n int out=18;\n for (int i=2;i<n;i++)\n out=out*10;\n return out;\n}\n"}, {"buggy_solution": " string str,bi=\"\";\n str=to_string(N);\n int i,sum=0;\n for (int i=0;i<str.length();i++)\n sum+=str[i]-48;\n while (sum>0)\n {\n bi=to_string(sum%2)+bi;\n sum=sum/2;\n }\n return bi;\n}\n"}, {"buggy_solution": " int sum=0;\n for (int i=0;i*2+1<lst.size();i++)\n if (lst[i*2+1]%2==0) sum+=lst[i*2+1];\n return sum;\n}\n"}, {"buggy_solution": " string out=\"\";\n string current=\"\";\n s=s+' ';\n for (int i=0;i<s.length();i++)\n if (s[i]==' ')\n {\n sort(current.begin(),current.end());\n if (out.length()>0) out=out+' ';\n out=out+current;\n current=\"\";\n }\n else current=current+s[i];\n return out;\n}\n"}, {"buggy_solution": " vector<vector<int>> out={};\n for (int i=0;i<lst.size();i++)\n for (int j=lst[i].size()-1;j>=0;j-=1)\n if (lst[i][j]==x) out.push_back({i,j});\n return out;\n}\n"}, {"buggy_solution": " if (array.size()==0) return {};\n if ((array[0]+array[array.size()-1]) %2==1)\n {\n sort(array.begin(),array.end());\n return array;\n }\n else\n {\n sort(array.begin(),array.end());\n vector<int> out={};\n for (int i=array.size()-1;i>=0;i-=1)\n out.push_back(array[i]);\n return out;\n }\n\n}\n"}, {"buggy_solution": " string out;\n int i;\n for (i=0;i<s.length();i++)\n {\n int w=((int)s[i]+4-(int)'a')%26+(int)'a'; \n out=out+(char)w;\n }\n return out;\n}\n"}, {"buggy_solution": " sort(lst.begin(),lst.end());\n for (int i=1;i<lst.size();i++)\n if (lst[i]!=lst[i-1]) return lst[i];\n return -1;\n}\n"}, {"buggy_solution": " bool isstart=true;\n bool isi=false;\n int sum=0;\n for (int i=0;i<S.length();i++)\n {\n if (S[i]==' ' and isi) {isi=false; sum+=1;}\n if (S[i]=='I' and isstart) {isi=true; }\n else isi=false; \n if (S[i]!=' ') { isstart=false;}\n if (S[i]=='.' or S[i]=='?' or S[i]=='!') isstart=true;\n }\n return sum;\n}\n"}, {"buggy_solution": " if (round(a)!=a) return false;\n if (round(b)!=b) return false;\n if (round(c)!=c) return false;\n if (a+b==c or a+c==b or b+c==a) return true;\n return false;\n}\n"}, {"buggy_solution": " string vowels=\"aeiouAEIOU\";\n string out=\"\";\n for (int i=0;i<message.length();i++)\n {\n char w=message[i];\n if (w>=97 and w<=122){w=w-32;}\n else if (w>=65 and w<=90) w=w+32;\n if (find(vowels.begin(),vowels.end(),w)!=vowels.end()) w=w+2;\n out=out+w;\n }\n return out;\n}\n"}, {"buggy_solution": " int largest=0;\n for (int i=0;i<lst.size();i++)\n if (lst[i]>largest)\n {\n bool prime=true;\n for (int j=2;j*j<=lst[i];j++)\n if (lst[i]%j==0) prime=false;\n if (prime) largest=lst[i];\n }\n int sum=0;\n string s;\n s=to_string(largest);\n for (int i=0;i<s.length();i++)\n sum+=s[i]-48;\n return sum;\n}\n#undef NDEBUG\n#include<assert.h>\n"}, {"buggy_solution": " map<string,string>::iterator it;\n int islower=0,isupper=0;\n if (dict.size()==0) return false;\n for (it=dict.begin();it!=dict.end();it++)\n {\n string key=it->first;\n \n for (int i=0;i<key.length();i++)\n {\n if (key[i]<65 or (key[i]>90 and key[i]<97) or key[i]>122) return false;\n if (key[i]>=65 and key[i]<=90) isupper=1;\n if (key[i]>=97 and key[i]<=122) islower=1;\n if (isupper+islower==2) return false;\n }\n\n }\n return true;\n}\n"}, {"buggy_solution": " vector<int> out={};\n int i,j;\n for (i=2;i<n;i++)\n if (out.size()==0) {out.push_back(i);}\n else\n {\n bool isp=true;\n for (j=0;out[j]*out[j]<=i;j++)\n if (i%out[j]==0) isp=false;\n if (isp) out.push_back(i);\n }\n return out;\n}\n"}, {"buggy_solution": " return (abs(a)%10)*(abs(b)%10);\n}\n"}, {"buggy_solution": " string uvowel=\"AEIOU\";\n int count=0;\n for (int i=0;i*2<s.length();i++)\n if (find(uvowel.begin(),uvowel.end(),s[i*2])!=uvowel.end())\n count+=1;\n return count;\n}\n"}, {"buggy_solution": " double w;\n w=atof(value.c_str());\n return round(w);\n}\n"}, {"buggy_solution": " vector<int> out={n};\n for (int i=1;i<n;i++)\n out.push_back(out[out.size()-1]+2);\n return out;\n}\n"}, {"buggy_solution": " string current=\"\";\n vector<string> out={};\n s=s+' ';\n for (int i=0;i<s.length();i++)\n if (s[i]==' ' or s[i]==',')\n {\n if (current.length()>0)\n {\n out.push_back(current);\n current=\"\";\n }\n }\n else current=current+s[i];\n return out;\n}\n"}, {"buggy_solution": " if (y<x) return -1;\n if (y==x and y%2==1) return -1;\n if (y%2==1) return y-1;\n return y;\n}\n"}, {"buggy_solution": " if (n>m) return \"-1\";\n int num=(m+n)/2;\n string out=\"\";\n while (num>0)\n {\n out=to_string(num%2)+out;\n num=num/2;\n }\n return out;\n}\n"}, {"buggy_solution": " vector<int> out={};\n for (int i=0;i<x.size();i++)\n {\n int num=x[i];\n bool u=true;\n if (num==0) u=false;\n while (num>0 and u)\n {\n if (num%2==0) u=false;\n num=num/10;\n }\n if (u) out.push_back(x[i]);\n }\n sort(out.begin(),out.end());\n return out;\n}\n"}, {"buggy_solution": " map<int,string> numto={{0,\"Zero\"},{1,\"One\"},{2,\"Two\"},{3,\"Three\"},{4,\"Four\"},{5,\"Five\"},{6,\"Six\"},{7,\"Seven\"},{8,\"Eight\"},{9,\"Nine\"}};\n sort(arr.begin(),arr.end());\n vector<string> out={};\n for (int i=arr.size()-1;i>=0;i-=1)\n if (arr[i]>=1 and arr[i]<=9)\n out.push_back(numto[arr[i]]);\n return out;\n}\n"}, {"buggy_solution": " int sum=0,prod=1;\n vector<int> out={};\n for (int i=1;i<=n;i++)\n {\n sum+=i;\n prod*=i;\n if (i%2==0) out.push_back(prod);\n else out.push_back(sum);\n } \n return out;\n}\n"}, {"buggy_solution": " int num1=0,num2=0;\n for (int i=1;i<=n;i++)\n {\n string w=to_string(i);\n string p(w.rbegin(),w.rend());\n if (w==p and i%2==1) num1+=1;\n if (w==p and i%2==0) num2+=1;\n \n }\n return {num2,num1};\n}\n"}, {"buggy_solution": " int num=0;\n for (int i=0;i<n.size();i++)\n if (n[i]>0) num+=1;\n else\n {\n int sum=0;\n int w;\n w=abs(n[i]);\n while (w>=10)\n {\n sum+=w%10;\n w=w/10;\n }\n sum-=w;\n if (sum>0) num+=1;\n }\n return num;\n}\n"}, {"buggy_solution": " int num=0;\n if (arr.size()==0) return true;\n for (int i=1;i<arr.size();i++)\n if (arr[i]<arr[i-1]) num+=1;\n if (arr[arr.size()-1]>arr[0]) num+=1;\n if (num<2) return true;\n return false;\n}\n"}, {"buggy_solution": " int num=0;\n for (int i=0;i<lst1.size();i++)\n if (lst1[i]%2==0) num+=1;\n for (int i=0;i<lst2.size();i++)\n if (lst2[i]%2==0) num+=1;\n if (num>=lst1.size()) return \"YES\";\n return \"NO\";\n}\n"}, {"buggy_solution": " map<char,int> count={},out={};\n map <char,int>::iterator it;\n int max=0;\n for (int i=0;i<test.length();i++)\n if (test[i]!=' ')\n {\n count[test[i]]+=1;\n if (count[test[i]]>max) max=count[test[i]];\n }\n for (it=count.begin();it!=count.end();it++)\n {\n char w1=it->first;\n int w2=it->second;\n if (w2==max) out[w1]=w2;\n }\n return out;\n}\n"}, {"buggy_solution": " string n=\"\";\n for (int i=0;i<s.length();i++)\n if (find(c.begin(),c.end(),s[i])==c.end())\n n=n+s[i]; \n if (n.length()==0) return {n,\"True\"};\n string w(n.rbegin(),n.rend());\n if (w==n) return {n,\"True\"};\n return {n,\"False\"};\n}\n"}, {"buggy_solution": " vector<string> out={};\n for (int i=0;i<lst.size();i++)\n {\n int sum=0;\n for (int j=0;j<lst[i].length();j++)\n if (lst[i][j]>=48 and lst[i][j]<=57 and lst[i][j]%2==1)\n sum+=1;\n string s=\"the number of odd elements in the string i of the input.\";\n string s2=\"\";\n for (int j=0;j<s.length();j++)\n if (s[j]=='i') s2=s2+to_string(sum);\n else s2=s2+s[j];\n out.push_back(s2);\n }\n return out;\n}\n"}, {"buggy_solution": " long long current,min;\n current=nums[0];\n min=nums[0];\n for (int i=1;i<nums.size();i++)\n {\n if (current<0) current=current+nums[i];\n else current=nums[i];\n if (current<min) min=current;\n }\n return min;\n}\n"}, {"buggy_solution": " int out=0;\n for (int i=0;i<grid.size();i++)\n {\n int sum=0;\n for (int j=0;j<grid[i].size();j++)\n sum+=grid[i][j];\n if (sum>0) out+=(sum-1)/capacity+1;\n }\n return out;\n}\n"}, {"buggy_solution": " vector<int> bin={};\n int m;\n\n for (int i=0;i<arr.size();i++)\n {\n int b=0,n=abs(arr[i]);\n while (n>0)\n {\n b+=n%2;n=n/2;\n }\n bin.push_back(b);\n }\n for (int i=0;i<arr.size();i++)\n for (int j=1;j<arr.size();j++)\n if (bin[j]<bin[j-1] or (bin[j]==bin[j-1] and arr[j]<arr[j-1]))\n {\n m=arr[j];arr[j]=arr[j-1];arr[j-1]=m;\n m=bin[j];bin[j]=bin[j-1];bin[j-1]=m;\n }\n return arr;\n}\n"}, {"buggy_solution": " string vowels=\"aeiouAEIOU\";\n string current=\"\";\n vector<string> out={};\n int numc=0;\n s=s+' ';\n for (int i=0;i<s.length();i++)\n if (s[i]==' ')\n {\n if (numc==n) out.push_back(current);\n current=\"\";\n numc=0;\n }\n else\n {\n current=current+s[i];\n if ((s[i]>=65 and s[i]<=90) or (s[i]>=97 and s[i]<=122))\n if (find(vowels.begin(),vowels.end(),s[i])==vowels.end())\n numc+=1;\n }\n return out;\n}\n"}, {"buggy_solution": " string out=\"\";\n string vowels=\"AEIOUaeiou\";\n for (int i=word.length()-2;i>=1;i-=1)\n if (find(vowels.begin(),vowels.end(),word[i])!=vowels.end())\n if (find(vowels.begin(),vowels.end(),word[i+1])==vowels.end())\n if (find(vowels.begin(),vowels.end(),word[i-1])==vowels.end())\n return out+word[i];\n return out;\n}\n"}, {"buggy_solution": " string l1=lst[0]+lst[1];\n int i,count=0;\n bool can=true;\n for (i=0;i<l1.length();i++)\n {\n if (l1[i]=='(') count+=1;\n if (l1[i]==')') count-=1;\n if (count<0) can=false;\n }\n if (count!=0) return \"No\";\n if (can==true) return \"Yes\";\n l1=lst[1]+lst[0];\n can=true;\n for (i=0;i<l1.length();i++)\n {\n if (l1[i]=='(') count+=1;\n if (l1[i]==')') count-=1;\n if (count<0) can=false;\n }\n if (can==true) return \"Yes\";\n return \"No\";\n}\n"}, {"buggy_solution": " sort(arr.begin(),arr.end());\n vector<int> out(arr.end()-k,arr.end());\n return out;\n}\n"}, {"buggy_solution": " int sum=0;\n for (int i=0;i*2<lst.size();i++)\n if (lst[i*2]%2==1) sum+=lst[i*2];\n return sum;\n}\n"}, {"buggy_solution": " int sum=0;\n for (int i=0;i<k;i++)\n if( arr[i]>=-99 and arr[i]<=99)\n sum+=arr[i];\n return sum;\n}\n"}, {"buggy_solution": " vector<int> out={1};\n while (n!=1)\n {\n if (n%2==1) {out.push_back(n); n=n*3+1;}\n else n=n/2;\n }\n sort(out.begin(),out.end());\n return out;\n}\n"}, {"buggy_solution": " int mm,dd,yy,i;\n if (date.length()!=10) return false;\n for (int i=0;i<10;i++)\n if (i==2 or i==5)\n {\n if (date[i]!='-') return false;\n }\n else\n if (date[i]<48 or date[i]>57) return false;\n\n mm=atoi(date.substr(0,2).c_str());\n dd=atoi(date.substr(3,2).c_str());\n yy=atoi(date.substr(6,4).c_str());\n if (mm<1 or mm>12) return false;\n if (dd<1 or dd>31) return false;\n if (dd==31 and (mm==4 or mm==6 or mm==9 or mm==11 or mm==2)) return false;\n if (dd==30 and mm==2) return false;\n return true;\n\n}\n"}, {"buggy_solution": " int i;\n string current=\"\";\n vector<string> out={};\n if (find(txt.begin(),txt.end(),' ')!=txt.end())\n {\n txt=txt+' ';\n for (i=0;i<txt.length();i++)\n if (txt[i]==' ') \n {\n if (current.length()>0)out.push_back(current); \n current=\"\";\n }\n else current=current+txt[i];\n return out;\n }\n if (find(txt.begin(),txt.end(),',')!=txt.end())\n {\n txt=txt+',';\n for (i=0;i<txt.length();i++)\n if (txt[i]==',') \n {\n if (current.length()>0)out.push_back(current); \n current=\"\";\n }\n else current=current+txt[i];\n return out;\n }\n int num=0;\n for (i=0;i<txt.length();i++)\n if (txt[i]>=97 and txt[i]<=122 and txt[i]%2==0)\n num+=1;\n return {to_string(num)};\n}\n"}, {"buggy_solution": " for (int i=1;i<lst.size();i++)\n {\n if (lst[i]<lst[i-1]) return false;\n if (i>=2 and lst[i]==lst[i-1] and lst[i]==lst[i-2]) return false;\n }\n return true;\n}\n"}, {"buggy_solution": " int inter1,inter2,l,i;\n inter1=max(interval1[0],interval2[0]);\n inter2=min(interval1[1],interval2[1]);\n l=inter2-inter1;\n if (l<2) return \"NO\";\n for (i=2;i*i<=l;i++)\n if (l%i==0) return \"NO\";\n return \"YES\";\n}\n"}, {"buggy_solution": " if (arr.size()==0) return -32768;\n int i,sum=0,prods=1;\n for (i=0;i<arr.size();i++)\n {\n sum+=abs(arr[i]);\n if (arr[i]==0) prods=0;\n if (arr[i]<0) prods=-prods;\n }\n return sum*prods;\n}\n"}, {"buggy_solution": " int i,j,x,y,min;\n for (i=0;i<grid.size();i++)\n for (j=0;j<grid[i].size();j++)\n if (grid[i][j]==1) {\n x=i;y=j;\n }\n min=grid.size()*grid.size();\n if (x>0 and grid[x-1][y]<min) min=grid[x-1][y];\n if (x<grid.size()-1 and grid[x+1][y]<min) min=grid[x+1][y];\n if (y>0 and grid[x][y-1]<min) min=grid[x][y-1];\n if (y<grid.size()-1 and grid[x][y+1]<min) min=grid[x][y+1];\n vector<int> out={};\n for (i=0;i<k;i++)\n if (i%2==0) out.push_back(1);\n else out.push_back(min);\n return out;\n}\n"}, {"buggy_solution": " vector<int> out={1,3};\n if (n==0) return {1};\n for (int i=2;i<=n;i++)\n {\n if (i%2==0) out.push_back(1+i/2);\n else out.push_back(out[i-1]+out[i-2]+1+(i+1)/2);\n }\n return out;\n}\n"}, {"buggy_solution": " int prod=1,has=0;\n string s=to_string(n);\n for (int i=0;i<s.length();i++)\n if (s[i]%2==1) \n {\n has=1;\n prod=prod*(s[i]-48);\n }\n if (has==0) return 0;\n return prod;\n}\n"}, {"buggy_solution": " int count=0,maxcount=0;\n for (int i=0;i<str.length();i++)\n {\n if (str[i]=='[') count+=1;\n if (str[i]==']') count-=1;\n if (count<0) count=0;\n if (count>maxcount) maxcount=count;\n if (count<=maxcount-2) return true;\n }\n return false;\n}\n"}, {"buggy_solution": " int sum=0;\n for (int i=0;i<lst.size();i++)\n sum+=ceil(lst[i])*ceil(lst[i]);\n return sum;\n}\n"}, {"buggy_solution": " if (txt.length()==0) return false;\n char chr=txt[txt.length()-1];\n if (chr<65 or (chr>90 and chr<97) or chr>122) return false;\n if (txt.length()==1) return true;\n chr=txt[txt.length()-2];\n if ((chr>=65 and chr<=90) or (chr>=97 and chr<=122)) return false;\n return true;\n}\n"}, {"buggy_solution": " int max=-1;\n for (int i=0;i<arr.size();i++)\n if (arr[i]<=i) max=i;\n return max;\n}\n"}, {"buggy_solution": " int maxneg=0,minpos=0;\n for (int i=0;i<lst.size();i++)\n {\n if (lst[i]<0 and (maxneg==0 or lst[i]>maxneg)) maxneg=lst[i];\n if (lst[i]>0 and (minpos==0 or lst[i]<minpos)) minpos=lst[i];\n }\n return {maxneg,minpos};\n}\n"}, {"buggy_solution": " double numa,numb;\n boost::any out;\n \n if (a.type()==typeid(string))\n {\n string s;\n s=boost::any_cast<string>(a);\n if (find(s.begin(),s.end(),',')!=s.end())\n for (int i=0;i<s.length();i++)\n if (s[i]==',') s=s.substr(0,i)+'.'+s.substr(i+1);\n numa=atof(s.c_str());\n \n }\n else \n {\n if (a.type()==typeid(int)) numa=boost::any_cast<int>(a);\n if (a.type()==typeid(double)) numa=boost::any_cast<double>(a);\n }\n if (b.type()==typeid(string))\n {\n string s;\n s=boost::any_cast<string>(b);\n if (find(s.begin(),s.end(),',')!=s.end())\n for (int i=0;i<s.length();i++)\n if (s[i]==',') s=s.substr(0,i)+'.'+s.substr(i+1);\n numb=atof(s.c_str());\n }\n else \n {\n if (b.type()==typeid(int)) numb=boost::any_cast<int>(b);\n if (b.type()==typeid(double)) numb=boost::any_cast<double>(b);\n }\n\n if (numa==numb) return string(\"None\");\n if (numa<numb) return b;\n if (numa>numb) return a;\n}\n"}, {"buggy_solution": " if (n%2==0 and n>=8) return true;\n return false;\n}\n"}, {"buggy_solution": " long long fact=1,bfact=1;\n for (int i=1;i<=n;i++)\n {\n fact=fact*i;\n bfact=bfact*fact;\n }\n return bfact;\n}\n"}, {"buggy_solution": " string out=\"\";\n int spacelen=0;\n for (int i=0;i<text.length();i++)\n if (text[i]==' ') spacelen+=1;\n else\n {\n if (spacelen==1) out=out+'_';\n if (spacelen==2) out=out+\"__\";\n if (spacelen>2) out=out+'-';\n spacelen=0;\n out=out+text[i];\n }\n if (spacelen==1) out=out+'_';\n if (spacelen==2) out=out+\"__\";\n if (spacelen>2) out=out+'-';\n return out;\n}\n"}, {"buggy_solution": " int numdigit=0,numdot=0;\n if (file_name.length()<5) return \"No\";\n char w=file_name[0];\n if (w<65 or (w>90 and w<97) or w>122) return \"No\";\n string last=file_name.substr(file_name.length()-4,4);\n if (last!=\".txt\" and last!=\".exe\" and last!=\".dll\") return \"No\";\n for (int i=0;i<file_name.length();i++)\n {\n if (file_name[i]>=48 and file_name[i]<=57) numdigit+=1;\n if (file_name[i]=='.') numdot+=1;\n }\n if (numdigit>3 or numdot!=1) return \"No\";\n return \"Yes\"; \n}\n"}, {"buggy_solution": " int sum=0;\n for (int i=0;i<lst.size();i++)\n if (i%3==0) sum+=lst[i]*lst[i];\n else if (i%4==0) sum+=lst[i]*lst[i]*lst[i];\n else sum+=lst[i];\n return sum;\n}\n"}, {"buggy_solution": " string out=\"\";\n string current=\"\";\n sentence=sentence+' ';\n\n for (int i=0;i<sentence.size();i++)\n if (sentence[i]!=' ') current=current+sentence[i];\n else\n {\n bool isp=true;\n int l=current.length();\n if (l<2) isp=false;\n for (int j=2;j*j<=l;j++)\n if (l%j==0) isp=false;\n if (isp) out=out+current+' ';\n current=\"\"; \n }\n if (out.length()>0)\n out.pop_back();\n return out;\n}\n"}, {"buggy_solution": " int a,b,c,d,i;\n for (i=0;i<x.size();i++)\n if (x[i]=='/') \n {\n a=atoi(x.substr(0,i).c_str());\n b=atoi(x.substr(i+1).c_str());\n }\n for (i=0;i<n.size();i++)\n if (n[i]=='/') \n {\n c=atoi(n.substr(0,i).c_str());\n d=atoi(n.substr(i+1).c_str());\n }\n if ((a*c)%(b*d)==0) return true;\n return false;\n}\n"}, {"buggy_solution": " vector<int> sumdigit={};\n for (int i=0;i<nums.size();i++)\n {\n string w=to_string(abs(nums[i]));\n int sum=0;\n for (int j=1;j<w.length();j++)\n sum+=w[j]-48;\n if (nums[i]>0) sum+=w[0]-48;\n else sum-=w[0]-48;\n sumdigit.push_back(sum);\n }\n int m;\n for (int i=0;i<nums.size();i++)\n for (int j=1;j<nums.size();j++)\n if (sumdigit[j-1]>sumdigit[j])\n {\n m=sumdigit[j];sumdigit[j]=sumdigit[j-1];sumdigit[j-1]=m;\n m=nums[j];nums[j]=nums[j-1];nums[j-1]=m;\n }\n \n return nums;\n}\n"}, {"buggy_solution": " int num=0;\n for (int i=0;i<nums.size();i++)\n if (nums[i]>10)\n {\n string w=to_string(nums[i]);\n if (w[0]%2==1 and w[w.length()-1]%2==1) num+=1;\n }\n return num;\n}\n"}, {"buggy_solution": " vector<int> a;\n vector<vector<int>> sum={{0,0,0}};\n vector<vector<int>> sum2={{0,0,0}};\n for (int i=1;i<=n;i++)\n {\n a.push_back((i*i-i+1)%3);\n sum.push_back(sum[sum.size()-1]);\n sum[i][a[i-1]]+=1;\n }\n for (int times=1;times<3;times++)\n {\n for (int i=1;i<=n;i++)\n {\n sum2.push_back(sum2[sum2.size()-1]);\n if (i>=1)\n for (int j=0;j<=2;j++)\n sum2[i][(a[i-1]+j)%3]+=sum[i-1][j];\n }\n sum=sum2;\n sum2={{0,0,0}};\n }\n\n return sum[n][0];\n}\n"}, {"buggy_solution": " vector<string> planets={\"Mercury\",\"Venus\",\"Earth\",\"Mars\",\"Jupiter\",\"Saturn\",\"Uranus\",\"Neptune\"};\n int pos1=-1,pos2=-1,m;\n for (m=0;m<planets.size();m++)\n {\n if (planets[m]==planet1) pos1=m;\n if (planets[m]==planet2) pos2=m;\n }\n if (pos1==-1 or pos2==-1) return {};\n if (pos1>pos2) {m=pos1;pos1=pos2;pos2=m;}\n vector<string> out={};\n for (m=pos1+1;m<pos2;m++)\n out.push_back(planets[m]);\n return out;\n}\n"}, {"buggy_solution": " vector<string> out={};\n for (int i=0;i<lst.size();i++)\n if (lst[i].length()%2==0) out.push_back(lst[i]);\n string mid;\n sort(out.begin(),out.end());\n for (int i=0;i<out.size();i++)\n for (int j=1;j<out.size();j++)\n if (out[j].length()<out[j-1].length())\n {\n mid=out[j];out[j]=out[j-1];out[j-1]=mid;\n }\n return out;\n}\n"}, {"buggy_solution": " bool isp=true;\n if (n<2) isp=false;\n for (int i=2;i*i<=n;i++)\n if (n%i==0) isp=false;\n if (isp) return x;\n return y;\n}\n"}, {"buggy_solution": " long long sum=0;\n for (int i=0;i<lst.size();i++)\n if (lst[i]-round(lst[i])<1e-4)\n if (lst[i]>0 and (int)(round(lst[i]))%2==1) sum+=(int)(round(lst[i]))*(int)(round(lst[i]));\n return sum;\n}\n"}, {"buggy_solution": " vector<int> out;\n for (int i=0;i<game.size();i++)\n out.push_back(abs(game[i]-guess[i]));\n return out;\n}\n"}, {"buggy_solution": " string strongest=\"\";\n int max=-1000;\n for (int i=0;i<extensions.size();i++)\n {\n int strength=0;\n for (int j=0;j<extensions[i].length();j++)\n {\n char chr=extensions[i][j];\n if (chr>=65 and chr<=90) strength+=1;\n if (chr>=97 and chr<=122) strength-=1;\n }\n if (strength>max) \n {\n max=strength;\n strongest=extensions[i];\n }\n }\n return class_name+'.'+strongest;\n}\n"}, {"buggy_solution": " for (int i=0;i<b.size();i++)\n {\n string rotate=b.substr(i)+b.substr(0,i);\n if (a.find(rotate)!=string::npos) return true;\n }\n return false;\n\n}\n"}, {"buggy_solution": " string w=to_string(abs(num));\n int n1=0,n2=0;\n for (int i=0;i<w.length();i++)\n if (w[i]%2==1) n1+=1;\n else n2+=1;\n return {n2,n1};\n}\n"}, {"buggy_solution": " string current=\"\";\n vector<string> rep={\"m\",\"cm\",\"d\",\"cd\",\"c\",\"xc\",\"l\",\"xl\",\"x\",\"ix\",\"v\",\"iv\",\"i\"};\n vector<int> num={1000,900,500,400,100,90,50,40,10,9,5,4,1};\n int pos=0;\n while(number>0)\n {\n while (number>=num[pos])\n {\n current=current+rep[pos];\n number-=num[pos];\n }\n if (number>0) pos+=1;\n }\n return current;\n}\n"}, {"buggy_solution": " if (abs(a*a+b*b-c*c)<1e-4 or abs(a*a+c*c-b*b)<1e-4 or abs(b*b+c*c-a*a)<1e-4) return true;\n return false;\n}\n"}, {"buggy_solution": " string max=\"\";\n int maxu=0;\n for (int i=0;i<words.size();i++)\n {\n string unique=\"\";\n for (int j=0;j<words[i].length();j++)\n if (find(unique.begin(),unique.end(),words[i][j])==unique.end())\n unique=unique+words[i][j];\n if (unique.length()>maxu or (unique.length()==maxu and words[i]<max))\n {\n max=words[i];\n maxu=unique.length();\n }\n }\n return max;\n}\n"}, {"buggy_solution": " if (need>remaining) return {number+remaining, 0};\n return {number+need,remaining-need};\n}\n"}, {"buggy_solution": " vector<int> num={};\n vector<int> posto={};\n for (int i=0;i<operand.size();i++)\n posto.push_back(i);\n for (int i=0;i<operato.size();i++)\n if (operato[i]==\"**\") \n {\n while (posto[posto[i]]!=posto[i]) posto[i]=posto[posto[i]];\n while (posto[posto[i+1]]!=posto[i+1]) posto[i+1]=posto[posto[i+1]];\n operand[posto[i]]=pow(operand[posto[i]],operand[posto[i+1]]);\n posto[i+1]=posto[i];\n }\n for (int i=0;i<operato.size();i++)\n if (operato[i]==\"*\" or operato[i]==\"//\") \n {\n while (posto[posto[i]]!=posto[i]) posto[i]=posto[posto[i]];\n while (posto[posto[i+1]]!=posto[i+1]) posto[i+1]=posto[posto[i+1]];\n if (operato[i]==\"*\")\n operand[posto[i]]=operand[posto[i]]*operand[posto[i+1]];\n else\n operand[posto[i]]=operand[posto[i]]/operand[posto[i+1]];\n posto[i+1]=posto[i];\n }\n for (int i=0;i<operato.size();i++)\n if (operato[i]==\"+\" or operato[i]==\"-\") \n {\n while (posto[posto[i]]!=posto[i]) posto[i]=posto[posto[i]];\n while (posto[posto[i+1]]!=posto[i+1]) posto[i+1]=posto[posto[i+1]];\n if (operato[i]==\"+\")\n operand[posto[i]]=operand[posto[i]]+operand[posto[i+1]];\n else\n operand[posto[i]]=operand[posto[i]]-operand[posto[i+1]];\n posto[i+1]=posto[i];\n }\n return operand[0];\n\n}\n"}, {"buggy_solution": " int nletter=0;\n string out=\"\";\n for (int i=0;i<s.length();i++)\n {\n char w=s[i];\n if (w>=65 and w<=90) w=w+32;\n else if (w>=97 and w<=122) w=w-32;\n else nletter+=1;\n out=out+w;\n }\n if (nletter==s.length())\n {\n string p(s.rbegin(),s.rend());\n return p;\n }\n else return out;\n}\n"}, {"buggy_solution": " unsigned char md[16];\n if (text.length()==0) return \"None\";\n MD5_CTX c;\n int i;\n MD5_Init(&c);\n MD5_Update(&c, (unsigned char*)text.c_str(), text.length());\n MD5_Final(md, &c);\n string out_str=\"\";\n for (int i=0;i<16;i++)\n {\n char w;\n if (md[i]<160) w=48+md[i]/16;\n else w=87+md[i]/16;\n out_str=out_str+w;\n if (md[i]%16<10) w=48+md[i]%16;\n else w=87+md[i]%16;\n out_str=out_str+w;\n }\n return out_str;\n}\n"}, {"buggy_solution": " int m;\n if (b<a)\n {\n m=a;a=b;b=m;\n }\n\n vector<int> out={};\n for (int i=a;i<=b;i++)\n if (i<10 and i%2==0) out.push_back(i);\n return out;\n}\n"}]
data/go/data/.DS_Store ADDED
Binary file (6.15 kB). View file
 
data/go/data/humaneval.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/go/data/humanevalbugs.json ADDED
@@ -0,0 +1 @@
 
 
1
+ [{"buggy_solution": " for i := 0; i < len(numbers); i++ {\n for j := i + 1; j < len(numbers); j++ {\n var distance float64 = math.Abs(numbers[i] - numbers[j])\n if distance < threshold {\n return true\n }\n }\n }\n return false\n}\n\n"}, {"buggy_solution": " result := make([]string, 0)\n current_string := make([]rune, 0)\n current_depth := 0\n\n for _, c := range paren_string {\n if c == '(' {\n current_depth += 1\n current_string = append(current_string, c)\n }else if c== ')'{\n current_depth -= 1\n current_string = append(current_string, c)\n\n if current_depth == 0{\n result = append(result, string(current_string))\n current_string = make([]rune, 0)\n }\n }\n\n }\n return result\n}\n\n"}, {"buggy_solution": " return math.Mod(number,1)\n}\n\n"}, {"buggy_solution": " balance := 0\n for _, op := range operations {\n balance += op\n if balance < 0 {\n return true\n }\n }\n return false\n}\n\n"}, {"buggy_solution": " sum := func(numbers []float64) float64 {\n sum := 0.0\n for _, num := range numbers {\n sum += num\n }\n return sum\n }\n\n mean := sum(numbers) / float64(len(numbers))\n numList := make([]float64, 0)\n for _, x := range numbers {\n numList = append(numList, math.Abs(x-mean))\n }\n return sum(numList) / float64(len(numbers))\n}\n\n"}, {"buggy_solution": " result := make([]int, 0)\n if len(numbers) == 0 {\n return result\n }\n for i := 0; i < len(numbers)-1; i++ {\n n := numbers[i]\n result = append(result, n)\n result = append(result, delimeter)\n }\n result = append(result, numbers[len(numbers)-1])\n return result\n}\n\n"}, {"buggy_solution": " parse_paren_group := func(s string) int {\n depth := 0\n max_depth := 0\n for _, c := range s {\n if c == '(' {\n depth += 1\n max_depth = int(math.Max(float64(depth), float64(max_depth)))\n } else {\n depth -= 1\n }\n }\n return max_depth\n }\n result := make([]int, 0)\n for _, x := range strings.Split(paren_string, \" \") {\n result = append(result, parse_paren_group(x))\n }\n return result\n\n}\n\n"}, {"buggy_solution": " result := make([]string, 0)\n for _, x := range stringList {\n if strings.Index(x, substring) != -1 {\n result = append(result, x)\n }\n }\n return result\n}\n\n"}, {"buggy_solution": " sum_value := 0\n prod_value := 1\n\n for _, n := range numbers {\n sum_value += n\n prod_value *= n\n }\n return [2]int{sum_value, prod_value}\n}\n\n"}, {"buggy_solution": " running_max := math.MinInt32\n result := make([]int, 0)\n\n for _, n := range numbers {\n if running_max == math.MinInt32 {\n running_max = n\n } else {\n running_max = int(math.Max(float64(running_max), float64(n)))\n }\n result = append(result, running_max)\n }\n\n return result\n}\n\n"}, {"buggy_solution": " if strings.TrimSpace(str) == \"\" {\n return \"\"\n }\n beginning_of_suffix := 0\n runes := []rune(str)\n for !IsPalindrome(string(runes[beginning_of_suffix:])) {\n beginning_of_suffix += 1\n }\n result := make([]rune, 0)\n for i := len(str[:beginning_of_suffix]) - 1; i >= 0; i-- {\n result = append(result, runes[i])\n }\n return str + string(result)\n}\n\n"}, {"buggy_solution": " s2b := func(bs string) int32 {\n result := int32(0)\n runes := []rune(bs)\n for _, r := range runes {\n result = result << 1\n temp := r - rune('0')\n result += temp\n }\n return result\n }\n ab := s2b(a)\n bb := s2b(b)\n res := ab ^ bb\n sprint := fmt.Sprintf(\"%b\", res)\n for i := 0; i < len(a)-len(sprint); i++ {\n sprint = \"0\" + sprint\n }\n return sprint\n}\n\n"}, {"buggy_solution": " if strings == nil || len(strings) == 0 {\n return nil\n }\n maxlen := 0\n maxi := 0\n for i, s := range strings {\n if maxlen < len(s) {\n maxlen = len(s)\n maxi = i\n }\n }\n return strings[maxi]\n}\n\n"}, {"buggy_solution": " if b < 2 {\n\t\treturn b\n\t}\n\tvar gcd int = 1\n\tfor i := 2; i < b; i++ {\n\t\tif a%i == 0 && b%i == 0 {\n\t\t\tgcd = i\n\t\t}\n\t}\n\treturn gcd\n}\n\n"}, {"buggy_solution": " prefixes := make([]string, 0, len(str))\n\tfor i := 0; i < len(str); i++ {\n\t\tprefixes = append(prefixes, str[:i+1])\n\t}\n\treturn prefixes\n}\n\n"}, {"buggy_solution": " var seq string\n for i := 0; i <= n; i++ {\n seq += strconv.Itoa(i)\n if i != n {\n seq += \" \"\n }\n }\n return seq\n}\n\n"}, {"buggy_solution": " lower := strings.ToLower(str)\n\tcount := 0\n\tset := make(map[rune]bool)\n\tfor _, i := range lower {\n\t\tif set[i] == true {\n\t\t\tcontinue\n\t\t} else {\n\t\t\tset[i] = true\n\t\t\tcount++\n\t\t}\n\t}\n\treturn count\n}\n\n\n"}, {"buggy_solution": " note_map := map[string]int{\"o\": 4, \"o|\": 2, \".|\": 1}\n\tsplit := strings.Split(music_string, \" \")\n\tresult := make([]int, 0)\n\tfor _, x := range split {\n\t\tif i, ok := note_map[x]; ok {\n\t\t\tresult = append(result, i)\n\t\t}\n\t}\n\treturn result\n}\n\n\n"}, {"buggy_solution": " times := 0\n\tfor i := 0; i < (len(str) - len(substring) + 1); i++ {\n\t\tif str[i:i+len(substring)] == substring {\n\t\t\ttimes += 1\n\t\t}\n\t}\n\treturn times\n}\n\n\n"}, {"buggy_solution": " valueMap := map[string]int{\n\t\t\"zero\": 0,\n\t\t\"one\": 1,\n\t\t\"two\": 2,\n\t\t\"three\": 3,\n\t\t\"four\": 4,\n\t\t\"five\": 5,\n\t\t\"six\": 6,\n\t\t\"seven\": 7,\n\t\t\"eight\": 8,\n\t\t\"nine\": 9,\n\t}\n\tstringMap := make(map[int]string)\n\tfor s, i := range valueMap {\n\t\tstringMap[i] = s\n\t}\n\tsplit := strings.Split(numbers, \" \")\n\ttemp := make([]int, 0)\n\tfor _, s := range split {\n\t\tif i, ok := valueMap[s]; ok {\n\t\t\ttemp = append(temp, i)\n\t\t}\n\t}\n\tsort.Ints(temp)\n\tresult := make([]string, 0)\n\tfor _, i := range temp {\n\t\tresult = append(result, stringMap[i])\n\t}\n\treturn strings.Join(result, \" \")\n}\n\n\n"}, {"buggy_solution": " distance := math.MaxFloat64\n\tvar closestPair [2]float64\n\tfor idx, elem := range numbers {\n\t\tfor idx2, elem2 := range numbers {\n\t\t\tif idx != idx2 {\n\t\t\t\tif distance == math.MinInt64 {\n\t\t\t\t\tdistance = math.Abs(elem - elem2)\n\t\t\t\t\tfloat64s := []float64{elem, elem2}\n\t\t\t\t\tsort.Float64s(float64s)\n\t\t\t\t\tclosestPair = [2]float64{float64s[0], float64s[1]}\n\t\t\t\t} else {\n\t\t\t\t\tnewDistance := math.Abs(elem - elem2)\n\t\t\t\t\tif newDistance < distance{\n\t\t\t\t\t\tdistance = newDistance\n\t\t\t\t\t\tfloat64s := []float64{elem, elem2}\n\t\t\t\t\t\tsort.Float64s(float64s)\n\t\t\t\t\t\tclosestPair = [2]float64{float64s[0], float64s[1]}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn closestPair\n}\n\n\n"}, {"buggy_solution": " smallest := numbers[0]\n\tlargest := smallest\n\tfor _, n := range numbers {\n\t\tif smallest > n {\n\t\t\tsmallest = n\n\t\t}\n\t\tif largest < n {\n\t\t\tlargest = n\n\t\t}\n\t}\n\tif smallest == largest {\n\t\treturn numbers\n\t}\n\tfor i, n := range numbers {\n\t\tnumbers[i] = (n - smallest) / (largest - smallest)\n\t}\n\treturn numbers\n}\n\n"}, {"buggy_solution": " result := make([]int, 0)\n for _, val := range values {\n switch i := val.(type) {\n case int:\n result = append(result, i)\n }\n }\n return result\n}\n\n"}, {"buggy_solution": " return len(str)\n}\n\n"}, {"buggy_solution": " for i := n - 1; i > 0; i-- {\n\t\tif n % i == 0 {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn 0\n}\n\n"}, {"buggy_solution": " fact := make([]int, 0)\n\tfor i := 2; i <= int(math.Sqrt(float64(n))+1); {\n\t\tif n%i == 0 {\n\t\t\tfact = append(fact, i)\n\t\t\tn = n / i\n\t\t} else {\n\t\t\ti++\n\t\t}\n\t}\n\tif n > 1 {\n\t\tfact = append(fact, n)\n\t}\n\treturn fact\n}\n\n"}, {"buggy_solution": " c := make(map[int] int)\n\tfor _, number := range numbers {\n\t\tif i, ok := c[number]; ok {\n\t\t\tc[number] = i + 1\n\t\t} else {\n\t\t\tc[number] = 1\n\t\t}\n\t}\n\tresult := make([]int, 0)\n\tfor _, number := range numbers {\n\t\tif c[number] <= 1 {\n\t\t\tresult = append(result, number)\n\t\t}\n\t}\n\treturn result\n}\n\n"}, {"buggy_solution": " result := []rune{}\n for _, c := range str {\n if c >= 'A' && c <= 'Z' {\n result = append(result, 'a' + ((c - 'A' + 26) % 26))\n } else if c >= 'a' && c <= 'z' {\n result = append(result, 'A' + ((c - 'a' + 26) % 26))\n } else {\n result = append(result, c)\n }\n }\n return string(result)\n}\n\n"}, {"buggy_solution": " if len(strings) == 0 {\n\t\treturn \"\"\n\t}\n\treturn strings[0] + Concatenate(strings[1:])\n}\n\n"}, {"buggy_solution": " if len(strings) == 0 {\n return []string{}\n }\n res := make([]string, 0, len(strings))\n\tfor _, s := range strings {\n\t\tif s[:len(prefix)] == prefix {\n\t\t\tres = append(res, s)\n\t\t}\n\t}\n\treturn res\n}\n\n\n"}, {"buggy_solution": " res := make([]int, 0)\n for _, x := range l {\n if x > 0 {\n res = append(res, x)\n }\n }\n return res\n}\n\n\n"}, {"buggy_solution": " if n <= 1 {\n\t\treturn false\n\t}\n\tif n == 2 {\n\t\treturn true\n\t}\n\tif n%2 == 0 {\n\t\treturn false\n\t}\n\tfor i := 3; i*i <= n; i += 2 {\n\t\tif n%i == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n\n"}, {"buggy_solution": " begin := -1.0\n\tend := 1.0\n\tfor Poly(xs, begin)*Poly(xs, end) > 0 {\n\t\tbegin *= 2\n\t\tend *= 2\n\t}\n\tfor end-begin > 1e-10 {\n\t\tcenter := (begin + end) / 2\n\t\tif Poly(xs, center)*Poly(xs, begin) > 0 {\n\t\t\tbegin = center\n\t\t} else {\n\t\t\tend = center\n\t\t}\n\t}\n\treturn begin\n}\n\n"}, {"buggy_solution": " temp := make([]int, 0)\n\tfor i := 0; i < len(l); i = i + 3 {\n\t\ttemp = append(temp, l[i])\n\t}\n\tsort.Ints(temp)\n\tj := 0\n\tfor i := 0; i < len(l); i = i + 3 {\n\t\tl[i] = temp[j]\n\t\tj++\n\t}\n\treturn l\n}\n\n"}, {"buggy_solution": " set := make(map[int]interface{})\n\tfor _, i := range l {\n\t\tset[i]=nil\n\t}\n\tl = make([]int,0)\n\tfor i, _ := range set {\n\t\tl = append(l, i)\n\t}\n\tsort.Ints(l)\n\treturn l\n}\n\n"}, {"buggy_solution": " max := l[0]\n\tfor _, x := range l {\n\t\tif x > max {\n\t\t\tmax = x\n\t\t}\n\t}\n\treturn max\n}\n\n"}, {"buggy_solution": " ns := make([]int, 0)\n\tfor i := 0; i < n; i++ {\n\t\tif i%11 == 0 || i%13 == 0 {\n\t\t\tns = append(ns, i)\n\t\t}\n\t}\n\ttemp := make([]string, 0)\n\tfor _, i := range ns {\n\t\ttemp = append(temp, strconv.Itoa(i))\n\t}\n\tjoin := strings.Join(temp, \"\")\n\tans := 0\n\tfor _, c := range join {\n\t\tif c == '7' {\n\t\t\tans++\n\t\t}\n\t}\n\treturn ans\n}\n\n"}, {"buggy_solution": " evens := make([]int, 0)\n\tfor i := 0; i < len(l); i += 2 {\n\t\tevens = append(evens, l[i])\n\t}\n\tsort.Ints(evens)\n\tj := 0\n\tfor i := 0; i < len(l); i += 2 {\n\t\tl[i] = evens[j]\n\t\tj++\n\t}\n\treturn l\n}\n\n"}, {"buggy_solution": " return EncodeCyclic(EncodeCyclic(s))\n}\n\n"}, {"buggy_solution": " isPrime := func(p int) bool {\n\t\tif p < 2 {\n\t\t\treturn false\n\t\t}\n\t\tfor i := 2; i < int(math.Min(math.Sqrt(float64(p))+1, float64(p-1))); i++ {\n\t\t\tif p%i == 0 {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\tf := []int{0, 1}\n\tfor {\n\t\tf = append(f, f[len(f)-1]+f[len(f)-2])\n\t\tif isPrime(f[len(f)-1]) {\n\t\t\tn -= 1\n\t\t}\n\t\tif n == 0 {\n\t\t\treturn f[len(f)-1]\n\t\t}\n\t}\n}\n\n"}, {"buggy_solution": " for i := 0; i < len(l) - 2; i++ {\n\t\tfor j := i + 1; j < len(l) - 1; j++ {\n\t\t\tfor k := j + 1; k < len(l); k++ {\n\t\t\t\tif l[i] + l[j] + l[k] == 0 {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n\n"}, {"buggy_solution": "\treturn n * n\n}\n\n"}, {"buggy_solution": " n := len(l)\n\tfor i := 0; i < n; i++ {\n\t\tl[i]++\n\t}\n\treturn l\n}\n\n"}, {"buggy_solution": " seen := map[int]bool{}\n\tfor i := 0; i < len(l); i++ {\n\t\tfor j := i + 1; j < len(l); j++ {\n\t\t\tif l[i] + l[j] == 0 {\n\t\t\t\tif _, ok := seen[l[i]]; !ok {\n\t\t\t\t\tseen[l[i]] = true\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\tif _, ok := seen[l[j]]; !ok {\n\t\t\t\t\tseen[l[j]] = true\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n\n"}, {"buggy_solution": " if x >= base {\n return ChangeBase(x/base, base) + ChangeBase(x%base, base)\n }\n return strconv.Itoa(x)\n}\n\n"}, {"buggy_solution": " return a * h / 2\n}\n\n"}, {"buggy_solution": " switch n {\n\tcase 0:\n\t\treturn 0\n\tcase 1:\n\t\treturn 0\n\tcase 2:\n\t\treturn 2\n\tcase 3:\n\t\treturn 0\n\tdefault:\n\t\treturn Fib4(n-1) + Fib4(n-2) + Fib4(n-3) + Fib4(n-4)\n\t}\n}\n\n"}, {"buggy_solution": " sort.Ints(l)\n\tif len(l)%2==1{\n\t\treturn float64(l[len(l)/2])\n\t}else{\n\t\treturn float64(l[len(l)/2-1]+l[len(l)/2])/2.0\n\t}\n}\n\n"}, {"buggy_solution": " runes := []rune(text)\n result := make([]rune, 0)\n for i := len(runes) - 1; i >= 0; i-- {\n result = append(result, runes[i])\n }\n return text == string(result)\n}\n\n"}, {"buggy_solution": " ret := 1\n for i:= 0; i < n; i++ {\n\t\tret = (2 * ret) % p\n\t}\n return ret\n}\n\n"}, {"buggy_solution": " runes := []rune(s)\n newRunes := make([]rune, 0)\n for _, ch := range runes {\n newRunes = append(newRunes, (ch-5-'a')%26+'a')\n }\n return string(runes)\n}\n\n"}, {"buggy_solution": " var re = regexp.MustCompile(\"[aeiouAEIOU]\")\n\ttext = re.ReplaceAllString(text, \"\")\n\treturn text\n}\n\n"}, {"buggy_solution": " for _, n := range l {\n\t\tif n >= t {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n"}, {"buggy_solution": " return x + y\n}\n\n"}, {"buggy_solution": " set0 := make(map[int32]interface{})\n\tset1 := make(map[int32]interface{})\n\tfor _, i := range s0 {\n\t\tset0[i] = nil\n\t}\n\tfor _, i := range s1 {\n\t\tset1[i] = nil\n\t}\n\tfor i, _ := range set0 {\n\t\tif _,ok:=set1[i];!ok{\n\t\t\treturn false\n\t\t}\n\t}\n\tfor i, _ := range set1 {\n\t\tif _,ok:=set0[i];!ok{\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n"}, {"buggy_solution": " if n <= 1 {\n\t\treturn n\n\t}\n\treturn Fib(n-1) + Fib(n-2)\n}\n\n"}, {"buggy_solution": " l := len(brackets)\n\tcount := 0\n\tfor index := 0; index < l; index++ {\n\t\tif brackets[index] == '<' {\n\t\t\tcount++\n\t\t} else if brackets[index] == '>' {\n\t\t\tcount--\n\t\t}\n\t\tif count < 0 {\n\t\t\treturn false\n\t\t}\n\t}\n if count == 0 {\n return true\n } else {\n return false\n }\n}\n\n"}, {"buggy_solution": " flag := true\n\tif len(l) > 1 {\n\t\tfor i := 0; i < len(l)-1; i++ {\n\t\t\tif l[i] != l[i+1] {\n\t\t\t\tflag = l[i] > l[i+1]\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t} else {\n\t\treturn false\n\t}\n\tfor i := 0; i < len(l)-1; i++ {\n\t\tif flag != (l[i] >= l[i+1]) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n"}, {"buggy_solution": " m := make(map[int]bool)\n\tfor _, e1 := range l1 {\n\t\tif m[e1] {\n\t\t\tcontinue\n\t\t}\n\t\tfor _, e2 := range l2 {\n\t\t\tif e1 == e2 {\n\t\t\t\tm[e1] = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tres := make([]int, 0, len(m))\n\tfor k, _ := range m {\n\t\tres = append(res, k)\n\t}\n\tsort.Ints(res)\n\treturn res\n}\n\n"}, {"buggy_solution": " isPrime := func(n int) bool {\n for i := 2; i < int(math.Pow(float64(n), 0.5)+1); i++ {\n if n%i == 0 {\n return false\n }\n }\n return true\n }\n\n largest := 1\n for j := 2; j < n + 1; j++ {\n\t\tif n % j == 0 && isPrime(j) {\n\t\t\tif j > largest {\n\t\t\t\tlargest = j\n\t\t\t}\n\t\t}\n\t}\n return largest\n}\n\n"}, {"buggy_solution": " if n <= 0 {\n\t\treturn 0\n\t} else {\n\t\treturn n + SumToN(n - 1)\n\t}\n}\n\n"}, {"buggy_solution": " brackets = strings.Replace(brackets, \"(\", \" ( \", -1)\n\tbrackets = strings.Replace(brackets, \")\", \") \", -1)\n\topen := 0\n\tfor _, b := range brackets {\n\t\tif b == '(' {\n\t\t\topen++\n\t\t} else if b == ')' {\n\t\t\topen--\n\t\t}\n\t\tif open < 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn open == 0\n}\n\n"}, {"buggy_solution": " l := len(xs)\n\ty := make([]int, l - 1)\n\tfor i := 0; i < l - 1; i++ {\n\t\ty[i] = xs[i + 1] * (i + 1)\n\t}\n\treturn y\n}\n\n"}, {"buggy_solution": " if n <= 0 {\n\t\treturn 0\n\t}\n switch n {\n\tcase 0:\n\t\treturn 0\n\tcase 1:\n\t\treturn 0\n\tcase 2:\n\t\treturn 1\n\tdefault:\n\t\treturn Fibfib(n-1) + Fibfib(n-2) + Fibfib(n-3)\n\t}\n}\n\n"}, {"buggy_solution": " s = strings.ToLower(s)\n\tvowels := map[int32]interface{}{'a': nil, 'e': nil, 'i': nil, 'o': nil, 'u': nil}\n\tcount := 0\n\tfor _, i := range s {\n\t\tif _, ok := vowels[i]; ok {\n\t\t\tcount++\n\t\t}\n\t}\n\tif (s[len(s)-1]) == 'y' {\n\t\tcount++\n\t}\n\treturn count\n}\n\n"}, {"buggy_solution": " s := strconv.Itoa(x)\n\tif shift > len(s) {\n\t\trunes := make([]rune, 0)\n\t\tfor i := len(s)-1; i >= 0; i-- {\n\t\t\trunes = append(runes, rune(s[i]))\n\t\t}\n\t\treturn string(runes)\n\t}else{\n\t\treturn s[len(s)-shift:]+s[:len(s)-shift]\n\t}\n}\n\n"}, {"buggy_solution": " if len(x) == 0 {\n\t\treturn 0\n\t}\n\tresult := 0\n\tfor _, i := range x {\n\t\tif 'A' <= i && i <= 'Z' {\n\t\t\tresult += int(i)\n\t\t}\n\t}\n\treturn result\n}\n\n"}, {"buggy_solution": " split := strings.Split(s, \" \")\n\tfor _, i := range split {\n\t\tatoi, err := strconv.Atoi(i)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tn = n - atoi\n\t}\n\treturn n\n}\n\n"}, {"buggy_solution": " result := make([]int, 0)\n\tif len(arr) == 0 {\n\t\treturn result\n\t}\n\tevens := make([]int, 0)\n\tmin := math.MaxInt64\n\tminIndex := 0\n\tfor i, x := range arr {\n\t\tif x%2 == 0 {\n\t\t\tevens = append(evens, x)\n\t\t\tif x < min {\n\t\t\t\tmin = x\n\t\t\t\tminIndex = i\n\t\t\t}\n\t\t}\n\t}\n\tif len(evens) == 0 {\n\t\treturn result\n\t}\n\tresult = []int{min, minIndex}\n\treturn result\n}\n\n"}, {"buggy_solution": " countMap := make(map[int]int)\n\tfor _, i := range lst {\n\t\tif count, ok := countMap[i]; ok {\n\t\t\tcountMap[i] = count + 1\n\t\t} else {\n\t\t\tcountMap[i] = 1\n\t\t}\n\t}\n\tmax := -1\n\tfor i, count := range countMap {\n\t\tif count >= i && count > max {\n\t\t\tmax = i\n\t\t}\n\t}\n\treturn max\n}\n\n"}, {"buggy_solution": " sort.Ints(lst)\n\tresult := make([]int, 0)\n\tfor i := 0; i < len(lst)/2; i++ {\n\t\tresult = append(result, lst[i])\n\t\tresult = append(result, lst[len(lst)-i-1])\n\t}\n\tif len(lst)%2 != 0 {\n\t\tresult = append(result, lst[len(lst)/2])\n\t}\n\treturn result\n}\n\n"}, {"buggy_solution": " if a+b <= c || a+c <= b || b+c <= a {\n\t\treturn -1\n\t}\n\ts := (a + b + c) / 2\n\tarea := math.Pow(s * (s - a) * (s - b) * (s - c), 0.5)\n\tarea = math.Round(area*100)/100\n\treturn area\n}\n\n"}, {"buggy_solution": " sum := 0\n\tfor i := 0; i < len(q); i++ {\n\t\tsum += q[i]\n\t}\n\tif sum <= w && isPalindrome(q) {\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc isPalindrome(arr []int) bool {\n\tfor i := 0; i < (len(arr) / 2); i++ {\n\t\tif arr[i] != arr[len(arr) - i - 1] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n"}, {"buggy_solution": " count := 0\n\tfor i := 0; i < len(arr) - 1; i++ {\n a := arr[len(arr) - i - 1]\n\t\tif arr[i] != a {\n\t\t\tarr[i] = a\n count++\n\t\t}\n\t}\n\treturn count\n}\n\n"}, {"buggy_solution": " var numchar1 = 0\n\tvar numchar2 = 0\n\tfor _, item := range lst1 {\n\t\tnumchar1 += len(item)\n\t}\n\tfor _, item := range lst2 {\n\t\tnumchar2 += len(item)\n\t}\n\tif numchar1 <= numchar2 {\n\t\treturn lst1\n\t} else {\n\t\treturn lst2\n\t}\n}\n\n"}, {"buggy_solution": " isPrime := func(n int) bool {\n for i := 2; i < int(math.Pow(float64(n), 0.5)+1); i++ {\n if n%i == 0 {\n return false\n }\n }\n return true\n }\n for i := 2; i < 101; i++ {\n\t\tif !isPrime(i) {\n\t\t\tcontinue\n\t\t}\n\t\tfor j := 2; j < 101; j++ {\n\t\t\tif !isPrime(j) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor k := 2; k < 101; k++ {\n\t\t\t\tif !isPrime(k) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif i*j*k == a {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n\n"}, {"buggy_solution": " if x == 1 {\n\t\treturn true\n\t}\n\tif n==1 {\n\t\treturn false\n\t}\n\tif x % n != 0 {\n\t\treturn false\n\t}\n\treturn IsSimplePower(x / n, n)\n}\n\n"}, {"buggy_solution": " abs := math.Abs(float64(a))\n\treturn int(math.Pow(math.Round(math.Pow(abs, 1.0/3.0)), 3.0)) == int(abs)\n}\n\n"}, {"buggy_solution": " primes := map[int32]interface{}{'2': nil, '3': nil, '5': nil, '7': nil, 'B': nil, 'D': nil}\n\ttotal := 0\n\tfor _, c := range num {\n\t\tif _, ok := primes[c]; ok {\n\t\t\ttotal++\n\t\t}\n\t}\n\treturn total\n}\n\n"}, {"buggy_solution": " return fmt.Sprintf(\"db%bdb\", decimal)\n}\n\n"}, {"buggy_solution": " if len(s) < 3 {\n return false\n }\n for i := 0; i < len(s)-2; i++ {\n if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] {\n return false\n }\n }\n return true\n}\n\n"}, {"buggy_solution": "letter_grade := make([]string, 0, len(grades))\n for _, gpa := range grades {\n switch {\n case gpa == 4.0:\n letter_grade = append(letter_grade, \"A+\")\n case gpa > 3.7:\n letter_grade = append(letter_grade, \"A\")\n case gpa > 3.3:\n letter_grade = append(letter_grade, \"A-\")\n case gpa > 3.0:\n letter_grade = append(letter_grade, \"B+\")\n case gpa > 2.7:\n letter_grade = append(letter_grade, \"B\")\n case gpa > 2.3:\n letter_grade = append(letter_grade, \"B-\")\n case gpa > 2.0:\n letter_grade = append(letter_grade, \"C+\")\n case gpa > 1.7:\n letter_grade = append(letter_grade, \"C\")\n case gpa > 1.3:\n letter_grade = append(letter_grade, \"C-\")\n case gpa > 1.0:\n letter_grade = append(letter_grade, \"D+\")\n case gpa > 0.7:\n letter_grade = append(letter_grade, \"D\")\n case gpa > 0.0:\n letter_grade = append(letter_grade, \"D-\")\n default:\n letter_grade = append(letter_grade, \"E\")\n }\n\n }\n return letter_grade\n}\n\n"}, {"buggy_solution": " l := len(s)\n if l == 0 || l == 1 {\n return false\n }\n for i := 2; i < l; i++ {\n if l%i == 0 {\n return false\n }\n }\n return true\n}\n\n"}, {"buggy_solution": " if n == 1 {\n return 1\n }\n return 18 * int(math.Pow(10, float64(n-2)))\n}\n\n"}, {"buggy_solution": " sum := 0\n for _, c := range strconv.Itoa(N) {\n sum += int(c - '0')\n }\n return fmt.Sprintf(\"%b\", sum)\n}\n\n"}, {"buggy_solution": " sum := 0\n for i := 1; i < len(lst); i += 2 {\n if lst[i]%2 == 0 {\n sum += lst[i]\n }\n }\n return sum\n}\n\n"}, {"buggy_solution": " strs := make([]string, 0)\n for _, i := range strings.Fields(s) {\n word := []rune(i)\n sort.Slice(word, func(i, j int) bool {\n return word[i] < word[j]\n })\n strs = append(strs, string(word))\n }\n return strings.Join(strs, \" \")\n}\n\n"}, {"buggy_solution": " coords := make([][2]int, 0)\n for i, row := range lst {\n for j, item := range row {\n if item == x {\n coords = append(coords, [2]int{i, j})\n }\n }\n }\n sort.Slice(coords, func(i, j int) bool {\n if coords[i][0] == coords[j][0] {\n return coords[i][1] > coords[j][1]\n }\n return coords[i][0] < coords[j][0]\n })\n\n return coords\n}\n\n"}, {"buggy_solution": " arr := make([]int, len(array))\n copy(arr, array)\n if len(arr) == 0 {\n return arr\n }\n if (arr[0]+arr[len(arr)-1])%2 == 0 {\n sort.Slice(arr, func(i, j int) bool {\n return arr[i] > arr[j]\n })\n } else {\n sort.Slice(arr, func(i, j int) bool {\n return arr[i] < arr[j]\n })\n }\n return arr\n}\n\n"}, {"buggy_solution": " d := \"abcdefghijklmnopqrstuvwxyz\"\n out := make([]rune, 0, len(s))\n for _, c := range s {\n pos := strings.IndexRune(d, c)\n if pos != -1 {\n out = append(out, []rune(d)[(pos+2*2)%26])\n } else {\n out = append(out, c)\n }\n }\n return string(out)\n}\n\n"}, {"buggy_solution": " set := make(map[int]struct{})\n for _, i := range lst {\n set[i] = struct{}{}\n }\n vals := make([]int, 0, len(set))\n for k := range set {\n vals = append(vals, k)\n }\n sort.Slice(vals, func(i, j int) bool {\n return vals[i] < vals[j]\n })\n if len(vals) < 2 {\n return nil\n }\n return vals[1]\n}\n\n"}, {"buggy_solution": " r, _ := regexp.Compile(`[.?!]\\s*`)\n sentences := r.Split(S, -1)\n sum := 0\n for _, s := range sentences {\n if len(s) >= 2 && s[:2] == \"I \" {\n sum++\n }\n }\n return sum\n}\n\n"}, {"buggy_solution": " xx, ok := x.(int)\n if !ok {\n return false\n }\n yy, ok := y.(int)\n if !ok {\n return false\n }\n zz, ok := z.(int)\n if !ok {\n return false\n }\n\n if (xx+yy == zz) || (xx+zz == yy) || (yy+zz == xx) {\n return true\n }\n return false\n}\n\n"}, {"buggy_solution": " vowels := \"aeiouAEIOU\"\n vowels_replace := make(map[rune]rune)\n for _, c := range vowels {\n vowels_replace[c] = c + 2\n }\n result := make([]rune, 0, len(message))\n for _, c := range message {\n if 'a' <= c && c <= 'z' {\n c += 'A' - 'a'\n } else if 'A' <= c && c <= 'Z' {\n c += 'a' - 'A'\n }\n if strings.ContainsRune(vowels, c) {\n result = append(result, vowels_replace[c])\n } else {\n result = append(result, c)\n }\n }\n return string(result)\n}\n\n"}, {"buggy_solution": " isPrime := func(n int) bool {\n for i := 2; i < int(math.Pow(float64(n), 0.5)+1); i++ {\n if n%i == 0 {\n return false\n }\n }\n return true\n }\n maxx := 0\n i := 0\n for i < len(lst) {\n if lst[i] > maxx && isPrime(lst[i]) {\n maxx = lst[i]\n }\n i++\n }\n sum := 0\n for _, d := range strconv.Itoa(maxx) {\n sum += int(d - '0')\n }\n return sum\n}\n\n"}, {"buggy_solution": " if len(dict) == 0 {\n return false\n }\n state := \"start\"\n key := \"\"\n ok := false\n for k := range dict {\n if key, ok = k.(string); !ok {\n state = \"mixed\"\n break\n }\n if state == \"start\" {\n if key == strings.ToUpper(key) {\n state = \"upper\"\n } else if key == strings.ToLower(key) {\n state = \"lower\"\n } else {\n break\n }\n } else if (state == \"upper\" && key != strings.ToUpper(key)) || (state == \"lower\" && key != strings.ToLower(key)) {\n state = \"mixed\"\n break\n } else {\n break\n }\n }\n return state == \"upper\" || state == \"lower\"\n}\n\n"}, {"buggy_solution": " primes := make([]int, 0)\n for i := 2; i < n; i++ {\n is_prime := true\n for j := 2; j < i; j++ {\n if i%j == 0 {\n is_prime = false\n break\n }\n }\n if is_prime {\n primes = append(primes, i)\n }\n }\n return primes\n}\n\n"}, {"buggy_solution": " return int(math.Abs(float64(a%10)) * math.Abs(float64(b%10)))\n}\n\n"}, {"buggy_solution": " count := 0\n runes := []rune(s)\n for i := 0; i < len(runes); i += 2 {\n if strings.ContainsRune(\"AEIOU\", runes[i]) {\n count += 1\n }\n }\n return count\n}\n\n"}, {"buggy_solution": " if strings.Count(value, \".\") == 1 {\n // remove trailing zeros\n for value[len(value)-1] == '0' {\n value = value[:len(value)-1]\n }\n }\n var res float64\n num, _ := strconv.ParseFloat(value, 64)\n if len(value) >= 2 && value[len(value)-2:] == \".5\" {\n if num > 0 {\n res = math.Ceil(num)\n } else {\n res = math.Floor(num)\n }\n } else if len(value) > 0 {\n res = math.Round(num)\n } else {\n res = 0\n }\n\n return int(res)\n}\n\n"}, {"buggy_solution": " result := make([]int, 0, n)\n for i := 0; i < n; i++ {\n result = append(result, n+2*i)\n }\n return result\n}\n\n"}, {"buggy_solution": " s_list := make([]rune, 0)\n\n for _, c := range s {\n if c == ',' {\n s_list = append(s_list, ' ')\n } else {\n s_list = append(s_list, c)\n }\n }\n return strings.Fields(string(s_list))\n}\n\n"}, {"buggy_solution": " if x > y {\n return -1\n }\n if y % 2 == 0 {\n return y\n }\n if x == y {\n return -1\n }\n return y - 1\n}\n\n"}, {"buggy_solution": " if m < n {\n return -1\n }\n summation := 0\n for i := n;i < m+1;i++{\n summation += i\n }\n return fmt.Sprintf(\"0b%b\", int(math.Round(float64(summation)/float64(m - n + 1))))\n}\n\n"}, {"buggy_solution": " odd_digit_elements := make([]int, 0)\n OUTER:\n for _, i := range x {\n for _, c := range strconv.Itoa(i) {\n if (c - '0') % 2 == 0 {\n continue OUTER\n }\n }\n odd_digit_elements = append(odd_digit_elements, i)\n }\n sort.Slice(odd_digit_elements, func(i, j int) bool {\n return odd_digit_elements[i] < odd_digit_elements[j]\n })\n return odd_digit_elements\n}\n\n"}, {"buggy_solution": " dic := map[int]string{\n 1: \"One\",\n 2: \"Two\",\n 3: \"Three\",\n 4: \"Four\",\n 5: \"Five\",\n 6: \"Six\",\n 7: \"Seven\",\n 8: \"Eight\",\n 9: \"Nine\",\n }\n sort.Slice(arr, func(i, j int) bool {\n return arr[i] > arr[j]\n })\n new_arr := make([]string, 0)\n for _, item := range arr {\n if v, ok := dic[item]; ok {\n new_arr = append(new_arr, v)\n }\n }\n return new_arr\n}\n\n"}, {"buggy_solution": " ret := make([]int, 0, 5)\n for i:=1;i<n+1;i++{\n if i%2 == 0 {\n x := 1\n for j:=1;j<i+1;j++{\n x*=j\n }\n ret = append(ret, x)\n }else {\n x := 0\n for j:=1;j<i+1;j++{\n x+=j\n }\n ret = append(ret, x)\n }\n }\n return ret\n}\n\n"}, {"buggy_solution": " is_palindrome := func (n int) bool {\n s := strconv.Itoa(n)\n for i := 0;i < len(s)>>1;i++ {\n if s[i] != s[len(s)-i-1] {\n return false\n }\n }\n return true\n }\n\n even_palindrome_count := 0\n odd_palindrome_count := 0\n\n for i :=1;i<n+1;i++ {\n if i%2 == 1 && is_palindrome(i){\n odd_palindrome_count ++\n } else if i%2 == 0 && is_palindrome(i) {\n even_palindrome_count ++\n }\n }\n return [2]int{even_palindrome_count, odd_palindrome_count}\n}\n\n"}, {"buggy_solution": " digits_sum:= func (n int) int {\n neg := 1\n if n < 0 {\n n, neg = -1 * n, -1 \n }\n r := make([]int,0)\n for _, c := range strconv.Itoa(n) {\n r = append(r, int(c-'0'))\n }\n r[0] *= neg\n sum := 0\n for _, i := range r {\n sum += i\n }\n return sum\n }\n count := 0\n for _, i := range arr {\n x := digits_sum(i)\n if x > 0 {\n count++\n }\n }\n return count\n}\n\n"}, {"buggy_solution": " if len(arr)==0 {\n return true\n }\n sorted_array := make([]int, len(arr))\n copy(sorted_array, arr)\n sort.Slice(sorted_array, func(i, j int) bool {\n return sorted_array[i] < sorted_array[j]\n }) \n min_value := math.MaxInt\n min_index := -1\n for i, x := range arr {\n if i < min_value {\n min_index, min_value = i, x\n }\n }\n my_arr := make([]int, len(arr[min_index:]))\n copy(my_arr, arr[min_index:])\n my_arr = append(my_arr, arr[0:min_index]...)\n for i :=0;i<len(arr);i++ {\n if my_arr[i]!=sorted_array[i]{\n return false\n }\n }\n return true\n}\n\n"}, {"buggy_solution": " odd := 0\n even := 0\n for _, i := range lst1 {\n if i%2 == 1 {\n odd++\n }\n }\n for _, i := range lst2 {\n if i%2 == 0 {\n even++\n }\n }\n if even >= odd {\n return \"YES\"\n }\n return \"NO\"\n}\n \n\n"}, {"buggy_solution": " dict1 := make(map[rune]int)\n list1 := strings.Fields(test)\n t := 0\n count := func(lst []string, v string) int {\n cnt := 0\n for _, i := range lst {\n if i == v {\n cnt++\n }\n }\n return cnt\n }\n for _, i := range list1 {\n if c := count(list1, i); c>t && i!=\"\" {\n t=c\n }\n }\n if t>0 {\n for _, i := range list1 {\n if count(list1, i)==t {\n dict1[[]rune(i)[0]]=t\n }\n }\n }\n return dict1\n}\n\n"}, {"buggy_solution": " rs := make([]rune, 0)\n for _, r := range s {\n if !strings.ContainsRune(c, r) {\n rs = append(rs, r)\n }\n }\n t := true\n for i := 0;i < len(rs)>>1;i++ {\n if rs[i] != rs[len(rs)-i-1] {\n t=false\n break\n }\n }\n return [2]interface{}{string(rs), t}\n}\n\n"}, {"buggy_solution": " res := make([]string, 0, len(lst))\n for _, arr := range lst {\n n := 0\n for _, d := range arr {\n if (d - '0') % 2 == 1 {\n n++\n }\n }\n res = append(res, fmt.Sprintf(\"the number of odd elements %dn the str%dng %d of the %dnput.\", n,n,n,n))\n }\n return res\n}\n\n"}, {"buggy_solution": " max_sum := 0\n s := 0\n for _, num := range nums {\n s += -num\n if s < 0 {\n s = 0\n }\n if s > max_sum {\n max_sum = s\n }\n }\n if max_sum == 0 {\n max_sum = math.MinInt\n for _, i := range nums {\n if -i > max_sum {\n max_sum = -i\n }\n }\n }\n return -max_sum\n}\n\n"}, {"buggy_solution": " result := 0\n for _, arr := range grid {\n sum := 0\n for _, i := range arr {\n sum += i\n }\n result += int(math.Ceil(float64(sum) / float64(capacity)))\n }\n return result\n}\n\n"}, {"buggy_solution": " sort.Slice(arr, func(i, j int) bool {\n return arr[i] < arr[j]\n })\n sort.Slice(arr, func(i, j int) bool {\n key := func(x int) int {\n b := fmt.Sprintf(\"%b\", x)\n cnt := 0\n for _, r := range b {\n if r == '1' {\n cnt++\n }\n }\n return cnt\n }\n return key(arr[i]) < key(arr[j])\n })\n return arr\n}\n\n"}, {"buggy_solution": " result := make([]string, 0)\n for _, word := range strings.Fields(s) {\n n_consonants := 0\n lower := strings.ToLower(word)\n for i := 0;i < len(word); i++ {\n if !bytes.Contains([]byte(\"aeiou\"), []byte{lower[i]}) {\n n_consonants++\n }\n }\n if n_consonants == n{\n result = append(result, word)\n }\n }\n return result\n}\n\n"}, {"buggy_solution": " if len(word) < 3 {\n return \"\"\n }\n\n vowels := []byte(\"aeiouAEOUI\")\n for i := len(word)-2; i > 0; i-- {\n if bytes.Contains(vowels, []byte{word[i]}) {\n if !bytes.Contains(vowels, []byte{word[i+1]}) && !bytes.Contains(vowels, []byte{word[i-1]}) {\n return string(word[i])\n }\n }\n }\n return \"\"\n}\n\n"}, {"buggy_solution": " check := func(s string) bool {\n val := 0\n for _, i := range s {\n if i == '(' {\n val++\n } else {\n val--\n }\n if val < 0 {\n return false\n }\n }\n return val == 0\n }\n\n S1 := lst[0] + lst[1]\n S2 := lst[1] + lst[0]\n if check(S1) || check(S2) {\n return \"Yes\"\n }\n return \"No\"\n}\n\n"}, {"buggy_solution": " if k == 0 {\n return []int{}\n }\n sort.Slice(arr, func(i, j int) bool {\n return arr[i] < arr[j]\n })\n return arr[len(arr)-k:]\n}\n\n"}, {"buggy_solution": " sum:=0\n for i, x := range lst {\n if i&1==0&&x&1==1 {\n sum+=x\n }\n }\n return sum\n}\n\n"}, {"buggy_solution": " sum := 0\n for _, elem := range arr[:k] {\n if len(strconv.Itoa(elem)) <= 2 {\n sum += elem\n }\n }\n return sum\n}\n\n"}, {"buggy_solution": " odd_collatz := make([]int, 0)\n if n&1==1 {\n odd_collatz = append(odd_collatz, n)\n }\n for n > 1 {\n if n &1==0 {\n n>>=1\n } else {\n n = n*3 + 1\n } \n if n&1 == 1 {\n odd_collatz = append(odd_collatz, n)\n }\n }\n sort.Slice(odd_collatz, func(i, j int) bool {\n return odd_collatz[i] < odd_collatz[j]\n })\n return odd_collatz\n}\n\n"}, {"buggy_solution": " isInArray := func(arr []int, i int) bool {\n for _, x := range arr {\n if i == x {\n return true\n }\n }\n return false\n }\n\n date = strings.TrimSpace(date)\n split := strings.SplitN(date, \"-\", 3)\n if len(split) != 3 {\n return false\n }\n month, err := strconv.Atoi(split[0])\n if err != nil {\n return false\n }\n day, err := strconv.Atoi(split[1])\n if err != nil {\n return false\n }\n _, err = strconv.Atoi(split[2])\n if err != nil {\n return false\n }\n if month < 1 || month > 12 {\n return false\n }\n \n if isInArray([]int{1,3,5,7,8,10,12}, month) && day < 1 || day > 31 {\n return false\n }\n if isInArray([]int{4,6,9,11}, month) && day < 1 || day > 30 {\n return false\n }\n if month == 2 && day < 1 || day > 29 {\n return false\n }\n\n return true\n}\n\n"}, {"buggy_solution": " if strings.Contains(txt, \" \") {\n return strings.Fields(txt)\n } else if strings.Contains(txt, \",\") {\n return strings.Split(txt, \",\")\n }\n cnt := 0\n for _, r := range txt {\n if 'a' <= r && r <= 'z' && (r-'a')&1==1 {\n cnt++\n }\n }\n return cnt\n}\n\n"}, {"buggy_solution": " count_digit := make(map[int]int)\n for _, i := range lst {\n count_digit[i] = 0\n }\n for _, i := range lst {\n count_digit[i]++\n }\n for _, i := range lst {\n if count_digit[i] > 2 {\n return false\n }\n }\n for i := 1;i < len(lst);i++ {\n if lst[i-1] > lst[i] {\n return false\n }\n }\n return true\n}\n \n\n"}, {"buggy_solution": " is_prime := func(num int) bool {\n if num == 1 || num == 0 {\n return false\n }\n if num == 2 {\n return true\n }\n for i := 2;i < num;i++ {\n if num%i == 0 {\n return false\n }\n }\n return true\n }\n l := interval1[0]\n if interval2[0] > l {\n l = interval2[0]\n }\n r := interval1[1]\n if interval2[1] < r {\n r = interval2[1]\n }\n length := r - l\n if length > 0 && is_prime(length) {\n return \"YES\"\n }\n return \"NO\"\n}\n\n"}, {"buggy_solution": " if len(arr) == 0 {\n return nil\n }\n cnt := 0\n sum := 0\n for _, i := range arr {\n if i == 0 {\n return 0\n }\n if i < 0 {\n cnt++\n }\n sum += int(math.Abs(float64(i)))\n }\n\n prod := int(math.Pow(-1, float64(cnt)))\n return prod * sum\n}\n\n"}, {"buggy_solution": " n := len(grid)\n val := n * n + 1\n for i:= 0;i < n; i++ {\n for j := 0;j < n;j++ {\n if grid[i][j] == 1 {\n temp := make([]int, 0)\n if i != 0 {\n temp = append(temp, grid[i - 1][j])\n }\n\n if j != 0 {\n temp = append(temp, grid[i][j - 1])\n }\n\n if i != n - 1 {\n temp = append(temp, grid[i + 1][j])\n }\n\n if j != n - 1 {\n temp = append(temp, grid[i][j + 1])\n }\n for _, x := range temp {\n if x < val {\n val = x\n }\n }\n }\n }\n }\n\n ans := make([]int, 0, k)\n for i := 0;i < k;i++ {\n if i & 1 == 0 {\n ans = append(ans, 1)\n } else {\n ans = append(ans, val)\n }\n }\n return ans\n}\n\n"}, {"buggy_solution": " if n == 0 {\n return []float64{1}\n }\n my_tri := []float64{1, 3}\n for i := 2; i < n + 1; i++ {\n if i &1 == 0 {\n my_tri = append(my_tri, float64(i) / 2 + 1)\n } else {\n my_tri = append(my_tri, my_tri[i - 1] + my_tri[i - 2] + (float64(i) + 3) / 2)\n }\n }\n return my_tri\n}\n\n"}, {"buggy_solution": " product := 1\n odd_count := 0\n for _, digit := range strconv.Itoa(n) {\n int_digit := int(digit-'0')\n if int_digit&1 == 1 {\n product= product*int_digit\n odd_count++\n }\n }\n if odd_count==0 {\n return 0\n }\n return product\n}\n\n"}, {"buggy_solution": " opening_bracket_index := make([]int, 0)\n closing_bracket_index := make([]int, 0)\n for i:=0;i < len(s);i++ {\n if s[i] == '[' {\n opening_bracket_index = append(opening_bracket_index, i)\n } else {\n closing_bracket_index = append(closing_bracket_index, i)\n }\n }\n for i := 0;i < len(closing_bracket_index)>>1;i++ {\n closing_bracket_index[i], closing_bracket_index[len(closing_bracket_index)-i-1] = closing_bracket_index[len(closing_bracket_index)-i-1], closing_bracket_index[i]\n }\n cnt := 0\n i := 0\n l := len(closing_bracket_index)\n for _, idx := range opening_bracket_index {\n if i < l && idx < closing_bracket_index[i] {\n cnt++\n i++\n }\n }\n return cnt >= 2\n}\n\n \n\n"}, {"buggy_solution": " squared := 0\n for _, i := range lst {\n squared += int(math.Pow(math.Ceil(i), 2))\n }\n return squared\n}\n\n"}, {"buggy_solution": " split := strings.Split(txt, \" \")\n check := strings.ToLower(split[len(split)-1])\n if len(check) == 1 && 'a' <= check[0] && check[0] <= 'z' {\n return true\n }\n return false\n}\n\n"}, {"buggy_solution": " ind:=-1\n i:=1\n for i<len(arr) {\n if arr[i]<arr[i-1] {\n ind=i\n }\n i++\n }\n return ind\n}\n\n"}, {"buggy_solution": " smallest := make([]int, 0)\n largest := make([]int, 0)\n for _, x := range lst {\n if x < 0 {\n smallest = append(smallest, x)\n } else if x > 0 {\n largest = append(largest, x)\n }\n }\n var result [2]interface{}\n if len(smallest) == 0 {\n result[0] = nil\n } else {\n max := smallest[0]\n for i := 1;i < len(smallest);i++ {\n if smallest[i] > max {\n max = smallest[i]\n }\n }\n result[0] = max\n }\n if len(largest) == 0 {\n result[1] = nil\n } else {\n min := largest[0]\n for i := 1;i < len(largest);i++ {\n if largest[i] < min {\n min = largest[i]\n }\n }\n result[1] = min\n }\n return result\n}\n\n"}, {"buggy_solution": " temp_a := fmt.Sprintf(\"%v\", a)\n temp_b := fmt.Sprintf(\"%v\", b)\n temp_a = strings.ReplaceAll(temp_a, \",\", \".\")\n temp_b = strings.ReplaceAll(temp_b, \",\", \".\")\n fa, _ := strconv.ParseFloat(temp_a, 64)\n fb, _ := strconv.ParseFloat(temp_b, 64)\n \n if fa == fb {\n return nil\n }\n if fa > fb {\n return a\n } else {\n return b\n }\n}\n\n"}, {"buggy_solution": " return n&1 == 0 && n >= 8\n}\n\n"}, {"buggy_solution": " fact_i := 1\n special_fact := 1\n for i := 1; i <= n; i++ {\n fact_i *= i\n special_fact *= fact_i\n }\n return special_fact\n}\n\n"}, {"buggy_solution": " new_text := make([]byte, 0)\n i := 0\n start, end := 0, 0\n for i < len(text) {\n if text[i] == ' ' {\n end++\n } else {\n switch {\n case end - start > 2:\n new_text = append(new_text, '-')\n case end - start > 0:\n for n := 0;n < end-start;n++ {\n new_text = append(new_text, '_')\n }\n }\n new_text = append(new_text, text[i])\n start, end = i+1, i+1\n }\n i+=1\n }\n if end - start > 2 {\n new_text = append(new_text, '-')\n } else if end - start > 0 {\n new_text = append(new_text, '_')\n }\n return string(new_text)\n}\n\n"}, {"buggy_solution": " suf := []string{\"txt\", \"exe\", \"dll\"}\n lst := strings.Split(file_name, \".\")\n isInArray := func (arr []string, x string) bool {\n for _, y := range arr {\n if x == y {\n return true\n }\n }\n return false\n }\n switch {\n case len(lst) != 2:\n return \"No\"\n case !isInArray(suf, lst[1]):\n return \"No\"\n case len(lst[0]) == 0:\n return \"No\"\n case 'a' > strings.ToLower(lst[0])[0] || strings.ToLower(lst[0])[0] > 'z':\n return \"No\"\n }\n t := 0\n for _, c := range lst[0] {\n if '0' <= c && c <= '9' {\n t++\n }\n }\n if t > 3 {\n return \"No\"\n }\n return \"Yes\"\n}\n\n"}, {"buggy_solution": " result := make([]int, 0)\n for i := 0;i < len(lst);i++ {\n switch {\n case i %3 == 0:\n result = append(result, int(math.Pow(float64(lst[i]), 2)))\n case i % 4 == 0 && i%3 != 0:\n result = append(result, int(math.Pow(float64(lst[i]), 3)))\n default:\n result = append(result, lst[i])\n }\n }\n sum := 0\n for _, x := range result {\n sum += x\n }\n return sum\n}\n\n"}, {"buggy_solution": " new_lst := make([]string, 0)\n for _, word := range strings.Fields(sentence) {\n flg := 0\n if len(word) == 1 {\n flg = 1\n }\n for i := 2;i < len(word);i++ {\n if len(word)%i == 0 {\n flg = 1\n }\n }\n if flg == 0 || len(word) == 2 {\n new_lst = append(new_lst, word)\n }\n }\n return strings.Join(new_lst, \" \")\n}\n\n"}, {"buggy_solution": " xx := strings.Split(x, \"/\")\n nn := strings.Split(n, \"/\")\n a, _ := strconv.Atoi(xx[0])\n b, _ := strconv.Atoi(xx[1])\n c, _ := strconv.Atoi(nn[0])\n d, _ := strconv.Atoi(nn[1])\n numerator := float64(a*c)\n denom := float64(b*d)\n return numerator/denom == float64(int(numerator/denom))\n}\n\n"}, {"buggy_solution": " digits_sum := func (n int) int {\n neg := 1\n if n < 0 {\n n, neg = -1 * n, -1 \n }\n sum := 0\n for i, c := range strconv.Itoa(n) {\n if i == 0 {\n sum += int(c-'0')*neg\n } else {\n sum += int(c-'0')\n }\n }\n return sum\n }\n sort.SliceStable(nums, func(i, j int) bool {\n return digits_sum(nums[i]) < digits_sum(nums[j])\n })\n return nums\n}\n\n"}, {"buggy_solution": " count := 0\n for _, num := range nums {\n if num > 10 {\n number_as_string := strconv.Itoa(num)\n if number_as_string[0]&1==1 && number_as_string[len(number_as_string)-1]&1==1 {\n count++\n }\n }\n } \n return count\n}\n\n"}, {"buggy_solution": " A := make([]int, 0)\n for i := 1;i <= n;i++ {\n A = append(A, i*i-i+1)\n }\n ans := 0\n for i := 0;i < n;i++ {\n for j := i + 1;j < n;j++ {\n for k := j + 1;k < n;k++ {\n if (A[i]+A[j]+A[k])%3 == 0 {\n ans++\n }\n }\n }\n }\n return ans\n}\n\n"}, {"buggy_solution": " planet_names := []string{\"Mercury\", \"Venus\", \"Earth\", \"Mars\", \"Jupiter\", \"Saturn\", \"Uranus\", \"Neptune\"}\n pos1 := -1\n pos2 := -1\n for i, x := range planet_names {\n if planet1 == x {\n pos1 = i\n }\n if planet2 == x {\n pos2 = i\n }\n }\n if pos1 == -1 || pos2 == -1 || pos1 == pos2 {\n return []string{}\n }\n if pos1 < pos2 {\n return planet_names[pos1 + 1: pos2]\n }\n return planet_names[pos2 + 1 : pos1]\n}\n\n"}, {"buggy_solution": " sort.SliceStable(lst, func(i, j int) bool {\n return lst[i] < lst[j]\n })\n new_lst := make([]string, 0)\n for _, i := range lst {\n if len(i)&1==0 {\n new_lst = append(new_lst, i)\n }\n }\n sort.SliceStable(new_lst, func(i, j int) bool {\n return len(new_lst[i]) < len(new_lst[j])\n })\n return new_lst\n}\n\n"}, {"buggy_solution": " if n == 1 {\n return y\n }\n for i := 2;i < n;i++ {\n if n % i == 0 {\n return y\n }\n }\n return x\n}\n\n"}, {"buggy_solution": " sum := 0\n for _, i := range lst {\n if i > 0 && math.Mod(i, 2) != 0 && i == float64(int(i)) {\n sum += int(math.Pow(i, 2))\n }\n }\n return sum\n}\n\n"}, {"buggy_solution": " ans := make([]int, 0, len(game))\n for i := range game {\n ans = append(ans, int(math.Abs(float64(game[i]-guess[i]))))\n }\n return ans\n}\n\n"}, {"buggy_solution": " strong := extensions[0]\n \n my_val := math.MinInt\n for _, s := range extensions {\n cnt0, cnt1 := 0, 0\n for _, c := range s {\n switch {\n case 'A' <= c && c <= 'Z':\n cnt0++\n case 'a' <= c && c <= 'z':\n cnt1++\n }\n }\n val := cnt0-cnt1\n if val > my_val {\n strong = s\n my_val = val\n }\n }\n return class_name + \".\" + strong\n}\n\n"}, {"buggy_solution": " l := len(b)\n pat := b + b\n for i := 0;i < len(a) - l + 1; i++ {\n for j := 0;j<l + 1;j++ {\n if a[i:i+l] == pat[j:j+l] {\n return true\n }\n }\n }\n return false\n}\n\n"}, {"buggy_solution": " even_count := 0\n odd_count := 0\n if num < 0 {\n num = -num\n }\n for _, r := range strconv.Itoa(num) {\n if r&1==0 {\n even_count++\n } else {\n odd_count++\n }\n }\n return [2]int{even_count, odd_count}\n}\n\n"}, {"buggy_solution": " num := []int{1, 4, 5, 9, 10, 40, 50, 90, \n 100, 400, 500, 900, 1000}\n sym := []string{\"I\", \"IV\", \"V\", \"IX\", \"X\", \"XL\", \n \"L\", \"XC\", \"C\", \"CD\", \"D\", \"CM\", \"M\"}\n i := 12\n res := \"\"\n for number != 0 {\n div := number / num[i] \n number %= num[i] \n for div != 0 {\n res += sym[i] \n div--\n }\n i--\n }\n return strings.ToLower(res)\n}\n\n"}, {"buggy_solution": " return a*a == b*b + c*c || b*b == a*a + c*c || c*c == a*a + b*b\n}\n\n"}, {"buggy_solution": " key := func (word string) (int, string) {\n set := make(map[rune]struct{})\n for _, r := range word {\n set[r] = struct{}{}\n }\n return -len(set), word\n }\n sort.SliceStable(words, func(i, j int) bool {\n ia, ib := key(words[i])\n ja, jb := key(words[j])\n if ia == ja {\n return ib < jb\n }\n return ia < ja\n })\n return words[0]\n}\n\n"}, {"buggy_solution": " if(need <= remaining) {\n return []int{ number + need , remaining-need }\n }\n return []int{ number + remaining , 0}\n}\n\n"}, {"buggy_solution": " higher := func(a, b string) bool {\n if b == \"*\" || b == \"//\" || b == \"**\" {\n return false\n }\n if a == \"*\" || a == \"//\" || a == \"**\" {\n return true\n }\n return false\n }\n for len(operand) > 1 {\n pos := 0\n sign := operator[0]\n for i, str := range operator {\n if higher(str, sign) {\n sign = str\n pos = i\n }\n }\n switch sign {\n case \"+\":\n operand[pos] += operand[pos+1]\n case \"-\":\n operand[pos] -= operand[pos+1]\n case \"*\":\n operand[pos] *= operand[pos+1]\n case \"//\":\n operand[pos] /= operand[pos+1]\n case \"**\":\n operand[pos] = int(math.Pow(float64(operand[pos]), float64(operand[pos+1])))\n }\n operator = append(operator[:pos], operator[pos+1:]...)\n operand = append(operand[:pos+1], operand[pos+2:]...)\n }\n return operand [0]\n}\n\n"}, {"buggy_solution": " flg := 0\n new_str := []rune(s)\n for i, r := range new_str {\n if ('a' <= r && r <= 'z') || ('A' <= r && r <= 'Z') {\n if 'a' <= r && r <= 'z' {\n new_str[i] = r - 'a' + 'A'\n } else {\n new_str[i] = r - 'A' + 'a'\n }\n flg = 1\n }\n }\n if flg == 0 {\n for i := 0;i < len(new_str)>>1;i++ {\n new_str[i], new_str[len(new_str)-i-1] = new_str[len(new_str)-i-1], new_str[i]\n }\n }\n return string(new_str)\n}\n\n"}, {"buggy_solution": " if text == \"\" {\n return nil\n }\n return fmt.Sprintf(\"%x\", md5.Sum([]byte(text)))\n}\n\n"}, {"buggy_solution": " min := func (a, b int) int {\n if a > b {\n return b\n }\n return a\n }\n max := func (a, b int) int {\n if a > b {\n return a\n }\n return b\n }\n lower := max(2, min(a, b))\n upper := min(8, max(a, b))\n ans := make([]int, 0)\n for i := lower;i <= upper;i++ {\n if i&1==0 {\n ans = append(ans, i)\n }\n }\n return ans\n}\n\n"}]
data/java/data/.DS_Store ADDED
Binary file (6.15 kB). View file
 
data/java/data/humaneval.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/java/data/humanevalbugs.json ADDED
@@ -0,0 +1 @@
 
 
1
+ [{"buggy_solution": " for (int i = 0; i < numbers.size(); i++) {\n for (int j = i + 1; j < numbers.size(); j++) {\n double distance = Math.abs(numbers.get(i) - numbers.get(j));\n if (distance < threshold) return true;\n }\n }\n return false;\n }\n}"}, {"buggy_solution": " List<String> result = new ArrayList<>();\n StringBuilder current_string = new StringBuilder();\n int current_depth = 0;\n\n for (char c : paren_string.toCharArray()) {\n if (c == '(') {\n current_depth += 1;\n current_string.append(c);\n } else if (c == ')') {\n current_depth -= 1;\n current_string.append(c);\n\n if (current_depth == 0) {\n result.add(current_string.toString());\n current_string.setLength(0);\n }\n }\n }\n return result;\n\n }\n}"}, {"buggy_solution": " return number % 1.0;\n }\n}"}, {"buggy_solution": " int balance = 0;\n\n for (int op : operations) {\n balance += op;\n if (balance < 0) {\n return true;\n }\n }\n\n return false;\n }\n}"}, {"buggy_solution": " double sum = 0.0;\n for (double num : numbers) {\n sum += num;\n }\n double mean = sum / numbers.size();\n double sum_abs_diff = 0.0;\n for (double num : numbers) {\n sum_abs_diff += Math.abs(num - mean);\n }\n return sum_abs_diff / numbers.size();\n }\n}"}, {"buggy_solution": " if (numbers.size() == 0) {\n return List.of();\n }\n List<Integer> result = new ArrayList<>(List.of());\n for (int i = 0; i < numbers.size() - 1; i++) {\n result.add(numbers.get(i));\n result.add(delimiter);\n }\n\n result.add(numbers.get(numbers.size() - 1));\n\n return result;\n }\n}"}, {"buggy_solution": " String[] groups = paren_string.split(\" \");\n List<Integer> result = new ArrayList<>(List.of());\n for (String group : groups) {\n if (group.length() > 0) {\n int depth = 0;\n int max_depth = 0;\n for (char c : group.toCharArray()) {\n if (c == '(') {\n depth += 1;\n max_depth = Math.max(depth, max_depth);\n } else {\n depth -= 1;\n }\n }\n result.add(max_depth);\n }\n }\n return result;\n }\n}"}, {"buggy_solution": " List<String> result = new ArrayList<>();\n for (String x : strings) {\n if (x.contains(substring)) {\n result.add(x);\n }\n }\n return result;\n }\n}"}, {"buggy_solution": " int sum = 0;\n int product = 1;\n\n for (int n : numbers) {\n sum += n;\n product *= n;\n }\n return Arrays.asList(sum, product);\n }\n}"}, {"buggy_solution": " List<Integer> result = new ArrayList<>();\n if (numbers.size() == 0) {\n return result;\n }\n int rollingMax = numbers.get(0);\n result.add(rollingMax);\n\n for (int i = 1; i < numbers.size(); i++) {\n if (numbers.get(i) > rollingMax) {\n rollingMax = numbers.get(i);\n }\n result.add(rollingMax);\n }\n\n return result;\n }\n}"}, {"buggy_solution": " if (string.length() == 0) {\n return \"\";\n }\n\n int beginning_of_suffix = 0;\n\n while (!isPalindrome(string.substring(beginning_of_suffix))) {\n beginning_of_suffix++;\n }\n\n return string + new StringBuffer(string.substring(0, beginning_of_suffix)).reverse().toString();\n }\n}"}, {"buggy_solution": " StringBuilder result = new StringBuilder();\n for (int i = 0; i < a.length(); i++) {\n if (a.charAt(i) == b.charAt(i)) {\n result.append(\"0\");\n } else {\n result.append(\"1\");\n }\n }\n return result.toString();\n }\n}"}, {"buggy_solution": " if (strings.isEmpty()) {\n return Optional.empty();\n }\n String longest = strings.get(0);\n for (String s : strings) {\n if (s.length() > longest.length()) {\n longest = s;\n }\n }\n return Optional.of(longest);\n }\n}"}, {"buggy_solution": " if (a == 0 || b == 0) {\n return a + b;\n }\n if (a == b) {\n return a;\n }\n if (a > b) {\n return greatestCommonDivisor(a % b, b);\n } else {\n return greatestCommonDivisor(a, b % a);\n }\n }\n}"}, {"buggy_solution": " List<String> result = new ArrayList<>();\n\n for (int i = 1; i <= string.length(); i++) {\n result.add(string.substring(0, i));\n }\n return result;\n }\n}"}, {"buggy_solution": " StringBuilder sb = new StringBuilder();\n for (int i = 0; i < n; i++) {\n sb.append(i);\n sb.append(\" \");\n }\n sb.append(n);\n return sb.toString();\n }\n}"}, {"buggy_solution": " Set<Character> set = new HashSet<>();\n for (char c : string.toLowerCase().toCharArray()) {\n set.add(c);\n }\n return set.size();\n }\n}"}, {"buggy_solution": " String[] notes = string.split(\" \");\n List<Integer> result = new ArrayList<>();\n for (String s : notes) {\n switch (s) {\n case \"o\" -> result.add(4);\n case \"o|\" -> result.add(2);\n case \".|\" -> result.add(1);\n }\n }\n return result;\n }\n}"}, {"buggy_solution": " int times = 0;\n\n for (int i = 0; i < string.length() - substring.length() + 1; i++) {\n if (string.substring(i, i + substring.length()).equals(substring)) {\n times += 1;\n }\n }\n\n return times;\n }\n}"}, {"buggy_solution": " String[] nums = numbers.split(\" \");\n List<Integer> num = new ArrayList<>();\n for (String string : nums) {\n switch (string) {\n case \"zero\" -> num.add(0);\n case \"one\" -> num.add(1);\n case \"two\" -> num.add(2);\n case \"three\" -> num.add(3);\n case \"four\" -> num.add(4);\n case \"five\" -> num.add(5);\n case \"six\" -> num.add(6);\n case \"seven\" -> num.add(7);\n case \"eight\" -> num.add(8);\n case \"nine\" -> num.add(9);\n }\n }\n Collections.sort(num);\n List<String> result = new ArrayList<>();\n for (int m : num) {\n switch (m) {\n case 0 -> result.add(\"zero\");\n case 1 -> result.add(\"one\");\n case 2 -> result.add(\"two\");\n case 3 -> result.add(\"three\");\n case 4 -> result.add(\"four\");\n case 5 -> result.add(\"five\");\n case 6 -> result.add(\"six\");\n case 7 -> result.add(\"seven\");\n case 8 -> result.add(\"eight\");\n case 9 -> result.add(\"nine\");\n }\n }\n return String.join(\" \", result);\n }\n}"}, {"buggy_solution": " List<Double> closest_pair = new ArrayList<>();\n closest_pair.add(numbers.get(0));\n closest_pair.add(numbers.get(1));\n double distance = Math.abs(numbers.get(1) - numbers.get(0));\n for (int i = 0; i < numbers.size(); i++) {\n for (int j = i + 1; j < numbers.size(); j++) {\n if (Math.abs(numbers.get(i) - numbers.get(j)) < distance) {\n closest_pair.clear();\n closest_pair.add(numbers.get(i));\n closest_pair.add(numbers.get(j));\n distance = Math.abs(numbers.get(i) - numbers.get(j));\n }\n }\n }\n Collections.sort(closest_pair);\n return closest_pair;\n }\n}"}, {"buggy_solution": " double min_number = Collections.min(numbers);\n double max_number = Collections.max(numbers);\n List<Double> result = new ArrayList<>();\n for (double x : numbers) {\n result.add((x - min_number) / (max_number - min_number));\n }\n return result;\n }\n}"}, {"buggy_solution": " List<Integer> result = new ArrayList<>();\n for (Object x : values) {\n if (x instanceof Integer) {\n result.add((Integer) x);\n }\n }\n return result;\n }\n}"}, {"buggy_solution": " return string.length();\n }\n}"}, {"buggy_solution": " for (int i = n - 1; i > 0; i--) {\n if (n % i == 0) {\n return i;\n }\n }\n return 1;\n }\n}"}, {"buggy_solution": " List<Integer> fact = new ArrayList<>();\n int i = 2;\n while (n > 1) {\n if (n % i == 0) {\n fact.add(i);\n n /= i;\n } else {\n i++;\n }\n }\n return fact;\n }\n}"}, {"buggy_solution": " Map<Integer, Integer> c = new HashMap<>();\n for (int i : numbers) {\n c.put(i, c.getOrDefault(i, 0) + 1);\n }\n return numbers.stream().filter(i -> c.get(i) == 1).collect(Collectors.toList());\n }\n}"}, {"buggy_solution": " StringBuilder sb = new StringBuilder();\n for (int i = 0; i < string.length(); i++) {\n if (Character.isLowerCase(string.charAt(i))) {\n sb.append(Character.toUpperCase(string.charAt(i)));\n } else {\n sb.append(Character.toLowerCase(string.charAt(i)));\n }\n }\n return sb.toString();\n }\n}"}, {"buggy_solution": " return String.join(\"\", strings);\n }\n}"}, {"buggy_solution": " return strings.stream().filter(p -> p.startsWith(prefix)).collect(Collectors.toList());\n }\n}"}, {"buggy_solution": " return l.stream().filter(p -> p > 0).collect(Collectors.toList());\n }\n}"}, {"buggy_solution": " if (n < 2) {\n return false;\n }\n for (int k = 2; k < n; k++) {\n if (n % k == 0) {\n return false;\n }\n }\n return true;\n }\n}"}, {"buggy_solution": " double begin = -1, end = 1;\n while (poly(xs, begin) * poly(xs, end) > 0) {\n begin *= 2;\n end *= 2;\n }\n while (end - begin > 1e-10) {\n double center = (begin + end) / 2;\n if (poly(xs, begin) * poly(xs, center) > 0) {\n begin = center;\n } else {\n end = center;\n }\n }\n return begin;\n }\n}"}, {"buggy_solution": " List<Integer> thirds = new ArrayList<>();\n for (int i = 0; i < l.size(); i += 3) {\n thirds.add(l.get(i));\n }\n Collections.sort(thirds);\n List<Integer> result = l;\n for (int i = 0; i < l.size(); i += 3) {\n result.set(i, thirds.get(i / 3));\n }\n return result;\n }\n}"}, {"buggy_solution": " List<Integer> result = new ArrayList<>(new HashSet<>(l));\n Collections.sort(result);\n return result;\n }\n}"}, {"buggy_solution": " return Collections.max(l);\n }\n}"}, {"buggy_solution": " int result = 0;\n for (int i = 1; i < n; i++) {\n if (i % 11 == 0 || i % 13 == 0) {\n char[] digits = String.valueOf(i).toCharArray();\n for (char c : digits) {\n if (c == '7') {\n result += 1;\n }\n }\n }\n }\n return result;\n }\n}"}, {"buggy_solution": " List<Integer> even = new ArrayList<>();\n for (int i = 0; i < l.size(); i += 2) {\n even.add(l.get(i));\n }\n Collections.sort(even);\n List<Integer> result = l;\n for (int i = 0; i < l.size(); i += 2) {\n result.set(i, even.get(i / 2));\n }\n return result;\n }\n}"}, {"buggy_solution": " return encodeCyclic(encodeCyclic(s));\n }\n}"}, {"buggy_solution": " int f0 = 0, f1 = 1;\n while (true) {\n int p = f0 + f1;\n boolean is_prime = p >= 2;\n for (int k = 2; k < Math.min(Math.sqrt(p) + 1, p - 1); k++) {\n if (p % k == 0) {\n is_prime = false;\n break;\n }\n }\n if (is_prime) {\n n -= 1;\n }\n if (n == 0) {\n return p;\n }\n f0 = f1;\n f1 = p;\n }\n }\n}"}, {"buggy_solution": " for (int i = 0; i < l.size(); i++) {\n for (int j = i + 1; j < l.size(); j++) {\n for (int k = j + 1; k < l.size(); k++) {\n if (l.get(i) + l.get(j) + l.get(k) == 0) {\n return true;\n }\n }\n }\n }\n return false;\n }\n}"}, {"buggy_solution": " return n * n;\n }\n}"}, {"buggy_solution": " return l.stream().map(p -> p + 1).collect(Collectors.toList());\n }\n}"}, {"buggy_solution": " for (int i = 0; i < l.size(); i++) {\n for (int j = i + 1; j < l.size(); j++) {\n if (l.get(i) + l.get(j) == 0) {\n return true;\n }\n }\n }\n return false;\n }\n}"}, {"buggy_solution": " StringBuilder ret = new StringBuilder();\n while (x > 0) {\n ret.append(String.valueOf(x % base));\n x /= base;\n }\n return ret.reverse().toString();\n }\n}"}, {"buggy_solution": " return a * h / 2;\n }\n}"}, {"buggy_solution": " List<Integer> results = new ArrayList<>();\n results.add(0);\n results.add(0);\n results.add(2);\n results.add(0);\n if (n < 4) {\n return results.get(n);\n }\n\n for (int i = 4; i <= n; i++) {\n results.add(results.get(0) + results.get(1) + results.get(2) + results.get(3));\n results.remove(0);\n }\n return results.get(3);\n }\n}"}, {"buggy_solution": " List<Integer> list = l;\n Collections.sort(list);\n if (l.size() % 2 == 1) {\n return l.get(l.size() / 2);\n } else {\n return (l.get(l.size() / 2 - 1) + l.get(l.size() / 2)) / 2.0;\n }\n }\n}"}, {"buggy_solution": " for (int i = 0; i < text.length(); i++) {\n if (text.charAt(i) != text.charAt(text.length() - 1 - i)) {\n return false;\n }\n }\n return true;\n }\n}"}, {"buggy_solution": " int ret = 1;\n for (int i = 0; i < n; i++) {\n ret = (ret * 2) % p;\n }\n return ret;\n }\n}"}, {"buggy_solution": " StringBuilder sb = new StringBuilder();\n for (char ch : s.toCharArray()) {\n sb.append((char) ('a' + ((ch + 21 - 'a') % 26)));\n }\n return sb.toString();\n }\n}"}, {"buggy_solution": " StringBuilder sb = new StringBuilder();\n for (char ch : text.toCharArray()) {\n if (\"aeiou\".indexOf(Character.toLowerCase(ch)) == -1) {\n sb.append(ch);\n }\n }\n return sb.toString();\n }\n}"}, {"buggy_solution": " for (int e : l) {\n if (e >= t) {\n return false;\n }\n }\n return true;\n }\n}"}, {"buggy_solution": " return x + y;\n }\n}"}, {"buggy_solution": " Set<Character> set0 = new HashSet<>();\n for (char c : s0.toCharArray()) {\n set0.add(c);\n }\n Set<Character> set1 = new HashSet<>();\n for (char c : s1.toCharArray()) {\n set1.add(c);\n }\n return set0.equals(set1);\n }\n}"}, {"buggy_solution": " if (n == 0) {\n return 0;\n }\n if (n == 1) {\n return 1;\n }\n return fib(n - 1) + fib(n - 2);\n }\n}"}, {"buggy_solution": " int depth = 0;\n for (char b : brackets.toCharArray()) {\n if (b == '<') {\n depth += 1;\n } else {\n depth -= 1;\n }\n if (depth < 0) {\n return false;\n }\n }\n return depth == 0;\n }\n}"}, {"buggy_solution": " List<Integer> l1 = new ArrayList<>(l), l2 = new ArrayList<>(l);\n Collections.sort(l1);\n l2.sort(Collections.reverseOrder());\n return l.equals(l1) || l.equals(l2);\n }\n}"}, {"buggy_solution": " Set<Integer> ret = new HashSet<>(l1);\n ret.retainAll(new HashSet<>(l2));\n List<Integer> result = new ArrayList<>(ret);\n Collections.sort(result);\n return result;\n }\n}"}, {"buggy_solution": " int largest = 1;\n for (int j = 2; j <= n; j++) {\n if (n % j == 0) {\n boolean is_prime = j >= 2;\n for (int i = 2; i < j - 1; i++) {\n if (j % i == 0) {\n is_prime = false;\n break;\n }\n }\n if (is_prime) {\n largest = Math.max(largest, j);\n }\n }\n }\n return largest;\n }\n}"}, {"buggy_solution": " int result = 0;\n for (int i = 1; i <= n; i++) {\n result += i;\n }\n return result;\n }\n}"}, {"buggy_solution": " int depth = 0;\n for (char b : brackets.toCharArray()) {\n if (b == '(') {\n depth += 1;\n } else {\n depth -= 1;\n }\n if (depth < 0) {\n return false;\n }\n }\n return depth == 0;\n }\n}"}, {"buggy_solution": " List<Integer> result = new ArrayList<>();\n for (int i = 1; i < xs.size(); i++) {\n result.add(i * xs.get(i));\n }\n return result;\n }\n}"}, {"buggy_solution": " if (n == 0) {\n return 0;\n }\n if (n == 1) {\n return 0;\n }\n if (n == 2) {\n return 1;\n }\n return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3);\n }\n}"}, {"buggy_solution": " String vowels = \"aeiouAEIOU\";\n int n_vowels = 0;\n for (char c : s.toCharArray()) {\n if (vowels.indexOf(c) != -1) {\n n_vowels += 1;\n }\n }\n if (s.charAt(s.length() - 1) == 'y' || s.charAt(s.length() - 1) == 'Y') {\n n_vowels += 1;\n }\n return n_vowels;\n }\n}"}, {"buggy_solution": " String s = String.valueOf(x);\n if (shift > s.length()) {\n return new StringBuilder(s).reverse().toString();\n } else {\n return s.substring(s.length() - shift) + s.substring(0, s.length() - shift);\n }\n }\n}"}, {"buggy_solution": " int sum = 0;\n for (char c : s.toCharArray()) {\n if (Character.isUpperCase(c)) {\n sum += c;\n }\n }\n return sum;\n }\n}"}, {"buggy_solution": " List<Integer> lis = new ArrayList<>();\n for (String i : s.split(\" \")) {\n try {\n lis.add(Integer.parseInt(i));\n } catch (NumberFormatException ignored) {\n\n }\n }\n return n - lis.stream().mapToInt(Integer::intValue).sum();\n }\n}"}, {"buggy_solution": " List<Integer> result = new ArrayList<>();\n if (arr.size() == 0) {\n return result;\n }\n int min = Integer.MAX_VALUE;\n int minIndex = -1;\n for (int i = 0; i < arr.size(); i++) {\n if (arr.get(i) % 2 == 0) {\n if (arr.get(i) < min) {\n min = arr.get(i);\n minIndex = i;\n }\n }\n }\n if (minIndex != -1) {\n result.add(min);\n result.add(minIndex);\n }\n return result;\n }\n}"}, {"buggy_solution": " int[] frq = new int[Collections.max(lst) + 1];\n for (int i : lst) {\n frq[i] += 1;\n }\n int ans = -1;\n for (int i = 1; i < frq.length; i++) {\n if (frq[i] >= i) {\n ans = i;\n }\n }\n return ans;\n }\n}"}, {"buggy_solution": " List<Integer> res = new ArrayList<>();\n boolean _switch = true;\n List<Integer> l = new ArrayList<>(lst);\n while (l.size() != 0) {\n if (_switch) {\n res.add(Collections.min(l));\n } else {\n res.add(Collections.max(l));\n }\n l.remove(res.get(res.size() - 1));\n _switch = !_switch;\n }\n return res;\n }\n}"}, {"buggy_solution": " if (a + b <= c || a + c <= b || b + c <= a) {\n return -1;\n }\n double s = (a + b + c) / 2;\n double area = Math.sqrt(s * (s - a) * (s - b) * (s - c));\n area = (double) Math.round(area * 100) / 100;\n return area;\n }\n}"}, {"buggy_solution": " if (q.stream().reduce(0, Integer::sum) > w) {\n return false;\n }\n int i = 0, j = q.size() - 1;\n while (i < j) {\n if (!Objects.equals(q.get(i), q.get(j))) {\n return false;\n }\n i += 1;\n j -= 1;\n }\n return true;\n }\n}"}, {"buggy_solution": " int ans = 0;\n for (int i = 0; i < arr.size() / 2; i++) {\n if (!Objects.equals(arr.get(i), arr.get(arr.size() - i - 1))) {\n ans += 1;\n }\n }\n return ans;\n }\n}"}, {"buggy_solution": " int l1 = 0;\n for (String st : lst1) {\n l1 += st.length();\n }\n\n int l2 = 0;\n for (String st : lst2) {\n l2 += st.length();\n }\n\n if (l1 <= l2) {\n return lst1;\n } else {\n return lst2;\n }\n }\n}"}, {"buggy_solution": " class IsPrime {\n public static boolean is_prime(int n) {\n for (int j = 2; j < n; j++) {\n if (n % j == 0) {\n return false;\n }\n }\n return true;\n }\n }\n for (int i = 2; i < 101; i++) {\n if (!IsPrime.is_prime(i)) {\n continue;\n }\n for (int j = i; j < 101; j++) {\n if (!IsPrime.is_prime(j)) {\n continue;\n }\n for (int k = j; k < 101; k++) {\n if (!IsPrime.is_prime(k)) {\n continue;\n }\n if (i * j * k == a) {\n return true;\n }\n }\n }\n }\n return false;\n }\n}"}, {"buggy_solution": " if (n == 1) {\n return x == 1;\n }\n int power = 1;\n while (power < x) {\n power = power * n;\n }\n return power == x;\n }\n}"}, {"buggy_solution": " a = Math.abs(a);\n return Math.round(Math.pow(Math.round(Math.pow(a, 1. / 3)), 3)) == a;\n }\n}"}, {"buggy_solution": " String primes = \"2357BD\";\n int total = 0;\n for (char c : num.toCharArray()) {\n if (primes.indexOf(c) != -1) {\n total += 1;\n }\n }\n return total;\n }\n}"}, {"buggy_solution": " return \"db\" + Integer.toBinaryString(decimal) + \"db\";\n }\n}"}, {"buggy_solution": " if (s.length() < 3) {\n return false;\n }\n\n for (int i = 0; i < s.length() - 2; i++) {\n if (s.charAt(i) == s.charAt(i + 1) || s.charAt(i + 1) == s.charAt(i + 2) || s.charAt(i) == s.charAt(i + 2)) {\n return false;\n }\n }\n return true;\n }\n}"}, {"buggy_solution": " List<String> letter_grade = new ArrayList<>();\n for (double gpa : grades) {\n if (gpa == 4.0) {\n letter_grade.add(\"A+\");\n } else if (gpa > 3.7) {\n letter_grade.add(\"A\");\n } else if (gpa > 3.3) {\n letter_grade.add(\"A-\");\n } else if (gpa > 3.0) {\n letter_grade.add(\"B+\");\n } else if (gpa > 2.7) {\n letter_grade.add(\"B\");\n } else if (gpa > 2.3) {\n letter_grade.add(\"B-\");\n } else if (gpa > 2.0) {\n letter_grade.add(\"C+\");\n } else if (gpa > 1.7) {\n letter_grade.add(\"C\");\n } else if (gpa > 1.3) {\n letter_grade.add(\"C-\");\n } else if (gpa > 1.0) {\n letter_grade.add(\"D+\");\n } else if (gpa > 0.7) {\n letter_grade.add(\"D\");\n } else if (gpa > 0.0) {\n letter_grade.add(\"D-\");\n } else {\n letter_grade.add(\"E\");\n }\n }\n return letter_grade;\n }\n}"}, {"buggy_solution": " int l = string.length();\n if (l == 0 || l == 1) {\n return false;\n }\n for (int i = 2; i < l; i++) {\n if (l % i == 0) {\n return false;\n }\n }\n return true;\n }\n}"}, {"buggy_solution": " if (n == 1) {\n return 1;\n }\n return 18 * (int) Math.pow(10, n - 2);\n }\n}"}, {"buggy_solution": " int sum = 0;\n for (char c : String.valueOf(N).toCharArray()) {\n sum += (c - '0');\n }\n return Integer.toBinaryString(sum);\n }\n}"}, {"buggy_solution": " int sum = 0;\n for (int i = 1; i < lst.size(); i += 2) {\n if (lst.get(i) % 2 == 0) {\n sum += lst.get(i);\n }\n }\n return sum;\n }\n}"}, {"buggy_solution": " String[] strings = s.split(\" \");\n List<String> result = new ArrayList<>();\n for (String string : strings) {\n char[] chars = string.toCharArray();\n Arrays.sort(chars);\n result.add(String.copyValueOf(chars));\n }\n return String.join(\" \", result);\n }\n}"}, {"buggy_solution": " List<List<Integer>> coords = new ArrayList<>();\n for (int i = 0; i < lst.size(); i++) {\n List<List<Integer>> row = new ArrayList<>();\n for (int j = lst.get(i).size() - 1; j >= 0; j--) {\n if (lst.get(i).get(j) == x) {\n row.add(Arrays.asList(i, j));\n }\n }\n coords.addAll(row);\n }\n return coords;\n }\n}"}, {"buggy_solution": " if (array.size() == 0) {\n return array;\n }\n List<Integer> result = new ArrayList<>(array);\n if ((result.get(0) + result.get(result.size() - 1)) % 2 == 1) {\n Collections.sort(result);\n } else {\n result.sort(Collections.reverseOrder());\n }\n return result;\n }\n}"}, {"buggy_solution": " StringBuilder sb = new StringBuilder();\n for (char c : s.toCharArray()) {\n if (Character.isLetter(c)) {\n sb.append((char) ('a' + (c - 'a' + 2 * 2) % 26));\n } else {\n sb.append(c);\n }\n }\n return sb.toString();\n }\n}"}, {"buggy_solution": " Set < Integer > set = new HashSet<>(lst);\n List<Integer> l = new ArrayList<>(set);\n Collections.sort(l);\n if (l.size() < 2) {\n return Optional.empty();\n } else {\n return Optional.of(l.get(1));\n }\n }\n}"}, {"buggy_solution": " String [] sentences = S.split(\"[.?!]\\s*\");\n int count = 0;\n for (String sentence : sentences) {\n if (sentence.subSequence(0, 2).equals(\"I \")) {\n count += 1;\n }\n }\n return count;\n }\n}"}, {"buggy_solution": " if (x instanceof Integer && y instanceof Integer && z instanceof Integer) {\n return (int) x + (int) y == (int) z || (int) x + (int) z == (int) y || (int) y + (int) z == (int) x;\n }\n return false;\n }\n}"}, {"buggy_solution": " String vowels = \"aeiouAEIOU\";\n StringBuilder sb = new StringBuilder();\n for (char c : message.toCharArray()) {\n char ch = c;\n if (Character.isUpperCase(ch)) {\n ch = Character.toLowerCase(ch);\n if (vowels.indexOf(ch) != -1) {\n ch = (char) ('a' + ((ch - 'a' + 28) % 26));\n }\n } else if (Character.isLowerCase(ch)) {\n ch = Character.toUpperCase(ch);\n if (vowels.indexOf(ch) != -1) {\n ch = (char) ('A' + ((ch - 'A' + 28) % 26));\n }\n }\n sb.append(ch);\n }\n return sb.toString();\n }\n}"}, {"buggy_solution": " int maxx = 0;\n for (int i : lst) {\n if (i > maxx) {\n boolean isPrime = i != 1;\n for (int j = 2; j < Math.sqrt(i) + 1; j++) {\n if (i % j == 0) {\n isPrime = false;\n break;\n }\n }\n if (isPrime) {\n maxx = i;\n }\n }\n }\n int sum = 0;\n for (char c : String.valueOf(maxx).toCharArray()) {\n sum += (c - '0');\n }\n return sum;\n }\n}"}, {"buggy_solution": " if (dict.isEmpty()) {\n return false;\n }\n String state = \"start\";\n for (Map.Entry entry : dict.entrySet()) {\n if (!(entry.getKey() instanceof String key)) {\n state = \"mixed\";\n break;\n }\n boolean is_upper = true, is_lower = true;\n for (char c : key.toCharArray()) {\n if (Character.isLowerCase(c)) {\n is_upper = false;\n } else if (Character.isUpperCase(c)) {\n is_lower = false;\n } else {\n is_upper = false;\n is_lower = false;\n }\n }\n if (state.equals(\"start\")) {\n if (is_upper) {\n state = \"upper\";\n } else if (is_lower) {\n state = \"lower\";\n } else {\n break;\n }\n } else if ((state.equals(\"upper\") && !is_upper) || (state.equals(\"lower\") && !is_lower)) {\n state = \"mixed\";\n break;\n }\n }\n return state.equals(\"upper\") || state.equals(\"lower\");\n }\n}"}, {"buggy_solution": " List<Integer> primes = new ArrayList<>();\n for (int i = 2; i < n; i++) {\n boolean is_prime = true;\n for (int j = 2; j < i; j++) {\n if (i % j == 0) {\n is_prime = false;\n break;\n }\n }\n if (is_prime) {\n primes.add(i);\n }\n }\n return primes;\n }\n}"}, {"buggy_solution": " return Math.abs(a % 10) * Math.abs(b % 10);\n }\n}"}, {"buggy_solution": " int count = 0;\n for (int i = 0; i < s.length(); i += 2) {\n if (\"AEIOU\".indexOf(s.charAt(i)) != -1) {\n count += 1;\n }\n }\n return count;\n }\n}"}, {"buggy_solution": " if (value.contains(\".\")) {\n while (value.charAt(value.length() - 1) == '0') {\n value = value.substring(0, value.length() - 1);\n }\n }\n double num = Double.parseDouble(value);\n int res = 0;\n if (value.substring(Math.max(value.length() - 2, 0)).equals(\".5\")) {\n if (num > 0) {\n res = (int) Math.ceil(num);\n } else {\n res = (int) Math.floor(num);\n }\n } else if(value.length() > 0) {\n res = (int) Math.round(num);\n }\n return res;\n }\n}"}, {"buggy_solution": " List<Integer> result = new ArrayList<>();\n for (int i = 0; i < n; i++) {\n result.add(n + 2 * i);\n }\n return result;\n }\n}"}, {"buggy_solution": " if (s.length() == 0) {\n return List.of();\n }\n StringBuilder sb = new StringBuilder();\n\n for (char letter : s.toCharArray()) {\n if (letter == ',') {\n sb.append(' ');\n } else {\n sb.append(letter);\n }\n }\n\n return new ArrayList<>(Arrays.asList(sb.toString().split(\"\\s+\" )));\n }\n}"}, {"buggy_solution": " if (x > y) {\n return -1;\n }\n if (y % 2 == 0) {\n return y;\n }\n if (x == y) {\n return -1;\n }\n return y - 1;\n }\n}"}, {"buggy_solution": " if (n > m) {\n return -1;\n }\n return Integer.toBinaryString((int) Math.round((double) (m + n) / 2));\n }\n}"}, {"buggy_solution": " List<Integer> odd_digit_elements = new ArrayList<>();\n for (int i : x) {\n boolean is_unique = true;\n for (char c : String.valueOf(i).toCharArray()) {\n if ((c - '0') % 2 == 0) {\n is_unique = false;\n break;\n }\n }\n if (is_unique) {\n odd_digit_elements.add(i);\n }\n }\n Collections.sort(odd_digit_elements);\n return odd_digit_elements;\n }\n}"}, {"buggy_solution": " List<Integer> sorted_arr = new ArrayList<>(arr);\n sorted_arr.sort(Collections.reverseOrder());\n List<String> new_arr = new ArrayList<>();\n for (int var : sorted_arr) {\n if (var >= 1 && var <= 9) {\n switch (var) {\n case 1 -> new_arr.add(\"One\");\n case 2 -> new_arr.add(\"Two\");\n case 3 -> new_arr.add(\"Three\");\n case 4 -> new_arr.add(\"Four\");\n case 5 -> new_arr.add(\"Five\");\n case 6 -> new_arr.add(\"Six\");\n case 7 -> new_arr.add(\"Seven\");\n case 8 -> new_arr.add(\"Eight\");\n case 9 -> new_arr.add(\"Nine\");\n }\n }\n }\n return new_arr;\n }\n}"}, {"buggy_solution": " List<Integer> ret = new ArrayList<>();\n for (int i = 1; i <= n; i++) {\n if (i % 2 == 0) {\n int x = 1;\n for (int j = 1; j <= i; j++) {\n x *= j;\n }\n ret.add(x);\n } else {\n int x = 0;\n for (int j = 1; j <= i; j++) {\n x += j;\n }\n ret.add(x);\n }\n }\n return ret;\n }\n}"}, {"buggy_solution": " int even_palindrome_count = 0, odd_palindrome_count = 0;\n\n for (int i = 1; i <= n; i++) {\n if (String.valueOf(i).equals(new StringBuilder(String.valueOf(i)).reverse().toString())) {\n if (i % 2 == 1) {\n odd_palindrome_count += 1;\n } else {\n even_palindrome_count += 1;\n }\n }\n }\n return Arrays.asList(even_palindrome_count, odd_palindrome_count);\n }\n}"}, {"buggy_solution": " int count = 0;\n for (int n: arr) {\n int neg = 1;\n if (n < 0) {\n n = -n;\n neg = -1;\n }\n List<Integer> digits = new ArrayList<>();\n for (char digit : String.valueOf(n).toCharArray()) {\n digits.add(digit - '0');\n }\n digits.set(0, digits.get(0) * neg);\n if (digits.stream().reduce(0, Integer::sum) > 0) {\n count += 1;\n }\n }\n return count;\n }\n}"}, {"buggy_solution": " if (arr.size() == 0) {\n return true;\n }\n List<Integer> sorted_arr = new ArrayList<>(arr);\n Collections.sort(sorted_arr);\n\n int min_value = Collections.min(arr);\n int min_index = arr.indexOf(min_value);\n List<Integer> my_arr = new ArrayList<>(arr.subList(min_index, arr.size()));\n my_arr.addAll(arr.subList(0, min_index));\n for (int i = 0; i < arr.size(); i++) {\n if (my_arr.get(i) != sorted_arr.get(i)) {\n return false;\n }\n }\n return true;\n }\n}"}, {"buggy_solution": " int odd = 0, even = 0;\n for (int i : lst1) {\n if (i % 2 == 1) {\n odd += 1;\n }\n }\n for (int i : lst2) {\n if (i % 2 == 0) {\n even += 1;\n }\n }\n if (even >= odd) {\n return \"YES\";\n }\n return \"NO\";\n }\n}"}, {"buggy_solution": " Map<String, Integer> dict1 = new HashMap<>();\n List<String> list1 = Arrays.asList(test.split(\" \" ));\n int t = 0;\n for (String i : list1) {\n if (Collections.frequency(list1, i) > t && !i.isEmpty()) {\n t = Collections.frequency(list1, i);\n }\n }\n if (t > 0) {\n for (String i : list1) {\n if (Collections.frequency(list1, i) == t) {\n dict1.put(i, t);\n }\n }\n }\n return dict1;\n }\n}"}, {"buggy_solution": " StringBuilder sb = new StringBuilder();\n for (char ch : s.toCharArray()) {\n if (c.indexOf(ch) == -1) {\n sb.append(ch);\n }\n }\n return Arrays.asList(sb.toString(), sb.toString().equals(sb.reverse().toString()));\n }\n}"}, {"buggy_solution": " List<String> res = new ArrayList<>();\n for (String arr : lst) {\n int n = 0;\n for (char d : arr.toCharArray()) {\n if ((d - '0') % 2 == 1) {\n n += 1;\n }\n }\n res.add(\"the number of odd elements \" + n + \"n the str\" + n + \"ng \" + n + \" of the \" + n + \"nput.\" );\n }\n return res;\n }\n}"}, {"buggy_solution": " int minSum = Integer.MAX_VALUE;\n int sum = 0;\n for (Integer num : nums) {\n sum += num;\n if (minSum > sum) {\n minSum = sum;\n }\n if (sum > 0) {\n sum = 0;\n }\n }\n return minSum;\n }\n}"}, {"buggy_solution": " int sum = 0;\n for (List<Integer> arr : grid) {\n sum += Math.ceil((double) arr.stream().reduce(Integer::sum).get() / capacity);\n }\n return sum;\n }\n}"}, {"buggy_solution": " List < Integer > sorted_arr = new ArrayList<>(arr);\n sorted_arr.sort(new Comparator<Integer>() {\n @Override\n public int compare(Integer o1, Integer o2) {\n int cnt1 = (int) Integer.toBinaryString(Math.abs(o1)).chars().filter(ch -> ch == '1').count();\n int cnt2 = (int) Integer.toBinaryString(Math.abs(o2)).chars().filter(ch -> ch == '1').count();\n if (cnt1 > cnt2) {\n return 1;\n } else if (cnt1 < cnt2) {\n return -1;\n } else {\n return o1.compareTo(o2);\n }\n }\n });\n return sorted_arr;\n }\n}"}, {"buggy_solution": " List<String> result = new ArrayList<>();\n for (String word : s.split(\" \")) {\n int n_consonants = 0;\n for (char c : word.toCharArray()) {\n c = Character.toLowerCase(c);\n if (\"aeiou\".indexOf(c) == -1) {\n n_consonants += 1;\n }\n }\n if (n_consonants == n) {\n result.add(word);\n }\n }\n return result;\n }\n}"}, {"buggy_solution": " if (word.length() < 3) {\n return \"\";\n }\n\n String vowels = \"aeiouAEIOU\";\n for (int i = word.length() - 2; i > 0; i--) {\n if (vowels.indexOf(word.charAt(i)) != -1 && vowels.indexOf(word.charAt(i + 1)) == -1 && vowels.indexOf(word.charAt(i - 1)) == -1) {\n return String.valueOf(word.charAt(i));\n }\n }\n return \"\";\n }\n}"}, {"buggy_solution": " List<String> S = Arrays.asList(lst.get(0) + lst.get(1), lst.get(1) + lst.get(0));\n for (String s : S) {\n int val = 0;\n for (char i : s.toCharArray()) {\n if (i == '(') {\n val += 1;\n } else {\n val -= 1;\n }\n if (val < 0) {\n break;\n }\n }\n if (val == 0) {\n return \"Yes\";\n }\n }\n return \"No\";\n }\n}"}, {"buggy_solution": " if (k == 0) {\n return List.of();\n }\n List<Integer> arr_sort = new ArrayList<>(arr);\n Collections.sort(arr_sort);\n return arr_sort.subList(arr_sort.size() - k, arr_sort.size());\n }\n}"}, {"buggy_solution": " int sum = 0;\n for (int i = 0; i < lst.size(); i += 2) {\n if ((lst.get(i) % 2) == 1) {\n sum += lst.get(i);\n }\n }\n return sum;\n }\n}"}, {"buggy_solution": " arr = arr.subList(0, k);\n Optional<Integer> sum = arr.stream().filter(p -> String.valueOf(Math.abs(p)).length() <= 2).reduce(Integer::sum);\n return sum.orElse(0);\n }\n}"}, {"buggy_solution": " List<Integer> odd_collatz = new ArrayList<>();\n if (n % 2 == 1) {\n odd_collatz.add(n);\n }\n while (n > 1) {\n if (n % 2 == 0) {\n n = n / 2;\n } else {\n n = n * 3 + 1;\n }\n if (n % 2 == 1) {\n odd_collatz.add(n);\n }\n }\n Collections.sort(odd_collatz);\n return odd_collatz;\n }\n}"}, {"buggy_solution": " try {\n date = date.strip();\n String[] dates = date.split(\"-\" );\n String m = dates[0];\n while (!m.isEmpty() && m.charAt(0) == '0') {\n m = m.substring(1);\n }\n String d = dates[1];\n while (!d.isEmpty() && d.charAt(0) == '0') {\n d = d.substring(1);\n }\n String y = dates[2];\n while (!y.isEmpty() && y.charAt(0) == '0') {\n y = y.substring(1);\n }\n int month = Integer.parseInt(m), day = Integer.parseInt(d), year = Integer.parseInt(y);\n if (month < 1 || month > 12) {\n return false;\n }\n if (Arrays.asList(1, 3, 5, 7, 8, 10, 12).contains(month) && (day < 1 || day > 31)) {\n return false;\n }\n if (Arrays.asList(4, 6, 9, 11).contains(month) && (day < 1 || day > 30)) {\n return false;\n }\n if (month == 2 && (day < 1 || day > 29)) {\n return false;\n }\n return true;\n } catch (Exception e) {\n return false;\n }\n }\n}"}, {"buggy_solution": " if (txt.contains(\" \" )) {\n return Arrays.asList(txt.split(\" \" ));\n } else if (txt.contains(\",\" )) {\n return Arrays.asList(txt.split(\"[,\\s]\" ));\n } else {\n int count = 0;\n for (char c : txt.toCharArray()) {\n if (Character.isLowerCase(c) && (c - 'a') % 2 == 1) {\n count += 1;\n }\n }\n return count;\n }\n }\n}"}, {"buggy_solution": " List<Integer> sorted_lst = new ArrayList<>(lst);\n Collections.sort(sorted_lst);\n if (!lst.equals(sorted_lst)) {\n return false;\n }\n for (int i = 0; i < lst.size() - 2; i++) {\n if (lst.get(i) == lst.get(i + 1) && lst.get(i) == lst.get(i + 2)) {\n return false;\n }\n }\n return true;\n }\n}"}, {"buggy_solution": " int l = Math.max(interval1.get(0), interval2.get(0));\n int r = Math.min(interval1.get(1), interval2.get(1));\n int length = r - l;\n if (length <= 0) {\n return \"NO\";\n }\n if (length == 1) {\n return \"NO\";\n }\n if (length == 2) {\n return \"YES\";\n }\n for (int i = 2; i < length; i++) {\n if (length % i == 0) {\n return \"NO\";\n }\n }\n return \"YES\";\n }\n}"}, {"buggy_solution": " if (arr.size() == 0) {\n return Optional.empty();\n }\n if (arr.contains(0)) {\n return Optional.of(0);\n }\n int prod = (int) (-2 * (arr.stream().filter(p -> p < 0).count() % 2) + 1);\n return Optional.of(prod * (arr.stream().map(Math::abs).reduce(Integer::sum)).get());\n }\n}"}, {"buggy_solution": " int n = grid.size();\n int val = n * n + 1;\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < n; j++) {\n if (grid.get(i).get(j) == 1) {\n List<Integer> temp = new ArrayList<>();\n if (i != 0) {\n temp.add(grid.get(i - 1).get(j));\n }\n if (j != 0) {\n temp.add(grid.get(i).get(j - 1));\n }\n if (i != n - 1) {\n temp.add(grid.get(i + 1).get(j));\n }\n if (j != n - 1) {\n temp.add(grid.get(i).get(j + 1));\n }\n val = Collections.min(temp);\n }\n }\n }\n List<Integer> ans = new ArrayList<>();\n for (int i = 0; i < k; i++) {\n if (i % 2 == 0) {\n ans.add(1);\n } else {\n ans.add(val);\n }\n }\n return ans;\n }\n}"}, {"buggy_solution": " if (n == 0) {\n return List.of(1);\n }\n List<Integer> my_tri = new ArrayList<>(Arrays.asList(1, 3));\n for (int i = 2; i <= n; i++) {\n if (i % 2 == 0) {\n my_tri.add(i / 2 + 1);\n } else {\n my_tri.add(my_tri.get(my_tri.size() - 1) + my_tri.get(my_tri.size() - 2) + (i + 3) / 2);\n }\n }\n return my_tri;\n }\n}"}, {"buggy_solution": " int product = 1, odd_count = 0;\n for (char digit : String.valueOf(n).toCharArray()) {\n int int_digit = digit - '0';\n if (int_digit % 2 == 1) {\n product *= int_digit;\n odd_count += 1;\n }\n }\n if (odd_count == 0) {\n return 0;\n } else {\n return product;\n }\n }\n}"}, {"buggy_solution": " List<Integer> opening_bracket_index = new ArrayList<>(), closing_bracket_index = new ArrayList<>();\n for (int i = 0; i < string.length(); i++) {\n if (string.charAt(i) == '[') {\n opening_bracket_index.add(i);\n } else {\n closing_bracket_index.add(i);\n }\n }\n Collections.reverse(closing_bracket_index);\n int i = 0, l = closing_bracket_index.size();\n for (int idx : opening_bracket_index) {\n if (i < l && idx < closing_bracket_index.get(i)) {\n i += 1;\n }\n }\n return i >= 2;\n }\n}"}, {"buggy_solution": " return lst.stream().map(p -> (int) Math.ceil(p)).map(p -> p * p).reduce(Integer::sum).get();\n }\n}"}, {"buggy_solution": " String[] words = txt.split(\" \", -1);\n String check = words[words.length - 1];\n return check.length() == 1 && Character.isLetter(check.charAt(0));\n }\n}"}, {"buggy_solution": " int ind = -1, i = 1;\n while (i < arr.size()) {\n if (arr.get(i) < arr.get(i - 1)) {\n ind = i;\n }\n i += 1;\n }\n return ind;\n }\n}"}, {"buggy_solution": " List<Integer> smallest = lst.stream().filter(p -> p < 0).toList();\n List<Integer> largest = lst.stream().filter(p -> p > 0).toList();\n Optional<Integer> s = Optional.empty();\n if (smallest.size() > 0) {\n s = Optional.of(Collections.max(smallest));\n }\n Optional<Integer> l = Optional.empty();\n if (largest.size() > 0) {\n l = Optional.of(Collections.min(largest));\n }\n return Arrays.asList(s, l);\n }\n}"}, {"buggy_solution": " double temp_a = 0, temp_b = 0;\n if (a instanceof Integer) {\n temp_a = (Integer) a * 1.0;\n } else if (a instanceof Double) {\n temp_a = (double) a;\n } else if (a instanceof String) {\n temp_a = Double.parseDouble(((String) a).replace(',', '.'));\n }\n if (b instanceof Integer) {\n temp_b = (Integer) b * 1.0;\n } else if (b instanceof Double) {\n temp_b = (double) b;\n } else if (b instanceof String) {\n temp_b = Double.parseDouble(((String) b).replace(',', '.'));\n }\n if (temp_a == temp_b) {\n return Optional.empty();\n } else if (temp_a > temp_b) {\n return Optional.of(a);\n } else {\n return Optional.of(b);\n }\n }\n}"}, {"buggy_solution": " return n % 2 == 0 && n >= 8;\n }\n}"}, {"buggy_solution": " long fact_i = 1, special_fact = 1;\n for (int i = 1; i <= n; i++) {\n fact_i *= i;\n special_fact *= fact_i;\n }\n return special_fact;\n }\n}"}, {"buggy_solution": " StringBuilder sb = new StringBuilder();\n int start = 0, end = 0;\n for (int i = 0; i < text.length(); i++) {\n if (text.charAt(i) == ' ') {\n end += 1;\n } else {\n if (end - start > 2) {\n sb.append('-');\n } else if (end - start > 0) {\n sb.append(\"_\".repeat(end - start));\n }\n sb.append(text.charAt(i));\n start = i + 1;\n end = i + 1;\n }\n }\n if (end - start > 2) {\n sb.append('-');\n } else if (end - start > 0) {\n sb.append(\"_\".repeat(end - start));\n }\n return sb.toString();\n }\n}"}, {"buggy_solution": " List<String> suf = Arrays.asList(\"txt\", \"exe\", \"dll\");\n String[] lst = file_name.split(\"\\\\.\" );\n if (lst.length != 2 || !suf.contains(lst[1]) || lst[0].isEmpty() || !Character.isLetter(lst[0].charAt(0))) {\n return \"No\";\n }\n int t = (int) lst[0].chars().map(x -> (char) x).filter(Character::isDigit).count();\n if (t > 3) {\n return \"No\";\n }\n return \"Yes\";\n }\n}"}, {"buggy_solution": " List<Integer> result = new ArrayList<>();\n for (int i = 0; i < lst.size(); i++) {\n if (i % 3 == 0) {\n result.add(lst.get(i) * lst.get(i));\n } else if (i % 4 == 0) {\n result.add((int) Math.pow(lst.get(i), 3));\n } else {\n result.add(lst.get(i));\n }\n }\n return result.stream().reduce(Integer::sum).orElse(0);\n }\n}"}, {"buggy_solution": " List<String> new_lst = new ArrayList<>();\n for (String word : sentence.split(\" \" )) {\n boolean flg = true;\n if (word.length() == 1) {\n continue;\n }\n for (int i = 2; i < word.length(); i++) {\n if (word.length() % i == 0) {\n flg = false;\n break;\n }\n }\n if (flg) {\n new_lst.add(word);\n }\n }\n return String.join(\" \", new_lst);\n }\n}"}, {"buggy_solution": " String[] a = x.split(\"/\");\n String[] b = n.split(\"/\");\n int numerator = Integer.parseInt(a[0]) * Integer.parseInt(b[0]);\n int denom = Integer.parseInt(a[1]) * Integer.parseInt(b[1]);\n return numerator / denom * denom == numerator;\n }\n}"}, {"buggy_solution": " List<Integer> result = new ArrayList<>(nums);\n result.sort((o1, o2) -> {\n int sum1 = 0;\n int sum2 = 0;\n\n for (int i = 0; i < String.valueOf(o1).length(); i++) {\n if (i != 0 || o1 >= 0) {\n sum1 += (String.valueOf(o1).charAt(i) - '0' );\n if (i == 1 && o1 < 0) {\n sum1 = -sum1;\n }\n }\n }\n for (int i = 0; i < String.valueOf(o2).length(); i++) {\n if (i != 0 || o2 >= 0) {\n sum2 += (String.valueOf(o2).charAt(i) - '0' );\n if (i == 1 && o2 < 0) {\n sum2 = -sum2;\n }\n }\n }\n return Integer.compare(sum1, sum2);\n });\n return result;\n }\n}"}, {"buggy_solution": " int count = 0;\n for (int num : nums) {\n if (num > 10) {\n String odd_digits = \"13579\";\n String number_as_string = String.valueOf(num);\n if (odd_digits.indexOf(number_as_string.charAt(0)) != -1 && odd_digits.indexOf(number_as_string.charAt(number_as_string.length() - 1)) != -1) {\n count += 1;\n }\n }\n }\n return count;\n }\n}"}, {"buggy_solution": " List<Integer> A = new ArrayList<>();\n for (int i = 1; i <= n; i++) {\n A.add(i * i - i + 1);\n }\n int count = 0;\n for (int i = 0; i < A.size(); i++) {\n for (int j = i + 1; j < A.size(); j++) {\n for (int k = j + 1; k < A.size(); k++) {\n if ((A.get(i) + A.get(j) + A.get(k)) % 3 == 0) {\n count += 1;\n }\n }\n }\n }\n return count;\n }\n}"}, {"buggy_solution": " List<String> planet_names = Arrays.asList(\"Mercury\", \"Venus\", \"Earth\", \"Mars\", \"Jupiter\", \"Saturn\", \"Uranus\", \"Neptune\");\n if (!planet_names.contains(planet1) || !planet_names.contains(planet2) || planet1.equals(planet2)) {\n return List.of();\n }\n int planet1_index = planet_names.indexOf(planet1);\n int planet2_index = planet_names.indexOf(planet2);\n if (planet1_index < planet2_index) {\n return planet_names.subList(planet1_index + 1, planet2_index);\n } else {\n return planet_names.subList(planet2_index + 1, planet1_index);\n }\n }\n}"}, {"buggy_solution": " List<String> lst_sorted = new ArrayList<>(lst);\n Collections.sort(lst_sorted);\n List<String> new_lst = new ArrayList<>();\n for (String i : lst_sorted) {\n if (i.length() % 2 == 0) {\n new_lst.add(i);\n }\n }\n new_lst.sort(Comparator.comparingInt(String::length));\n return new_lst;\n }\n}"}, {"buggy_solution": " if (n == 1) {\n return y;\n }\n for (int i = 2; i < n; i++) {\n if (n % i == 0) {\n return y;\n }\n }\n return x;\n }\n}"}, {"buggy_solution": " return lst.stream().filter(i -> i instanceof Integer p && p > 0 && p % 2 != 0).map(i -> (Integer) i * (Integer) i).reduce(Integer::sum).orElse(0);\n }\n}"}, {"buggy_solution": " List<Integer> result = new ArrayList<>();\n for (int i = 0; i < game.size(); i++) {\n result.add(Math.abs(game.get(i) - guess.get(i)));\n }\n return result;\n }\n}"}, {"buggy_solution": " String strong = extensions.get(0);\n int my_val = (int) (strong.chars().filter(Character::isUpperCase).count() - strong.chars().filter(Character::isLowerCase).count());\n for (String s : extensions) {\n int val = (int) (s.chars().filter(Character::isUpperCase).count() - s.chars().filter(Character::isLowerCase).count());\n if (val > my_val) {\n strong = s;\n my_val = val;\n }\n }\n return class_name + \".\" + strong;\n }\n}"}, {"buggy_solution": " int l = b.length();\n String pat = b + b;\n for (int i = 0; i <= a.length() - l; i++) {\n for (int j = 0; j <= l; j++) {\n if (a.substring(i, i + l).equals(pat.substring(j, j + l))) {\n return true;\n }\n }\n }\n return false;\n }\n}"}, {"buggy_solution": " int even_count = 0, odd_count = 0;\n for (char i : String.valueOf(Math.abs(num)).toCharArray()) {\n if ((i - '0') % 2 == 0) {\n even_count += 1;\n } else {\n odd_count += 1;\n }\n }\n return Arrays.asList(even_count, odd_count);\n }\n}"}, {"buggy_solution": " List<Integer> num = Arrays.asList(1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000);\n List<String> sym = Arrays.asList(\"I\", \"IV\", \"V\", \"IX\", \"X\", \"XL\", \"L\", \"XC\", \"C\", \"CD\", \"D\", \"CM\", \"M\");\n int i = 12;\n String res = \"\";\n while (number > 0) {\n int div = number / num.get(i);\n number %= num.get(i);\n while (div != 0) {\n res += sym.get(i);\n div -= 1;\n }\n i -= 1;\n }\n return res.toLowerCase();\n }\n}"}, {"buggy_solution": " return a * a == b * b + c * c || b * b == a * a + c * c || c * c == a * a + b * b;\n }\n}"}, {"buggy_solution": " List<String> words_sort = new ArrayList<>(words);\n words_sort.sort(new Comparator<String>() {\n @Override\n public int compare(String o1, String o2) {\n Set<Character> s1 = new HashSet<>();\n for (char ch : o1.toCharArray()) {\n s1.add(ch);\n }\n Set<Character> s2 = new HashSet<>();\n for (char ch : o2.toCharArray()) {\n s2.add(ch);\n }\n if (s1.size() > s2.size()) {\n return 1;\n } else if (s1.size() < s2.size()) {\n return -1;\n } else {\n return -o1.compareTo(o2);\n }\n }\n });\n return words_sort.get(words_sort.size() - 1);\n }\n}"}, {"buggy_solution": " if (need <= remaining) {\n return Arrays.asList(number + need, remaining - need);\n } else {\n return Arrays.asList(number + remaining, 0);\n }\n }\n}"}, {"buggy_solution": " List<String> ops = new ArrayList<>(operator);\n List<Integer> nums = new ArrayList<>(operand);\n for (int i = ops.size() - 1; i >= 0; i--) {\n if (ops.get(i).equals(\"**\")) {\n nums.set(i, (int) Math.round(Math.pow(nums.get(i), nums.get(i + 1))));\n nums.remove(i + 1);\n ops.remove(i);\n }\n }\n for (int i = 0; i < ops.size(); i++) {\n if (ops.get(i).equals(\"*\")) {\n nums.set(i, nums.get(i) * nums.get(i + 1));\n nums.remove(i + 1);\n ops.remove(i);\n i--;\n } else if (ops.get(i).equals(\"/\")) {\n nums.set(i, nums.get(i) / nums.get(i + 1));\n nums.remove(i + 1);\n ops.remove(i);\n i--;\n }\n }\n for (int i = 0; i < ops.size(); i++) {\n if (ops.get(i).equals(\"+\")) {\n nums.set(i, nums.get(i) + nums.get(i + 1));\n nums.remove(i + 1);\n ops.remove(i);\n i--;\n } else if (ops.get(i).equals(\"-\")) {\n nums.set(i, nums.get(i) - nums.get(i + 1));\n nums.remove(i + 1);\n ops.remove(i);\n i--;\n }\n }\n return nums.get(0);\n }\n}"}, {"buggy_solution": " boolean flag = true;\n StringBuilder new_string = new StringBuilder();\n for (char i : s.toCharArray()) {\n if (Character.isUpperCase(i)) {\n new_string.append(Character.toLowerCase(i));\n flag = false;\n } else if (Character.isLowerCase(i)) {\n new_string.append(Character.toUpperCase(i));\n flag = false;\n } else {\n new_string.append(i);\n }\n }\n if (flag) {\n new_string.reverse();\n }\n return new_string.toString();\n }\n}"}, {"buggy_solution": " if (text.isEmpty()) {\n return Optional.empty();\n }\n\n String md5 = new BigInteger(1, java.security.MessageDigest.getInstance(\"MD5\").digest(text.getBytes())).toString(16);\n md5 = \"0\".repeat(32 - md5.length()) + md5;\n return Optional.of(md5);\n }\n}"}, {"buggy_solution": " int lower = Math.max(2, Math.min(a, b));\n int upper = Math.min(8, Math.max(a, b));\n\n List<Integer> result = new ArrayList<>();\n for (int i = lower; i <= upper; i += 2) {\n result.add(i);\n }\n return result;\n }\n}"}]
data/js/data/.DS_Store ADDED
Binary file (6.15 kB). View file
 
data/js/data/humaneval.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/js/data/humanevalbugs.json ADDED
@@ -0,0 +1 @@
 
 
1
+ [{"buggy_solution": " for (let i = 0; i < numbers.length; i++) {\n for (let j = 0; j < numbers.length; j++) {\n if (i != j) {\n let distance = Math.abs(numbers[i] - numbers[j]);\n if (distance < threshold) {\n return true;\n }\n }\n }\n }\n return false;\n}\n\n"}, {"buggy_solution": " var result = [];\n var current_string = [];\n var current_depth = 0;\n\n for (const c of paren_string) {\n if (c == '(') {\n current_depth += 1;\n current_string.push(c);\n } else if (c == ')') {\n current_depth -= 1;\n current_string.push(c);\n if (current_depth == 0) {\n result.push(current_string.join(''));\n current_string = [];\n }\n }\n }\n\n return result;\n}\n\n"}, {"buggy_solution": " return number % 1.0;\n}\n\n"}, {"buggy_solution": " var balance = 0;\n for (const op of operations) {\n balance += op;\n if (balance < 0) {\n return true;\n }\n }\n return false;\n}\n\n"}, {"buggy_solution": " var mean = numbers.reduce((prev, item) => {\n return prev + item;\n }, 0) / numbers.length;\n return numbers.reduce((prev, item) => {\n return prev + Math.abs(item - mean);\n }, 0) / numbers.length;\n\n}\n\n"}, {"buggy_solution": " if (!Array.isArray(numbers) || numbers.length == 0)\n return [];\n var result = [];\n for (const n of numbers) {\n result.push(n, delimeter);\n }\n result.pop();\n return result;\n}\n\n"}, {"buggy_solution": " var parseParenGroup = function (s) {\n let depth = 0, max_depth = 0;\n for (const c of s) {\n if (c == '(') {\n depth += 1;\n max_depth = Math.max(max_depth, depth);\n } else {\n depth -= 1;\n }\n }\n return max_depth;\n }\n return paren_string.split(' ')\n .filter(x => x != '')\n .map(x => parseParenGroup(x));\n}\n\n"}, {"buggy_solution": " return strings.filter(x => x.indexOf(substring) != -1);\n}\n\n"}, {"buggy_solution": " var sum_value = 0, prod_value = 1;\n for (const n of numbers) {\n sum_value += n;\n prod_value *= n;\n }\n return [sum_value, prod_value];\n}\n\n"}, {"buggy_solution": " var running_max, result = [];\n for (const n of numbers) {\n if (running_max == undefined)\n running_max = n;\n else\n running_max = Math.max(running_max, n);\n result.push(running_max);\n }\n return result;\n}\n\n"}, {"buggy_solution": " if (string == '')\n return '';\n var beginning_of_suffix = 0;\n while (!isPalindrome(string.slice(beginning_of_suffix)))\n beginning_of_suffix += 1;\n return string + string.slice(0, beginning_of_suffix).split('').reverse().join('');\n}\n\n"}, {"buggy_solution": " var xor = function (i, j) {\n if (i == j)\n return '0';\n else\n return '1';\n }\n return a.split('').map((item, index) => xor(item, b[index])).join('');\n}\n\n"}, {"buggy_solution": " if (!Array.isArray(strings) || strings.length == 0)\n return null;\n var maxlen = Math.max(...strings.map(x => x.length));\n for (const s of strings) {\n if (s.length == maxlen) {\n return s;\n }\n }\n}\n\n"}, {"buggy_solution": " while (b != 0) {\n let temp = a;\n a = b;\n b = temp % b;\n }\n return a;\n}\n\n"}, {"buggy_solution": " var result = [];\n for (let i = 0; i < string.length; i++) {\n result.push(string.slice(0, i+1));\n }\n return result;\n}\n\n"}, {"buggy_solution": " return [...Array(n).keys(), n].join(' ')\n}\n\n"}, {"buggy_solution": " return (new Set(string.toLowerCase())).size;\n\n}\n\n"}, {"buggy_solution": " const note_map = {'o': 4, 'o|': 2, '.|': 1};\n return music_string.split(' ').filter(x => x != '').map(x => note_map[x]);\n}\n\n"}, {"buggy_solution": " var times = 0;\n for (let i = 0; i < string.length - substring.length + 1; i++) {\n if (string.slice(i, i+substring.length) == substring) {\n times += 1;\n }\n }\n return times;\n}\n\n"}, {"buggy_solution": " const value_map = {\n 'zero': 0,\n 'one': 1,\n 'two': 2,\n 'three': 3,\n 'four': 4,\n 'five': 5,\n 'six': 6,\n 'seven': 7,\n 'eight': 8,\n 'nine': 9\n };\n return numbers.split(' ')\n .filter(x => x != '')\n .sort((a, b) => value_map[a] - value_map[b])\n .join(' ');\n}\n\n"}, {"buggy_solution": " var closest_pair, distance;\n for (let i = 0; i < numbers.length; i++)\n for (let j = 0; j < numbers.length; j++)\n if (i != j) {\n let a = numbers[i], b = numbers[j];\n if (distance == null) {\n distance = Math.abs(a - b);\n closest_pair = [Math.min(a, b), Math.max(a, b)];\n } else {\n let new_distance = Math.abs(a - b);\n if (new_distance < distance) {\n distance = new_distance;\n closest_pair = [Math.min(a, b), Math.max(a, b)];\n }\n }\n }\n return closest_pair;\n}\n\n"}, {"buggy_solution": " var min_number = Math.min(...numbers);\n var max_number = Math.max(...numbers);\n return numbers.map(x => (x - min_number) / (max_number - min_number));\n}\n\n"}, {"buggy_solution": " return values.filter(x => Number.isInteger(x));\n}\n\n"}, {"buggy_solution": " return string.length;\n}\n\n"}, {"buggy_solution": " for (let i = n - 1; i >= 0; i--)\n if (n % i == 0)\n return i;\n}\n\n"}, {"buggy_solution": " var fact = [], i = 2;\n while (i <= Math.sqrt(n) + 1) {\n if (n % i == 0) {\n fact.push(i);\n n = n / i;\n } else {\n i += 1;\n }\n }\n\n if (n > 1)\n fact.push(n);\n return fact;\n}\n\n"}, {"buggy_solution": " var dict = new Object();\n for (const num of numbers) {\n if (num in dict) {\n dict[num] += 1;\n } else {\n dict[num] = 1;\n }\n }\n return numbers.filter(x => dict[x] <= 1);\n}\n\n"}, {"buggy_solution": " return string.split('')\n .map(x => (x.toUpperCase() == x ? x.toLowerCase() : x.toUpperCase()))\n .join('');\n}\n\n"}, {"buggy_solution": " return strings.join('');\n}\n\n"}, {"buggy_solution": " return strings.filter(x => x.startsWith(prefix));\n}\n\n"}, {"buggy_solution": " return l.filter(e => e > 0);\n}\n\n"}, {"buggy_solution": " if (n < 2)\n return false;\n for (let k = 2; k < n - 1; k++)\n if (n % k == 0)\n return false;\n return true;\n}\n\n"}, {"buggy_solution": " var begin = -1.0, end = 1.0;\n while (poly(xs, begin) * poly(xs, end) > 0) {\n begin *= 2.0;\n end *= 2.0;\n }\n while (end - begin > 1e-10) {\n let center = (begin + end) / 2.0;\n if (poly(xs, center) * poly(xs, begin) > 0)\n begin = center;\n else\n end = center;\n }\n return begin;\n}\n\n"}, {"buggy_solution": " var three = l.filter((item, index) => index % 3 == 0);\n three.sort((a, b) => (a - b));\n return l.map((item, index) => (index % 3 == 0 ? three[index / 3] : item));\n}\n\n"}, {"buggy_solution": " return Array.from(new Set(l)).sort((a, b) => (a - b));\n}\n\n"}, {"buggy_solution": " return Math.max(...l);\n}\n\n"}, {"buggy_solution": " var ns = [], ans = 0;\n for (let i = 0; i < n; i++)\n if (i % 11 == 0 || i % 13 == 0)\n ns.push(i);\n var s = ns.map(x => x.toString()).join('');\n for (const c of s)\n ans += (c == '7');\n return ans;\n}\n\n"}, {"buggy_solution": " var even = l.filter((item, index) => index % 2 == 0);\n even.sort((a, b) => (a - b));\n return l.map((item, index) => (index % 2 == 0 ? even[index / 2] : item));\n}\n\n"}, {"buggy_solution": " return encodeCyclic(encodeCyclic(s));\n}\n\n"}, {"buggy_solution": " var isPrime = function (p) {\n if (p < 2)\n return false;\n for (let k = 2; k < Math.min(Math.floor(Math.sqrt(p)) + 1, p - 1); k++) {\n if (p % k == 0)\n return false;\n }\n return true;\n }\n\n var f = [0, 1];\n while (true) {\n f.push(f.at(-1) + f.at(-2));\n if (isPrime(f.at(-1)))\n n -= 1;\n if (n == 0)\n return f.at(-1);\n }\n}\n\n"}, {"buggy_solution": " for (let i = 0; i < l.length; i++)\n for (let j = i + 1; j < l.length; j++)\n for (let k = j + 1; k < l.length; k++)\n if (l[i] + l[j] + l[k] == 0)\n return true;\n return false;\n}\n\n"}, {"buggy_solution": " return Math.pow(n, 2);\n}\n\n"}, {"buggy_solution": " return l.map(e => e + 1);\n}\n\n"}, {"buggy_solution": " for (let i = 0; i < l.length; i++)\n for (let j = i + 1; j < l.length; j++)\n if (l[i] + l[j] == 0)\n return true;\n return false;\n}\n\n"}, {"buggy_solution": " var ret = \"\";\n while (x > 0) {\n ret = (x % base).toString() + ret;\n x = Math.floor(x / base);\n }\n return ret;\n}\n\n"}, {"buggy_solution": " return a * h / 2.0;\n}\n\n"}, {"buggy_solution": " var results = [0, 0, 2, 0];\n if (n < 4)\n return results[n];\n for (let i = 4; i < n + 1; i++) {\n results.push(results.at(-1) + results.at(-2) +\n results.at(-3) + results.at(-4));\n results.shift();\n }\n return results.pop();\n}\n\n"}, {"buggy_solution": " l.sort((a, b) => a - b);\n var len = l.length;\n if (l.length % 2 == 1)\n return l[Math.floor(len / 2)];\n else\n return (l[len / 2 - 1] + l[len / 2]) / 2.0;\n}\n\n"}, {"buggy_solution": " for (let i = 0; i < text.length; i++)\n if (text[i] != text.at(-i-1))\n return false;\n return true;\n}\n\n"}, {"buggy_solution": " var ret = 1;\n for (let i = 0; i < n; i++)\n ret = (2 * ret) % p;\n return ret;\n}\n\n"}, {"buggy_solution": " return s.split(\"\").map(ch => String.fromCharCode(\n ((ch.charCodeAt(0) - 5 + 26 - \"a\".charCodeAt(0)) % 26) + \"a\".charCodeAt(0)\n )).join(\"\");\n}\n\n"}, {"buggy_solution": " return text.split(\"\")\n .filter(s => ![\"a\", \"e\", \"i\", \"o\", \"u\"]\n .includes(s.toLowerCase())\n )\n .join(\"\")\n}\n\n"}, {"buggy_solution": " for (const e of l)\n if (e >= t)\n return false;\n return true;\n}\n\n"}, {"buggy_solution": " return x + y;\n}\n\n"}, {"buggy_solution": " return JSON.stringify([...new Set(s0)].sort()) === JSON.stringify([...new Set(s1)].sort());\n}\n\n"}, {"buggy_solution": " if (n == 0)\n return 0;\n if (n == 1)\n return 1;\n return fib(n - 1) + fib(n - 2);\n}\n\n"}, {"buggy_solution": " var depth = 0;\n for (const b of brackets) {\n if (b == \"<\")\n depth += 1;\n else\n depth -= 1;\n if (depth < 0)\n return false;\n }\n return depth == 0;\n}\n\n"}, {"buggy_solution": " var sort1 = [...l].sort((a, b) => a - b);\n var sort2 = [...l].sort((a, b) => b - a);\n if (JSON.stringify(l) === JSON.stringify(sort1) ||\n JSON.stringify(l) === JSON.stringify(sort2))\n return true;\n return false;\n}\n\n"}, {"buggy_solution": " var ret = new Set();\n for (const e1 of l1)\n for (const e2 of l2)\n if (e1 == e2)\n ret.add(e1);\n return [...ret].sort();\n}\n\n"}, {"buggy_solution": " var isPrime = function (k) {\n if (k < 2)\n return false;\n for (let i = 2; i < k - 1; i++)\n if (k % i == 0)\n return false;\n return true;\n }\n\n var largest = 1;\n for (let j = 2; j < n + 1; j++)\n if (n % j == 0 && isPrime(j))\n largest = Math.max(largest, j);\n return largest;\n}\n\n"}, {"buggy_solution": " return n * (n + 1) / 2;\n}\n\n"}, {"buggy_solution": " var depth = 0;\n for (const b of brackets) {\n if (b == \"(\")\n depth += 1;\n else\n depth -= 1;\n if (depth < 0)\n return false;\n }\n return depth == 0;\n}\n\n"}, {"buggy_solution": " return xs.map((x, i) => x * i).slice(1);\n}\n\n"}, {"buggy_solution": " if (n == 0 || n == 1)\n return 0;\n if (n == 2)\n return 1;\n return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3);\n}\n\n"}, {"buggy_solution": " var vowels = \"aeiouAEIOU\";\n var n_vowels = s.split('').reduce((prev, item) => {\n return prev + (vowels.includes(item));\n }, 0);\n if (s.at(-1) == 'y' || s.at(-1) == 'Y')\n n_vowels += 1;\n return n_vowels;\n}\n\n"}, {"buggy_solution": " s = x.toString();\n if (shift > s.length)\n return s.split('').reverse().join('');\n else\n return s.slice(-shift) + s.slice(0, -shift);\n}\n\n"}, {"buggy_solution": " if (s == '') return 0;\n return s.split('').reduce((prev, char) => {\n let ord_char = char.charCodeAt(0)\n return prev + (ord_char > 64 && ord_char < 91 ? ord_char : 0);\n }, 0);\n}\n\n"}, {"buggy_solution": " var lis = [];\n for (const i of s.split(\" \"))\n if (!isNaN(i))\n lis.push(Number(i))\n return n - lis.reduce(((prev, item) => prev + item), 0);\n}\n\n"}, {"buggy_solution": " if (arr.length == 0) return [];\n var evens = arr.filter(x => x % 2 == 0);\n if (evens.length == 0) return [];\n return [Math.min(...evens), arr.indexOf(Math.min(...evens))];\n}\n\n"}, {"buggy_solution": " var frq = new Array(Math.max(...lst) + 1).fill(0);\n for (const i of lst)\n frq[i] += 1;\n var ans = -1;\n for (let i = 1; i < frq.length; i++)\n if (frq[i] >= i)\n ans = i;\n return ans;\n}\n\n"}, {"buggy_solution": " var res = [], sw = true;\n while (lst.length) {\n res.push(sw ? Math.min(...lst) : Math.max(...lst));\n lst.splice(lst.indexOf(res.at(-1)), 1);\n sw = !sw;\n }\n return res;\n}\n\n"}, {"buggy_solution": " if (a + b <= c || a + c <= b || b + c <= a)\n return -1;\n var s = (a + b + c) / 2;\n var area = Math.pow(s * (s - a) * (s - b) * (s - c), 0.5);\n area = area.toFixed(2);\n return area;\n}\n\n"}, {"buggy_solution": " if (q.reduce(((prev, item) => prev + item), 0) > w)\n return false;\n var i = 0, j = q.length - 1;\n while (i < j) {\n if (q[i] != q[j])\n return false;\n i++;\n j--;\n }\n return true;\n}\n\n"}, {"buggy_solution": " var ans = 0;\n for (let i = 0; i < Math.floor(arr.length / 2); i++)\n if (arr[i] != arr.at(-i - 1))\n ans++;\n return ans;\n}\n\n"}, {"buggy_solution": " var l1 = lst1.reduce(((prev, item) => prev + item.length), 0);\n var l2 = lst2.reduce(((prev, item) => prev + item.length), 0);\n if (l1 <= l2)\n return lst1;\n else\n return lst2;\n}\n\n"}, {"buggy_solution": " var isPrime = function (n) {\n for (let j = 2; j < n; j++)\n if (n % j == 0)\n return false;\n return true;\n }\n\n for (let i = 2; i < 101; i++) {\n if (!isPrime(i)) continue;\n for (let j = 2; j < 101; j++) {\n if (!isPrime(j)) continue;\n for (let k = 2; k < 101; k++) {\n if (!isPrime(k)) continue;\n if (i*j*k == a)\n return true;\n }\n }\n }\n return false;\n}\n\n"}, {"buggy_solution": " if (n == 1)\n return (x == 1);\n var power = 1;\n while (power < x)\n power = power * n;\n return (power == x);\n}\n\n"}, {"buggy_solution": " a = Math.abs(a);\n return (Math.pow(Math.round(Math.pow(a, 1.0 / 3.0)), 3) == a);\n}\n\n"}, {"buggy_solution": " var primes = \"2357BD\",\n total = 0;\n for (let i = 0; i < num.length; i++)\n if (primes.includes(num[i]))\n total++;\n return total;\n}\n\n"}, {"buggy_solution": " return \"db\" + decimal.toString(2) + \"db\";\n}\n\n"}, {"buggy_solution": " if (s.length < 3)\n return false;\n for (let i = 0; i < s.length - 2; i++)\n if (s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2])\n return false;\n return true;\n}\n\n"}, {"buggy_solution": " let letter_grade = []\n for (let i = 0, len = grades.length; i < len; i++) {\n let gpa = grades[i]\n if (gpa == 4.0) {\n letter_grade.push('A+')\n } else if (gpa > 3.7) {\n letter_grade.push('A')\n } else if (gpa > 3.3) {\n letter_grade.push('A-')\n } else if (gpa > 3.0) {\n letter_grade.push('B+')\n } else if (gpa > 2.7) {\n letter_grade.push('B')\n } else if (gpa > 2.3) {\n letter_grade.push('B-')\n } else if (gpa > 2.0) {\n letter_grade.push('C+')\n } else if (gpa > 1.7) {\n letter_grade.push('C')\n } else if (gpa > 1.3) {\n letter_grade.push('C-')\n } else if (gpa > 1.0) {\n letter_grade.push('D+')\n } else if (gpa > 0.7) {\n letter_grade.push('D')\n } else if (gpa > 0.0) {\n letter_grade.push('D-')\n } else {\n letter_grade.push('E')\n }\n }\n return letter_grade\n}\n\n"}, {"buggy_solution": " let len = string.length\n if (len == 1 || len == 0) { return false }\n for (let i = 2; i * i <= len; i++) {\n if (len % i == 0) { return false }\n }\n return true\n}\n\n"}, {"buggy_solution": " if (n == 1) { return 1 }\n let t = 18\n for (let i = 2; i < n; i++) {\n t = t * 10\n }\n return t\n}\n\n"}, {"buggy_solution": " let t = 0\n while (N > 0) {\n t += N % 10\n N = (N - N % 10) / 10\n }\n return t.toString(2)\n}\n\n"}, {"buggy_solution": " let t = 0\n for (let i = 1; i < lst.length; i += 2) {\n if (lst[i] % 2 == 0) {\n t += lst[i]\n }\n }\n return t\n}\n\n"}, {"buggy_solution": " let arr = s.split(/\\s/)\n for (let i = 0; i < arr.length; i++) {\n for (let j = 0; j < arr[i].length; j++) {\n let ind = j\n for (let k = j + 1; k < arr[i].length; k++) {\n if (arr[i][k].charCodeAt() < arr[i][ind].charCodeAt()) {\n ind = k\n }\n }\n if (ind > j) {\n arr[i] = arr[i].slice(0, j) + arr[i][ind] + arr[i].slice(j + 1, ind) + arr[i][j] + arr[i].slice(ind + 1, arr[i].length)\n }\n }\n }\n let t = ''\n for (let i = 0; i < arr.length; i++) {\n if (i > 0) {\n t = t + ' '\n }\n t = t + arr[i]\n }\n return t\n}\n\n"}, {"buggy_solution": " let t = []\n for (let i = 0; i < lst.length; i++) {\n for (let j = lst[i].length - 1; j >= 0; j--) {\n if (lst[i][j] == x) {\n t.push((i, j))\n }\n }\n }\n return t\n}\n\n"}, {"buggy_solution": " let arr = array\n let tot = arr[0] + arr[arr.length-1]\n for (let j = 0; j < arr.length; j++) {\n let ind = j\n for (let k = j + 1; k < arr.length; k++) {\n if ((tot % 2 == 1 && arr[k] < arr[ind]) || (tot % 2 == 0 && arr[k] > arr[ind])) {\n ind = k\n }\n }\n let tmp = arr[j]\n arr[j] = arr[ind]\n arr[ind] = tmp\n }\n return arr\n}\n\n"}, {"buggy_solution": " let t = ''\n for (let i = 0; i < s.length; i++) {\n let p = s[i].charCodeAt() + 4\n if (p > 122) { p -= 26 }\n t += String.fromCharCode(p)\n }\n return t\n}\n\n"}, {"buggy_solution": " let arr = lst\n for (let j = 0; j < arr.length; j++) {\n let ind = j\n for (let k = j + 1; k < arr.length; k++) {\n if (arr[k] < arr[ind]) {\n ind = k\n }\n }\n let tmp = arr[j]\n arr[j] = arr[ind]\n arr[ind] = tmp\n }\n let smallest = arr[0]\n let pt = 1\n while(pt<arr.length){\n if(arr[pt]>smallest){\n return arr[pt]\n }\n pt++\n }\n return null\n}\n\n"}, {"buggy_solution": " let t = 0\n if (S[0] == 'I' && S[1] == ' ') { t = 1 }\n for (let i = 0; i < S.length; i++) {\n if (S[i] == '.' || S[i] == '!' || S[i] == '?') {\n if (S[i + 1] == ' ' && S[i + 2] == 'I' && S[i + 3] == ' ') {\n t++\n }\n }\n }\n return t\n}\n\n"}, {"buggy_solution": " if (x % 1 === 0 && y % 1 === 0 && z % 1 === 0 && (x + y === z || x + z === y || x === y + z)) {\n return true\n }\n return false\n}\n\n"}, {"buggy_solution": " let t = ''\n for (let i = 0; i < message.length; i++) {\n let p = message[i].charCodeAt()\n if (p > 96) { p -= 32 }\n else if (p!=32 && p < 96) { p += 32 }\n if (p == 65 || p == 97 || p == 69 || p == 101 || p == 73 || p == 105 || p == 79 || p == 111 || p == 85 || p == 117) { p += 2 }\n t += String.fromCharCode(p)\n }\n return t\n}\n\n"}, {"buggy_solution": " let t = 0\n for (let i = 0; i < lst.length; i++) {\n let p = 1\n for (let j = 2; j * j <= lst[i]; j++) {\n if (lst[i] % j == 0) { p = 0; break }\n }\n if (p == 1 && lst[i] > t) { t = lst[i] }\n }\n let k = 0\n while (t != 0) {\n k += t % 10\n t = (t - t % 10) / 10\n }\n return k\n}\n\n"}, {"buggy_solution": " let c = 0\n let lo = 1\n let hi = 1\n for (let key in dict) {\n c++\n for (let i = 0; i < key.length; i++) {\n if (key[i].charCodeAt() < 65 || key[i].charCodeAt() > 90) { hi = 0 }\n if (key[i].charCodeAt() < 97 || key[i].charCodeAt() > 122) { lo = 0 }\n }\n }\n if ((lo == 0 && hi == 0) || c == 0) { return false }\n return true\n}\n\n"}, {"buggy_solution": " let t = []\n for (let i = 2; i < n; i++) {\n let p = 1\n for (let j = 2; j * j <= i; j++) {\n if (i % j == 0) { p = 0; break }\n }\n if (p == 1) { t.push(i) }\n }\n return t\n}\n\n"}, {"buggy_solution": " if (a < 0) { a = -a }\n if (b < 0) { b = -b }\n return (a % 10) * (b % 10)\n}\n\n"}, {"buggy_solution": " let p = 0\n for (let i = 0; i < s.length; i += 2) {\n if (s[i] == 'A' || s[i] == 'E' || s[i] == 'I' || s[i] == 'O' || s[i] == 'U') { p++ }\n }\n return p\n}\n\n"}, {"buggy_solution": " value = Number(value)\n let t = value % 1\n if (t < 0.5 && t > -0.5) { value -= t }\n else { value += t }\n return value\n}\n\n"}, {"buggy_solution": " let t = []\n for (let i = n; i < n * 3; i += 2) {\n t.push(i)\n }\n return t\n}\n\n"}, {"buggy_solution": " let t = ''\n let p = []\n let k = 0\n for (let i = 0; i < s.length; i++) {\n if (s[i] == ' ' || s[i] == ',') {\n if (k == 0) {\n k = 1;\n p.push(t);\n t = '';\n }\n }\n else {\n k = 0;\n t += s[i]\n }\n }\n if (t != '') {\n p.push(t);\n }\n return p\n}\n\n"}, {"buggy_solution": " for (let i = y; i >= x; i--) {\n if (i % 2 == 0) {return i }\n }\n return -1\n}\n\n"}, {"buggy_solution": " if (n > m) { return -1 }\n let k = (n + m) / 2\n if (k % 1 != 0) { k = (n + m + 1) / 2 }\n return '0b' + k.toString(2)\n}\n\n"}, {"buggy_solution": " let p = []\n for (let i = 0; i < x.length; i++) {\n let h = x[i]\n let boo = 1\n while (h > 0) {\n let r = h % 10\n if (r % 2 == 0) {\n boo = 0;\n break;\n }\n h = (h - r) / 10\n }\n if (boo) {\n p.push(x[i])\n }\n }\n for (let j = 0; j < p.length; j++) {\n let ind = j\n for (let k = j + 1; k < p.length; k++) {\n if (p[k] < p[ind]) {\n ind = k\n }\n }\n if (ind > j) {\n let tmp = p[j]\n p[j] = p[ind]\n p[ind] = tmp\n }\n }\n return p\n}\n\n"}, {"buggy_solution": " p = []\n for (let i = 0; i < arr.length; i++) {\n if (arr[i] > 0 && arr[i] < 10) { p.push(arr[i]) }\n }\n for (let j = 0; j < p.length; j++) {\n let ind = j\n for (let k = j + 1; k < p.length; k++) {\n if (p[k] > p[ind]) {\n ind = k\n }\n }\n if (ind > j) {\n let tmp = p[j]\n p[j] = p[ind]\n p[ind] = tmp\n }\n }\n let l = ['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine']\n let t = []\n for (let j = 0; j < p.length; j++) {\n t.push(l[p[j]-1])\n }\n return t\n}\n\n"}, {"buggy_solution": " let f = 1\n let p = 0\n let k = []\n for (let i = 1; i <= n; i++) {\n p += i;\n f *= i;\n if (i % 2 == 0) { k.push(f) }\n else { k.push(p) }\n }\n return k\n}\n\n"}, {"buggy_solution": " let e = 0\n let o = 0\n for (let i = 1; i <= n; i++) {\n let k = i.toString()\n let p = 1\n for (let j = 0; j < k.length; j++) {\n if (k[j] != k[k.length - j - 1]) {\n p = 0;\n break;\n }\n }\n if (p == 1) {\n if (k % 2 == 0) { e++ }\n else { o++ }\n }\n }\n return (e, o)\n}\n\n"}, {"buggy_solution": " let p = 0\n for (let i = 0; i < arr.length; i++) {\n let h = arr[i]\n if (h > 0) {\n p++;\n continue;\n }\n let k = 0\n h = -h\n while (h >= 10) {\n k += h % 10;\n h = (h - h % 10) / 10;\n }\n k -= h;\n if (k > 0) { p++ }\n }\n return p\n}\n\n"}, {"buggy_solution": " if (arr.length == 0) { return true }\n let k = 0\n let len = arr.length\n for (let i = 0; i < len; i++) {\n let t = 1;\n for (let j = 1; j < len; j++) {\n if (arr[j] < arr[j - 1]) {\n t = 0;\n break;\n }\n }\n if (t == 1) {\n k = 1;\n break;\n }\n arr.push(arr[0]);\n arr.shift()\n }\n if (k == 1) { return true }\n return false\n}\n\n"}, {"buggy_solution": " let k = lst1.length\n let t = 0\n for (let i = 0; i < lst1.length; i++) {\n if (lst1[i] % 2 == 0) { t++ }\n }\n for (let i = 0; i < lst2.length; i++) {\n if (lst2[i] % 2 == 0) { t++ }\n }\n if (t >= k) { return 'YES' }\n return 'NO'\n}\n\n"}, {"buggy_solution": " let d = {}\n let t = test.split(/\\s/)\n if (test == '') { t = [] }\n for (m in t) {\n if (t[m] in d) {\n d[t[m]]++\n }\n else {\n d[t[m]] = 1\n }\n }\n s = Object.keys(d).sort(function (a, b) { return - d[a] + d[b]; });\n if (s.length == 0) { return {} }\n let g = d[s[0]]\n let l = {}\n for (let ss=0; ss<s.length; ss++) {\n if (d[s[ss]] == g) {\n l[s[ss]] = d[s[ss]]\n }\n }\n return l\n}\n\n"}, {"buggy_solution": " let t = ''\n for (let i = 0; i < s.length; i++) {\n let y = 1\n for (let j = 0; j < c.length; j++) {\n if (s[i] == c[j]) {\n y = 0\n }\n }\n if (y == 1) {\n t += s[i]\n }\n }\n let z = 1\n for (let i = 0; i < t.length; i++) {\n if (t[i] != t[t.length - i - 1]) {\n z = 0\n }\n }\n if (z == 0) {\n return (z, false)\n }\n return (z, true)\n}\n\n"}, {"buggy_solution": " let d = []\n for (let i = 0; i < lst.length; i++) {\n let p = 0;\n let h = lst[i].length\n for (let j = 0; j < h; j++) {\n if (lst[i][j].charCodeAt() % 2 == 1) { p++ }\n }\n p = p.toString()\n d.push('the number of odd elements ' + p + 'n the str' + p + 'ng ' + p + ' of the ' + p + 'nput.')\n }\n return d\n}\n\n"}, {"buggy_solution": " let min = nums[0]\n for (let i = 0; i < nums.length; i++) {\n for (let j = i + 1; j <= nums.length; j++) {\n let s = 0;\n for (let k = i; k < j; k++) {\n s += nums[k]\n }\n if (s < min) { min = s }\n }\n }\n return min\n}\n\n"}, {"buggy_solution": " let p = 0\n for (let i = 0; i < grid.length; i++) {\n let m = 0\n for (let j = 0; j < grid[i].length; j++) {\n if (grid[i][j] == 1) { m++ }\n }\n while (m > 0) {\n m -= capacity;\n p++;\n }\n }\n return p\n}\n\n"}, {"buggy_solution": " let p = arr\n for (let j = 0; j < p.length; j++) {\n let ind = j\n for (let k = j + 1; k < p.length; k++) {\n let w1 = p[ind].toString(2)\n let f1 = 0\n for (let u = 0; u < w1.length; u++) {\n if (w1[u] == '1') { f1++ }\n }\n let w2 = p[k].toString(2)\n let f2 = 0\n for (let u = 0; u < w2.length; u++) {\n if (w2[u] == '1') { f2++ }\n }\n if (f2 < f1 || (f1 == f2 && p[k] < p[ind])) {\n ind = k\n }\n }\n if (ind > j) {\n let tmp = p[j]\n p[j] = p[ind]\n p[ind] = tmp\n }\n }\n return p\n}\n\n"}, {"buggy_solution": " let t = s.split(/\\s/)\n if (s == '') { return [] }\n let k = []\n for (let i = 0; i < t.length; i++) {\n let l = 0\n for (let j = 0; j < t[i].length; j++) {\n if (t[i][j] != 'a' && t[i][j] != 'e' && t[i][j] != 'i' && t[i][j] != 'o' && t[i][j] != 'u' && t[i][j] != 'A' &&\n t[i][j] != 'U' && t[i][j] != 'O' && t[i][j] != 'I' && t[i][j] != 'E') {\n l++\n }\n }\n if (l == n) { k.push(t[i]) }\n }\n return k\n}\n\n"}, {"buggy_solution": " for (let i = word.length - 2; i > 0; i--) {\n if (\n !(word[i] != 'a' && word[i] != 'e' && word[i] != 'i' && word[i] != 'o' && word[i] != 'u' && word[i] != 'A' &&\n word[i] != 'U' && word[i] != 'O' && word[i] != 'I' && word[i] != 'E')\n &&\n (word[i + 1] != 'a' && word[i + 1] != 'e' && word[i + 1] != 'i' && word[i + 1] != 'o' && word[i + 1] != 'u' && word[i + 1] != 'A' &&\n word[i + 1] != 'U' && word[i + 1] != 'O' && word[i + 1] != 'I' && word[i + 1] != 'E')\n &&\n (word[i - 1] != 'a' && word[i - 1] != 'e' && word[i - 1] != 'i' && word[i - 1] != 'o' && word[i - 1] != 'u' && word[i - 1] != 'A' &&\n word[i - 1] != 'U' && word[i - 1] != 'O' && word[i - 1] != 'I' && word[i - 1] != 'E')\n ) {\n return word[i]\n }\n }\n return ''\n}\n\n"}, {"buggy_solution": " let w1 = lst[0] + lst[1]\n let y = 0\n let u = 1\n for (let i = 0; i < w1.length; i++) {\n if (w1[i] == '(') { y++ }\n else { y-- }\n if (y < 0) {\n u = 0;\n break;\n }\n }\n if (u == 1 && y == 0) { return 'Yes' }\n w1 = lst[1] + lst[0]\n y = 0\n u = 1\n for (let i = 0; i < w1.length; i++) {\n if (w1[i] == '(') { y++ }\n else { y-- }\n if (y < 0) {\n u = 0;\n break;\n }\n }\n if (u == 1 && y == 0) { return 'Yes' }\n return 'No'\n}\n\n"}, {"buggy_solution": " let p = arr\n for (let j = 0; j < p.length; j++) {\n let ind = j\n for (let k = j + 1; k < p.length; k++) {\n if (p[k] < p[ind]) {\n ind = k\n }\n }\n if (ind > j) {\n let tmp = p[j]\n p[j] = p[ind]\n p[ind] = tmp\n }\n }\n if (k == 0) { return [] }\n return p.slice(-k)\n}\n\n"}, {"buggy_solution": " let p = 0\n for (let i = 0; i < lst.length; i += 2) {\n if (lst[i] % 2 == 1) {\n p += lst[i]\n }\n }\n return p\n}\n\n"}, {"buggy_solution": " let p = 0\n for (let i = 0; i < k; i++) {\n if (arr[i] < 100 && arr[i] > -100) { p += arr[i] }\n }\n return p\n}\n\n"}, {"buggy_solution": " let p = []\n let t = n\n while (1) {\n let u = 0\n for (let i = 0; i < p.length; i++) {\n if (t == p[i]) {\n u = 1\n break;\n }\n }\n if (u == 1) { break }\n if (t % 2 == 1) { p.push(t); t = 3 * t + 1 }\n else { t = t / 2 }\n }\n for (let j = 0; j < p.length; j++) {\n let ind = j\n for (let k = j + 1; k < p.length; k++) {\n if (p[k] < p[ind]) {\n ind = k\n }\n }\n if (ind > j) {\n let tmp = p[j]\n p[j] = p[ind]\n p[ind] = tmp\n }\n }\n return p\n}\n\n"}, {"buggy_solution": " let t = date.split(/-/)\n if (t.length != 3) { return false }\n if (t[0] < 1 || t[0] > 12 || t[1] < 1) { return false }\n if (t[0] == 2 && t[1] > 29) { return false }\n if ((t[0] == 1 || t[0] == 3 || t[0] == 5 || t[0] == 7 || t[0] == 8 || t[0] == 10 || t[0] == 12) && t[1] > 31) { return false }\n if ((t[0] == 4 || t[0] == 6 || t[0] == 9 || t[0] == 11) && t[1] > 30) { return false }\n return true\n}\n\n"}, {"buggy_solution": " let t = txt.split(/\\s/)\n if (t.length > 1) {\n return t\n } else {\n t = txt.split(/,/)\n if (t.length > 1) {\n return t\n } else {\n let p = 0\n for (let i = 0; i < txt.length; i++) {\n let m = txt[i].charCodeAt()\n if (m >= 97 && m <= 122 && m % 2 == 0) {\n p++\n }\n }\n return p\n }\n }\n}\n\n"}, {"buggy_solution": " if (lst.length == 0) { return true }\n let dup = 1\n let pre = lst[0]\n for (let i = 1; i < lst.length; i++) {\n if (lst[i] < pre) { return false }\n if (lst[i] == pre) {\n dup += 1;\n if (dup == 3) { return false }\n } else {\n pre = lst[i]\n dup = 1\n }\n }\n return true\n}\n\n"}, {"buggy_solution": " let lo = interval1[0]\n if (interval2[0] > lo) { lo = interval2[0] }\n let hi = interval1[1]\n if (interval2[1] < hi) { hi = interval2[1] }\n let len = 0\n if (hi > lo) { len = hi - lo }\n if (len == 1 || len == 0) { return 'NO' }\n for (let i = 2; i * i <= len; i++) {\n if (len % i == 0) { return 'NO' }\n }\n return 'YES'\n}\n\n"}, {"buggy_solution": " if (arr.length == 0) { return null }\n let n = 1\n let s = 0\n for (let i = 0; i < arr.length; i++) {\n s += arr[i]\n if (arr[i] == 0) { return 0 }\n if (arr[i] < 0) { n = -n; s -= 2 * arr[i] }\n }\n return s * n\n}\n\n"}, {"buggy_solution": " let m = 0\n let n = 0\n for (let i = 0; i < grid.length; i++) {\n for (let j = 0; j < grid.length; j++) {\n if (grid[i][j] == 1) {\n m = i;\n n = j;\n break;\n }\n }\n }\n let min = grid.length * grid.length\n if (m > 0 && grid[m - 1][n] < min) { min = grid[m - 1][n] }\n if (n > 0 && grid[m][n - 1] < min) { min = grid[m][n - 1] }\n if (m < grid.length - 1 && grid[m + 1][n] < min) { min = grid[m + 1][n] }\n if (n < grid.length - 1 && grid[m][n + 1] < min) { min = grid[m][n + 1] }\n let p = []\n for (let i = 0; i < k; i++) {\n if (i % 2 == 0) { p.push(1) }\n else { p.push(min) }\n }\n return p\n}\n\n"}, {"buggy_solution": " if (n == 0) { return [1] }\n if (n == 1) { return [1, 3] }\n let p = [1, 3]\n for (let i = 2; i <= n; i++) {\n if (i % 2 == 0) {\n p.push(1 + i / 2)\n }\n else {\n p.push(p[i - 2] + p[i - 1] + 1 + (i + 1) / 2)\n }\n }\n return p\n}\n\n"}, {"buggy_solution": " let p = 1\n let k = 1\n while (n > 0) {\n let y = n % 10\n if (y % 2 == 1) {\n p *= y; k = 0;\n }\n n = (n - n % 10) / 10\n }\n if (k == 0) { return p }\n return 0\n}\n\n"}, {"buggy_solution": " let opening_bracket_index = []\n let closing_bracket_index1 = []\n for (let i = 0; i < string.length; i++) {\n if (string[i] == '[') {\n opening_bracket_index.push(i)\n }\n else {\n closing_bracket_index1.push(i)\n }\n }\n let closing_bracket_index = []\n for (let i = 0; i < closing_bracket_index1.length; i++) {\n closing_bracket_index.push(closing_bracket_index1[closing_bracket_index1.length - i - 1])\n }\n let cnt = 0\n let i = 0\n let l = closing_bracket_index.length\n for (let k = 0; k < opening_bracket_index.length; k++) {\n if (i < l && opening_bracket_index[k] < closing_bracket_index[i]) {\n cnt += 1;\n i += 1;\n }\n }\n return cnt >= 2\n}\n\n"}, {"buggy_solution": " let p = 0\n for (let i = 0; i < lst.length; i++) {\n let y = lst[i]\n if (y % 1 != 0) {\n if (y > 0) { y = y - y % 1 + 1 }\n else { y = -y; y = y - y % 1 }\n }\n p += y * y\n }\n return p\n}\n\n"}, {"buggy_solution": " let len = txt.length\n if (len == 0) { return false }\n let y = txt[len - 1].charCodeAt()\n if (len == 1) {\n if ((y >= 65 && y <= 90) || (y >= 97 && y <= 122)) { return true }\n return false\n }\n if (txt[len - 2] == ' ' && ((y >= 65 && y <= 90) || (y >= 97 && y <= 122))) { return true }\n return false\n}\n\n"}, {"buggy_solution": " if (arr.length == 0) { return -1 }\n for (let i = arr.length - 1; i > 0; i--) {\n if (arr[i] < arr[i - 1]) { return i }\n }\n return -1\n}\n\n"}, {"buggy_solution": " let a = Infinity\n let b = -Infinity\n for (let i = 0; i < lst.length; i++) {\n if (lst[i] > 0 && lst[i] < a) { a = lst[i] }\n if (lst[i] < 0 && lst[i] > b) { b = lst[i] }\n }\n if (a == Infinity) { a = null }\n if (b == -Infinity) { b = null }\n return (b, a)\n}\n\n"}, {"buggy_solution": " let aa = Number(a)\n if (typeof a == 'string') { aa = Number(a.replace(',', '.')) }\n let bb = Number(b)\n if (typeof b == 'string') { bb = Number(b.replace(',', '.')) }\n if (aa > bb) { return a }\n if (aa < bb) { return b }\n return null\n}\n\n"}, {"buggy_solution": " return (n >= 8 && n % 2 == 0)\n}\n\n"}, {"buggy_solution": " let p = 1;\n let t = 1;\n while (n > 1) {\n let y = p;\n while (y > 0) {\n y--;\n t *= n;\n }\n p++;\n n--;\n }\n return t\n}\n\n"}, {"buggy_solution": " let t = ''\n let c = 0\n for (let i = 0; i < text.length; i++) {\n if (text[i] == ' ') { c++ }\n else if (c > 0) {\n if (c == 1) { t += '_' }\n if (c == 2) { t += '__' }\n if (c > 2) { t += '-' }\n t += text[i]\n c = 0;\n } else {\n t += text[i]\n }\n }\n if (c == 1) { t += '_' }\n if (c == 2) { t += '__' }\n if (c > 2) { t += '-' }\n return t\n}\n\n"}, {"buggy_solution": " let t = file_name.split(/\\./)\n if (t.length != 2) { return 'No' }\n if (t[1] != 'txt' && t[1] != 'dll' && t[1] != 'exe') { return 'No' }\n if (t[0] == '') { return 'No' }\n let a = t[0][0].charCodeAt()\n if (!((a >= 65 && a <= 90) || (a >= 97 && a <= 122))) { return 'No' }\n let y = 0\n for (let i = 1; i < t[0].length; i++) {\n if (t[0][i].charCodeAt() >= 48 && t[0][i].charCodeAt() <= 57) { y++ }\n if (y > 3) { return 'No' }\n }\n return 'Yes'\n}\n\n"}, {"buggy_solution": " let y = 0\n for (let i = 0; i < lst.length; i++) {\n if (i % 3 == 0) { y += lst[i] * lst[i] }\n else if (i % 4 == 0) { y += lst[i] * lst[i] * lst[i] }\n else { y += lst[i] }\n }\n return y\n}\n\n"}, {"buggy_solution": " let t = sentence.split(/\\s/)\n let p = ''\n for (let j = 0; j < t.length; j++) {\n let len = t[j].length;\n let u = 1\n if (len == 1 || len == 0) { continue }\n for (let i = 2; i * i <= len; i++) {\n if (len % i == 0) { u = 0 }\n }\n if (u == 0) { continue }\n if (p == '') { p += t[j] }\n else { p = p + ' ' + t[j] }\n }\n return p\n}\n\n"}, {"buggy_solution": " let a = x.split(/\\//)\n let b = n.split(/\\//)\n let m = Number(a[0]) * Number(b[0])\n let r = Number(a[1]) * Number(b[1])\n return m % r == 0\n}\n\n"}, {"buggy_solution": " let p = nums\n for (let j = p.length - 2; j >= 0; j--) {\n for (let k = 0; k <= j; k++) {\n let m = 0\n let n = 0\n let h = p[k]\n let d = p[k + 1]\n let y = 1\n let u = 1\n if (h < 0) { y = -1; h = -h; }\n if (d < 0) { u = -1; d = -d; }\n while (h >= 10) {\n m += h % 10;\n h = (h - h % 10) / 10;\n }\n m += y * h\n while (d >= 10) {\n n += d % 10;\n d = (d - d % 10) / 10;\n }\n n += u * d\n if (m > n) {\n let tmp = p[k]\n p[k] = p[k + 1]\n p[k + 1] = tmp\n }\n }\n }\n return p\n}\n\n"}, {"buggy_solution": " let p = 0\n for (let i = 0; i < nums.length; i++) {\n if (nums[i] < 10) { continue }\n let y = nums[i].toString()\n if (Number(y[0]) % 2 == 1 && Number(y[y.length - 1]) % 2 == 1) {\n p++\n }\n }\n return p\n}\n\n"}, {"buggy_solution": " let y = []\n for (let i = 1; i <= n; i++) {\n y.push(i * i - i + 1)\n }\n let u = 0\n for (let i = 0; i < n - 2; i++) {\n for (let j = i + 1; j < n - 1; j++) {\n for (let k = j + 1; k < n; k++) {\n if ((y[i] + y[j] + y[k]) % 3 == 0) { u++ }\n }\n }\n }\n return u\n}\n\n"}, {"buggy_solution": " let y = ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune']\n let u = []\n let lo = -1\n let hi = -1\n for (let i = 0; i < 8; i++) {\n if (y[i] == planet1) { lo = i }\n }\n for (let i = 0; i < 8; i++) {\n if (y[i] == planet2) { hi = i }\n }\n if (lo == -1 || hi == -1 || lo == hi) { return [] }\n if (lo > hi) {\n let tmp = lo;\n lo = hi;\n hi = tmp;\n }\n for (let i = lo + 1; i < hi; i++) {\n u.push(y[i])\n }\n return u\n}\n\n"}, {"buggy_solution": " let p = []\n for (let i = 0; i < lst.length; i++) {\n if (lst[i].length % 2 == 0) {\n p.push(lst[i])\n }\n }\n for (let j = p.length - 2; j >= 0; j--) {\n for (let k = 0; k <= j; k++) {\n let f = 0\n if (p[k].length > p[k + 1].length) { f = 1 }\n if (p[k].length == p[k + 1].length) {\n let r = p[k].length\n for (let l = 0; l < r; l++) {\n if (p[k][l].charCodeAt() > p[k + 1][l].charCodeAt()) {\n f = 1;\n break;\n }\n if (p[k][l].charCodeAt() < p[k + 1][l].charCodeAt()) {\n break;\n }\n }\n }\n if (f == 1) {\n let tmp = p[k]\n p[k] = p[k + 1]\n p[k + 1] = tmp\n }\n }\n }\n return p\n}\n\n"}, {"buggy_solution": " let len = n\n if (len == 1 || len == 0) { return y }\n for (let i = 2; i * i <= len; i++) {\n if (len % i == 0) { return y }\n }\n return x\n}\n\n"}, {"buggy_solution": " let p = 0\n for (let i = 0; i < lst.length; i++) {\n if (lst[i] % 2 == 1 && lst[i] > 0) {\n p += lst[i] * lst[i]\n }\n }\n return p\n}\n\n"}, {"buggy_solution": " for (let i = 0; i < guess.length; i++) {\n game[i] -= guess[i]\n if (game[i]<0)\n game[i]=-game[i]; }\n return game\n}\n\n"}, {"buggy_solution": " let u = 0\n let s = -Infinity\n for (let i = extensions.length - 1; i >= 0; i--) {\n let y = 0\n for (let j = 0; j < extensions[i].length; j++) {\n let k = extensions[i][j].charCodeAt()\n if (k >= 65 && k <= 90) { y += 1 }\n if (k >= 97 && k <= 122) { y -= 1 }\n }\n if (y >= s) {\n s = y;\n u = i;\n }\n }\n return class_name + '.' + extensions[u]\n}\n\n"}, {"buggy_solution": " let l = b.length\n let pat = b + b\n for (let i = 0; i < a.length - l + 1; i++) {\n for (let j = 0; j < l + 1; j++) {\n let y = 1\n for (let k = 0; k < l; k++) {\n if (a[i + k] != pat[j + k]) { y = 0 }\n }\n if (y == 1) {\n return true\n }\n }\n }\n return false\n}\n\n"}, {"buggy_solution": " let o = 0\n let e = 0\n if (num < 0) { num = -num }\n while (num > 0) {\n if (num % 2 == 0) { e++ }\n else { o++ }\n num = (num - num % 10) / 10\n }\n return (e, o)\n}\n\n"}, {"buggy_solution": " let num = [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000]\n let sym = ['i', 'iv', 'v', 'ix', 'x', 'xl', 'l', 'xc', 'c', 'cd', 'd', 'cm', 'm']\n let i = 12\n let res = ''\n while (number) {\n let div = (number - number % num[i]) / num[i]\n number = number % num[i]\n while (div) {\n res += sym[i]\n div -= 1\n }\n i -= 1\n }\n return res\n}\n\n"}, {"buggy_solution": " return (a * a + b * b == c * c || a * a == b * b + c * c || b * b == a * a + c * c)\n}\n\n"}, {"buggy_solution": " let s = -1\n let u = -1\n if (words.length == 0) { return '' }\n for (let i = 0; i < words.length; i++) {\n let p = 0\n for (let j = 0; j < words[i].length; j++) {\n let y = 1\n for (let k = 0; k < j; k++) {\n if (words[i][j] == words[i][k]) { y = 0 }\n }\n if (y == 1) { p++ }\n }\n if (p > s || (p == s && words[i] < words[u])) {\n u = i;\n s = p;\n }\n }\n return words[u]\n}\n\n"}, {"buggy_solution": " if (need <= remaining) {\n return [need + number, remaining - need]\n }\n return [remaining + number, 0]\n}\n\n"}, {"buggy_solution": " while (operator.length > 0) {\n let y = 0\n for (let i = operator.length - 1; i >= 0; i--) {\n if (operator[i] == '**') {\n let u = operand[i]\n while (operand[i + 1] > 1) {\n operand[i + 1]--;\n operand[i] *= u;\n }\n operand.splice(i + 1, 1)\n operator.splice(i, 1)\n y = 1;\n break;\n }\n }\n if (y == 1) { continue }\n for (let i = 0; i < operator.length; i++) {\n if (operator[i] == '*') {\n operand[i] *= operand[i + 1]\n operand.splice(i + 1, 1)\n operator.splice(i, 1)\n y = 1;\n break;\n }\n else if (operator[i] == '//') {\n operand[i] = (operand[i] - operand[i] % operand[i + 1]) / operand[i + 1]\n operand.splice(i + 1, 1)\n operator.splice(i, 1)\n y = 1;\n break;\n }\n }\n if (y == 1) { continue }\n for (let i = 0; i < operator.length; i++) {\n if (operator[i] == '+') {\n operand[i] += operand[i + 1]\n operand.splice(i + 1, 1)\n operator.splice(i, 1)\n y = 1;\n break;\n }\n else if (operator[i] == '-') {\n operand[i] -= operand[i + 1]\n operand.splice(i + 1, 1)\n operator.splice(i, 1)\n y = 1;\n break;\n }\n }\n if (y == 1) { continue }\n }\n return operand[0]\n}\n\n"}, {"buggy_solution": " let t = 0\n let p = ''\n for (let i = 0; i < s.length; i++) {\n let y = s[i].charCodeAt()\n if (y >= 65 && y <= 90) {\n y += 32;\n t = 1;\n } else if (y >= 97 && y <= 122) {\n y -= 32;\n t = 1;\n }\n p += String.fromCharCode(y)\n }\n if (t == 1) { return p }\n let u = ''\n for (let i = 0; i < p.length; i++) {\n u += p[p.length - i - 1]\n }\n return u\n}\n\n"}, {"buggy_solution": " if (text == '') { return null }\n var md5 = require('js-md5')\n return md5(text)\n}\n\n"}, {"buggy_solution": " if (a > b) {\n let tmp = a;\n a = b;\n b = tmp;\n }\n let y = []\n for (let i = a; i <= b; i++) {\n if (i == 2 || i == 4 || i == 6 || i == 8) { y.push(i) }\n }\n return y\n}\n\n"}]
data/python/data/.DS_Store ADDED
Binary file (6.15 kB). View file
 
data/python/data/humaneval.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/python/data/humanevalbugs.json ADDED
@@ -0,0 +1 @@
 
 
1
+ [{"buggy_solution": " for idx, elem in enumerate(numbers):\n for idx2, elem2 in enumerate(numbers):\n if idx != idx2:\n distance = abs(elem - elem2)\n if distance < threshold:\n return True\n\n return False\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " result = []\n current_string = []\n current_depth = 0\n\n for c in paren_string:\n if c == '(':\n current_depth += 1\n current_string.append(c)\n elif c == ')':\n current_depth -= 1\n current_string.append(c)\n\n if current_depth == 0:\n result.append(''.join(current_string))\n current_string.clear()\n\n return result\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return number % 1.0\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " balance = 0\n\n for op in operations:\n balance += op\n if balance < 0:\n return True\n\n return False\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " mean = sum(numbers) / len(numbers)\n return sum(abs(x - mean) for x in numbers) / len(numbers)\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if not numbers:\n return []\n\n result = []\n\n for n in numbers[:-1]:\n result.append(n)\n result.append(delimeter)\n\n result.append(numbers[-1])\n\n return result\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " def parse_paren_group(s):\n depth = 0\n max_depth = 0\n for c in s:\n if c == '(':\n depth += 1\n max_depth = max(depth, max_depth)\n else:\n depth -= 1\n\n return max_depth\n\n return [parse_paren_group(x) for x in paren_string.split(' ') if x]\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return [x for x in strings if substring in x]\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " sum_value = 0\n prod_value = 1\n\n for n in numbers:\n sum_value += n\n prod_value *= n\n return sum_value, prod_value\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " running_max = None\n result = []\n\n for n in numbers:\n if running_max is None:\n running_max = n\n else:\n running_max = max(running_max, n)\n\n result.append(running_max)\n\n return result\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if not string:\n return ''\n\n beginning_of_suffix = 0\n\n while not is_palindrome(string[beginning_of_suffix:]):\n beginning_of_suffix += 1\n\n return string + string[:beginning_of_suffix][::-1]\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " def xor(i, j):\n if i == j:\n return '0'\n else:\n return '1'\n\n return ''.join(xor(x, y) for x, y in zip(a, b))\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if not strings:\n return None\n\n maxlen = max(len(x) for x in strings)\n for s in strings:\n if len(s) == maxlen:\n return s\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " while b:\n a, b = b, a % b\n return a\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " result = []\n\n for i in range(len(string)):\n result.append(string[:i+1])\n return result\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return ' '.join([str(x) for x in range(n + 1)])\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return len(set(string.lower()))\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " note_map = {'o': 4, 'o|': 2, '.|': 1}\n return [note_map[x] for x in music_string.split(' ') if x]\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " times = 0\n\n for i in range(len(string) - len(substring) + 1):\n if string[i:i+len(substring)] == substring:\n times += 1\n\n return times\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " value_map = {\n 'zero': 0,\n 'one': 1,\n 'two': 2,\n 'three': 3,\n 'four': 4,\n 'five': 5,\n 'six': 6,\n 'seven': 7,\n 'eight': 8,\n 'nine': 9\n }\n return ' '.join(sorted([x for x in numbers.split(' ') if x], key=lambda x: value_map[x]))\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " closest_pair = None\n distance = None\n\n for idx, elem in enumerate(numbers):\n for idx2, elem2 in enumerate(numbers):\n if idx != idx2:\n if distance is None:\n distance = abs(elem - elem2)\n closest_pair = tuple(sorted([elem, elem2]))\n else:\n new_distance = abs(elem - elem2)\n if new_distance < distance:\n distance = new_distance\n closest_pair = tuple(sorted([elem, elem2]))\n\n return closest_pair\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " min_number = min(numbers)\n max_number = max(numbers)\n return [(x - min_number) / (max_number - min_number) for x in numbers]\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return [x for x in values if isinstance(x, int)]\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return len(string)\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " for i in reversed(range(n)):\n if n % i == 0:\n return i\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " import math\n fact = []\n i = 2\n while i <= int(math.sqrt(n) + 1):\n if n % i == 0:\n fact.append(i)\n n //= i\n else:\n i += 1\n\n if n > 1:\n fact.append(n)\n return fact\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " import collections\n c = collections.Counter(numbers)\n return [n for n in numbers if c[n] <= 1]\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return string.swapcase()\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return ''.join(strings)\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return [x for x in strings if x.startswith(prefix)]\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return [e for e in l if e > 0]\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if n < 2:\n return False\n for k in range(2, n - 1):\n if n % k == 0:\n return False\n return True\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " begin, end = -1., 1.\n while poly(xs, begin) * poly(xs, end) > 0:\n begin *= 2.0\n end *= 2.0\n while end - begin > 1e-10:\n center = (begin + end) / 2.0\n if poly(xs, center) * poly(xs, begin) > 0:\n begin = center\n else:\n end = center\n return begin\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " l = list(l)\n l[::3] = sorted(l[::3])\n return l\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return sorted(list(set(l)))\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " m = l[0]\n for e in l:\n if e > m:\n m = e\n return m\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " ns = []\n for i in range(n):\n if i % 11 == 0 or i % 13 == 0:\n ns.append(i)\n s = ''.join(list(map(str, ns)))\n ans = 0\n for c in s:\n ans += (c == '7')\n return ans\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " evens = l[::2]\n odds = l[1::2]\n evens.sort()\n ans = []\n for e, o in zip(evens, odds):\n ans.extend([e, o])\n if len(evens) > len(odds):\n ans.append(evens[-1])\n return ans\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return encode_cyclic(encode_cyclic(s))\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " import math\n\n def is_prime(p):\n if p < 2:\n return False\n for k in range(2, min(int(math.sqrt(p)) + 1, p - 1)):\n if p % k == 0:\n return False\n return True\n f = [0, 1]\n while True:\n f.append(f[-1] + f[-2])\n if is_prime(f[-1]):\n n -= 1\n if n == 0:\n return f[-1]\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " for i in range(len(l)):\n for j in range(i + 1, len(l)):\n for k in range(j + 1, len(l)):\n if l[i] + l[j] + l[k] == 0:\n return True\n return False\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return n**2\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return [(e + 1) for e in l]\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " for i, l1 in enumerate(l):\n for j in range(i + 1, len(l)):\n if l1 + l[j] == 0:\n return True\n return False\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " ret = \"\"\n while x > 0:\n ret = str(x % base) + ret\n x //= base\n return ret\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return a * h / 2.0\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " results = [0, 0, 2, 0]\n if n < 4:\n return results[n]\n\n for _ in range(4, n + 1):\n results.append(results[-1] + results[-2] + results[-3] + results[-4])\n results.pop(0)\n\n return results[-1]\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " l = sorted(l)\n if len(l) % 2 == 1:\n return l[len(l) // 2]\n else:\n return (l[len(l) // 2 - 1] + l[len(l) // 2]) / 2.0\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " for i in range(len(text)):\n if text[i] != text[len(text) - 1 - i]:\n return False\n return True\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " ret = 1\n for i in range(n):\n ret = (2 * ret) % p\n return ret\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return \"\".join([chr(((ord(ch) - 5 - ord(\"a\")) % 26) + ord(\"a\")) for ch in s])\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return \"\".join([s for s in text if s.lower() not in [\"a\", \"e\", \"i\", \"o\", \"u\"]])\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " for e in l:\n if e >= t:\n return False\n return True\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return x + y\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return set(s0) == set(s1)\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if n == 0:\n return 0\n if n == 1:\n return 1\n return fib(n - 1) + fib(n - 2)\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " depth = 0\n for b in brackets:\n if b == \"<\":\n depth += 1\n else:\n depth -= 1\n if depth < 0:\n return False\n return depth == 0\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if l == sorted(l) or l == sorted(l, reverse=True):\n return True\n return False\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " ret = set()\n for e1 in l1:\n for e2 in l2:\n if e1 == e2:\n ret.add(e1)\n return sorted(list(ret))\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " def is_prime(k):\n if k < 2:\n return False\n for i in range(2, k - 1):\n if k % i == 0:\n return False\n return True\n largest = 1\n for j in range(2, n + 1):\n if n % j == 0 and is_prime(j):\n largest = max(largest, j)\n return largest\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return sum(range(n + 1))\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " depth = 0\n for b in brackets:\n if b == \"(\":\n depth += 1\n else:\n depth -= 1\n if depth < 0:\n return False\n return depth == 0\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return [(i * x) for i, x in enumerate(xs)][1:]\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if n == 0:\n return 0\n if n == 1:\n return 0\n if n == 2:\n return 1\n return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " vowels = \"aeiouAEIOU\"\n n_vowels = sum(c in vowels for c in s)\n if s[-1] == 'y' or s[-1] == 'Y':\n n_vowels += 1\n return n_vowels\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " s = str(x)\n if shift > len(s):\n return s[::-1]\n else:\n return s[len(s) - shift:] + s[:len(s) - shift]\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if s == \"\": return 0\n return sum(ord(char) if char.isupper() else 0 for char in s)\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " lis = list()\n for i in s.split(' '):\n if i.isdigit():\n lis.append(int(i))\n return n - sum(lis)\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if(len(arr) == 0): return []\n evens = list(filter(lambda x: x%2 == 0, arr))\n if(evens == []): return []\n return [min(evens), arr.index(min(evens))]\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " frq = [0] * (max(lst) + 1)\n for i in lst:\n frq[i] += 1;\n\n ans = -1\n for i in range(1, len(frq)):\n if frq[i] >= i:\n ans = i\n \n return ans\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " res, switch = [], True\n while lst:\n res.append(min(lst) if switch else max(lst))\n lst.remove(res[-1])\n switch = not switch\n return res\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if a + b <= c or a + c <= b or b + c <= a:\n return -1 \n s = (a + b + c)/2 \n area = (s * (s - a) * (s - b) * (s - c)) ** 0.5\n area = round(area, 2)\n return area\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if sum(q) > w:\n return False\n\n i, j = 0, len(q)-1\n while i<j:\n if q[i] != q[j]:\n return False\n i+=1\n j-=1\n return True\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " ans = 0\n for i in range(len(arr) // 2):\n if arr[i] != arr[len(arr) - i - 1]:\n ans += 1\n return ans\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " l1 = 0\n for st in lst1:\n l1 += len(st)\n \n l2 = 0\n for st in lst2:\n l2 += len(st)\n \n if l1 <= l2:\n return lst1\n else:\n return lst2\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " def is_prime(n):\n for j in range(2,n):\n if n%j == 0:\n return False\n return True\n\n for i in range(2,101):\n if not is_prime(i): continue\n for j in range(2,101):\n if not is_prime(j): continue\n for k in range(2,101):\n if not is_prime(k): continue\n if i*j*k == a: return True\n return False\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if (n == 1): \n return (x == 1) \n power = 1\n while (power < x): \n power = power * n \n return (power == x) \n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " a = abs(a)\n return int(round(a ** (1. / 3))) ** 3 == a\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " primes = ('2', '3', '5', '7', 'B', 'D')\n total = 0\n for i in range(0, len(num)):\n if num[i] in primes:\n total += 1\n return total\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return \"db\" + bin(decimal)[2:] + \"db\"\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if len(s) < 3:\n return False\n\n for i in range(len(s) - 2):\n \n if s[i] == s[i+1] or s[i+1] == s[i+2] or s[i] == s[i+2]:\n return False\n return True\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": "\n \n letter_grade = []\n for gpa in grades:\n if gpa == 4.0:\n letter_grade.append(\"A+\")\n elif gpa > 3.7:\n letter_grade.append(\"A\")\n elif gpa > 3.3:\n letter_grade.append(\"A-\")\n elif gpa > 3.0:\n letter_grade.append(\"B+\")\n elif gpa > 2.7:\n letter_grade.append(\"B\")\n elif gpa > 2.3:\n letter_grade.append(\"B-\")\n elif gpa > 2.0:\n letter_grade.append(\"C+\")\n elif gpa > 1.7:\n letter_grade.append(\"C\")\n elif gpa > 1.3:\n letter_grade.append(\"C-\")\n elif gpa > 1.0:\n letter_grade.append(\"D+\")\n elif gpa > 0.7:\n letter_grade.append(\"D\")\n elif gpa > 0.0:\n letter_grade.append(\"D-\")\n else:\n letter_grade.append(\"E\")\n return letter_grade\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " l = len(string)\n if l == 0 or l == 1:\n return False\n for i in range(2, l):\n if l % i == 0:\n return False\n return True\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if n == 1: return 1\n return 18 * (10 ** (n - 2))\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return bin(sum(int(i) for i in str(N)))[2:]\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return sum([lst[i] for i in range(1, len(lst), 2) if lst[i]%2 == 0])\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return ' '.join([''.join(sorted(list(i))) for i in s.split(' ')])\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " coords = [(i, j) for i in range(len(lst)) for j in range(len(lst[i])) if lst[i][j] == x]\n return sorted(sorted(coords, key=lambda x: x[1], reverse=True), key=lambda x: x[0])\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return [] if len(array) == 0 else sorted(array, reverse= (array[0]+array[-1]) % 2 == 0) \n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " d = 'abcdefghijklmnopqrstuvwxyz'\n out = ''\n for c in s:\n if c in d:\n out += d[(d.index(c)+2*2) % 26]\n else:\n out += c\n return out\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " lst = sorted(set(lst))\n return None if len(lst) < 2 else lst[1]\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " import re\n sentences = re.split(r'[.?!]\\s*', S)\n return sum(sentence[0:2] == 'I ' for sentence in sentences)\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " \n if isinstance(x,int) and isinstance(y,int) and isinstance(z,int):\n if (x+y==z) or (x+z==y) or (y+z==x):\n return True\n return False\n return False\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " vowels = \"aeiouAEIOU\"\n vowels_replace = dict([(i, chr(ord(i) + 2)) for i in vowels])\n message = message.swapcase()\n return ''.join([vowels_replace[i] if i in vowels else i for i in message])\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " def isPrime(n):\n for i in range(2,int(n**0.5)+1):\n if n%i==0:\n return False\n\n return True\n maxx = 0\n i = 0\n while i < len(lst):\n if(lst[i] > maxx and isPrime(lst[i])):\n maxx = lst[i]\n i+=1\n result = sum(int(digit) for digit in str(maxx))\n return result\n\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if len(dict.keys()) == 0:\n return False\n else:\n state = \"start\"\n for key in dict.keys():\n\n if isinstance(key, str) == False:\n state = \"mixed\"\n break\n if state == \"start\":\n if key.isupper():\n state = \"upper\"\n elif key.islower():\n state = \"lower\"\n else:\n break\n elif (state == \"upper\" and not key.isupper()) or (state == \"lower\" and not key.islower()):\n state = \"mixed\"\n break\n else:\n break\n return state == \"upper\" or state == \"lower\" \n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " primes = []\n for i in range(2, n):\n is_prime = True\n for j in range(2, i):\n if i % j == 0:\n is_prime = False\n break\n if is_prime:\n primes.append(i)\n return primes\n\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return abs(a % 10) * abs(b % 10)\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " count = 0\n for i in range(0,len(s),2):\n if s[i] in \"AEIOU\":\n count += 1\n return count\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " from math import floor, ceil\n\n if value.count('.') == 1:\n # remove trailing zeros\n while (value[-1] == '0'):\n value = value[:-1]\n\n num = float(value)\n if value[-2:] == '.5':\n if num > 0:\n res = ceil(num)\n else:\n res = floor(num)\n elif len(value) > 0:\n res = int(round(num))\n else:\n res = 0\n\n return res\n\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return [n + 2*i for i in range(n)]\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if not s:\n return []\n\n s_list = []\n\n for letter in s:\n if letter == ',':\n s_list.append(' ')\n else:\n s_list.append(letter)\n\n s_list = \"\".join(s_list)\n return s_list.split()\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if x > y:\n return -1\n if y % 2 == 0:\n return y\n if x == y:\n return -1\n return y - 1\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if m < n:\n return -1\n summation = 0\n for i in range(n, m+1):\n summation += i\n return bin(round(summation/(m - n + 1)))\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " odd_digit_elements = []\n for i in x:\n if all (int(c) % 2 == 1 for c in str(i)):\n odd_digit_elements.append(i)\n return sorted(odd_digit_elements)\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " dic = {\n 1: \"One\",\n 2: \"Two\",\n 3: \"Three\",\n 4: \"Four\",\n 5: \"Five\",\n 6: \"Six\",\n 7: \"Seven\",\n 8: \"Eight\",\n 9: \"Nine\",\n }\n sorted_arr = sorted(arr, reverse=True)\n new_arr = []\n for var in sorted_arr:\n try:\n new_arr.append(dic[var])\n except:\n pass\n return new_arr\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " ret = []\n for i in range(1,n+1):\n if i%2 == 0:\n x = 1\n for j in range(1,i+1): x *= j\n ret += [x]\n else:\n x = 0\n for j in range(1,i+1): x += j\n ret += [x]\n return ret\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " def is_palindrome(n):\n return str(n) == str(n)[::-1]\n\n even_palindrome_count = 0\n odd_palindrome_count = 0\n\n for i in range(1, n+1):\n if i%2 == 1 and is_palindrome(i):\n odd_palindrome_count += 1\n elif i%2 == 0 and is_palindrome(i):\n even_palindrome_count += 1\n return (even_palindrome_count, odd_palindrome_count)\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " def digits_sum(n):\n neg = 1\n if n < 0: n, neg = -1 * n, -1 \n n = [int(i) for i in str(n)]\n n[0] = n[0] * neg\n return sum(n)\n return len(list(filter(lambda x: x > 0, [digits_sum(i) for i in arr])))\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if len(arr)==0:\n return True\n sorted_array=sorted(arr)\n my_arr=[]\n \n min_value=min(arr)\n min_index=arr.index(min_value)\n my_arr=arr[min_index:]+arr[0:min_index]\n for i in range(len(arr)):\n if my_arr[i]!=sorted_array[i]:\n return False\n return True\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " odd = 0\n even = 0\n for i in lst1:\n if i%2 == 1:\n odd += 1\n for i in lst2:\n if i%2 == 0:\n even += 1\n if even >= odd:\n return \"YES\"\n return \"NO\"\n \n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " dict1={}\n list1=test.split(\" \")\n t=0\n\n for i in list1:\n if(list1.count(i)>t) and i!='':\n t=list1.count(i)\n if t>0:\n for i in list1:\n if(list1.count(i)==t):\n \n dict1[i]=t\n return dict1\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " s = ''.join([char for char in s if char not in c])\n return (s,s[::-1] == s)\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " res = []\n for arr in lst:\n n = sum(int(d)%2==1 for d in arr)\n res.append(\"the number of odd elements \" + str(n) + \"n the str\"+ str(n) +\"ng \"+ str(n) +\" of the \"+ str(n) +\"nput.\")\n return res\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " max_sum = 0\n s = 0\n for num in nums:\n s += -num\n if (s < 0):\n s = 0\n max_sum = max(s, max_sum)\n if max_sum == 0:\n max_sum = max(-i for i in nums)\n min_sum = -max_sum\n return min_sum\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return sum([math.ceil(sum(arr)/capacity) for arr in grid])\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return sorted(sorted(arr), key=lambda x: bin(x)[2:].count('1'))\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " result = []\n for word in s.split():\n n_consonants = 0\n for i in range(0, len(word)):\n if word[i].lower() not in [\"a\",\"e\",\"i\",\"o\",\"u\"]:\n n_consonants += 1 \n if n_consonants == n:\n result.append(word)\n return result\n\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if len(word) < 3:\n return \"\"\n\n vowels = {\"a\", \"e\", \"i\", \"o\", \"u\", \"A\", \"E\", 'O', 'U', 'I'}\n for i in range(len(word)-2, 0, -1):\n if word[i] in vowels:\n if (word[i+1] not in vowels) and (word[i-1] not in vowels):\n return word[i]\n return \"\"\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " def check(s):\n val = 0\n for i in s:\n if i == '(':\n val = val + 1\n else:\n val = val - 1\n if val < 0:\n return False\n return True if val == 0 else False\n\n S1 = lst[0] + lst[1]\n S2 = lst[1] + lst[0]\n return 'Yes' if check(S1) or check(S2) else 'No'\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if k == 0:\n return []\n arr.sort()\n ans = arr[-k:]\n return ans\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return sum([x for idx, x in enumerate(lst) if idx%2==0 and x%2==1])\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return sum(elem for elem in arr[:k] if len(str(elem)) <= 2)\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if n%2==0:\n odd_collatz = [] \n else:\n odd_collatz = [n]\n while n > 1:\n if n % 2 == 0:\n n = n/2\n else:\n n = n*3 + 1\n \n if n%2 == 1:\n odd_collatz.append(int(n))\n\n return sorted(odd_collatz)\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " try:\n date = date.strip()\n month, day, year = date.split('-')\n month, day, year = int(month), int(day), int(year)\n if month < 1 or month > 12:\n return False\n if month in [1,3,5,7,8,10,12] and day < 1 or day > 31:\n return False\n if month in [4,6,9,11] and day < 1 or day > 30:\n return False\n if month == 2 and day < 1 or day > 29:\n return False\n except:\n return False\n\n return True\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if \" \" in txt:\n return txt.split()\n elif \",\" in txt:\n return txt.replace(',',' ').split()\n else:\n return len([i for i in txt if i.islower() and ord(i)%2 == 0])\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " count_digit = dict([(i, 0) for i in lst])\n for i in lst:\n count_digit[i]+=1 \n if any(count_digit[i] > 2 for i in lst):\n return False\n if all(lst[i-1] <= lst[i] for i in range(1, len(lst))):\n return True\n else:\n return False\n \n \n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " def is_prime(num):\n if num == 1 or num == 0:\n return False\n if num == 2:\n return True\n for i in range(2, num):\n if num%i == 0:\n return False\n return True\n\n l = max(interval1[0], interval2[0])\n r = min(interval1[1], interval2[1])\n length = r - l\n if length > 0 and is_prime(length):\n return \"YES\"\n return \"NO\"\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if not arr: return None\n prod = 0 if 0 in arr else (-1) ** len(list(filter(lambda x: x < 0, arr)))\n return prod * sum([abs(i) for i in arr])\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " n = len(grid)\n val = n * n + 1\n for i in range(n):\n for j in range(n):\n if grid[i][j] == 1:\n temp = []\n if i != 0:\n temp.append(grid[i - 1][j])\n\n if j != 0:\n temp.append(grid[i][j - 1])\n\n if i != n - 1:\n temp.append(grid[i + 1][j])\n\n if j != n - 1:\n temp.append(grid[i][j + 1])\n\n val = min(temp)\n\n ans = []\n for i in range(k):\n if i % 2 == 0:\n ans.append(1)\n else:\n ans.append(val)\n return ans\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if n == 0:\n return [1]\n my_tri = [1, 3]\n for i in range(2, n + 1):\n if i % 2 == 0:\n my_tri.append(i / 2 + 1)\n else:\n my_tri.append(my_tri[i - 1] + my_tri[i - 2] + (i + 3) / 2)\n return my_tri\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " product = 1\n odd_count = 0\n for digit in str(n):\n int_digit = int(digit)\n if int_digit%2 == 1:\n product= product*int_digit\n odd_count+=1\n if odd_count ==0:\n return 0\n else:\n return product\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " opening_bracket_index = []\n closing_bracket_index = []\n for i in range(len(string)):\n if string[i] == '[':\n opening_bracket_index.append(i)\n else:\n closing_bracket_index.append(i)\n closing_bracket_index.reverse()\n cnt = 0\n i = 0\n l = len(closing_bracket_index)\n for idx in opening_bracket_index:\n if i < l and idx < closing_bracket_index[i]:\n cnt += 1\n i += 1\n return cnt >= 2\n\n \n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " import math\n squared = 0\n for i in lst:\n squared += math.ceil(i)**2\n return squared\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " \n check = txt.split(' ')[-1]\n return True if len(check) == 1 and (97 <= ord(check.lower()) <= 122) else False\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " ind=-1\n i=1\n while i<len(arr):\n if arr[i]<arr[i-1]:\n ind=i\n i+=1\n return ind\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " smallest = list(filter(lambda x: x < 0, lst))\n largest = list(filter(lambda x: x > 0, lst))\n return (max(smallest) if smallest else None, min(largest) if largest else None)\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " temp_a, temp_b = a, b\n if isinstance(temp_a, str): temp_a = temp_a.replace(',','.')\n if isinstance(temp_b, str): temp_b = temp_b.replace(',','.')\n if float(temp_a) == float(temp_b): return None\n return a if float(temp_a) > float(temp_b) else b \n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return n%2 == 0 and n >= 8\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " fact_i = 1\n special_fact = 1\n for i in range(1, n+1):\n fact_i *= i\n special_fact *= fact_i\n return special_fact\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " new_text = \"\"\n i = 0\n start, end = 0, 0\n while i < len(text):\n if text[i] == \" \":\n end += 1\n else:\n if end - start > 2:\n new_text += \"-\"+text[i]\n elif end - start > 0:\n new_text += \"_\"*(end - start)+text[i]\n else:\n new_text += text[i]\n start, end = i+1, i+1\n i+=1\n if end - start > 2:\n new_text += \"-\"\n elif end - start > 0:\n new_text += \"_\"\n return new_text\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " suf = ['txt', 'exe', 'dll']\n lst = file_name.split(sep='.')\n if len(lst) != 2:\n return 'No'\n if not lst[1] in suf:\n return 'No'\n if len(lst[0]) == 0:\n return 'No'\n if not lst[0][0].isalpha():\n return 'No'\n t = len([x for x in lst[0] if x.isdigit()])\n if t > 3:\n return 'No'\n return 'Yes'\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " result =[]\n for i in range(len(lst)):\n if i %3 == 0:\n result.append(lst[i]**2)\n elif i % 4 == 0 and i%3 != 0:\n result.append(lst[i]**3)\n else:\n result.append(lst[i])\n return sum(result)\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " new_lst = []\n for word in sentence.split():\n flg = 0\n if len(word) == 1:\n flg = 1\n for i in range(2, len(word)):\n if len(word)%i == 0:\n flg = 1\n if flg == 0 or len(word) == 2:\n new_lst.append(word)\n return \" \".join(new_lst)\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " a, b = x.split(\"/\")\n c, d = n.split(\"/\")\n numerator = int(a) * int(c)\n denom = int(b) * int(d)\n if (numerator/denom == int(numerator/denom)):\n return True\n return False\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " def digits_sum(n):\n neg = 1\n if n < 0: n, neg = -1 * n, -1 \n n = [int(i) for i in str(n)]\n n[0] = n[0] * neg\n return sum(n)\n return sorted(nums, key=digits_sum)\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " \n count = 0\n for num in nums:\n if num > 10:\n odd_digits = (1, 3, 5, 7, 9)\n number_as_string = str(num)\n if int(number_as_string[0]) in odd_digits and int(number_as_string[-1]) in odd_digits:\n count += 1\n \n return count \n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " A = [i*i - i + 1 for i in range(1,n+1)]\n ans = []\n for i in range(n):\n for j in range(i+1,n):\n for k in range(j+1,n):\n if (A[i]+A[j]+A[k])%3 == 0:\n ans += [(A[i],A[j],A[k])]\n return len(ans)\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " planet_names = (\"Mercury\", \"Venus\", \"Earth\", \"Mars\", \"Jupiter\", \"Saturn\", \"Uranus\", \"Neptune\")\n if planet1 not in planet_names or planet2 not in planet_names or planet1 == planet2:\n return ()\n planet1_index = planet_names.index(planet1)\n planet2_index = planet_names.index(planet2)\n if planet1_index < planet2_index:\n return (planet_names[planet1_index + 1: planet2_index])\n else:\n return (planet_names[planet2_index + 1 : planet1_index])\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " lst.sort()\n new_lst = []\n for i in lst:\n if len(i)%2 == 0:\n new_lst.append(i)\n return sorted(new_lst, key=len)\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if n == 1:\n return y\n for i in range(2, n):\n if n % i == 0:\n return y\n break\n else:\n return x\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return sum([i**2 for i in lst if i > 0 and i%2!=0 and \".\" not in str(i)])\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return [abs(x-y) for x,y in zip(game,guess)]\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " strong = extensions[0]\n my_val = len([x for x in extensions[0] if x.isalpha() and x.isupper()]) - len([x for x in extensions[0] if x.isalpha() and x.islower()])\n for s in extensions:\n val = len([x for x in s if x.isalpha() and x.isupper()]) - len([x for x in s if x.isalpha() and x.islower()])\n if val > my_val:\n strong = s\n my_val = val\n\n ans = class_name + \".\" + strong\n return ans\n\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " l = len(b)\n pat = b + b\n for i in range(len(a) - l + 1):\n for j in range(l + 1):\n if a[i:i+l] == pat[j:j+l]:\n return True\n return False\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " even_count = 0\n odd_count = 0\n for i in str(abs(num)):\n if int(i)%2==0:\n even_count +=1\n else:\n odd_count +=1\n return (even_count, odd_count)\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " num = [1, 4, 5, 9, 10, 40, 50, 90, \n 100, 400, 500, 900, 1000] \n sym = [\"I\", \"IV\", \"V\", \"IX\", \"X\", \"XL\", \n \"L\", \"XC\", \"C\", \"CD\", \"D\", \"CM\", \"M\"] \n i = 12\n res = ''\n while number: \n div = number // num[i] \n number %= num[i] \n while div: \n res += sym[i] \n div -= 1\n i -= 1\n return res.lower()\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return a*a == b*b + c*c or b*b == a*a + c*c or c*c == a*a + b*b\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " return sorted(words, key = lambda x: (-len(set(x)), x))[0]\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " if(need <= remaining):\n return [ number + need , remaining-need ]\n else:\n return [ number + remaining , 0]\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " expression = str(operand[0])\n for oprt, oprn in zip(operator, operand[1:]):\n expression+= oprt + str(oprn)\n return eval(expression)\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " flg = 0\n idx = 0\n new_str = list(s)\n for i in s:\n if i.isalpha():\n new_str[idx] = i.swapcase()\n flg = 1\n idx += 1\n s = \"\"\n for i in new_str:\n s += i\n if flg == 0:\n return s[len(s)::-1]\n return s\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " import hashlib\n return hashlib.md5(text.encode('ascii')).hexdigest() if text else None\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}, {"buggy_solution": " lower = max(2, min(a, b))\n upper = min(8, max(a, b))\n\n return [i for i in range(lower, upper+1) if i % 2 == 0]\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output"}]
data/rust/.DS_Store ADDED
Binary file (6.15 kB). View file
 
data/rust/data/humaneval.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/rust/data/humanevalbugs.json ADDED
@@ -0,0 +1 @@
 
 
1
+ [{"buggy_solution": "\n for i in 0..numbers.len(){\n for j in 1..numbers.len(){\n\n if i != j {\n let distance:f32 = numbers[i] - numbers[j];\n\n if distance.abs() < threshold{\n return true;\n }\n\n }\n \n }\n }\n\n return false;\n\n}\n"}, {"buggy_solution": "\n let mut result:Vec<String> = vec![];\n let mut current_string:String = String::new();\n let mut current_depth:u32 = 0;\n\n for c in paren_string.chars(){\n if c == '('{\n current_depth += 1;\n current_string.push(c);\n }\n else if c == ')' {\n current_depth -= 1;\n current_string.push(c);\n\n if current_depth == 0{\n result.push(current_string.clone());\n current_string.clear()\n }\n \n }\n\n\n }\n return result;\n}\n"}, {"buggy_solution": "\n return number % 1.0;\n}\n"}, {"buggy_solution": "\n\nlet mut balance:i32 = 0;\nfor op in operations {\n balance = balance + op;\n if balance < 0 {\n return true;\n }\n }\n return false;\n}\n"}, {"buggy_solution": "\n let mean:f32 = numbers.iter().fold(0.0,|acc:f32, x:&f32| acc + x) / numbers.len() as f32;\n return numbers.iter().map(|x:&f32| (x - mean).abs()).sum::<f32>() / numbers.len() as f32;\n}\n\n"}, {"buggy_solution": "\n let mut res:Vec<u32> = vec![];\n numbers.iter().for_each(|item:&u32| {res.push(*item); res.push(delimeter);});\n res.pop();\n return res;\n}\n"}, {"buggy_solution": "\n let mut result:Vec<i32> = vec![];\n let mut depth:i32 = 0;\n let mut max_depth:i32 = 0;\n\n for splits in paren_string.split(' '){\n for c in splits.chars(){ \n if c == '('{\n depth = depth + 1;\n max_depth = max(depth, max_depth);\n }\n else{\n depth = depth - 1;\n }\n }\n \n if depth == 0 {\n result.push(max_depth);\n max_depth = 0;\n }\n }\n\n return result;\n}\n"}, {"buggy_solution": "\n return strings.iter().filter(|x:&&String| x.contains(&substring)).map(String::from).collect();\n}\n"}, {"buggy_solution": "\n let sum = |xs: &Vec<i32>| xs.iter()\n .fold(0, |mut sum, &val| { sum += val; \n sum }\n );\n let product = |xs: &Vec<i32>| xs.iter()\n .fold(1, |mut prod, &val| { prod *= val; \n prod }\n );\n return (sum(&numbers),product(&numbers));\n}\n"}, {"buggy_solution": "\n let mut running_max :Option<i32> = None;\n let mut result:Vec<i32> = vec![];\n\n for n in numbers{\n if running_max == None {\n running_max = Some(n);\n\n }else{\n running_max = max(running_max, Some(n));\n }\n\n result.push(running_max.unwrap());\n }\n return result;\n\n}\n"}, {"buggy_solution": "\n let s: String = str.chars().rev().collect();\n return s==str;\n }\n \n fn make_palindrome(str: &str) -> String {\n let mut i: usize = 0;\n for i in 0..str.len() {\n let rstr: &str = &str[i..];\n if is_palindrome_10(rstr) {\n let nstr: &str = &str[0..i];\n let n2str: String = nstr.chars().rev().collect();\n return str.to_string()+&n2str;\n }\n }\n let n2str: String = str.chars().rev().collect();\n return str.to_string()+&n2str;\n }\n"}, {"buggy_solution": "\n\n let xor = |i:char, j:char| {if i == j{return \"0\".to_string()}else{return \"1\".to_string()}};\n return a.chars().into_iter().zip(b.chars().into_iter()).map(|(i,j)| \"\".to_string() + &xor(i,j)).collect(); \n}\n"}, {"buggy_solution": "\n if strings.is_empty(){\n return None;\n }\n let mut max:i32 = 0;\n let mut res:String = String::new();\n\n for s in strings{\n if s.len() as i32 > max {\n res = s;\n max = res.len() as i32;\n } \n }\n return Some(res);\n}\n"}, {"buggy_solution": "\n while b > 0 {\n (a, b) = (b, a % b);\n }\n return a;\n}\n\n"}, {"buggy_solution": "\n let mut res:Vec<String> = vec![];\n let mut res_str:String = String::new();\n\nfor c in string.chars(){\n res_str.push(c);\n res.push(res_str.clone());\n}\nreturn res;\n}\n\n"}, {"buggy_solution": "\n let mut res:String = String::new();\n\n for number in 0..n + 1{\n res = res + &number.to_string() + \" \";\n }\n \n return res.trim_end().to_string();\n\n}\n"}, {"buggy_solution": "\n let res:HashSet<char> = str.chars().into_iter().map(|x:char| x.to_ascii_lowercase()).collect();\n return res.len() as i32;\n}\n"}, {"buggy_solution": "\n\n let map = |x:&str| {match x {\n \"o\" => 4,\n \"o|\" => 2,\n \".|\" => 1,\n _ => 0\n } \n};\n return music_string.split(\" \").map(|x:&str| map(&x.to_string())).filter(|x:&i32| x != &0).collect();\n}\n"}, {"buggy_solution": "\n let mut times:i32 = 0;\n\n for i in 0..(string.len() as i32 - substring.len() as i32 + 1){\n if string.get(i as usize..(i + substring.len() as i32) as usize).unwrap().to_string() == substring {\n times += 1;\n } \n }\n return times;\n}\n"}, {"buggy_solution": "\n let str_to_i32 = |x:&str| {match x{\n \"zero\" => 0,\n \"one\" => 1,\n \"two\" => 2,\n \"three\" => 3,\n \"four\" => 4,\n \"five\" => 5,\n \"six\" => 6,\n \"seven\" => 7,\n \"eight\" => 8,\n \"nine\" => 9,\n _ => 1000\n }};\n\n let i32_to_str = |x:&i32| {match x{\n 0 => \"zero\".to_string(),\n 1 => \"one\".to_string(),\n 2 => \"two\".to_string(),\n 3 => \"three\".to_string(),\n 4 => \"four\".to_string(),\n 5 => \"five\".to_string(),\n 6 => \"six\".to_string(),\n 7 => \"seven\".to_string(),\n 8 => \"eight\".to_string(),\n 9 => \"nine\".to_string(),\n _ => \"none\".to_string()\n}};\n\n let mut nmbrs:Vec<i32> = numbers.split_ascii_whitespace().map(|x:&str| str_to_i32(x)).collect(); \n nmbrs.sort();\n let res:String = nmbrs.iter().map(|x:&i32| i32_to_str(x) + \" \").collect();\n return res.trim_end().to_string();\n}\n"}, {"buggy_solution": "\n let mut closest_pair = (0.0,0.0);\n let mut distance:Option<f32> = None;\n\n for (idx, elem) in numbers.iter().enumerate(){\n for (idx2, elem2) in numbers.iter().enumerate() {\n if idx != idx2 {\n if distance == None {\n distance = Some((elem - elem2).abs());\n if *elem < *elem2{\n closest_pair = (*elem, *elem2);\n }else{\n closest_pair = (*elem2, *elem);\n }\n\n }else{\n let new_distance:f32= (elem - elem2).abs();\n if new_distance < distance.unwrap(){\n distance = Some(new_distance);\n\n if *elem < *elem2{\n closest_pair = (*elem, *elem2);\n }else{\n closest_pair = (*elem2, *elem);\n }\n \n \n }\n }\n }\n }\n }\n return closest_pair;\n\n\n}\n"}, {"buggy_solution": "\n let min_number= *numbers.iter().min_by(|a, b| a.partial_cmp(b).unwrap()).unwrap();\n let max_number= *numbers.iter().max_by(|a, b| a.partial_cmp(b).unwrap()).unwrap();\n return numbers.iter().map(|x:&f32| (x-min_number) / (max_number - min_number)).collect();\n}\n"}, {"buggy_solution": "\n let mut out: Vec<i32> = Vec::new();\n for value in values {\n if let Some(i) = value.downcast_ref::<i32>() {\n out.push(*i);\n }\n }\n out\n }\n"}, {"buggy_solution": "\n return strings.len() as i32;\n}\n"}, {"buggy_solution": "\n let mut res:i32 = 0;\n let sqn = 1..n;\n \n for i in sqn.rev(){\n if n % i == 0 {\n res = i;\n break;\n }\n }\n\n return res;\n}\n"}, {"buggy_solution": "\n let mut n = n;\n let mut factors = vec![];\n let mut divisor = 2;\n while divisor * divisor <= n {\n while n % divisor == 0 {\n factors.push(divisor);\n n = n / divisor;\n }\n divisor = divisor + 1;\n }\n if n > 1 {\n factors.push(n);\n }\n factors\n}\n"}, {"buggy_solution": "\n let mut m: HashMap<i32, i32> = HashMap::new();\n\n for n in &numbers {\n *m.entry(*n).or_default() += 1;\n }\n let res:Vec<i32> = numbers.into_iter().filter(|x| m.get(x) == Some(&1)).collect();\n return res;\n}\n"}, {"buggy_solution": "\n return string.chars().into_iter().fold(String::new(), |res:String, c:char| {if c.is_ascii_lowercase(){return res + &c.to_uppercase().to_string();}else{return res + &c.to_ascii_lowercase().to_string();}});\n}\n"}, {"buggy_solution": "\n return strings.iter().fold(String::new(),|res: String, x:&String| res + &x.to_string());\n\n}\n"}, {"buggy_solution": "\n return strings.into_iter().filter(|s| s.starts_with(&prefix)).collect();\n}\n"}, {"buggy_solution": "\n return numbers.into_iter().filter(|n| n.is_positive()).collect();\n\n}\n"}, {"buggy_solution": "\n if n < 2{\n return false;\n}\nfor k in 2..n-1 {\n if n % k == 0{\n return false;\n }\n}\nreturn true;\n\n}\n"}, {"buggy_solution": "\n let mut sum = 0.0;\n for i in 0..xs.len() {\n sum += xs[i] * x.powi(i as i32);\n }\n sum\n }\n \n fn find_zero(xs: &Vec<f64>) -> f64 {\n let mut ans = 0.0;\n let mut value = poly(xs, ans);\n while value.abs() > 1e-6 {\n let mut driv = 0.0;\n for i in 1..xs.len() {\n driv += xs[i] * ans.powi((i - 1) as i32) * (i as f64);\n }\n ans = ans - value / driv;\n value = poly(xs, ans);\n }\n ans\n }\n"}, {"buggy_solution": "\n let mut third = vec![];\n let mut out:Vec<i32> = vec![];\n\n for (indx,elem) in l.iter().enumerate(){\n if indx%3 == 0 && indx != 0{\n third.push(elem)\n }\n }\n third.sort();\n let mut indx_t:usize = 0;\n\n for i in 0..l.len() {\n if i%3 == 0 && i != 0{\n if indx_t < third.len(){\n out.push(*third[indx_t]);\n indx_t += 1;\n }\n }else{\n out.push(l[i]);\n }\n \n }\n return out;\n}\n"}, {"buggy_solution": "\n let mut res:Vec<i32> = nmbs.clone();\n res.sort();\n res.dedup();\n return res;\n }\n"}, {"buggy_solution": "\n return *nmbs.iter().max().unwrap();\n }\n\n"}, {"buggy_solution": "\n let mut ns:Vec<i32> = vec![];\n\n for i in 0..n{\n if i % 11 == 0 || i % 13 == 0{\n ns.push(i);\n }\n }\n\n let s:String = ns.into_iter().fold(String::new(),|s:String, n:i32| {s + &n.to_string()});\n let mut ans:i32 = 0;\n\n for c in s.chars(){\n if c == '7'{\n ans += 1;\n }\n }\n return ans;\n}\n"}, {"buggy_solution": "\n let mut even = vec![];\n let mut out:Vec<i32> = vec![];\n\n for (indx,elem) in nmbs.iter().enumerate(){\n if indx%2 == 0{\n even.push(elem)\n }\n }\n even.sort();\n let mut indx_t:usize = 0;\n\n for i in 0..nmbs.len() {\n if i%2 == 0{\n if indx_t < even.len(){\n out.push(*even[indx_t]);\n indx_t += 1;\n }\n }else{\n out.push(nmbs[i]);\n }\n \n }\n return out;\n}\n"}, {"buggy_solution": "\n\n let l = s.len();\n let num = (l + 2) / 3;\n let mut output = String::new();\n for i in 0..num {\n let group = &s[i * 3..std::cmp::min(l, (i + 1) * 3)];\n // revert the cycle performed by the encode_cyclic function\n if group.len() == 3 {\n let x = format!(\"{}{}{}\", &group[2..3], &group[0..1], &group[1..2]);\n output.push_str(&x);\n } else {\n output.push_str(group);\n }\n }\n output\n}\n\npub fn encode_cyclic(s: &str) -> String {\n // returns encoded string by cycling groups of three characters.\n // split string to groups. Each of length 3.\n let l = s.len();\n let num = (l + 2) / 3;\n let mut output = String::new();\n for i in 0..num {\n let group = &s[i * 3..std::cmp::min(l, (i + 1) * 3)];\n // cycle elements in each group. Unless group has fewer elements than 3.\n if group.len() == 3 {\n let x = format!(\"{}{}{}\", &group[1..2], &group[2..3], &group[0..1]);\n output.push_str(&x);\n } else {\n output.push_str(group);\n }\n }\n output\n}\n\n"}, {"buggy_solution": "\n let mut f1 = 1;\n let mut f2 = 2;\n let mut count = 0;\n while count < n {\n f1 = f1 + f2;\n let m = f1;\n f1 = f2;\n f2 = m;\n let mut isprime = true;\n for w in 2..(f1 as f32).sqrt() as i32 + 1 {\n if f1 % w == 0 {\n isprime = false;\n break;\n }\n }\n if isprime {\n count += 1;\n }\n if count == n {\n return f1;\n }\n }\n 0\n}\n"}, {"buggy_solution": "\n for i in 0.. nmbs.len(){\n for j in i + 1.. nmbs.len(){\n for k in j + 1.. nmbs.len(){\n if *nmbs.get(i).unwrap() + *nmbs.get(j).unwrap() + *nmbs.get(k).unwrap() == 0{\n return true;\n }\n }\n }\n }\nreturn false;\n\n}\n"}, {"buggy_solution": "\n return n*n;\n}\n"}, {"buggy_solution": "\n return l.into_iter().map(|n:i32| n + 1).collect();\n}\n"}, {"buggy_solution": "\n for (i, l1) in l.iter().enumerate(){\n for j in i + 1.. l.len(){\n if l1 + l[j] == 0{\n return true;\n }\n }\n }\n\n return false;\n}\n"}, {"buggy_solution": "\n let mut ret:String = \"\".to_string();\n let mut x1 = x;\n\n while x1 > 0{\n ret = (x1 % base).to_string() + &ret;\n x1 = x1 / base;\n }\n return ret;\n}\n"}, {"buggy_solution": "\n return (a * h) as f64 / 2.0;\n}\n"}, {"buggy_solution": "\n let mut results:Vec<i32> = vec![0, 0, 2, 0];\n\n if n < 4 {\n return *results.get(n as usize).unwrap();\n }\n\n for _ in 4.. n + 1{\n results.push(results.get(results.len()-1).unwrap() + results.get(results.len()-2).unwrap()\n + results.get(results.len()-3).unwrap() + results.get(results.len()-4).unwrap());\n results.remove(0);\n }\n\n return *results.get(results.len()-1).unwrap();\n\n \n}\n"}, {"buggy_solution": "\n let mut res:Vec<i32> = l.clone();\n res.sort();\n if res.len() % 2 == 1{\n return *res.get(res.len() / 2).unwrap() as f64;\n }else{ \n return (res.get(res.len() / 2 -1).unwrap() + res.get(res.len() / 2).unwrap()) as f64/ 2.0;\n }\n}\n"}, {"buggy_solution": "\n let pr: String = text.chars().rev().collect();\n return pr == text;\n}\n"}, {"buggy_solution": "\n if n == 0 {\n return 1;\n } else {\n return (modp(n - 1, p) * 2) % p;\n }\n}\n"}, {"buggy_solution": "\n let alphabet:Vec<&str> = vec![\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\"\n , \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\"];\n let mut output = String::new();\n\n for c in s.chars() {\n let mut lower = false;\n if c.is_ascii_lowercase(){\n lower = true;\n }\n let mut c_shift:String = \"\".to_string();\n if lower {\n let index:usize = alphabet.iter().position(|&x| x == c.to_string()).unwrap();\n c_shift = alphabet[(index + 5) % 26].to_string();\n }else{\n let c_lower:String = c.to_ascii_lowercase().to_string();\n let index:usize = alphabet.iter().position(|&x| x == c_lower).unwrap();\n c_shift = alphabet[(index + 5) % 26].to_string();\n c_shift = c_shift.to_ascii_uppercase().to_string();\n \n }\n\n output.push_str(&c_shift);\n }\n output\n}\n\npub fn decode_shift(s: &str) -> String {\n let alphabet:Vec<&str> = vec![\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\"\n , \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\"];\n let mut output = String::new();\n\n for c in s.chars() {\n let mut lower = false;\n if c.is_ascii_lowercase(){\n lower = true;\n }\n let mut c_shift:String = \"\".to_string();\n if lower {\n let index:usize = alphabet.iter().position(|&x| x == c.to_string()).unwrap();\n c_shift = alphabet[((26 + (index as i32 - 5)) % 26) as usize].to_string();\n }else{\n let c_lower:String = c.to_ascii_lowercase().to_string();\n let index:usize = alphabet.iter().position(|&x| x == c_lower).unwrap();\n c_shift = alphabet[((26 + (index as i32 - 5)) % 26) as usize].to_string();\n c_shift = c_shift.to_ascii_uppercase().to_string();\n \n }\n\n output.push_str(&c_shift);\n }\n output\n}\n"}, {"buggy_solution": "\n let vowels = \"AEIOUaeiou\";\n let mut out = String::new();\n for c in text.chars() {\n if !vowels.contains(c) {\n out.push(c);\n }\n }\n out\n}\n"}, {"buggy_solution": "\n for i in l {\n if i >= t {\n return false;\n }\n }\n return true;\n}\n"}, {"buggy_solution": "\n return x + y;\n}\n"}, {"buggy_solution": "\n let mut v1:Vec<char> = str1.chars().into_iter().collect();\n v1.sort();\n v1.dedup();\n\n let mut v2:Vec<char> = str2.chars().into_iter().collect();\n v2.sort();\n v2.dedup();\n\n return v1 == v2;\n}\n"}, {"buggy_solution": "\n if n == 0{\n return 0;\n }\n if n == 1{\n return 1;\n }\n\n return fib(n-1) + fib(n-2);\n}\n"}, {"buggy_solution": "\n let mut level:i32=0;\n\n for i in 0..bkts.len(){\n\n if bkts.chars().nth(i).unwrap()== '<' {level+=1;}\n \n if bkts.chars().nth(i).unwrap() == '>' { level-=1;}\n \n if level<0 {return false;} \n }\n if level!=0 {return false;}\n return true;\n}\n"}, {"buggy_solution": "\n let mut l1:Vec<i32> = l.clone();\n let mut l2:Vec<i32> = l.clone();\n l2.sort(); l2.reverse();\n l1.sort();\n\n if l == l1 || l == l2 {return true}\n return false;\n\n}\n"}, {"buggy_solution": "\nlet mut res:Vec<i32> = l1.into_iter().filter(|n:&i32| l2.contains(n)).collect();\nres.sort();\nreturn res;\n}\n"}, {"buggy_solution": "\n let mut n1 = n.clone();\n for i in 2.. n1{\n while n1%i == 0 && n1>i{n1 = n1/i;}\n }\n return n1;\n}\n"}, {"buggy_solution": "\n n*(n+1)/2\n}\n"}, {"buggy_solution": "\n let mut level:i32=0;\n\n for i in 0..bkts.len(){\n\n if bkts.chars().nth(i).unwrap()== '(' {level+=1;}\n \n if bkts.chars().nth(i).unwrap() == ')' { level-=1;}\n \n if level<0 {return false;} \n }\n if level!=0 {return false;}\n return true;\n }\n"}, {"buggy_solution": "\n let mut res:Vec<i32> =vec![];\n for i in 1..xs.len(){\n res.push(i as i32 * xs.get(i).unwrap());\n }\n return res;\n\n} \n"}, {"buggy_solution": "\n if n == 0 || n == 1{\n return 0;\n }\n if n == 2{\n return 1;\n }\n\n return fibfib(n-1) + fibfib(n-2) + fibfib(n-3);\n\n}\n"}, {"buggy_solution": "\n let vowels:&str = \"aeiouAEIOU\";\n let mut count:i32 = 0;\n\n for i in 0..s.len() {\n let c:char = s.chars().nth(i).unwrap();\n if vowels.contains(c){\n count += 1;\n } \n }\n if s.chars().nth(s.len() -1).unwrap() == 'y' || s.chars().nth(s.len() -1).unwrap() == 'Y' {count+=1;}\n\n return count;\n}\n"}, {"buggy_solution": "\n let mut xcp:Vec<char> = x.to_string().chars().into_iter().collect();\n let mut res:Vec<char> = x.to_string().chars().into_iter().collect();\n\n for (indx,c) in xcp.iter().enumerate(){\n let despl = (indx as i32 + shift) % x.to_string().len() as i32;\n replace(&mut res[despl as usize], *c);\n }\n\n return res.into_iter().collect();\n\n}\n"}, {"buggy_solution": "\n return s.chars().into_iter().filter(|c:&char| c.is_uppercase()).map(|c:char| c as i32).sum();\n}\n"}, {"buggy_solution": "\n let sub:i32 = s.split_ascii_whitespace().into_iter().filter(|c| c.parse::<i32>().is_ok()).map(|c| c.parse::<i32>().unwrap()).sum();\n return n-sub;\n}\n\n"}, {"buggy_solution": "\n let mut out:Vec<i32> = vec![];\n\n for i in 0.. arr.len(){\n if arr[i]%2 == 0 && (out.len() == 0 || arr[i]<out[0]){\n out = vec![arr[i], i as i32];\n }\n \n }\n return out;\n}\n"}, {"buggy_solution": "\n let mut freq: Vec<Vec<i32>> = Vec::new();\n let mut max = -1;\n for i in 0..lst.len() {\n let mut has = false;\n for j in 0..freq.len() {\n if lst[i] == freq[j][0] {\n freq[j][1] += 1;\n has = true;\n if freq[j][1] >= freq[j][0] && freq[j][0] > max {\n max = freq[j][0];\n }\n }\n }\n if !has {\n freq.push(vec![lst[i], 1]);\n if max == -1 && lst[i] == 1 {\n max = 1;\n }\n }\n }\n return max;\n}\n"}, {"buggy_solution": "\n let mut cp:Vec<i32> = lst.clone();\n let mut res:Vec<i32> = vec![];\n\n for (indx, _) in lst.iter().enumerate(){\n if indx%2 == 1 {\n let max:i32 = *cp.iter().max().unwrap();\n res.push(max);\n cp.remove(cp.iter().position(|x| *x == max).unwrap());\n }\n else{\n let min:i32 = *cp.iter().min().unwrap();\n res.push(min);\n cp.remove(cp.iter().position(|x| *x == min).unwrap());\n }\n }\n return res;\n}\n"}, {"buggy_solution": "\n if a+b<=c || a+c<=b || b+c<=a {return -1.0;}\n let h:f64=(a+b+c) / 2.0;\n let mut area:f64;\n area = f64::powf(h*(h-a)*(h-b)*(h-c),0.5);\n return area;\n}\n"}, {"buggy_solution": "\n if q.iter().sum::<i32>() > w {\n return false;\n }\n let mut i = 0;\n let mut j = q.len() - 1;\n\n while i < j {\n if q[i] != q[j] {\n return false;\n }\n i += 1;\n j -= 1;\n }\n return true;\n}\n"}, {"buggy_solution": "\n let mut ans: i32 = 0;\n for i in 0..arr.len() / 2 {\n if arr[i] != arr[arr.len() - i - 1] {\n ans += 1\n }\n }\n return ans;\n}\n"}, {"buggy_solution": "\n let total_1: usize = lst1\n .iter()\n .fold(0, |acc: usize, str: &&str| acc + str.chars().count());\n let total_2: usize = lst2\n .iter()\n .fold(0, |acc: usize, str: &&str| acc + str.chars().count());\n\n if total_1 <= total_2 {\n return lst1.into_iter().map(|x| x.to_string()).collect();\n } else {\n return lst2.into_iter().map(|x| x.to_string()).collect();\n }\n}\n"}, {"buggy_solution": "\n let mut a1 = a;\n let mut num = 0;\n for i in 2..a {\n while a1 % i == 0 && a1 > i {\n a1 /= i;\n num += 1;\n }\n }\n if num == 2 {\n return true;\n }\n return false;\n}\n"}, {"buggy_solution": "\n let mut p: i32 = 1;\n let mut count: i32 = 0;\n\n while p <= x && count < 100 {\n if p == x {\n return true;\n };\n p = p * n;\n count += 1;\n }\n return false;\n}\n"}, {"buggy_solution": "\n let a1: f64 = i32::abs(a) as f64;\n let sqrt_3 = f64::powf(a1, 1.0 / 3.0).ceil();\n\n return i32::pow(sqrt_3 as i32, 3) == a1 as i32;\n}\n\n"}, {"buggy_solution": "\n let primes: Vec<&str> = vec![\"2\", \"3\", \"5\", \"7\", \"B\", \"D\"];\n let mut total: i32 = 0;\n for i in 0..num.len() {\n if primes.contains(&num.get(i..i + 1).unwrap()) {\n total += 1;\n }\n }\n return total;\n}\n"}, {"buggy_solution": "\n let mut d_cp = decimal;\n let mut out: String = String::from(\"\");\n if d_cp == 0 {\n return \"db0db\".to_string();\n }\n while d_cp > 0 {\n out = (d_cp % 2).to_string() + &out;\n d_cp = d_cp / 2;\n }\n out = \"db\".to_string() + &out + &\"db\".to_string();\n return out;\n}\n"}, {"buggy_solution": "\n let str: Vec<char> = s.chars().into_iter().collect();\n if str.len() < 3 {\n return false;\n }\n for i in 2..str.len() {\n if str[i] == str[i - 1] || str[i] == str[i - 2] {\n return false;\n }\n }\n return true;\n}\n"}, {"buggy_solution": "\n let mut res: Vec<String> = vec![];\n for (i, gpa) in grades.iter().enumerate() {\n if gpa == &4.0 {\n res.push(\"A+\".to_string());\n } else if gpa > &3.7 {\n res.push(\"A\".to_string());\n } else if gpa > &3.3 {\n res.push(\"A-\".to_string());\n } else if gpa > &3.0 {\n res.push(\"B+\".to_string());\n } else if gpa > &2.7 {\n res.push(\"B\".to_string());\n } else if gpa > &2.3 {\n res.push(\"B-\".to_string());\n } else if gpa > &2.0 {\n res.push(\"C+\".to_string());\n } else if gpa > &1.7 {\n res.push(\"C\".to_string());\n } else if gpa > &1.3 {\n res.push(\"C-\".to_string());\n } else if gpa > &1.0 {\n res.push(\"D+\".to_string());\n } else if gpa > &0.7 {\n res.push(\"D\".to_string());\n } else if gpa > &0.0 {\n res.push(\"D-\".to_string());\n } else {\n res.push(\"E\".to_string());\n }\n }\n return res;\n}\n"}, {"buggy_solution": "\n let l: usize = str.len();\n if l == 0 || l == 1 {\n return false;\n }\n\n for i in 2..l {\n if l % i == 0 {\n return false;\n }\n }\n return true;\n}\n"}, {"buggy_solution": "\n if n == 1 {\n return 1;\n };\n return 18 * i32::pow(10, (n - 2) as u32);\n}\n"}, {"buggy_solution": "\n let sum: i32 = n\n .to_string()\n .chars()\n .into_iter()\n .fold(0, |acc, c| acc + c.to_digit(10).unwrap() as i32);\n return format!(\"{sum:b}\");\n}\n"}, {"buggy_solution": "\n let mut sum: i32 = 0;\n\n for (indx, elem) in lst.iter().enumerate() {\n if indx % 2 == 1 {\n if elem % 2 == 0 {\n sum += elem\n }\n }\n }\n return sum;\n}\n"}, {"buggy_solution": "\n let mut res: String = String::new();\n\n for i in s.split_ascii_whitespace() {\n let mut str: Vec<char> = i.chars().into_iter().collect();\n str.sort_by(|a, b| (*a as u32).cmp(&(*b as u32)));\n let str_sorted: String = str.into_iter().collect();\n res.push_str(&(str_sorted + &\" \".to_string()));\n }\n res = res.trim_end().to_string();\n return res;\n}\n"}, {"buggy_solution": "\n let mut out: Vec<Vec<i32>> = vec![];\n for (indxi, elem1) in lst.iter().enumerate() {\n for (indxj, _) in elem1.iter().rev().enumerate() {\n if lst[indxi][indxj] == x {\n out.push(vec![indxi as i32, indxj as i32]);\n }\n }\n }\n return out;\n}\n"}, {"buggy_solution": "\n let mut res: Vec<i32> = array.clone();\n\n if array.len() == 0 {\n return res;\n }\n\n if (array[0] + array[array.len() - 1]) % 2 == 0 {\n res.sort();\n return res.into_iter().rev().collect();\n } else {\n res.sort();\n return res;\n }\n}\n"}, {"buggy_solution": "\n let d: Vec<char> = \"abcdefghijklmnopqrstuvwxyz\"\n .to_string()\n .chars()\n .into_iter()\n .collect();\n let mut out: String = String::new();\n for c in s.chars() {\n if d.contains(&c) {\n let indx: usize = (d.iter().position(|x| c == *x).unwrap() + 2 * 2) % 26;\n out += &d[indx].to_string();\n } else {\n out += &c.to_string();\n }\n }\n\n return out;\n}\n"}, {"buggy_solution": "\n let mut res = 0;\n let mut lst_cp = lst.clone();\n let mut first: i32 = 0;\n let mut second: i32 = 0;\n\n if lst.iter().min() == None {\n res = -1;\n } else {\n if lst.iter().min() != None {\n first = *lst.iter().min().unwrap();\n let indx = lst.iter().position(|x| *x == first).unwrap();\n lst_cp.remove(indx);\n\n if lst_cp.iter().min() != None {\n second = *lst_cp.iter().min().unwrap();\n }\n if first != second {\n res = second;\n } else {\n res = -1;\n }\n }\n }\n return res;\n}\n"}, {"buggy_solution": "\n let mut count = 0;\n let regex = Regex::new(r\"[.?!]\\s*\").expect(\"Invalid regex\");\n let sqn: Vec<&str> = regex.split(s).into_iter().collect();\n for s in sqn {\n if s.starts_with(\"I \") {\n count += 1;\n }\n }\n return count;\n}\n"}, {"buggy_solution": "\n if a.fract() == 0.0 && b.fract() == 0.0 && c.fract() == 0.0 {\n return a + b == c || a + c == b || b + c == a;\n } else {\n return false;\n }\n}\n"}, {"buggy_solution": "\n let mut res: String = String::new();\n let v: Vec<char> = \"aeiouAEIOU\".to_string().chars().into_iter().collect();\n let d: Vec<char> = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n .to_string()\n .chars()\n .into_iter()\n .collect();\n\n for (indx, elem) in message.chars().into_iter().enumerate() {\n let mut c = elem.to_string();\n\n if v.contains(&elem) {\n let indx: usize = d.iter().position(|x| &elem == x).unwrap();\n c = d[indx + 2 as usize].to_string();\n }\n\n if elem.is_uppercase() {\n c = c.to_lowercase().to_string();\n } else {\n c = c.to_uppercase().to_string();\n }\n res.push_str(&c);\n }\n return res;\n}\n"}, {"buggy_solution": "\n let mut largest = 0;\n for i in 0..lst.len() {\n if lst[i] > largest {\n let mut prime = true;\n let mut j = 2;\n while j * j <= lst[i] {\n if lst[i] % j == 0 {\n prime = false;\n }\n j += 1;\n }\n\n if prime {\n largest = lst[i];\n }\n }\n }\n let mut sum: i32 = 0;\n let mut s: String = String::new();\n s = largest.to_string();\n\n for n in s.chars().into_iter() {\n sum += n.to_digit(10).unwrap() as i32;\n }\n return sum;\n}\n"}, {"buggy_solution": "\n if dict.is_empty() {\n return false;\n }\n let string_lower: fn(str: &str) -> bool = |str: &str| {\n return str.chars().into_iter().all(|c| c.is_ascii_lowercase());\n };\n let string_upper: fn(str: &str) -> bool = |str: &str| {\n return str.chars().into_iter().all(|c| c.is_ascii_uppercase());\n };\n\n let lower: bool = dict.keys().into_iter().all(|str| string_lower(str));\n let upper: bool = dict.keys().into_iter().all(|str| string_upper(str));\n return lower || upper;\n}\n"}, {"buggy_solution": "\n let mut primes: Vec<i32> = vec![];\n\n for i in 2..n {\n let mut is_prime: bool = true;\n\n for j in 2..i {\n if i % j == 0 {\n is_prime = false;\n break;\n }\n }\n if is_prime {\n primes.push(i);\n }\n }\n return primes;\n}\n"}, {"buggy_solution": "\n return (i32::abs(a) % 10) * (i32::abs(b) % 10);\n}\n"}, {"buggy_solution": "\n let uvowel: &str = \"AEIOU\";\n let mut count: i32 = 0;\n\n for (indx, elem) in s.chars().into_iter().enumerate() {\n if indx % 2 == 0 {\n if uvowel.contains(elem) {\n count += 1;\n }\n }\n }\n return count;\n}\n"}, {"buggy_solution": "\n return value.parse::<f64>().unwrap().round() as i32;\n}\n"}, {"buggy_solution": "\n let mut out: Vec<i32> = vec![n];\n\n for i in 1..n {\n out.push(out[out.len() - 1] + 2);\n }\n\n return out;\n}\n"}, {"buggy_solution": "\n return s\n .to_string()\n .split(|c: char| c == ',' || c.is_whitespace())\n .into_iter()\n .filter(|x| x != &\"\")\n .map(|x| x.to_string())\n .collect();\n}\n"}, {"buggy_solution": "\n if y < x {\n return -1;\n }\n if y == x && y % 2 == 1 {\n return -1;\n }\n if y % 2 == 1 {\n return y - 1;\n }\n return y;\n}\n"}, {"buggy_solution": "\n if n > m {\n return \"-1\".to_string();\n };\n let mut num: i32 = (m + n) / 2;\n let mut out: String = String::from(\"\");\n while num > 0 {\n out = (num % 2).to_string() + &out;\n num = num / 2;\n }\n return out;\n}\n"}, {"buggy_solution": "\n let mut res: Vec<i32> = vec![];\n for (_, elem) in x.into_iter().enumerate() {\n let mut elem_cp: i32 = elem;\n let mut u: bool = true;\n if elem == 0 {\n u = false;\n }\n while elem_cp > 0 && u {\n if elem_cp % 2 == 0 {\n u = false;\n }\n elem_cp = elem_cp / 10;\n }\n if u {\n res.push(elem)\n };\n }\n res.sort();\n return res;\n}\n"}, {"buggy_solution": "\n let mut res: Vec<String> = vec![];\n let mut arr_cp: Vec<i32> = arr.clone();\n arr_cp.sort();\n arr_cp.reverse();\n let map: HashMap<i32, &str> = HashMap::from([\n (0, \"Zero\"),\n (1, \"One\"),\n (2, \"Two\"),\n (3, \"Three\"),\n (4, \"Four\"),\n (5, \"Five\"),\n (6, \"Six\"),\n (7, \"Seven\"),\n (8, \"Eight\"),\n (9, \"Nine\"),\n ]);\n\n for elem in arr_cp {\n if elem >= 1 && elem <= 9 {\n res.push(map.get(&elem).unwrap().to_string());\n }\n }\n\n return res;\n}\n"}, {"buggy_solution": "\n let mut sum: i32 = 0;\n let mut prod: i32 = 1;\n let mut out: Vec<i32> = vec![];\n\n for i in 1..n + 1 {\n sum += i;\n prod *= i;\n\n if i % 2 == 0 {\n out.push(prod);\n } else {\n out.push(sum)\n };\n }\n return out;\n}\n"}, {"buggy_solution": "\n let mut even = 0;\n let mut odd = 0;\n\n for i in 1..n + 1 {\n let mut w: String = i.to_string();\n let mut p: String = w.chars().rev().collect();\n\n if w == p && i % 2 == 1 {\n odd += 1;\n }\n if w == p && i % 2 == 0 {\n even += 1;\n }\n }\n (even, odd)\n}\n"}, {"buggy_solution": "\n let mut num: i32 = 0;\n\n for nmbr in n {\n if nmbr > 0 {\n num += 1;\n } else {\n let mut sum: i32 = 0;\n let mut w: i32;\n w = i32::abs(nmbr);\n\n while w >= 10 {\n sum += w % 10;\n w = w / 10;\n }\n sum -= w;\n if sum > 0 {\n num += 1;\n }\n }\n }\n return num;\n}\n"}, {"buggy_solution": "\n let mut num = 0;\n if arr.len() == 0 {\n return true;\n }\n for i in 1..arr.len() {\n if arr[i] < arr[i - 1] {\n num += 1;\n }\n }\n if arr[arr.len() - 1] > arr[0] {\n num += 1;\n }\n if num < 2 {\n return true;\n }\n return false;\n}\n"}, {"buggy_solution": "\n let mut num = 0;\n for i in 0..lst1.len() {\n if lst1[i] % 2 == 0 {\n num += 1;\n }\n }\n for i in 0..lst2.len() {\n if lst2[i] % 2 == 0 {\n num += 1;\n }\n }\n if num >= lst1.len() {\n return \"YES\".to_string();\n }\n return \"NO\".to_string();\n}\n"}, {"buggy_solution": "\n let mut res: HashMap<char, i32> = HashMap::new();\n if test == \"\" {\n return res;\n }\n for c in test.split_ascii_whitespace() {\n if res.contains_key(&c.chars().next().unwrap()) {\n res.entry(c.chars().next().unwrap()).and_modify(|n| {\n *n += 1;\n });\n } else {\n res.insert(c.chars().next().unwrap(), 1);\n }\n }\n let max: i32 = *res.values().max().unwrap();\n let non_maxs: Vec<char> = res\n .keys()\n .filter(|k: &&char| *res.get(k).unwrap() != max)\n .map(|c| *c)\n .collect();\n non_maxs.iter().for_each(|c| {\n res.remove(c);\n });\n\n return res;\n}\n"}, {"buggy_solution": "\n let mut n = String::new();\n for i in 0..s.len() {\n if !c.contains(s.chars().nth(i).unwrap()) {\n n.push(s.chars().nth(i).unwrap());\n }\n }\n if n.len() == 0 {\n return vec![n, \"True\".to_string()];\n }\n let w: String = n.chars().rev().collect();\n if w == n {\n return vec![n, \"True\".to_string()];\n }\n return vec![n, \"False\".to_string()];\n}\n"}, {"buggy_solution": "\n let mut out: Vec<String> = Vec::new();\n for i in 0..lst.len() {\n let mut sum = 0;\n for j in 0..lst[i].len() {\n if lst[i].chars().nth(j).unwrap() >= '0'\n && lst[i].chars().nth(j).unwrap() <= '9'\n && lst[i].chars().nth(j).unwrap().to_digit(10).unwrap() % 2 == 1\n {\n sum += 1;\n }\n }\n let mut s = \"the number of odd elements in the string i of the input.\".to_string();\n let mut s2 = \"\".to_string();\n for j in 0..s.len() {\n if s.chars().nth(j).unwrap() == 'i' {\n s2.push_str(&sum.to_string());\n } else {\n s2.push(s.chars().nth(j).unwrap());\n }\n }\n out.push(s2);\n }\n return out;\n}\n"}, {"buggy_solution": "\n let mut current = nums[0];\n let mut min = nums[0];\n for i in 1..nums.len() {\n if current < 0 {\n current = current + nums[i];\n } else {\n current = nums[i];\n }\n if current < min {\n min = current;\n }\n }\n min\n}\n"}, {"buggy_solution": "\n let mut out: i32 = 0;\n\n for i in 0..grid.len() {\n let mut sum: i32 = 0;\n\n for j in 0..grid[i].len() {\n sum += grid[i][j];\n }\n if sum > 0 {\n out += (sum - 1) / capacity + 1;\n }\n }\n return out;\n}\n"}, {"buggy_solution": "\n let mut arr_cp = arr.clone();\n let mut bin = vec![];\n let mut m;\n\n for i in 0..arr_cp.len() {\n let mut b = 0;\n let mut n = arr_cp[i].abs();\n while n > 0 {\n b += n % 2;\n n = n / 2;\n }\n bin.push(b);\n }\n for i in 0..arr_cp.len() {\n for j in 1..arr_cp.len() {\n if bin[j] < bin[j - 1] || (bin[j] == bin[j - 1] && arr_cp[j] < arr_cp[j - 1]) {\n m = arr_cp[j];\n arr_cp[j] = arr_cp[j - 1];\n arr_cp[j - 1] = m;\n m = bin[j];\n bin[j] = bin[j - 1];\n bin[j - 1] = m;\n }\n }\n }\n return arr_cp;\n}\n"}, {"buggy_solution": "\n let vowels = \"aeiouAEIOU\";\n let mut current = String::new();\n let mut out = Vec::new();\n let mut numc = 0;\n let mut s = s.to_string();\n s.push(' ');\n for i in 0..s.len() {\n if s.chars().nth(i).unwrap() == ' ' {\n if numc == n {\n out.push(current);\n }\n current = String::new();\n numc = 0;\n } else {\n current.push(s.chars().nth(i).unwrap());\n if (s.chars().nth(i).unwrap() >= 'A' && s.chars().nth(i).unwrap() <= 'Z')\n || (s.chars().nth(i).unwrap() >= 'a' && s.chars().nth(i).unwrap() <= 'z')\n {\n if !vowels.contains(s.chars().nth(i).unwrap()) {\n numc += 1;\n }\n }\n }\n }\n out\n}\n"}, {"buggy_solution": "\n let vowels = \"AEIOUaeiou\";\n let mut out = \"\".to_string();\n for i in (1..word.len() - 1).rev() {\n if vowels.contains(word.chars().nth(i).unwrap()) {\n if !vowels.contains(word.chars().nth(i + 1).unwrap()) {\n if !vowels.contains(word.chars().nth(i - 1).unwrap()) {\n out.push(word.chars().nth(i).unwrap());\n return out;\n }\n }\n }\n }\n out\n}\n"}, {"buggy_solution": "\n let l1 = lst[0].to_string() + lst[1];\n let mut count = 0;\n let mut can = true;\n for i in 0..l1.len() {\n if l1.chars().nth(i).unwrap() == '(' {\n count += 1;\n }\n if l1.chars().nth(i).unwrap() == ')' {\n count -= 1;\n }\n if count < 0 {\n can = false;\n }\n }\n if count != 0 {\n return \"No\";\n }\n if can == true {\n return \"Yes\";\n }\n let l1 = lst[1].to_string() + lst[0];\n let mut can = true;\n for i in 0..l1.len() {\n if l1.chars().nth(i).unwrap() == '(' {\n count += 1;\n }\n if l1.chars().nth(i).unwrap() == ')' {\n count -= 1;\n }\n if count < 0 {\n can = false;\n }\n }\n if can == true {\n return \"Yes\";\n }\n return \"No\";\n}\n"}, {"buggy_solution": "\n let mut arr = arr;\n arr.sort();\n let mut arr_res: Vec<i32> = arr.iter().rev().take(k as usize).cloned().collect();\n arr_res.sort();\n return arr_res;\n}\n"}, {"buggy_solution": "\n let mut sum = 0;\n for (indx, elem) in lst.iter().enumerate() {\n if indx % 2 == 0 {\n if elem % 2 == 1 {\n sum += elem;\n }\n }\n }\n return sum;\n}\n"}, {"buggy_solution": "\n let mut sum = 0;\n for i in 0..k {\n if arr[i as usize] >= -99 && arr[i as usize] <= 99 {\n sum += arr[i as usize];\n }\n }\n sum\n}\n"}, {"buggy_solution": "\n let mut out = vec![1];\n let mut n = n;\n while n != 1 {\n if n % 2 == 1 {\n out.push(n);\n n = n * 3 + 1;\n } else {\n n = n / 2;\n }\n }\n out.sort();\n out\n}\n\n"}, {"buggy_solution": "\n let mut mm = 0;\n let mut dd = 0;\n let mut yy = 0;\n let mut i = 0;\n if date.len() != 10 {\n return false;\n }\n for i in 0..10 {\n if i == 2 || i == 5 {\n if date.chars().nth(i).unwrap() != '-' {\n return false;\n }\n } else if date.chars().nth(i).unwrap() < '0' || date.chars().nth(i).unwrap() > '9' {\n return false;\n }\n }\n mm = date[0..2].parse::<i32>().unwrap();\n dd = date[3..5].parse::<i32>().unwrap();\n yy = date[6..10].parse::<i32>().unwrap();\n if mm < 1 || mm > 12 {\n return false;\n }\n if dd < 1 || dd > 31 {\n return false;\n }\n if dd == 31 && (mm == 4 || mm == 6 || mm == 9 || mm == 11 || mm == 2) {\n return false;\n }\n if dd == 30 && mm == 2 {\n return false;\n }\n return true;\n}\n"}, {"buggy_solution": "\n let mut out: Vec<String> = Vec::new();\n let alphabet: HashMap<char, i32> = HashMap::from([\n ('a', 0),\n ('b', 1),\n ('c', 2),\n ('d', 3),\n ('e', 4),\n ('f', 5),\n ('g', 6),\n ('h', 7),\n ('i', 8),\n ('j', 9),\n ('k', 10),\n ('l', 11),\n ('m', 12),\n ('n', 13),\n ('o', 14),\n ('p', 15),\n ('q', 16),\n ('r', 17),\n ('s', 18),\n ('t', 19),\n ('u', 20),\n ('v', 21),\n ('w', 22),\n ('x', 23),\n ('y', 24),\n ('z', 25),\n ]);\n\n if txt.contains(' ') {\n out = txt\n .split_whitespace()\n .into_iter()\n .map(|c| c.to_string())\n .collect();\n } else if txt.contains(',') {\n out = txt.split(',').into_iter().map(|c| c.to_string()).collect();\n } else {\n let count = txt\n .chars()\n .into_iter()\n .filter(|c| c.is_ascii_lowercase())\n .filter(|c| alphabet.get(c).unwrap() % 2 == 1)\n .count();\n out.push(count.to_string());\n }\n\n return out;\n}\n"}, {"buggy_solution": "\n for i in 1..lst.len() {\n if lst[i] < lst[i - 1] {\n return false;\n }\n if i >= 2 && lst[i] == lst[i - 1] && lst[i] == lst[i - 2] {\n return false;\n }\n }\n true\n}\n"}, {"buggy_solution": "\n let inter1 = std::cmp::max(interval1[0], interval2[0]);\n let inter2 = std::cmp::min(interval1[1], interval2[1]);\n let l = inter2 - inter1;\n if l < 2 {\n return \"NO\".to_string();\n }\n for i in 2..l {\n if l % i == 0 {\n return \"NO\".to_string();\n }\n }\n return \"YES\".to_string();\n}\n"}, {"buggy_solution": "\n if arr.is_empty() {\n return -32768;\n }\n let mut sum = 0;\n let mut prods = 1;\n for i in arr {\n sum += i.abs();\n if i == 0 {\n prods = 0;\n }\n if i < 0 {\n prods = -prods;\n }\n }\n sum * prods\n}\n\n"}, {"buggy_solution": "\n let mut out: Vec<i32> = vec![];\n let mut x = 0;\n let mut y = 0;\n let mut min: i32 = (grid.len() * grid.len()) as i32;\n for i in 0..grid.len() {\n for j in 0..grid[i].len() {\n if grid[i][j] == 1 {\n x = i;\n y = j;\n }\n }\n }\n if x > 0 && grid[x - 1][y] < min {\n min = grid[x - 1][y];\n }\n if x < grid.len() - 1 && grid[x + 1][y] < min {\n min = grid[x + 1][y];\n }\n if y > 0 && grid[x][y - 1] < min {\n min = grid[x][y - 1];\n }\n if y < grid.len() - 1 && grid[x][y + 1] < min {\n min = grid[x][y + 1];\n }\n let mut out = vec![];\n for i in 0..k {\n if i % 2 == 0 {\n out.push(1);\n } else {\n out.push(min);\n }\n }\n out\n}\n"}, {"buggy_solution": "\n let mut out = vec![1, 3];\n if n == 0 {\n return vec![1];\n }\n for i in 2..=n {\n if i % 2 == 0 {\n out.push(1 + i / 2);\n } else {\n out.push(out[(i - 1) as usize] + out[(i - 2) as usize] + 1 + (i + 1) / 2);\n }\n }\n out\n}\n"}, {"buggy_solution": "\n let mut prod: i32 = 1;\n let mut has = 0;\n let s = n.to_string();\n for i in 0..s.len() {\n if s.chars().nth(i).unwrap().to_digit(10).unwrap() % 2 == 1 {\n has = 1;\n prod = prod * (s.chars().nth(i).unwrap().to_digit(10).unwrap()) as i32;\n }\n }\n if has == 0 {\n return 0;\n }\n prod\n}\n"}, {"buggy_solution": "\n let mut count = 0;\n let mut maxcount = 0;\n for i in 0..str.len() {\n if str.chars().nth(i).unwrap() == '[' {\n count += 1;\n }\n if str.chars().nth(i).unwrap() == ']' {\n count -= 1;\n }\n if count < 0 {\n count = 0;\n }\n if count > maxcount {\n maxcount = count;\n }\n if count <= maxcount - 2 {\n return true;\n }\n }\n return false;\n}\n"}, {"buggy_solution": "\n let mut sum: f32 = 0.0;\n for i in 0..lst.len() {\n sum = sum + (lst[i].ceil() * lst[i].ceil());\n }\n sum as i32\n}\n"}, {"buggy_solution": "\n if txt.len() == 0 {\n return false;\n }\n let chr = txt.chars().last().unwrap();\n if chr < 'A' || (chr > 'Z' && chr < 'a') || chr > 'z' {\n return false;\n }\n if txt.len() == 1 {\n return true;\n }\n let chr = txt.chars().nth(txt.len() - 2).unwrap();\n if (chr >= 'A' && chr <= 'Z') || (chr >= 'a' && chr <= 'z') {\n return false;\n }\n true\n}\n"}, {"buggy_solution": "\n let mut max: i32 = -1;\n for i in 0..arr.len() {\n if arr[i] <= i as i32 {\n max = i as i32;\n }\n }\n max\n}\n\n"}, {"buggy_solution": "\n let mut maxneg = 0;\n let mut minpos = 0;\n for i in 0..lst.len() {\n if lst[i] < 0 && (maxneg == 0 || lst[i] > maxneg) {\n maxneg = lst[i];\n }\n if lst[i] > 0 && (minpos == 0 || lst[i] < minpos) {\n minpos = lst[i];\n }\n }\n vec![maxneg, minpos]\n}\n"}, {"buggy_solution": "\n let a_f64 = Any_to_f64(a);\n let b_f64 = Any_to_f64(b);\n\n if a_f64 > b_f64 {\n return original_type(a);\n }\n\n if a_f64 < b_f64 {\n return original_type(b);\n } else {\n return RtnType::String(\"None\".to_string());\n }\n}\n\n#[derive(Debug, PartialEq)]\npub enum RtnType<S, F, I> {\n Empty(),\n String(S),\n Float(F),\n Int(I),\n}\n\nfn Any_to_f64(a: &dyn Any) -> f64 {\n let mut a_f64 = 0.0;\n\n if a.downcast_ref::<f64>() == None {\n match a.downcast_ref::<&str>() {\n Some(as_string) => {\n a_f64 = as_string.parse::<f64>().unwrap();\n }\n None => {}\n }\n\n match a.downcast_ref::<i32>() {\n Some(as_i32) => {\n a_f64 = *as_i32 as f64;\n }\n None => {}\n }\n } else {\n a_f64 = *a.downcast_ref::<f64>().unwrap();\n }\n\n return a_f64;\n}\n\nfn original_type(a: &dyn Any) -> RtnType<String, f64, i32> {\n let mut res = RtnType::Empty();\n match a.downcast_ref::<&str>() {\n Some(as_string) => {\n res = RtnType::String(as_string.parse::<String>().unwrap());\n }\n None => {}\n }\n\n match a.downcast_ref::<i32>() {\n Some(as_i32) => {\n res = RtnType::Int(*as_i32);\n }\n None => {}\n }\n\n match a.downcast_ref::<f64>() {\n Some(as_f64) => res = RtnType::Float(*as_f64),\n None => {}\n }\n return res;\n}\n"}, {"buggy_solution": "\n if n % 2 == 0 && n >= 8 {\n return true;\n }\n return false;\n}\n"}, {"buggy_solution": "\n let mut fact = 1;\n let mut bfact: i64 = 1;\n for i in 1..=n {\n fact = fact * i;\n bfact = bfact * fact as i64;\n }\n bfact\n}\n"}, {"buggy_solution": "\n let mut out = String::new();\n let mut spacelen = 0;\n for c in text.chars() {\n if c == ' ' {\n spacelen += 1;\n } else {\n if spacelen == 1 {\n out.push('_');\n }\n if spacelen == 2 {\n out.push_str(\"__\");\n }\n if spacelen > 2 {\n out.push('-');\n }\n spacelen = 0;\n out.push(c);\n }\n }\n if spacelen == 1 {\n out.push('_');\n }\n if spacelen == 2 {\n out.push_str(\"__\");\n }\n if spacelen > 2 {\n out.push('-');\n }\n out\n}\n"}, {"buggy_solution": "\n let mut numdigit = 0;\n let mut numdot = 0;\n if file_name.len() < 5 {\n return \"No\";\n }\n let w = file_name.chars().nth(0).unwrap();\n if w < 'A' || (w > 'Z' && w < 'a') || w > 'z' {\n return \"No\";\n }\n let last = &file_name[file_name.len() - 4..];\n if last != \".txt\" && last != \".exe\" && last != \".dll\" {\n return \"No\";\n }\n for c in file_name.chars() {\n if c >= '0' && c <= '9' {\n numdigit += 1;\n }\n if c == '.' {\n numdot += 1;\n }\n }\n if numdigit > 3 || numdot != 1 {\n return \"No\";\n }\n return \"Yes\";\n}\n"}, {"buggy_solution": "\n let mut sum = 0;\n for i in 0..lst.len() {\n if i % 3 == 0 {\n sum += lst[i] * lst[i];\n } else if i % 4 == 0 {\n sum += lst[i] * lst[i] * lst[i];\n } else {\n sum += lst[i];\n }\n }\n return sum;\n}\n"}, {"buggy_solution": "\n let mut out = String::new();\n let mut current = String::new();\n let mut sentence = sentence.to_string();\n sentence.push(' ');\n\n for i in 0..sentence.len() {\n if sentence.chars().nth(i).unwrap() != ' ' {\n current.push(sentence.chars().nth(i).unwrap());\n } else {\n let mut isp = true;\n let l = current.len();\n if l < 2 {\n isp = false;\n }\n for j in 2..(l as f64).sqrt() as usize + 1 {\n if l % j == 0 {\n isp = false;\n }\n }\n if isp {\n out.push_str(&current);\n out.push(' ');\n }\n current = String::new();\n }\n }\n if out.len() > 0 {\n out.pop();\n }\n out\n}\n"}, {"buggy_solution": "\n let mut a = 0;\n let mut b = 0;\n let mut c = 0;\n let mut d = 0;\n let mut i = 0;\n for i in 0..x.len() {\n if x.chars().nth(i).unwrap() == '/' {\n a = x\n .chars()\n .take(i)\n .collect::<String>()\n .parse::<i32>()\n .unwrap();\n b = x\n .chars()\n .skip(i + 1)\n .collect::<String>()\n .parse::<i32>()\n .unwrap();\n }\n }\n for i in 0..n.len() {\n if n.chars().nth(i).unwrap() == '/' {\n c = n\n .chars()\n .take(i)\n .collect::<String>()\n .parse::<i32>()\n .unwrap();\n d = n\n .chars()\n .skip(i + 1)\n .collect::<String>()\n .parse::<i32>()\n .unwrap();\n }\n }\n if (a * c) % (b * d) == 0 {\n return true;\n }\n return false;\n}\n"}, {"buggy_solution": "\n let mut result = arr.clone();\n result.sort_by_key(|&x| (sum_of_digits(x)));\n result\n}\n\npub fn sum_of_digits(n: i32) -> i32 {\n let mut sum = 0;\n let mut n = n;\n if n < 0 {\n let right = n / 10;\n let mut left;\n\n if right != 0 {\n left = n % 10;\n left = -1 * left;\n } else {\n left = n % 10;\n }\n sum = right + left;\n return sum;\n }\n\n while n > 0 {\n sum += n % 10;\n n /= 10;\n }\n sum\n}\n"}, {"buggy_solution": "\n let mut num = 0;\n for i in 0..nums.len() {\n if nums[i] > 10 {\n let w = nums[i].to_string();\n if w.chars().nth(0).unwrap().to_digit(10).unwrap() % 2 == 1\n && w.chars().last().unwrap().to_digit(10).unwrap() % 2 == 1\n {\n num += 1;\n }\n }\n }\n num\n}\n"}, {"buggy_solution": "\n let mut a = vec![];\n let mut sum = vec![vec![0, 0, 0]];\n let mut sum2 = vec![vec![0, 0, 0]];\n\n for i in 1..=n {\n a.push((i * i - i + 1) % 3);\n sum.push(sum[sum.len() - 1].clone());\n sum[i as usize][a[i as usize - 1] as usize] += 1;\n }\n\n for times in 1..3 {\n for i in 1..=n {\n sum2.push(sum2[sum2.len() - 1].clone());\n if i >= 1 {\n for j in 0..=2 {\n sum2[i as usize][(a[i as usize - 1] + j) as usize % 3] +=\n sum[i as usize - 1][j as usize];\n }\n }\n }\n sum = sum2.clone();\n sum2 = vec![vec![0, 0, 0]];\n }\n\n return sum[n as usize][0];\n}\n"}, {"buggy_solution": "\n let planets = vec![\n \"Mercury\", \"Venus\", \"Earth\", \"Mars\", \"Jupiter\", \"Saturn\", \"Uranus\", \"Neptune\",\n ];\n let mut pos1: i32 = -1;\n let mut pos2: i32 = -1;\n let mut m;\n for m in 0..planets.len() {\n if planets[m] == planet1 {\n pos1 = m as i32;\n }\n if planets[m] == planet2 {\n pos2 = m as i32;\n }\n }\n if pos1 == -1 || pos2 == -1 {\n return vec![];\n }\n if pos1 > pos2 {\n m = pos1;\n pos1 = pos2;\n pos2 = m;\n }\n let mut out = vec![];\n for m in pos1 + 1..pos2 {\n out.push(planets[m as usize].to_string());\n }\n return out;\n}\n"}, {"buggy_solution": "\n let mut out: Vec<&str> = Vec::new();\n for i in 0..lst.len() {\n if lst[i].len() % 2 == 0 {\n out.push(lst[i]);\n }\n }\n out.sort();\n for i in 0..out.len() {\n for j in 1..out.len() {\n if out[j].len() < out[j - 1].len() {\n let mid = out[j];\n out[j] = out[j - 1];\n out[j - 1] = mid;\n }\n }\n }\n return out;\n}\n"}, {"buggy_solution": "\n let mut isp = true;\n if n < 2 {\n isp = false;\n }\n for i in 2..=n / 2 {\n if n % i == 0 {\n isp = false;\n }\n }\n if isp {\n return x;\n }\n return y;\n}\n"}, {"buggy_solution": "\n let mut sum: i64 = 0;\n for i in 0..lst.len() {\n if (lst[i] - lst[i].round()).abs() < 1e-4 {\n if lst[i] > 0.0 && (lst[i].round() as i64) % 2 == 1 {\n sum += (lst[i].round() as i64) * (lst[i].round() as i64);\n }\n }\n }\n return sum;\n}\n"}, {"buggy_solution": "\n let mut out: Vec<i32> = Vec::new();\n for i in 0..game.len() {\n out.push(i32::abs(game[i] - guess[i]));\n }\n return out;\n}\n"}, {"buggy_solution": "\n let mut strongest = \"\";\n let mut max = -1000;\n for i in 0..extensions.len() {\n let mut strength = 0;\n for j in 0..extensions[i].len() {\n let chr = extensions[i].chars().nth(j).unwrap();\n if chr >= 'A' && chr <= 'Z' {\n strength += 1;\n }\n if chr >= 'a' && chr <= 'z' {\n strength -= 1;\n }\n }\n if strength > max {\n max = strength;\n strongest = extensions[i];\n }\n }\n format!(\"{}.{}\", class_name, strongest)\n}\n"}, {"buggy_solution": "\n for i in 0..b.len() {\n let rotate = format!(\"{}{}\", &b[i..], &b[..i]);\n if a.contains(&rotate) {\n return true;\n }\n }\n false\n}\n\n"}, {"buggy_solution": "\n let w = num.abs().to_string();\n let mut n1 = 0;\n let mut n2 = 0;\n for i in 0..w.len() {\n if w.chars().nth(i).unwrap().to_digit(10).unwrap() % 2 == 1 {\n n1 += 1;\n } else {\n n2 += 1;\n }\n }\n vec![n2, n1]\n}\n"}, {"buggy_solution": "\n let mut current = String::new();\n let mut number = number;\n let rep = vec![\n \"m\", \"cm\", \"d\", \"cd\", \"c\", \"xc\", \"l\", \"xl\", \"x\", \"ix\", \"v\", \"iv\", \"i\",\n ];\n let num = vec![1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];\n let mut pos = 0;\n while number > 0 {\n while number >= num[pos] {\n current.push_str(rep[pos]);\n number -= num[pos];\n }\n if number > 0 {\n pos += 1;\n }\n }\n current\n}\n"}, {"buggy_solution": "\n if (a * a + b * b - c * c).abs() < 1e-4\n || (a * a + c * c - b * b).abs() < 1e-4\n || (b * b + c * c - a * a).abs() < 1e-4\n {\n return true;\n }\n return false;\n}\n"}, {"buggy_solution": "\n let mut max = \"\";\n let mut maxu = 0;\n for i in 0..words.len() {\n let mut unique = String::from(\"\");\n for j in 0..words[i].len() {\n if !unique.contains(words[i].chars().nth(j).unwrap()) {\n unique.push(words[i].chars().nth(j).unwrap());\n }\n }\n if unique.len() > maxu || (unique.len() == maxu && words[i] < max) {\n max = words[i];\n maxu = unique.len();\n }\n }\n max\n}\n"}, {"buggy_solution": "\n if need > remaining {\n return vec![number + remaining, 0];\n }\n return vec![number + need, remaining - need];\n}\n"}, {"buggy_solution": "\n let mut operand: Vec<i32> = operand;\n let mut num: Vec<i32> = vec![];\n let mut posto: Vec<i32> = vec![];\n for i in 0..operand.len() {\n posto.push(i as i32);\n }\n for i in 0..operato.len() {\n if operato[i] == \"**\" {\n while posto[posto[i] as usize] != posto[i] {\n posto[i] = posto[posto[i] as usize];\n }\n while posto[posto[i + 1] as usize] != posto[i + 1] {\n posto[i + 1] = posto[posto[i + 1] as usize];\n }\n operand[posto[i] as usize] =\n operand[posto[i] as usize].pow(operand[posto[i + 1] as usize] as u32);\n posto[i + 1] = posto[i];\n }\n }\n for i in 0..operato.len() {\n if operato[i] == \"*\" || operato[i] == \"//\" {\n while posto[posto[i] as usize] != posto[i] {\n posto[i] = posto[posto[i] as usize];\n }\n while posto[posto[i + 1] as usize] != posto[i + 1] {\n posto[i + 1] = posto[posto[i + 1] as usize];\n }\n if operato[i] == \"*\" {\n operand[posto[i] as usize] =\n operand[posto[i] as usize] * operand[posto[i + 1] as usize];\n } else {\n operand[posto[i] as usize] =\n operand[posto[i] as usize] / operand[posto[i + 1] as usize];\n }\n posto[i + 1] = posto[i];\n }\n }\n for i in 0..operato.len() {\n if operato[i] == \"+\" || operato[i] == \"-\" {\n while posto[posto[i] as usize] != posto[i] {\n posto[i] = posto[posto[i] as usize];\n }\n while posto[posto[i + 1] as usize] != posto[i + 1] {\n posto[i + 1] = posto[posto[i + 1] as usize];\n }\n if operato[i] == \"+\" {\n operand[posto[i] as usize] =\n operand[posto[i] as usize] + operand[posto[i + 1] as usize];\n } else {\n operand[posto[i] as usize] =\n operand[posto[i] as usize] - operand[posto[i + 1] as usize];\n }\n posto[i + 1] = posto[i];\n }\n }\n operand[0]\n}\n"}, {"buggy_solution": "\n let mut nletter = 0;\n let mut out = String::new();\n for c in s.chars() {\n let mut w = c;\n if w >= 'A' && w <= 'Z' {\n w = w.to_ascii_lowercase();\n } else if w >= 'a' && w <= 'z' {\n w = w.to_ascii_uppercase();\n } else {\n nletter += 1;\n }\n out.push(w);\n }\n if nletter == s.len() {\n out.chars().rev().collect()\n } else {\n out\n }\n}\n"}, {"buggy_solution": "\n if text.is_empty() {\n return \"None\".to_string();\n }\n\n let digest = md5::compute(text.as_bytes());\n return format!(\"{:x}\", digest);\n}\n"}, {"buggy_solution": "\n let mut a = a;\n let mut b = b;\n let mut m;\n\n if b < a {\n m = a;\n a = b;\n b = m;\n }\n\n let mut out = vec![];\n for i in a..=b {\n if i < 10 && i % 2 == 0 {\n out.push(i);\n }\n }\n out\n}\n"}]