fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define dd double
  5. #define ld long double
  6. #define pi 3.14159265359
  7. #define ull unsigned long long
  8. #define yes cout<<"YES\n"
  9. #define no cout<<"NO\n"
  10. #define el "\n"
  11. #define Arwa ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  12. #define fix(x) cout<<fixed<<setprecision(x)
  13. ll gcd(ll a,ll b) {return b==0?a:gcd(b,a%b);}
  14. ll lcm(int a,int b) {return a/gcd(a,b)*b;}
  15. bool prime(ll n)
  16. {
  17. if(n==2) return true;
  18. if(n%2==0||n==1) return false;
  19. else { for(ll i=3; i*i<=n; i+=2) {if(n%i==0) return false;}}return true;
  20. }
  21. //here we go again
  22. int main()
  23. {
  24. Arwa
  25. int t=1;
  26. //cin>>t;
  27. while(t--)
  28. {
  29. int n,k,count=0;
  30. ll freq[100]={};
  31. cin>>n>>k;
  32. int arr[n];
  33. for(int i=0;i<n;i++)
  34. cin>>arr[i];
  35. for(int i=0;i<n;i++)
  36. arr[i]%=k;
  37. for(int i=0;i<n;i++)
  38. freq[arr[i]]++;
  39. if(freq[0])
  40. {
  41. count+=freq[0]/2*2;
  42. freq[0]=0;
  43. }
  44. for(int i=1;i<k;i++)
  45. {
  46. if(freq[i]&&freq[k-i]&&i!=0)
  47. {
  48. freq[i]--;
  49. freq[k-i]--;
  50. count+=2;
  51. }
  52. }
  53. cout<<count<<el;
  54. }
  55. return 0;
  56. }
  57. /*
  58. */
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
0