https://www.acmicpc.net/problem/13304
using System;
class Program
{
static int num(int sum,int k){
int room=sum%k;
int c=0;
if(room==0) c=sum/k;
else c=(sum/k)+1;
return c;
}
static void Main() {
string[] s=Console.ReadLine().Split(' ');
int n=int.Parse(s[0]);
int k=int.Parse(s[1]);
int[] boy=new int[6];
int[] girl=new int[6];
int count=0;
for(int i=0;i<n;i++){
string[] s1=Console.ReadLine().Split(' ');
int e=int.Parse(s1[0]);
int y=int.Parse(s1[1]);
if(e==0) girl[y-1]++;
else boy[y-1]++;
}
int sum=0;
for(int i=0;i<6;i+=2){
if(i==0){
sum=boy[i]+boy[i+1]+girl[i]+girl[i+1];
count+=num(sum,k);
}
else{
sum=boy[i]+boy[i+1];
count+=num(sum,k);
sum=girl[i]+girl[i+1];
count+=num(sum,k);
}
}
Console.Write(count);
}
}