```
public class Solution {
public int distributeCandies(int[] candies) {
HashMap<Integer,Integer> map=new HashMap<Integer,Integer>();
for(int i=0;i<candies.length;i++){
map.put(candies[i],candies[i]);
}
int result=0;
int kinds=map.size();
int half=candies.length/2+candies.length%2;
return kinds<half?kinds:half;
}
}
```