```
public class Solution {
public int distributeCandies(int[] candies) {
int len=candies.length;
Map<Integer,Integer> hashK=new HashMap<>(1024);
for(int i=0;i<len;i++){
if(!hashK.containsKey(candies[i])){
hashK.put(candies[i],i);
}
}
int kindSize=hashK.size();
return kindSize>=len/2?len/2:kindSize;
}
}
```