akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)

template<class T, class E>
struct SegTree{
  typedef function<T(T,T)> F;
  typedef function<T(T,E)> G;
  typedef function<E(E,E)> H;
  typedef function<E(E,int)> P;
  int n;
  F f;
  G g;
  H h;
  P p;
  T d1;
  E d0;
  vector<T> dat;
  vector<E> lazy;
  SegTree(int n_, F f, G g, H h, T d1, E d0, P p=[](E a, int b){ return a; })
    : f(f), g(g), h(h), d1(d1), d0(d0), p(p) {
    n = 1;
    while (n < n_) n *= 2;
    dat.resize(2 * n - 1, d1);
    lazy.resize(2 * n - 1, d0);
  }
  void eval(int k, int l, int r) {
    if (lazy[k] == d0) return;
    dat[k] = g(dat[k], p(lazy[k], r - l));
    if (k < n - 1) {
      lazy[2 * k + 1] = h(lazy[2 * k + 1], lazy[k]);
      lazy[2 * k + 2] = h(lazy[2 * k + 2], lazy[k]);
    }
    lazy[k] = d0;
  }
  void update(int a, int b, E x, int k = 0, int l = 0, int r = -1) {
    if (r == -1) r = n;
    eval(k, l, r);
    if (b <= l || r <= a) return;
    if (a <= l && r <= b) {
      lazy[k] = h(lazy[k], x);
      eval(k, l, r);
    }
    else {
      update(a, b, x, 2 * k + 1, l, (l + r) / 2);
      update(a, b, x, 2 * k + 2, (l + r) / 2, r);
      dat[k] = f(dat[2 * k + 1], dat[2 * k + 2]);
    }
  }
  // return op[a..b)
  // k: node id, [l, r): node interval
  E query(int a, int b, int k = 0, int l = 0, int r = -1) {
    // cerr << "a = " << a << ", b = " << b << ", k = " << k << ", l = " << l << ", r = " << r << endl;
    if (r == -1) r = n;
    eval(k, l, r);
    if (r <= a || b <= l) return d1;
    if (a <= l && r <= b) return dat[k];
    E vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
    E vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
    return f(vl, vr);
  }
  void print() {
   int j = 2;
   for (int i = 0; i < 2 * n - 1; i++) {
     cerr << "(" << dat[i] << ", " << lazy[i] << ")";
     if (i == j - 2) { cerr << endl; j *= 2;}
     else { cerr << " "; }
   }
 }
};

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

  int n, q;
  cin >> n >> q;
  SegTree<int, int> seg(
    n,
    [](int a, int b){ return std::min(a, b); },
    [](int a, int b){ return b; },
    [](int a, int b){ return b; },
    INT_MAX,
    -1);
  rep(i, q) {
    int t;
    cin >> t;
    if (t == 0) {
      int a, b, x;
      cin >> a >> b >> x;
      seg.update(a, b + 1, x);
    }
    else {
      int a;
      cin >> a;
      cout << seg.query(a, a + 1) << endl;
    }
    // cerr << "i = " << i << endl;
    // seg.print();
  }

  return 0;
}



Measured memory_bytes: 4976
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

int main(){
  int n,a;
  cin >> n >> a;
  if(n%500>a){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
H,W = map(int, input().split())
ab = [input() for i in range(H)]

res = [0 for i in range(H*2)]

for i in range(0,H):
    res[(i+1)*2-1] = ab[i]
    res[(i)*2] = ab[i]

for j in range(0,H*2):
    print(res[j])

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
#include <map>
#include <queue>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>
#include <set>
using namespace std;
const int inf = (1 << 30);
typedef long long ll;
const ll maxn = 1e5 + 5;
vector<ll> vec;
ll n, sum[maxn * 10], c[maxn * 10], a[maxn];
ll lowbit(ll x)
{
    return x & (-x);
}
void modify(ll i)
{
    while (i <= 2 * maxn)
    {
        ++c[i];
        i += lowbit(i);
    }
}
ll getsum(ll i)
{
    ll res = 0;
    while (i > 0)
    {
        res += c[i];
        i -= lowbit(i);
    }
    return res;
}
bool check(ll mid)
{
    memset(c, 0, sizeof c);
    for (ll i = 1; i <= n; i++)
        sum[i] = sum[i - 1] + (a[i] >= mid ? 1 : -1);
    ll res = 0;
    for (ll i = 0; i <= n; i++)
    {
        res += getsum(sum[i] + maxn);
        modify(sum[i] + maxn);
    }
    if (res >= ((n + 1) * n / 4))
        return true;
    return false;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll l = 0, r = 0;
    cin >> n;
    for (ll i = 1; i <= n; i++)
        cin >> a[i], r = max(r, a[i]);
    ll ans = 0;
    while (l <= r)
    {
        ll mid = l + r >> 1;
        if (check(mid))
            l = mid + 1, ans = mid;
        else
            r = mid - 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
string a;
int ans=0;

int main(){
	IOS
	cin >> a;
	int b=a.length();
	for(int i=0;i<b;i++){
		if(a[i]==a[i-1]){
			ans++;
			if(a[i]=='0') a[i]='1';
			else a[i]='0';
		}
	}	
	cout << ans << '\n';
}


Measured memory_bytes: 3716
use std::cmp;
// use std::collections::HashMap;
// use std::collections::HashSet;


const INF: i64 = 1_000_000_000;


fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let a: i64 = sc.read();
    let b: i64 = sc.read();
    let c: i64 = sc.read();
    let k: i64 = sc.read();
    let ans = if k%2 == 0 {
        a - b
    } else {
        b - a
    };
    println!("{}", ans);
}

// thanks, ir5
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


Measured memory_bytes: 4352
main :: IO ()                                                                                                                          
main = do                                                                                                                              
  [n,a,b] <- map read . words <$> getLine :: IO [Int]                                                                                  
  print . sum . map fst . filter (\x -> (snd x>=a) && (snd x<=b)) . zip [1..n] . map (sum . map (read . (:[])) . show) $ [1..n]

Measured memory_bytes: 1020
#include "bits/stdc++.h"
using namespace std;

int main() {
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	int ans = 1e9;
	for (int i = 0; i <= max(X, Y); ++i) {
		int num = 0;
		num += i * 2 * C;
		num += max(0, X - i)*A;
		num += max(0, Y - i)*B;
		ans = min(num, ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int,int> pii;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=(int)(n);v>=0;v--)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int DX9[9]={0,1,1,1,0,-1,-1,-1,0}, DY9[9]={-1,-1,0,1,1,1,0,-1,0};
const int INF = 1e9;
const ll INFLL = 1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":"\n");return os;}
//------------------------------------------------------------------------------

signed main() {
    int a,b,h;
    cin>>a>>b>>h;
    cout<<(a+b)*h*0.5<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int n;
vector<int> h,w;

vector<vector<int>> fie(4,vector<int>(4));

vector<int> dist(1 << 16,-1);

int main(){
	cin >> n;
	h.resize(n);
	w.resize(n);
	rep(i,0,n - 1) cin >> h[i] >> w[i];
	rep(i,0,3)rep(j,0,3){
		char c;
		cin >> c;
		if(c == 'R') fie[i][j] = 0;
		if(c == 'G') fie[i][j] = 1;
		if(c == 'B') fie[i][j] = 2;
	}
	queue<int> que;
	que.push(0);
	dist[0] = 0;

	while(!que.empty()){
		int v = que.front();
		que.pop();
		if(v == (1 << 16) - 1)
		{
			cout << dist[v] << endl;
			return 0;
		}
		rep(c,0,2) rep(s,0,n - 1){
			rep(i,-h[s] + 1,3) rep(j,-w[s] + 1,3){
				int u = v;
				rep(x,max(i,0),min(i + h[s] - 1,3)) rep(y,max(j,0),min(j + w[s] - 1,3)){
					int index = (x * 4 + y);
					if(u & (1 << index)){
						if(fie[x][y] != c) u ^= (1 << index);
					}
					else{
						if(fie[x][y] == c) u ^= (1 << index);
					}
				}
				if(dist[u] == -1){
					dist[u] = dist[v] + 1;
					que.push(u);
				}
			}
		}
	}
}



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

const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
  int h, w;
  cin >> h >> w;
  int si, sj;
  cin >> si >> sj;
  int ti, tj;
  cin >> ti >> tj;
  --si; --sj; --ti; --tj;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  const int INF = 1e9;
  vector<vector<int>> dist(h,vector<int>(w,INF));
  deque<P> q;
  dist[si][sj] = 0;
  q.emplace_back(si,sj);
  while (!q.empty()) {
    int i = q.front().first;
    int j = q.front().second;
    int d = dist[i][j];
    q.pop_front();
    if (dist[i][j] != d) continue;
    rep(v,4) {
      int ni = i+di[v], nj = j+dj[v];
      if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
      if (s[ni][nj] == '#') continue;
      if (dist[ni][nj] <= d) continue;
      dist[ni][nj] = d;
      q.emplace_front(ni,nj);
    }
    for (int ei = -2; ei <= 2; ++ei) {
      for (int ej = -2; ej <= 2; ++ej) {
        int ni = i+ei, nj = j+ej;
        if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
        if (s[ni][nj] == '#') continue;
        if (dist[ni][nj] <= d+1) continue;
        dist[ni][nj] = d+1;
        q.emplace_back(ni,nj);
      }
    }
  }
  int ans = dist[ti][tj];
  if (ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9508
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int dp[1010][1<<12];
int main(){
	int N,M; cin >> N >> M;
	vector<int> a(M);
	vector<int> bc(M);
	rep(i,M){
		cin >> a[i];
		int b; cin >> b;
		rep(j,b){
			int c; cin >> c;
			c--;
			bc[i] |= 1<<c;
		}
	}
	rep(i,1010)rep(j,1<<12) dp[i][j] = INF;
	dp[0][0] = 0;
	rep(i,M){
		rep(j,1<<N){
			dp[i+1][j|bc[i]] = min(dp[i+1][j|bc[i]],dp[i][j]+a[i]);
			dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
		}
	}
	if(dp[M][(1<<N)-1] == INF){
		cout << -1 << endl;
		return 0;
	}
	cout << dp[M][(1<<N)-1] << endl;
}
   


Measured memory_bytes: 16384
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
using namespace std;

int GCD(int a,int b){
    if(b == 0){
        return a;
    }

    return GCD(b, a%b);
}

int main()
{
    int n, gcd;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    gcd = a[0];
    for(int i = 1;i < n;i++){
        gcd = GCD(gcd, a[i]);
    }

    cout << gcd;

    
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;

int main(){
    int a, b;
    
    cin >> a;
    cin >> b;
    
    if(a >= -1000 && b <= 1000){
        if(a > b){
            cout << "a > b" << endl;
        }
        else if(a < b){
            cout << "a < b" << endl;
        }
        else{
            cout << "a == b" << endl;
        }
    }
   
   return 0; 
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for(int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if(k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main() {
  ll n, k;
  cin >> n >> k;
  vl a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  combination c(2e5);
  mint ans = 0;
  rep(i, n) ans += (c(i, k - 1) - c(n - i - 1, k - 1)) * a[i];
  cout << ans << endl;
}

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

typedef long long ll;

ll arr[100001];

int main(void)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	int n;
	std::cin>>n;
	ll sx = 0;
	for(int i=0;i<n;i++)
	{	
		std::cin>>arr[i];
		sx += arr[i];
	}
	bool ok = 0;
	if(sx & 1)
	ok = 1;
	for(int i=0;i<n;i++)
	{
		if(arr[i] & 1)
		ok = 1;	
	}	
	if(ok)
	std::cout<<"first\n";
	else std::cout<<"second\n";
	return 0;	
}

Measured memory_bytes: 1024
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: i64,
        b: i64,
        c: i64,
    }
    println!("{}", if b - a == c - b { "YES" } else { "NO" });
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,j) for (int (i)=0;(i)<(int)(j);++(i))
#define put(i) cout << (i) << endl
using namespace std;
typedef long long ll;

int main() {
    int n;
    while (cin >> n, n) {
        vector<string> s(n);
        int len = 0;
        rep(i,n){
            string ts, t = "";
            cin >> ts;

            t += ts[0];
            string chk = "aiueo";
            rep(j, ts.length()+1) {
                rep(k,5) {
                    if (ts[j] == chk[k]) {
                        t += (j+1 < ts.length() ? ts[j+1] : ' ');
                    }
                }
            }

            len = max(len, (int)t.length());
            s[i] = t;
        }

        int cnt = 0;
        while (cnt++ < len) {
            set<string> q;
            rep(i, n) {
                string t = s[i].substr(0, min(cnt, (int)s[i].length()));
                for (int j = t.length(); j < cnt; ++j) t += " ";
                q.insert(t);
            }
            if (q.size() == n) {
                cout << cnt << endl;
                cnt = -1;
                break;
            }
        }
        if (cnt != -1) cout << -1 << endl;
    }
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  int n,h,w;cin>>n>>h>>w;
  int result=0;
  rep(i,n){
    int th,tw;cin>>th>>tw;
    if(th>=h && tw>=w)result++;
  }

  cout<<result<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int A, B, H, M;

void solve() {
    cin >> A >> B >> H >> M;
    cout << fixed << setprecision(10);
    complex<double> h = polar(
                            (double)A,
                            2.0 * M_PI * ((double)H * 60 + (double)M) / (12.0 * 60.0)
                        );
    complex<double> m = polar((double)B, 2.0 * M_PI * (double)M / 60.0);
    double reals = h.real() - m.real();
    double imags = h.imag() - m.imag();
    double x = pow(reals * reals + imags * imags, 0.5);
    cout << x << endl;
}

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


Measured memory_bytes: 4308
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int x,y,z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
 string str, ans = "Good";
  cin >> str;
  if(str.at(0) == str.at(1) || str.at(1) == str.at(2) || str.at(2) == str.at(3))
    ans = "Bad";
  cout << ans << endl; 
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std ;
int main(){
    int a,b,c,i,n;
    int d;
    int arr[100005];
    arr[0] = 0;
    //cin>>arr[0]>>arr[1]>>arr[2];
    cin>>n;
    for(i = 1;i <= n;i++){
        cin>>arr[i];
    }
    arr[n+1] = arr[0];
    n++;
    int j , f=0;
    for(i = 1;i <= n;i++){
        f = f+abs(arr[i]-arr[i-1]);
        if(i == n){
            f = f+abs(arr[i]-arr[0]);
        }
    }
    c = f;
    for(i = 1;i < n;i++){
        f = c;
        f =f-abs(arr[i]-arr[i-1])-abs(arr[i+1]-arr[i])+abs(arr[i-1]-arr[i+1]);
        cout<<f<<endl;
    }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll k,q,a[100010],x;
int n;
int main()
{
	cin>>n>>k>>q;
	for (int i=0;i<n;++i) a[i]=k;
	for (int i=0;i<q;++i)
	{
		cin>>x;
		--x;
		++a[x];
	}
	for (int i=0;i<n;++i)
	{
		a[i]-=q;
		if (a[i]>0) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

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

long long gcd(ll a, ll b){
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

map< ll, ll > prime_factor(ll n) {
    map< ll, ll > ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}


int main(){
    ll a, b;
    cin >> a >> b;
    ll g =  gcd(a,b);
    cout << prime_factor(g).size() + 1 << endl;
}

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

int figit(int x){
	int res = 0;
	while(x){
		res+=x%10;
		x/=10;
	}
	return res;
}



int main(){
	
	int n,a,b;
	cin>>n>>a>>b;

	int ans = 0;

	for(int i=1;i<=n;i++){
		int t = figit(i);
		if(t<=b && t>=a) ans+=i;
	}

	cout<<ans;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  ll N, M; cin >> N >> M;

  ll a = N;
  ll b = M / 2;
  if (a > b) {
    cout << b << CRLF;
    return;
  }
  ll c = (N * 2 + M) / 4;
  auto ans = c;
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int leap(int);

int main(void){
	int a,b,i;
	int flag;
	int ff=0;
	while(scanf("%d %d",&a,&b),(a||b)){
		if(ff!=0) printf("\n");
		ff=1;
		flag=1;
		for(i=a;i<=b;i++){
			if(leap(i)){
				printf("%d\n",i);
				flag=0;
			}
		}
		if(flag) printf("NA\n");
	}
}

int leap(int k){
	if(k%100!=0){
		if(k%4==0) return 1;
	}else{
		if(k%400==0) return 1;
	}
	return 0;
}

Measured memory_bytes: 616
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    d = defaultdict(int)
    for e in a:
        d[e] += 1
    sq = []
    re = []
    for k in d:
        if d[k] > 1:
            re.append(k)
        if d[k] > 3:
            sq.append(k)
    sq.sort()
    re.sort()
    ans = 0
    if sq:
        ans = sq[-1] * sq[-1]
    if len(re) > 1:
        ans = max(ans, re[-1] * re[-2])
    print(ans)

        



t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""



"""


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

int INF = 1001001001;
int n;
vector<int> abc(3);
vector<int> l(8);

int cost(vector<int> v, vector<int> c, int j) {
  if (j == n) {
    for (int i = 0; i < 3; i++) {
      if (!c[i]) return INF;
    }
    int ans = 10 * (c[0] + c[1] + c[2] - 3);
    for (int i = 0; i < 3; i++) ans += abs(abc[i] - v[i]);
    return ans;
  }
  int ans = cost(v, c, j+1);
  for (int i = 0; i < 3; i++) {
    vector<int> nv = v, nc = c;
    nv[i] += l[j]; nc[i]++;
    ans = min(ans, cost(nv, nc, j+1));
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < 3; i++) cin >> abc[i];
  for (int i = 0; i < n; i++) cin >> l[i];
  cout << cost({0, 0, 0}, {0, 0, 0}, 0) << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
	int len, angle;
	int sum_ang = 90; // start
	double x = 0.0, y = 0.0;

	// ang(+) -> right 
	while (scanf("%d,%d", &len, &angle), len != 0 || angle != 0){
		x += len * cos(M_PI * sum_ang / 180.0);
		y += len * sin(M_PI * sum_ang / 180.0);

		sum_ang = (sum_ang - angle + 360) % 360;
	}

	printf("%d\n", (int)x);
	printf("%d\n", (int)y);

	return (0);
}

Measured memory_bytes: 1192
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;

const int MAX_N = 15;
int N;
int No[MAX_N], Dist[MAX_N], Sen[MAX_N];
int G[1<<MAX_N][MAX_N][MAX_N];
int T[1<<MAX_N][MAX_N], path[1<<MAX_N][MAX_N];

const int INF = 1000000000;

int calcW(int s) {
  int w = 0;
  for(int i = 0; i < N; ++i) {
    if(s & (1<<i)) w += Sen[i];
  }
  return w*2;
}

void make() {
  for(int s = 0; s < (1<<N); ++s) {
    for(int i=0;i<N;++i){
      for(int j=0;j<N;++j){
	//if(i == j) G[s][i][j] = INF;
	 G[s][i][j] = abs(Dist[i]-Dist[j])*(7+calcW(s));
      }
    }
  }
}

void rec(int s, int p) {
  if(p == -1) return;
  rec(s&~(1<<p), path[s][p]);
  cout << No[p];
  if(s != (1<<N)-1) cout << " ";
}

void solve() {
  make();
  for(int i=0;i<(1<<N);++i) {
    fill(T[i],T[i]+N,INF);
    fill(path[i], path[i]+N, -1);
  }

  for(int i = 0; i < N; ++i)
    T[1<<i][i] = 0;

  for(int s = 1; s < (1<<N); ++s) {
    for(int i = 0; i < N; ++i) {
      if(!(s&(1<<i))) continue;
      for(int j = 0; j < N; ++j) {
	if(s&(1<<j)) continue;
	int newValue = T[s][i] + G[s][i][j];
	if(newValue < T[s|(1<<j)][j]) {
	  T[s|(1<<j)][j] = newValue;
	  path[s|(1<<j)][j] = i;
	}
      }
    }
  }

  int mini, mi;
  mini = INF, mi = -1;
  for(int i = 0; i < N; ++i) {
    if(T[(1<<N)-1][i] < mini) {
      mini = T[(1<<N)-1][i];
      mi = i;
    }
  }
  rec((1<<N)-1, mi);
  cout << endl;
}

int main() {
  cin >> N;
  for(int i=0;i<N;++i)cin >>No[i]>>Dist[i]>>Sen[i];
  solve();
  return 0;
}

Measured memory_bytes: 32000
#include<bits/stdc++.h>
#define LL long long
#define F(x,y,z) for(int x=y;x<=z;++x)
#define D(x,y,z) for(int x=y;x>=z;--x)
using namespace std;
const int Mod=998244353;
const int N=30000010;
const int maxn=30000001;
LL Min(LL x,LL y){return x<y?x:y;}
LL Max(LL x,LL y){return x>y?x:y;}
LL R(){
    LL ans=0,f=1;char c=getchar();
    for(;c<'0'||c>'9';c=getchar()) if (c=='-') f=-1;
    for(;c>='0'&&c<='9';c=getchar()) ans=ans*10+c-'0';
    return ans*f;
}
LL jc[N],ni[N],n,m;
LL C(LL n,LL m){return jc[n]*ni[m]%Mod*ni[n-m]%Mod;}
LL Calc(LL n,LL m,LL js){
	LL ans=0;
	int ma=min(n,m);
	F(i,0,ma){
		if((i+m)&1)continue;
		ans+=C(n,i)*C(js+(m-i)/2+n-1,n-1);
		ans%=Mod;
	}
	return ans;
}
LL Pow(LL x,LL bs){
	LL an=1;
	for(;bs;bs>>=1,x=x*x%Mod)
		if(bs&1)an=an*x%Mod;
	return an; 
}
void Pre(){
	jc[0]=ni[0]=1;
	F(i,1,maxn)jc[i]=jc[i-1]*i%Mod;
	ni[maxn]=Pow(jc[maxn],Mod-2);
	D(i,maxn-1,1)ni[i]=ni[i+1]*(i+1)%Mod;
}
int main(){
	Pre();
	n=R();m=R();
	LL ans=Calc(n,m,m);
	ans-=n*(Calc(n,m,0)-Calc(n-1,m,0));
	ans%=Mod;ans+=Mod;ans%=Mod;
	cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 469120
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=5e2+5;
const ll inf=1e18;
const int mod=1e9+7;
map<int,int>vis;
struct node
{
    int x,y,num;
    node() {}
    node(int a,int b):x(a),y(b) {}
    bool operator < (const node& b) const
    {
        return x < b.x;
    }
} N[maxn];
long double dp[maxn][maxn];
int main()
{
    long double n,m;
    cin>>n>>m;
    long double x,y;
    cin>>x>>y;
    long double t;
    cin>>t;
    if(n<x&&m-y>0&&(m-y)>=(x-n)/t)printf("YES");
    else if(n>x&&m-y>0&&(m-y)>=(n-x)/t)printf("YES");
    else printf("NO");
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin>>n;
    vector<ll> a(n),b(n);
    ll sa=0,sb=0;
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n){
        cin>>b[i];
    }

    ll ba=0,bb=0;
    rep(i,n){
        if(a[i]>b[i]) ba+=a[i]-b[i];
        if(b[i]>a[i]) bb+=(b[i]-a[i])/2;
    }

    if(bb>=ba) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
} 


Measured memory_bytes: 3716
#include "bits/stdc++.h"

#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
constexpr int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#include "bits/stdc++.h"
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<vector<vector<int>>> dp(
	    n + 1, vector<vector<int>>(n + 1, vector<int>(k + 1)));
	dp[0][0][0] = 1;
	auto add = [&](int a, int b, int c, int val) {
		if (a >= 0 && a < n + 1 && b >= 0 && b < n + 1 && c >= 0 && c < k + 1) {
			dp[a][b][c] += val;
			dp[a][b][c] %= MOD;
		}
	};
	REP(a, n) {
		REP(b, n + 1) {
			REP(c, k + 1) {
				add(a + 1, b + 1, c + 2 * (b + 1), dp[a][b][c]);
				add(a + 1, b, c + 2 * b, dp[a][b][c] * (2 * b + 1) % MOD);
				add(a + 1, b - 1, c + 2 * (b - 1),
				    dp[a][b][c] * b % MOD * b % MOD);
			}
		}
	}
	cout << dp[n][0][k] << endl;
}

Measured memory_bytes: 26240
n=int(input())
m={}
p=[]

for i in range(n+1):
    m[i]=[0 for j in range(n+1)]
for i in range(n):
    tmp=list(map(int,input().split()))
    if i==0:
        p.append(tmp[0])
        p.append(tmp[1])
    else:
        p.append(tmp[1])

for l in range(2,n+1):
    for i in range(1,n-l+2):
        j=i+l-1
        m[i][j]=10000000
        for k in range(i,j):
            m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+(p[i-1]*p[k]*p[j]))
            
print(m[1][n])


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

int main(){
  long long K,n;
  cin >> n >> K;
  int A[n];
  for(int i=0;i<n;i++){
    cin >> A[i];
  }
  long long srn=0,drn=0,ans=0;
  for(int i=0;i<n;i++){
    for (int j=i+1;j<n;j++){
      if(A[i]>A[j]) srn++;
    }
  }
  for(int i=0;i<n;i++){
    for (int j=0;j<n;j++){
      if(A[i]>A[j]) drn++;
    }
  }
  long long comb=(K*(K-1)/2)%1000000007; 
  ans=(srn*K%1000000007+(drn*comb)%1000000007)%1000000007;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<utility>
#include<tuple>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
using namespace std;
using ll = long long;

int main() {

	int n, r;

	cin >> n >> r;

	int ans = 0;
	if (n <= 10) ans = 100 * (10 - n) + r;
	else ans = r;

	cout << ans << endl;

	return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 4;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define int ll
const ll MAX_N = 1 << 13;
int n;
vl dat(2 * MAX_N - 1);
vi a(MAX_N);

void init(int k, int l, int r) {
	if (r - l == 1) {
		dat[k] = a[l];
	}
	else {
		int lch = 2 * k + 1, rch = 2 * k + 2;
		init(lch, l, (l + r) / 2);
		init(rch, (l + r) / 2, r);
		dat[k] = min(dat[lch], dat[rch]);
	}
}

//k番目の値をaに変更
void update(int k, int a, int l, int r) {
	if (r - l == 1) {
		dat[k] = a;
	}
	else {
		int lch = 2 * k + 1, rch = 2 * k + 2;
		update(lch, a, l, (l + r) / 2);
		update(rch, a, l, (l + r) / 2);
		dat[k] = min(dat[lch], dat[rch]);
	}
}

//[a,b)の最小値を求める
//後ろのほうの引数は計算の簡単のための引数
//kは接点の番号,l,rはその接点が[l,r)に対応していることを表す
//従って、外からはquery(a,b,0,0,n)としてよぶ
int query(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l) {
		return inf;
	}
	if (a <= l && r <= b) {
		return dat[k];
	}
	else {
		ll ul = query(a, b, k * 2 + 1, l, (l + r) / 2);
		ll ur = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(ul, ur);
	}
}

signed main() {
	int _n, x, i, j;
	scanf("%lld%lld", &_n, &x);
	a.resize(_n);
	for (i = 0; i < _n; i++) {
		scanf("%lld", &a[i]);
	}
	a.insert(a.end(), a.begin(), a.end());
	n = 2 * _n;
	init(0, 0, n);
	ll ans = INF;
	for (i = 0; i < _n; i++) {
		ll res = 0;
		res += i*x;
		for (j = 0; j < _n; j++) {
			res += query(j, j + i + 1, 0, 0, n);
		}
		ans = min(ans, res);
	}
	for (i = 0; i < _n; i++) {
		ll res = 0;
		res += i*x;
		for (j = _n; j < 2*_n; j++) {
			res += query(j - i, j + 1, 0, 0, n);
		}
		ans = min(ans, res);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;

int main()
{
    int x,y = 0;
    
    cin >> x >> y;
    
    if(x == 2)
    {
        if(y == 2){
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    else if((x==4)||(x==6)||(x==9)||(x==11)){
        if((y ==4)||(y==6)||(y==9)||(y==11)){
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    else if((x ==1)||(x==3)||(x==5)||(x==7)||(x==8)||(x==10)||(x==12)){
        if((y ==1)||(y==3)||(y==5)||(y==7)||(y==8)||(y==10)||(y==12)){
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    return 0;
}

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

int main() {
  string a,b,c;
  cin >> a >> b >> c;

  if (a[a.length() - 1] == b[0] && c[0] == b[b.length() - 1])
    cout << "YES" << endl;
  else 
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int x, y, i, j;
int main(){
    scanf("%d %d",&x ,&y );
    while(!(x==0 && y==0)){
        for (i=1;i<=x;i++){
            for(j=1;j<=y;j++){
            	if (i==1||i==x||j==1||j==y){
                printf("#");}
                else{
                	printf(".");
				}
            }
            printf("\n");
        }
        printf("\n");
        scanf("%d %d",&x ,&y );
    }
}


Measured memory_bytes: 2032
ans=0
N=int(input())
if N//100==1:
  N=N-100
  ans=ans+900
else:
  N=N-900
  ans=ans+100
if N//10==1:
  N=N-10
  ans=ans+90
else:
  N=N-90
  ans=ans+10
if N//1==1:
  ans=ans+9
else:
  ans=ans+1
print(ans)

Measured memory_bytes: 3060
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll N, M;
    cin >> N >> M;
    VV<ll> modm(M);
    V<ll> cnt(M);
    for(ll i = 0; i < N; i++) {
        ll X;
        cin >> X;
        modm[X % M].push_back(X);
    }
    
    for(ll i = 0; i < M; i++) {
        sort(ALL(modm[i]));
        ll pre = -1;
        ll cnt_e = 0;
        for(ll e : modm[i]) {
            DEBUG(e, cnt_e);
            if(pre == e) {
                cnt_e++;
            } else {
                cnt[i] += cnt_e / 2;
                cnt_e = 1;
            }
            pre = e;
        }
        cnt[i] += cnt_e / 2;
    }

    ll ans = modm[0].size() / 2;
    DEBUG(cnt);
    for(ll mod = 1;; mod++) {
        ll i = mod, j = M - mod;
        if(j <= i) break;
        if(modm[i].size() < modm[j].size()) swap(i, j);
        ans += modm[j].size();
        ll diff = modm[i].size() - modm[j].size();
        ans += min(cnt[i], diff / 2);
    }
    if(M % 2 == 0) ans += modm[M / 2].size() / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6656
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod1 1000000007
#define mod2 1000000009
int getTheAnswer() {
    return 42;
}

using namespace std;
using ll=long long;

class CRepsept {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        ll k;
        cin>>k;
        ll val=7,cnt=1;
        while (1){
            if (cnt>k){
                cout<<-1;
                break;
            }
            if (val%k!=0){
                ll rem=val%k;
                val=rem*10+7;
                cnt++;
            }
            else{
                cout<<cnt;
                break;
            }
        }
	}
};


int main() {
	CRepsept solver;
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> b(m);
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        for(int j=0;j<k;j++){
            int a;
            cin>>a;
            b.at(a-1)++;
        }
    }
    int cnt=0;
    for(int i=0;i<m;i++){
        if(b.at(i)==n) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
signed main(void){
    int h,w; cin>>h>>w;
    vector <vector<char>> g(h,vector <char>(w));
    rep(i,h)rep(j,w){
        cin>>g[i][j];
    }   
    vector <vector<int>> dp(h,vector <int>(w));
    dp[0][0] = 1;
    rep(i,h){
        rep(j,w){
            if(g[i][j] == '#') continue;
            if(i != 0){
                dp[i][j] += dp[i-1][j];
            }
            if(j != 0){
                dp[i][j] += dp[i][j-1];
            }
            dp[i][j] %= MOD;
        }
    }
    cout<<dp[h-1][w-1]<<endl;
}


Measured memory_bytes: 9088
#include <iostream>
#include <vector>

void showVector(std::vector<int> readVec){
    int length = readVec.size();
    for(int i = 0; i < length; ++i){
        if(length - 1 != i){
            std::cout << readVec.at(i) << " ";
        }else{
            std::cout << readVec.at(i);
        }
    }
    
    std::cout << std::endl;
}

int main(){
    int n;
    std::cin >> n;

    std::vector<int> a(n);
    for(int i = 0; i < n; ++i){
        std::cin >> a.at(i);
    }

    bool flg = true;
    int tmp;
    int count = 0;
    while(flg){
        flg = 0;
        for(int i = n - 1; 0 < i; --i){
            if(a.at(i) < a.at(i - 1)){
                a.at(i) += a.at(i - 1);
                a.at(i - 1) = a.at(i) - a.at(i - 1);
                a.at(i) = a.at(i) - a.at(i - 1);
                flg = true;
                ++count;
            }
        }
    }
    
    showVector(a);    
    std::cout << count << std::endl;

    return 0;
}



Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include<utility>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, forall_a, forall_b) for (int i = (forall_a); i < (forall_b); ++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

typedef pair<int, int> P;

bool ps1(const P &forall_a, const P &forall_b)
{ //first昇順
	return forall_a.first < forall_b.first;
}
bool ps2(const P &forall_a, const P &forall_b)
{ //first降順
	return forall_a.first > forall_b.first;
}
bool ps3(const P &forall_a, const P &forall_b)
{ //second昇順
	return forall_a.second < forall_b.second;
}
bool ps4(const P &forall_a, const P &forall_b)
{ //second降順
	return forall_a.second > forall_b.second;
}
int GCD(int x, int y) {
	return x ? GCD(y % x, x) : y;
}

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	
	bool still=true;
	int cnt=0;
	if(a%2!=0 or b%2!=0 or c%2!=0){
		still=false;
	}
	else if(a==b&&b==c){
		still=false;
		cnt=-1;
	}
	
	
	while(still){
		cnt++;
		vector<int>next(3);
		next[0]=(b+c)/2;
		next[1]=(a+c)/2;
		next[2]=(a+b)/2;
		rep(i,3){
			if(next[i]%2!=0){
				still=false;
			}
		}
		a=next[0];
		b=next[1];
		c=next[2];

	}
	cout<<cnt<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main(void)
{
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    vector<int> dist(m-1);
    rep(i,m) cin >> x[i];
    sort(x.begin(), x.end(), greater<int>());
    for(int i=0; i<m-1; i++){
        dist[i] = x[i] - x[i+1];
    }
    sort(dist.begin(), dist.end());
    int ans = 0;
    for(int i=0; i<m-1-(n-1); i++){
        ans += dist[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};

random_device rnd;
mt19937 mt(rnd());
uniform_int_distribution<> rand100(1, 100);
uniform_int_distribution<> rand200(1, 200);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w; cin >> h >> w;
    char table[51][51] = {0};
    int c = 0;
    rep(i, h) rep(j, w) {cin >> table[i][j]; if (table[i][j] == '#') c++;}
    queue<pii> q;
    q.push({0, 0});
    int reached[51][51] = {0};
    reached[0][0] = 1;
    while (!q.empty()) {
        int y = q.front().first;
        int x = q.front().second;
        q.pop();
        rep(i, 4) {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if (reached[ny][nx] || table[ny][nx] == '#') continue;
            reached[ny][nx] = reached[y][x] + 1;
            q.push({ny, nx});
        }
    }
    if (reached[h - 1][w - 1] == 0) cout << -1 << endl;
    else cout << h * w - c - reached[h - 1][w - 1] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int i, j, k;
    int n, x;
    int count;

    while(1){
        scanf("%d %d ", &n, &x);
        if(n==0&&x==0)break;
        count=0;
        for(i=1;3*i+3<=x;i++){
            for(j=i+1;i+2*j+1<=x;j++){
                for(k=n;k>j;k--){
                    if(x==i+j+k){
                        count++;
                        break;
                    }else if(x>=i+j+k){
                        break;
                    }
                }
            }
        }
        printf("%d\n", count);
    }
    return 0;
}


Measured memory_bytes: 2748