akhauriyash/Code-Regression huggingface dataset:
///HELLO THERE~!
///CREATED BY MD SADMAN MEHEDI SIVAN(IUT CSE[SWE'19])

#include<bits/stdc++.h>
using namespace std;

#define FASTIO          ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define READ            freopen("input.txt","r",stdin);
#define WRITE           freopen("red.txt","w",stdout);

using ll=long long;
using ull=unsigned long long;
const double pi = 2*acos(0.0);
const long long MX = 2e5+7;

int main()
{
    FASTIO;
    string s;
    cin>>s;
    ll d=s.size();
    ll a=0,b=0;
    string p,q;
    if(d%2==0)

    {
        for(ll i=0; i<d; i++)
        {
            p.push_back('1');
            p.push_back('0');
        }
        for(ll i=0; i<d; i++)
        {
            q.push_back('0');
            q.push_back('1');
        }
        for(ll i=0; i<d; i++)
        {
            if(s[i]!=p[i])
                a++;
            if(s[i]!=q[i])
                b++;

        }
        cout<<min(a,b);
    }



       if(d%2==1)

    {
        for(ll i=0; i<d-1; i++)
        {
            p.push_back('1');
            p.push_back('0');
        }
        p.push_back('1');
        for(ll i=0; i<d-1; i++)
        {
            q.push_back('0');
            q.push_back('1');
        }
        q.push_back('0');
        for(ll i=0; i<d; i++)
        {
            if(s[i]!=p[i])
                a++;
            if(s[i]!=q[i])
                b++;

        }
        cout<<min(a,b);
    }



    return 0;



}


Measured memory_bytes: 3960
#include <iostream>
#include <sstream>

int main() {
    int H, W;
    std::stringstream ss;
    while (std::cin >> H >> W) {
        if (H == 0 && W == 0) break;
        else {
            for (int i=0;i<H;i++) {
                for (int j=0;j<W;j++)
                    if ((i + j) % 2 == 0)
                        ss << "#";
                    else
                        ss << ".";
                ss << "\n";
            }
            ss << "\n";
        }
    }

    std::cout << ss.str();
    
    return 0;
}


Measured memory_bytes: 3296
#include <iostream>
#include <algorithm>
using namespace std;
int solve(int x) {
	int ret = 0;
	for (int i = 0; i * i * i <= x; i++) {
		int l = 0, r = 100;
		while (r - l > 1) {
			int m = (l + r) / 2;
			int res = m * (m + 1) * (m + 2) / 6;
			if (res + i * i * i <= x) l = m;
			else r = m;
		}
		ret = max(ret, i * i * i + l * (l + 1) * (l + 2) / 6);
	}
	return ret;
}
int main() {
	int n;
	while (cin >> n, n) cout << solve(n) << endl;
	return 0;
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
#include<iostream>
using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < n; i++)
#define REP(n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using INT64 = long long;
using UINT64 = unsigned long long;

int main(void)
{
    IOS
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    a--;b--;c--;d--;
    string s;
    cin >> s;

    int st = 0;
    int dt = 0;
    int dtmp = 0;
    int e = max(c,d);
    FOR(i,a,e) {
        if (((i > a) || (i < c)) && ((i > b) || (i < d))) {
            if (s[i] == '#') {
                st++;
                if (st == 2) {
                    cout << "No" << endl;
                    return 0;
                }
            } else {
                st = 0;
            }
        } else {
            st = 0;
        }
        if ((i >= b-1) && (i <= d+1)) {
            if (s[i] == '.') {
                dtmp++;
            } else {
                dtmp = 0;
            }
            if (dt < dtmp) {
                dt = dtmp;
            }

        }

    }
    if ((c < d) || (dt > 2)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
            return 0;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
template<typename T> T gcd(T a,T b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 100005;
int n;
ll c, x[N], s[N], l[N], r;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> c;
  FOR(i, 1, n+1){
    cin >> x[i] >> s[i];
    s[i] += s[i-1];
    l[i] = max(l[i-1], s[i]-x[i]);
  }
  ll ans = 0;
  FORR(i, n, 1){
    maxs(ans, s[i]-x[i]);
    maxs(ans, s[i]-x[i]*2+r);
    maxs(ans, s[n]-s[i-1]-c+x[i]);
    maxs(ans, s[n]-s[i-1]-(c-x[i])*2+l[i-1]);
    maxs(r, s[n]-s[i-1]-c+x[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll n;
    cin >> n;

    ll a[n];
    ll sum = 0;
    rep(i, 0, n){
        cin >> a[i];
        sum += a[i];
    }

    ll x = round(sum / double(n));

    ll ans = 0;
    rep(i, 0, n){
        ans += pow(a[i] - x, 2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

#define N 200
int n;
int a[N];

int main()
{
	int ans = 0;

	cin >> n;
	for( int i = 0; i < n; i++ ) {
		cin >> a[i];
	}

	while( 1 ) {
		int flag = 0;
		for( int i = 0; i < n; i++ ) {
			if( (a[i] % 2) != 0 ) {
				flag = 1;
				break;
			}
			a[i] /= 2;
		}
		if( flag != 0 ) {
			break;
		}
		ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int N, K;
  cin >> N >> K;
  int x = N % K;
  int y = abs(x - K);
  cout << min(x, y) << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

S = input()
N = len(S)

def counter(str, index):
    n_s = len(str)
    cnt = 0
    if n_s == 1 and index == N - 1:
        if str == 'g':
            cnt += 1
    # 一番最初の手については両者ともg

    elif n_s == 2:
        if str == 'gg':
            cnt += 1
        # 存在しない
        elif str == 'pp':
            cnt -= 1
    return cnt

ans = 0
for i in range(-1, N, 2):
    str_S = S[max(0, i):min(N - 1, i + 1) + 1]
    ans += counter(str_S, i)
print(ans)

Measured memory_bytes: 61548
n ,t = gets.split.map(&:to_i)
tn = gets.split.map(&:to_i)
sum = 0
(n - 1).times do |i|
  sum += tn[i+ 1] - tn[i] < t ? tn[i+ 1] - tn[i] : t
end
sum += t
print sum

Measured memory_bytes: 15876
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

int n;
cin>>n;
vector<long long>a(n);
for(int i=0;i<n;i++)
cin>>a[i];
// vector<int>max(n);
// max[0] = a[0];
long long sum =0;
long long m = a[0];
for(int i=1;i<n;i++)
{
    if(a[i] > m)
       m = a[i];
    sum+= m - a[i];

}
cout<<sum<<endl;
return 0;
}

Measured memory_bytes: 4708
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++) a[i] = scan.nextInt();
        int out = Integer.MAX_VALUE;
        for(int i = -100; i <= 100; i++){
            int r = 0;
            for(int j = 0; j < n; j++) r += (int)(Math.pow(a[j] - i, 2));
            out = Math.min(out, r);
        }
        System.out.println(out);
    }
    
    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 35888
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vect vector<ll>
#define unmap unordered_map
#define pb push_back
#define pi 3.1415926536
#define mod int(1e9+7)
#define mp make_pair
#define testcases ll t; cin>>t; while(t--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int h,w;
    cin>>h>>w;
    vector<string> v(h);
    for(int i=0;i<h;i++) cin>>v[i];
    vector<vector<ll>> dp(h,vector<ll>(w,0));

    dp[0][0]=1;
    for(int i=1;i<w;i++) dp[0][i]=dp[0][i-1]&(v[0][i]!='#');
    for(int i=1;i<h;i++) dp[i][0]=dp[i-1][0]&(v[i][0]!='#');
    for(int i=1;i<h;i++)
    {
        for(int j=1;j<w;j++)
        {
            if(v[i][j]=='#') dp[i][j]=0;
            else dp[i][j]=dp[i-1][j]+dp[i][j-1];
            dp[i][j]%=mod;
        }
    }
    cout<<dp[h-1][w-1];
    return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;

int N;


int main(){
  ios_base::sync_with_stdio(false); 
  string s; cin >> s;
  N = s.length();
  char c = ' ';
  int res = 0;
  for(int i=0; i<N; ++i){
   if(c == ' ')
     c = s[i];
   if(c != s[i]){
     ++res;
     c = s[i];
   }
  }
  cout << res << "\n";
  return 0;
}



Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define BUF 1002

int main(void) {
  char s[BUF], t[BUF];
  scanf("%s %s", s, t);

  int min = strlen(t);
  for (int i = 0; i < strlen(s) - strlen(t) + 1; i++) {
    int count = 0;
    for (int j = 0; j < strlen(t); j++) {
      if (s[i + j] != t[j]) { count++; }
    }
    if (min > count) { min = count; }
  }
  printf("%d\n", min);

  return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    ll A[N];
    rep(i, N) cin >> A[i];
    //1〜nまでのmod(m)における逆元
    ll n = 1e6, m = MOD, inv[n+1];
    rep2(i, 1, n){
        ll e[31];
        e[0] = i;
        rep2(j, 1, 30) e[j] = (e[j-1]*e[j-1]) % m;
        inv[i] = 1;
        ll k = m-2;
        int cnt = 0;
        while(k > 0){
            if(k % 2 == 1) inv[i] *= e[cnt], inv[i] %= m;
            k /= 2;
            cnt++;
        }
    }
    //i!とi!の逆元
    ll fac[n+1], ifac[n+1];
    fac[0] = 1, ifac[0] = 1;
    rep2(i, 1, n){
        fac[i] = (fac[i-1]*i) % m;
        ifac[i] = (ifac[i-1]*inv[i]) % m;
    }
    ll a = 0;
    rep(i, N){
        a += inv[A[i]];
        a %= MOD;
    }
    map<ll, int> mp;
    rep(i, N){
        ll k = A[i];
        int j = 2;
        while(j*j <= k){
            int cnt = 0;
            while(k%j == 0){
                k /= j;
                cnt++;
            }
            if(cnt > 0){
                if(!mp.count(j)) mp[j] = cnt;
                else{
                    mp[j] = max(mp[j], cnt);
                }
            }
            if(k == 1) break;
            j++;
        }
        if(k != 1){
            if(!mp.count(k)) mp[k] = 1;
        }
    }
    map<ll, int>::iterator ite;;
    ite = mp.begin();
    ll lcm = a;
    while(ite != mp.end()){
        ll x = ite->first;
        int y = ite->second;
        rep(i, y){
            lcm *= x;
            lcm %= MOD;
        }
        ite++;
    }
    cout << lcm << endl;
}

Measured memory_bytes: 24448
#include <iostream>
#include <algorithm>

#define P 1000000007

using namespace std;

long dp[200][100001];
long S[200];

int main(){
    long N, X;
    cin >> N >> X;
    for(int i = 0; i < N; i++){
        cin >> S[i];
    }
    sort(S, S+N);
    for(int i = 0; i <= 100000; i++){
        dp[0][i] = i%S[0];
    }
    for(int i = 1; i < N; i++){
        for(int j = 0; j <= 100000; j++){
            dp[i][j] = (dp[i-1][j]*i+dp[i-1][j%S[i]])%P;
        }
    }
    cout << dp[N-1][X] << endl;
}

Measured memory_bytes: 156544
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<cmath>
#include<stack>
#include<algorithm>
#define rg register
#define ll long long
#define LDB long double
#define ull unsigned long long
#define view(i,x) for(rg int i=hd[x];i!=-1;i=e[i].nt)
#define go(i,x,a) for(rg int i=a;i<x;i++)
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
using namespace std;

int n,m,a,b;

inline int rd(){
	int ret=0,af=1; char gc=getchar();
	while(gc < '0' || gc > '9'){ if(gc=='-') af=-af; gc=getchar(); }
	while(gc >= '0' && gc <= '9') ret=ret*10+gc-'0',gc=getchar();
	return ret*af;
}

int main(){
	#ifndef ONLINE_JUDGE
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	#endif
	n=rd(); int x;
	go(i,n+1,1){
		if(rd()%2 == 0) b++;
		else a++;
	}
	if(a == 0 || b == 0 || a%2 == 0) puts("YES");
	else puts("NO");
	return 0;
}//Faze


Measured memory_bytes: 256
import bisect

n, m, k = map(int, input().split())
a = [int(_) for _ in input().split()]
b = [int(_) for _ in input().split()]

for i in range(1, n):
    a[i] += a[i-1]
for i in range(1, m):
    b[i] += b[i-1]

a = [0] + a
b = [0] + b

ans = 0

for i in range(n+1):
    can = k - a[i]
    if can < 0:
        break
    j = bisect.bisect_right(b, can)
    ans = max(ans, i+j-1)
print(ans)

Measured memory_bytes: 40652
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     SPEED       ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());




int main()
{
	SPEED;
	ll i,k,j,n,c=0,cs=0,t;
	t=1;
	double m;
	// cin>>t;
	string s;
	setprecn(12);
	while(t--)
	{
		cin>>n>>k;
		// n=s.length();
		// ll a[n];
		double l=n*1.0;
		repe(i,1,n+1)
		{
			ll x=i;
			double p=1.0;
			while(x<k)
			{
				x*=2;
				p/=2;
			}
			p/=l;
			m+=p;
		}
		
		
		cout<<m;
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>



ll n, s[110000], pos[110000], ans[110000];
set<ll> se;
int main() {
	cin >> n;
	REP(i, n) cin >> s[i];
	REP(i, n) {
		pos[s[i]] = i;
	}
	se.insert(-1);
	se.insert(n);
	se.insert(pos[n]);
	FORR(i, n - 1, 1) {
		auto r = se.upper_bound(pos[i]);
		auto l = se.lower_bound(pos[i]);
		ll a = 1, b = 1, c = 1, d = 1;
		if (r != se.end()) {
			b = *r - pos[i];
			auto r2 = se.upper_bound(*r);
			if (r2 != se.end()) {
				d = *r2 - *r;
				if (*r == n)d = 0;
			}
			else d = 0;
		}
		if (l != se.begin()) {
			l--;
			a = pos[i] - *l;
			auto l2 = se.lower_bound(*l);
			if (l2 != se.begin()) {
				l2--;
				c = *l - *l2;
				if (*l == -1)c = 0;
			}
			else c = 0;
		}
		else b = 0;
		ans[i] = (b * c + a * d) * i;
		se.insert(pos[i]);
	}
	ll out = 0;
	REPO(i, n) {
		out += ans[i];
	}
	cout << out << endl;
}



Measured memory_bytes: 7296
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define iinf (3000LL*1000LL*1000LL*1000LL*1000LL*1000LL+5LL)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
 int a[100005],b[100005];
int main(){
	std::ios::sync_with_stdio(false);
	int i,j,k,k1,k2,cont,n;
	ll ans=0,res=0;
	cin>>n>>k;
	rep(i,n){
		cin>>a[i]>>b[i];
	}
	rep(j,n){
			cont=k;
			cont^=a[j];
			rep(k2,31){
				//if(k2==1){
				//	cout<<(cont&(1<<k2))<<" "<<(k&(1<<k2))<<endl;
				//}
				if(((cont&(1<<k2))>0)&&((k&(1<<k2))==0)){
					//cout<<k2<<endl;
					break;
				}
			}
			if(k2==31){
				//cout<<j<<" "<<cont<<endl;
				ans+=b[j];
			}
		}
	res=max(ans,res);
	//cout<<res<<endl;
	rep(i,31){
		k1=k;
		if(k&(1<<i)){
			k1|=(1<<i)-1;
			k1^=(1<<i);
			ans=0;
			rep(j,n){
				cont=k1;
				cont^=a[j];
				rep(k2,31){
						if(((cont&(1<<k2))>0)&&((k1&(1<<k2))==0)){
						//cout<<k2<<endl;
						break;
					}
				}
				if(k2==31){
					ans+=b[j];
				}
			}
			res=max(ans,res);
		}
	}
	cout<<res<<endl;
} 


Measured memory_bytes: 1024
a,b,c,x,y=map(x->parse(Int,x),split(readline()))
c=c*2
ans=min(x,y)*min(a+b,c)
if x<y
  y-=x
  x=0
else
  x-=y
  y=0
end
ans+=x*min(a,c)
ans+=y*min(b,c)
println(ans)

Measured memory_bytes: 110668
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <sstream>
#include <tuple>
#include <vector>

using namespace std;
using namespace chrono;

#ifdef DEBUG
	#define LOCAL_INPUT_FILE
#else
	//~ #define USE_FILE_IO
#endif

#ifdef USE_FILE_IO
	#define INPUT_FILE "input.txt"
	#define OUTPUT_FILE "output.txt"
	#define cin ____cin
	#define cout ____cout
	ifstream cin(INPUT_FILE);
	ofstream cout(OUTPUT_FILE);
#else
	#ifdef LOCAL_INPUT_FILE
		#define cin ____cin
		ifstream cin("input.txt");
	#endif
#endif

const int infinity = (int)1e9 + 42;
const int64_t llInfinity = (int64_t)1e18 + 256;
const int module = (int)1e9 + 7; 
const long double eps = 1e-8;

mt19937_64 randGen(system_clock().now().time_since_epoch().count());

inline void raiseError(string errorCode) {
	cerr << "Error : " << errorCode << endl;
	exit(42);
}

signed main() {
	#ifndef USE_FILE_IO
		ios_base::sync_with_stdio(false);
	#endif
	int n, m, k; cin >> n >> m >> k;
	vector<int> aa(n), bb(m);
	for (int i = 0; i < n; ++i) {
		cin >> aa[i];
	}
	for (int i = 0; i < m; ++i) {
		cin >> bb[i];
	}
	int ans = *min_element(begin(aa), end(aa)) + *min_element(begin(bb), end(bb));
	for (int i = 0; i < k; ++i) {
		int a, b, c; cin >> a >> b >> c; --a; --b;
		ans = min(ans, aa[a] + bb[b] - c);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
import math
N = int(input())
S = input()

R = len([s for s in S if s == "R"])
G = len([s for s in S if s == "G"])
B = len([s for s in S if s == "B"])

out = R * G * B
for i in range(N):
    intvl = math.ceil((N - i)/2)
    for j in range(1,intvl):
        if S[i] != S[i+j] and S[i+j] != S[i+2*j] and S[i] != S[i+2*j]:
            out -= 1
print(out)

Measured memory_bytes: 9228
#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxn = 110;

int n;
char s[maxn + 5];
int a[maxn + 5];

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%s", s);
	n = strlen(s);
	REP(i, 0, n) a[i] = s[i] - 'a';
	int ans = n;
	REP(i, 0, 26)
	{
		int lst = n;
		int tmp = 0;
		for (int j = n - 1; j >= 0; --j)
		{
			if (a[j] == i) lst = j;
			chkmax(tmp, lst - j);
		}
		chkmin(ans, tmp);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long i=0; i<n; i++)

void solve(){
    int n;
    int a,b;
    cin >> n >> a >> b;
    cout << min(n*a,b) << endl;
}

int main(){
  solve();
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = Integer.parseInt(sc.next());
		int W = Integer.parseInt(sc.next());
		String[][] map = new String[H + 2][W + 2];
		String[][] answer = new String[H + 2][W + 2];
		for(int j = 0; j < W + 2; j++) {
			map[0][j] = ".";
		}
		
		for(int i = 1; i <= H; i++) {
			String S = sc.next();
			map[i][0] = ".";
			for(int j = 1; j <= W; j++) {
				map[i][j] = S.split("")[j - 1];
			}
			map[i][W + 1] = ".";
		}
		
		for(int j = 0; j < W + 2; j++) {
			map[H + 1][j] = ".";
		}
		sc.close();

		for(int i = 1; i <= H; i++) {
			int h = i;
			for(int j = 1; j <= W; j++) {
				int w = j;
				int count = 0;
				if(map[h - 1][w - 1].equals("#")) {
					count++;
				}
				if(map[h - 1][w].equals("#")) {
					count++;
				}
				if(map[h - 1][w + 1].equals("#")) {
					count++;
				}
				if(map[h][w - 1].equals("#")) {
					count++;
				}
				if(map[h][w].equals("#")) {
					answer[h][w] = "#";
					continue;
				}
				if(map[h][w + 1].equals("#")) {
					count++;
				}
				if(map[h + 1][w - 1].equals("#")) {
					count++;
				}
				if(map[h + 1][w].equals("#")) {
					count++;
				}
				if(map[h + 1][w + 1].equals("#")) {
					count++;
				}
				answer[h][w] = String.valueOf(count);
			}
		}


		for(int i = 1; i <= H; i++) {
			for(int j = 1; j <= W; j++) {
				if(j == W) {
					System.out.println(answer[i][j]);
				}else {
					System.out.print(answer[i][j]);
				}
			}
		}

	}

}

Measured memory_bytes: 35812
#include <bits/stdc++.h>

int n;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main() {
	scanf("%d", &n), n %= 360;
	printf("%d\n", 360 / gcd(n, 360));
	return 0;
}

Measured memory_bytes: 3764
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);

    ll a, b;
    char t;
    int d;
    cin>>a>>b>>t>>d;
    b*=100; b+=d;
    cout<<(ll)(a*b/100);
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>

using namespace std;

int main(){
	int t;	cin>>t;
	int grid[16][16];
	bool route[16][16][16][16];
	while(t--){
		int gx,gy;	cin>>gx>>gy;
		for(int i=0;i<=gy;i++)for(int j=0;j<=gx;j++)for(int k=0;k<=gy;k++)for(int l=0;l<=gx;l++)
			route[i][j][k][l]=true;

		int p;	cin>>p;
		while(p--){
			int x1,y1,x2,y2;	cin>>x1>>y1>>x2>>y2;
			route[min(y1,y2)][min(x1,x2)][max(y1,y2)][max(x1,x2)]=false;
		}

		grid[0][0]=1;
		for(int i=1;i<=gy;i++)	grid[i][0]=(route[i-1][0][i][0]?grid[i-1][0]:0);
		for(int j=1;j<=gx;j++)	grid[0][j]=(route[0][j-1][0][j]?grid[0][j-1]:0);
		for(int i=1;i<=gy;i++)for(int j=1;j<=gx;j++){
			grid[i][j]=(route[i-1][j][i][j]?grid[i-1][j]:0)
					  +(route[i][j-1][i][j]?grid[i][j-1]:0);
		}

		if(grid[gy][gx]>0)	cout<<grid[gy][gx]<<endl;
		else		cout<<"Miserable Hokusai!"<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main(){

	map<string,int> m;
	string str;
	string maxLength;
	while(cin>>str){
		m[str]++;
		if(maxLength.size() < str.size())
			maxLength=str;
	}
	int maxCnt=0;
	string maxString;
	for(map<string,int>::iterator it = m.begin(); it != m.end(); it++){
		if(maxCnt<it->second){
			maxCnt=it->second;
			maxString=it->first;
		}
	}
	cout<<maxString<<" "<<maxLength<<endl;

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		boolean ans = false;
		
		for (int i=0; i<=x; i++) {
			if(y == 2*i + 4*(x-i)) {
				ans = true;
			}
		}

		System.out.println(ans ? "Yes" : "No");
		sc.close();
	}

}

Measured memory_bytes: 35596
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    vector<bool> prime(40005, true);
    prime[0] = prime[1] = false;
    rep(i, 0, 40005) {
        if (prime[i]) {
            for (int j = 2 * i; j < 40005; j += i) {
                prime[j] = false;
            }
        }
    }
    vector<int> primes;
    rep(i, 0, 40005) {
        if (prime[i]) primes.push_back(i);
    }
    int n = primes.size();

    while (true) {
        int m, a, b;
        cin >> m >> a >> b;
        if (m == 0) break;

        int max_v = -1;
        int ans_p = -1, ans_q = -1;
        rep(i, 0, n) {
            int p = primes[i];
            int kq = upper_bound(all(primes), b * p / a) - primes.begin();
            if (kq <= 0) continue;
            int q = primes[kq - 1];

            if (p <= q && a * q <= b * p) {
//                    max_v = max(p * q,max_v);
                if (p * q <= m) {
                    if (max_v < p * q) {
                        max_v = p * q;
                        ans_p = p;
                        ans_q = q;
                    }
                } else {
                    kq = upper_bound(all(primes), m / p) - primes.begin();
                    if (kq <= 0) continue;
                    q = primes[kq - 1];

                    if (p <= q && a * q <= b * p) {
                        if (max_v < p * q) {
                            max_v = p * q;
                            ans_p = p;
                            ans_q = q;
                        }
                    }
                }
            }
        }
        cout << ans_p << " " << ans_q << endl;
    }


    return 0;
}



Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;

int h,w,a[201][201],c[10][10];
long long ans;
int main(){
	cin>>h>>w;
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++){
			int in;
			cin>>in;
			c[i][j]=in;
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			int b;
			cin>>b;
			a[i][j]=b;
		}
	}
	for(int k=0;k<=9;k++){
		for(int i=0;i<=9;i++){
			for(int j=0;j<=9;j++){
				c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
			}
		}
	} 
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(a[i][j]!=1&&a[i][j]!=-1){
				ans+=c[a[i][j]][1];
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
from collections import deque
def main():
    h,w = map(int,input().split())
    Map = []
    Visited = [[False for j in range(w)]for i in range(h)]
    DYDX = [[0,1],[1,0],[0,-1],[-1,0]]
    white = 0
    black = 0
    for i in range(h):
        tmp = [i for i in input()]
        white += tmp.count('.')
        black += tmp.count('#')
        #print(tmp)
        Map.append(tmp)
    q = deque()
    q.append((0,0,0))
    ans = 0
    while q:
        y,x,cnt = q.popleft()
        if y<0 or y>=h or x<0 or x>=w:
            continue
        if Visited[y][x]:
            continue
        if Map[y][x]=='#':
            continue
        if y==h-1 and x==w-1:
            ans = cnt
            break
        Visited[y][x] = True
        cnt += 1
        for dy,dx in DYDX:
            q.append((y+dy,x+dx,cnt))
    if ans == 0:
        print('-1')
    else:
        print(white-ans-1) 

if __name__ == '__main__':
    main()
    

Measured memory_bytes: 9500
h,w,k = map(int, input().split())
A = [input() for _ in range(h)]
ans = 0
for gyou in range(2**h):
  for retsu in range(2**w):
    black = 0
    for x in range(h):
      for y in range(w):
        if ((gyou >> x) & 1) == 0 and ((retsu >> y) & 1) == 0 and A[x][y] == "#":
          black = black + 1
    if black == k:
      ans = ans + 1
print(ans)

Measured memory_bytes: 9108
#include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main() {
    int x, y;
    cin >> x >> y;

    vector<int> group = {1, 3, 5, 7, 8, 10, 12, 4, 6, 9, 11, 2};
    int group_num_x, group_num_y;
    rep(i, group.size()) {
        if (x == group[i]) {
            if (i < 7) {
                group_num_x = 1;
            } else if (i < 11) {
                group_num_x = 2;
            } else {
                group_num_x = 3;
            }
            break;
        }
    }
    rep(i, group.size()) {
        if (y == group[i]) {
            if (i < 7) {
                group_num_y = 1;
            } else if (i < 11) {
                group_num_y = 2;
            } else {
                group_num_y = 3;
            }
            break;
        }
    }
    if (group_num_x == group_num_y) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
typedef unsigned long long ULL;
using namespace std;

const int maxD = 10, maxN = 10000 + 24;
int N, M;
int A[maxD], Num[maxD] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
string res[maxN];

string _max(string a, string b)
{
	if (a.size() > b.size()) return a;
	if (a.size() < b.size()) return b;
	return a > b ? a : b;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	while (scanf("%d%d", &N, &M) == 2) {
		res[0] = "";
		for (int i = 1; i <= N; i++) res[i] = "-";
		for (int i = 0; i < M; i++) scanf("%d", &A[i]);
		for (int i = 0; i <= N; i++) {
			if (res[i] != "-") {
				for (int j = 0; j < M; j++) {
					int num = Num[A[j]];
					res[i+num] = _max(res[i+num], res[i]+char(A[j]+'0'));
				}
			}
		}
		cout << res[N] << endl;
	}

	return 0;
}
/*
    input:
    output:
    modeling:
    methods:
    complexity:
    summary:
*/

Measured memory_bytes: 45056
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

const ll MOD = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
const double INF3 = 900000000000000;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()


ll s[200010], n, k, a[200010], bit[1000010] = { 0 }, ans = 0, t[200010];

void add(ll a, ll w) {
	for (int x = a; x <= n + 2; x += x & -x) bit[x] += w;
}
int sum(ll a) {
	ll ret = 0;
	for (int x = a; x > 0; x -= x & -x) ret += bit[x];
	return ret;
}


int main() {
	cin >> n >> k;
	t[0] = 0;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		a[i] -= k;
		t[i + 1] = s[i + 1] = a[i] + t[i];
	}
	sort(t, t + n + 1);
	ll p = unique(t, t + n + 1) - t;
	for (int i = 0;i <= n;i++)s[i] = lower_bound(t, t + p + 1, s[i]) - t + 1;
	for (int i = 0;i <= n;i++) {
		ans += sum(s[i]);
		add(s[i], 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 8704
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
typedef pair<LL,LL> LP;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	int n,m;
	while(cin >> n >> m){
		vector<int> x(n);
		int hoge = 0;
		REP(i,n){
			cin >> x[i];
			hoge = max(hoge,x[i]);
		}
		vector<int> cnt(hoge+1,0);
		REP(i,n){
			cnt[x[i]]++;
		}
		int ans = 0;
		vector<int> mv(m,0);
		vector<int> mv2(m,0);
		REP(i,SZ(cnt)){
			mv[i%m] += cnt[i];
			mv2[i%m] += cnt[i]/2;
		}
		dpite(ALL(mv));
		dpite(ALL(mv2));
		FOR(i,1,(m+1)/2){
			int t = min({max(mv[i]-2*mv2[i],mv[m-i]-2*mv2[m-i]),
						mv[i],mv[m-i]});
			DEBUG(i); DEBUG(t);
			ans += t;
			mv[i] -= t;
			mv[m-i] -= t;
			ans += min(2*mv2[i],mv[i])/2;
			ans += min(2*mv2[m-i],mv[m-i])/2;
		}
		ans += mv[0]/2;
		if(m%2 == 0){
			ans += mv[m/2]/2;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
#define int long long
const double EPS = 1e-10;

vector<int> par;

int root(int x){
  if (par[x] == x){// 根
    return x;
  }
  else {
    return par[x] = root(par[x]); // 経路圧縮
  }
}

void unite(int x, int y){
  x = root(x);
  y = root(y);
  if (x == y){}
  else{
    par[x] = y;     //xの親をyの親にする
  }
}

int same(int x, int y){
  return root(x) == root(y);
}

signed main(){
	int h,w;
	cin>>h>>w;
	int n=h*w;
	par.assign(n,0);
	for(int i=0;i<n;i++){
		par[i]=i;
	}
	string x;
	vector<int> a(n,0);
	for(int i=0;i<h;i++){
		cin>>x;
		for(int j=0;j<w;j++){
			if(x[j]=='#') a[i*w+j]=1;
		}
	}

	for(int i=0;i<h-1;i++){
		for(int j=0;j<w-1;j++){
			if(a[i*w+j]!=a[(i+1)*w+j]){
				unite(i*w+j,(i+1)*w+j);
			}
			if(a[i*w+j]!=a[i*w+j+1]){
				unite(i*w+j,i*w+j+1);
			}
		}
		int j=w-1;
		if(a[i*w+j]!=a[(i+1)*w+j]){
			unite(i*w+j,(i+1)*w+j);
		}
	}
	for(int j=0;j<w-1;j++){
		int i=h-1;
		if(a[i*w+j]!=a[i*w+j+1]){
			unite(i*w+j,i*w+j+1);
		}
	}
	ll ans=0;

	vector<int>bk(n,0);
	vector<int>wh(n,0);
	for(int i=0;i<n;i++){
		if(a[i]==1)bk[root(i)]++;
		else wh[root(i)]++;
	}
	for(int i=0;i<n;i++){
		ans+=bk[i]*wh[i];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 5248
N=int(input())
X=0
for i in range(1,1000):
  X+=i
  if X==N:
    P=[[] for j in range(i+1)]
    X=0
    for j in range(i):
      for k in range(i-j):
        P[j].append(k+X+1)
      for k in range(i-j):
        P[k+j+1].append(k+X+1)
      X+=i-j
    print('Yes')
    print(i+1)
    for j in range(i+1):
      print(len(P[j]),end=' ')
      print(*P[j])
    exit()
print('No')

Measured memory_bytes: 76028
D[13][3]={{1,0,0},{0,1,0},{0,0,1},{1,1,0},{1,0,1},{0,1,1},{1,-1,0},{1,0,-1},{0,1,-1},{1,1,1},{-1,1,1},{1,-1,1},{1,1,-1}};
M[9][9][9],q[2];main(n,m,p,I,x,y,z,j,c,d){for(;scanf("%d%d%d",&n,&m,&p),n;){
	for(memset(M,0,sizeof(M)),c=1,I=0;I<p;c*=-1){
		scanf("%d%d",&x,&y),I++;
		for(z=1;;z++)if(!M[x][y][z]){M[x][y][z]=c;break;}
		for(d=0;d<13;d++){
			for(j=0;j<2;j++)for(q[j]=0;q[j]<m;q[j]+=2*j-1)if(M[x+D[d][0]*q[j]][y+D[d][1]*q[j]][z+D[d][2]*q[j]]!=c)break;
			if(q[1]-q[0]-1>=m){printf("%s %d\n",c==1?"Black":"White",I);goto next;}
		}
	}
	puts("Draw");
next:
	for(;I<p;I++)scanf("%d%d",&x,&y);
}exit(0);}

Measured memory_bytes: 612
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;

const int N=100005;

int n;
bool ans;
int a[N];

int main(){
	int i,j;
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	reverse(a+1,a+1+n);
	for (i=1;i<=n;i++)
		if (i+1>a[i+1]){
			for (j=i+1;a[j]==i;j++) ans^=1;
			ans|=(a[i]-i)&1;
			if (ans) printf("First\n");
			else printf("Second\n");
			return 0;
		} 
	return 0;
} 

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm> 

using namespace std;



int main(){

    int n;
    cin >> n;
    
    long long seq[n];
    
    int i = 0;
    while(i < n){
        cin >> seq[i];
        i++;
    }
    
    bool dup = false;

    
    std::vector<long long> myvector (seq, seq+n);  
    std::sort(myvector.begin(),myvector.end());

    for(int i = 0; i < myvector.size() - 1; i++) {
        if (myvector[i] == myvector[i + 1]) {
            dup = true;
            break;
        }
    }

    if(dup){
        cout << "NO";
    }else{
        cout << "YES";
    }

}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include<bitset>

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find algo with array
// Find()
int findpar(int curr, int arr[])
{
  while(arr[curr] != curr) curr = arr[curr];
  return curr;
}
// Union()
void Union(int b, int spa, int arr[])
{
  while(arr[b] != b)
  {
    int c = arr[b];
    arr[b] = spa;
    b = c;
  }
  arr[b] = spa;
}

// Main Code

map<int, int> mp;
vector<int> v;

int main()
{
  int n;
  cin>>n;
  int ans = 0;
  rep(i, 0, n)
  {
    int a;
    cin>>a;
    if(mp[a] == 0) {ans++;
      v.pb(a);
    }
    mp[a]++;
  }
  //cout<<ans<<endl;
  int aa = 0;
  for(int x: v)
  {
    aa += (mp[x]-1);
  }
  //cout<<aa<<endl;
  if(aa%2 == 0) cout<<ans<<endl;
  else cout<<ans-1<<endl;
  return 0;
}


Measured memory_bytes: 7672
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
double maxvolume(double s) 
{ 
    double length = s / 3; 
  
    s -= length; 
    double breadth = s / 2;  
    double height = s - breadth; 
  
    return length * breadth * height; 
} 
int main()
{
	chutiyaap;
	double l;
	cin>>l;
	double maxi=maxvolume(l);
	cout<<fixed<<setprecision(10)<<maxi;

}

Measured memory_bytes: 256
def main():
    n, y = map(int, input().split())
    for i in range(n+1):
        for j in range(n-i+1):
            k = (n-i-j)
            if (i * 10000 + j * 5000 + k * 1000) == y:
                ans = [i, j, k]
                print(*ans)
                exit()
    ans = [-1, -1, -1]
    print(*ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        in_vec: [usize; 5],
    }

    let mut res_i = 0;
    for i in 1..=5 {
        if in_vec[i - 1] == 0 {
            res_i = i;
        }
    }

    println!("{}", res_i);
}


Measured memory_bytes: 2124