akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }


using namespace std;

int N;
vector<int>a,b;

int main(){
    cin >> N;
    a.resize(N); for (int i = 0; i < N; ++i) cin >> a[i];
    b.resize(N); for (int i = 0; i < N; ++i) cin >> b[i];

    int res = 0;
    for (int digit = 29; digit >= 0; --digit) {
        int bekihigh = 1 << (digit+1), bekilow = 1 << digit;
        for (int i = 0; i < N; ++i) a[i] %= bekihigh, b[i] %= bekihigh;
        sort(b.begin(), b.end());
        long long num = 0;
        for (int i = 0; i < N; ++i) {
            int add = 0;
            if (bekilow - a[i] >= 0) {
                add += lower_bound(b.begin(), b.end(), bekihigh - a[i])
                       - lower_bound(b.begin(), b.end(), bekilow - a[i]);
            }
            else {
                add += lower_bound(b.begin(), b.end(), bekihigh-a[i]) - b.begin();
                add += lower_bound(b.begin(), b.end(), bekihigh)
                       - lower_bound(b.begin(), b.end(), bekihigh + bekilow - a[i]);
            }
            num += add;
        }
        if (num & 1) res += bekilow;
    }

    cout << res << endl;

}

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define ll long long
#define el '\n'

using namespace std;

int n,m;
int par[100005],sz[100005];
pair <int,int> ar[100005];
ll cnt;

int parent(int a){
    if (par[a]!=a) return parent(par[a]);
    return a;
}

void make(int a, int b){
    int pa=parent(a);
    int pb=parent(b);

    if (pa==pb) return;

    cnt-=(ll)(sz[pa])*((ll)(sz[pb]));
    if (sz[pa]>=sz[pb]){
        sz[pa]+=sz[pb];
        par[pb]=pa;
    } else{
        sz[pb]+=sz[pa];
        par[pa]=pb;
    }
}

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

    cin >> n >> m;

    cnt=(ll)n*((ll)(n-1))/2;

    for (int i=1;i<=n;i++){
        par[i]=i;
        sz[i]=1;
    }

    for (int i=0;i<m;i++){
        cin >> ar[i].fi >> ar[i].se;
    }

    ll ans[m+1];
    for (int i=m;i>0;i--){
        ans[i]=cnt;
        make(ar[i-1].fi,ar[i-1].se);
    }

    for (int i=1;i<=m;i++) cout << ans[i] << el;

    return 0;
}

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef long long i64;

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

  int n, Ma, Mb;
  cin >> n >> Ma >> Mb;
  vi a(n), b(n), c(n);
  int asum = 0, bsum = 0;
  rep(i, 0, n) {
    cin >> a[i] >> b[i] >> c[i];
    asum += a[i];
    bsum += b[i];
  }

  vvi dp(asum + 1, vi(bsum + 1, INF));
  dp[0][0] = 0;
  rep(i, 0, n) {
    auto next = dp;
    erep(ca, 0, asum) {
      erep(cb, 0, bsum) {
        if(ca - a[i] >= 0 && cb - b[i] >= 0) {
          next[ca][cb] = min(next[ca][cb], dp[ca - a[i]][cb - b[i]] + c[i]);
        }
      }
    }
    swap(next, dp);
  }

  int ans = INF;
  int ca = Ma;
  int cb = Mb;
  while(ca <= asum && cb <= bsum) {
    ans = min(ans, dp[ca][cb]);
    ca += Ma;
    cb += Mb;
  }
  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;
}


Measured memory_bytes: 784
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
using namespace std;
long long inf=100000000000007;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
typedef pair<int,int>  P;
string alph("abcdefghijklmnopqrstuvwxyz");
struct edge{int to,cost;};
vector<edge> G[22];
vector<int> O[10];
P sg[10];
int d[1005][1005]={};
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
pair<int,double> s[1005];
int c=0;
int fi[1005][1005];
int ans[1005][1005]={};
bool graph[55][55];
bool visited[55];
int a[55],b[55];

signed main(){
    string s;
    cin>>s;
    int n=s.length();
    int maxi;
    maxi=n;
    for(int i=1;i<n;i++)
        if(s[i]!=s[i-1])
            maxi=min(maxi,max(i,n-i));
    cout<<maxi<<endl;
}


Measured memory_bytes: 512
#include <stdio.h>
int main(){
  int x,a,b;
  int sum;
  scanf("%d\n",&x);
  scanf("%d\n",&a);
  scanf("%d\n",&b);
  sum=x-a;
  while(sum>=b)
    sum-=b;
    
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define ll	long long
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define fastio	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell 1000000007
#define PI 3.141592653589793

int n, m, x;

bool check(vector <int> v) {
	for (int i = 0; i < m; i++) {
		if (v[i] < x) return false;
	}
	return true;
}
int main() 
{	fastio;
	int testcases = 1;
	//cin>>testcases;
	while (testcases--) {
		cin>>n>>m>>x;
		vvi v(n, vector <int> (m+1));
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= m; j++) {
				cin>>v[i][j]; //v[i][0] stores the price of ith book
			}
		}
		int min_amount = 1200005;
		bool can = false;
		for (int b = 0; b < (1<<n); b++) {
			int amount = 0;
			vector <int> skills(m, 0);
			vector<int> subset;
			for (int i = 0; i < n; i++) {
				if (b&(1<<i)) subset.pb(i);
			}
			for (auto element : subset) {
				amount += v[element][0];
				for (int k = 0; k < m; k++) {
					skills[k] += v[element][k+1];
				}
			}
			if(check(skills)) {
				can = true;
				min_amount = min(min_amount, amount);
			}
		}
		if(!can) min_amount = -1;
		cout<<min_amount;
		cout<<"\n";
		
	}
    return 0; 
}


Measured memory_bytes: 3656
N = int(input())
ary = list(map(int, input().split()))

ary = sorted(ary, reverse=True)
scores = [0, 0]
turn = 0
while len(ary) > 0:
    s = ary.pop(0)
    scores[turn] += s
    turn = (turn + 1) % 2

diff = scores[0] - scores[1]
print(diff)


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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define each(i,mp) for(auto& i:mp)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const lb pi=acos(-1);
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll n,m;cin>>n>>m;
  // ll a[m],b[m];
  vector<vector<ll>>v(n);
  rep(i,0,m){
    ll a,b;cin>>a>>b;
    a--,b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  ll cost[n];
  rep(i,0,n)cost[i]=INF;
  cost[0]=0;
  queue<ll>q;
  q.push(0);
  ll ans[n];CLR(ans,0);
  while(!q.empty()){
    ll k=q.front();
    q.pop();

    each(e,v[k]){
      if(cost[k]+1<cost[e]){
        cost[e]=cost[k]+1;
        q.push(e);
        ans[e]=k+1;
      }
    }
  }
  out("Yes");
  rep(i,1,n){
    out(ans[i]);
  }



  return 0;
}


Measured memory_bytes: 13732
#![allow(unused_imports)]
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]

use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};
use std::{cmp, fmt};

fn main() {
    let (n, m, d): (f64, f64, f64) = {
        let mut sc = InputScanOnce::new(io::stdin(), 1024);
        (sc.next(), sc.next(), sc.next())
    };
    let r = if d == 0.0 {
        1.0 * (m - 1.0) / n
    } else {
        2.0 * (m - 1.0) * (n - d) / n.powf(2.0)
    };
    println!("{}", r);
}

struct InputScanOnce {
    buf: Vec<u8>,
    pos: usize,
}

#[allow(dead_code)]
impl InputScanOnce {
    fn new<R: Read>(mut reader: R, estimated: usize) -> Self {
        let mut buf = Vec::with_capacity(estimated);
        let _ = io::copy(&mut reader, &mut buf).unwrap();
        InputScanOnce { buf: buf, pos: 0 }
    }

    #[inline]
    fn next<T: FromStr>(&mut self) -> T
    where
        T::Err: fmt::Debug,
    {
        let mut start = None;
        loop {
            match (self.buf[self.pos], start.is_some()) {
                (b' ', true) | (b'\n', true) => break,
                (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                (_, false) => start = Some(self.pos),
            }
        }
        let target = &self.buf[start.unwrap()..self.pos];
        unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        T::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
        T3::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        T::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }

    fn strings_as_mat<T, F: FnMut(u8) -> T>(&mut self, h: usize, mut f: F) -> Vec<Vec<T>> {
        (0..h)
            .map(|_| {
                let l = self.next::<String>();
                l.as_bytes().iter().cloned().map(&mut f).collect()
            })
            .collect()
    }
}


Measured memory_bytes: 4352
n, m, x = map(int, input().split())
bl = []
for i in range(n):
  b = list(map(int, input().split()))
  bl.append(b)
ans = 10 ** 8

# bit全探索でそれぞれの本の読む / 読まない のパターンすべてを調べる
for i in range(1<<n):
  c = 0
  # 目標値を設定し、本を読んだら理解度を引く
  # 最終的にすべてが0以下なら全アルゴリズムを理解できた
  u = [x] * m
  
  for j in range(n):
    # 本のbitが立っていれば読んだものとして計算
    if i & 1<<j:
      b = bl[j]
      c += b[0]
      for k in range(1, m+1):
        u[k-1] -= b[k]
  # 最終的な理解度チェック
  if max(u) <= 0:
    ans = min(ans, c)

# ansに変更がない場合、目標に届かなかっったアルゴリズムがある
if ans == 10 ** 8:
  print('-1')
else:
  print(ans)

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n+1), b(n);
    rep(i,n+1) cin >> a[i];
    rep(i,n) cin >> b[i];
    ll ans = 0;
    rep(i,n){
        if(a[i]>=b[i]){
            ans += b[i];
            a[i] -= b[i];
        }else{
            ans += a[i];
            b[i] -= a[i];
            if(a[i+1]>=b[i]){
                ans += b[i];
                a[i+1] -= b[i];
            }else{
                ans += a[i+1];
                a[i+1] = 0;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4008
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
using namespace std;
using ll = long long int;
typedef pair<int,int> P;
 
int main(void){
    int N;
    cin >> N;
    int mp[200009]={0};
    int k;
    for(int i=1;i<N;i++){
       scanf("%d",&k);
        mp[k]++;
    }
    
    for(int i=1;i<N+1;i++){
        cout << mp[i] << endl;
    }
}

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

int main(){
	int n, h, maxA = -1, a, b;
	cin >> n >> h;
	vector<int> mb;

	for( int i = 0; i < n; ++i ){
		cin >> a >> b;
		maxA = max(maxA, a);
		mb.push_back(b);
	}

	mb.push_back(maxA);
	sort(mb.begin(), mb.end());

	auto it = find(mb.begin(),mb.end(), maxA);
	int tot = 0, cnt = 0;
	for( auto it2 = mb.end()-1; it2 != it; --it2 ){
		tot += *it2;
		cnt++;
		if( tot >= h )
			break;
	}
	if( tot > h)
		cout << cnt << endl;
	else{
		h -= tot;
		if( h%maxA == 0 )
			cout << h/maxA + cnt << endl;
		else
			cout << cnt + (h-h%maxA)/maxA+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 892
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)









vector<vector<ll>> g;
vector<ll> c;

void dfs(ll now, ll par, ll val){
    c[now] += val;
    for(auto &child : g[now]){
        if(child == par) continue;
        dfs(child, now, c[now]);
    }
}

int main(){
    ll n, q;
    cin >> n >> q;
    g.resize(n);
    c.resize(n);
    REP(i, n - 1){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    REP(i, q){
        ll p, x;
        cin >> p >> x;
        p--;
        c[p] += x;
    }
    dfs(0, -1, 0);
    REP(i, n){
        cout << c[i] << " \n"[i == n - 1];
    }
}


Measured memory_bytes: 24320
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define INF 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());//昇順ソート
#define usort(a) sort(a.rbegin(),a.rend());//降順ソート

using namespace::std;

int jo(ll int a, ll int b){//累乗
    ll int num=1;
    rep(i,0,b) num=num*a;
    return num;
}
char tobig(char s){//char大文字化
  return (s-0x20);
}
char tolow(char s){//char小文字化
  return (s+0x20);
}
int ctoi(char a){//char->int
  if('0'<=a&&a<='9') return (a-'0');
  return -1;
}

int gcd(ll int a,ll int b) {//最大公約数
  if(a<b) return gcd(b,a);
  int c;
  while ((c=a%b)) {
    a=b;
    b=c;
  }
  return b;
}
int lcm(ll int a,ll int b){//最小公倍数
 return (a*b)/gcd(a,b);
}


int main(){
  int A,B,C; cin>>A>>B>>C;
  cout<<min(B,C)<<" "<<(B+C-A<0?0:B+C-A);
}




// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示

//  vector<pair<int,int>> data(N);  //2つのデータを格納、.first/.secondで参照
// pairのソートはfirst優先の昇順


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

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.st <<","<<P.nd <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int n, m, k;

int main() {
  cin >> n >> m >> k;
  vector<int> fridges;
  int minF = 1 << 30;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    minF = min(minF, x);
    fridges.push_back(x);
  }

  int minM = 1 << 30;
  vector<int> microwaves;
  for (int i = 1; i <= m; ++i) {
    int x;
    cin >> x;
    minM = min(minM, x);
    microwaves.push_back(x);
  }

  int res = minM + minF;

  for (int i = 1; i <= k; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    res = min(res, fridges[a - 1] + microwaves[b - 1] - c);
  }
  cout << res;
}


Measured memory_bytes: 1400
def BFS(i,A,N):
  dist=[0]*N
  d=[-1]*N
  d[i]=0#未訪問ならd=-1,訪問済みならiからの距離
  que=[i]
  dist=1
  while que:
    for j in range(len(que)):
      label=que.pop(0)
      for i in range(len(A[label])):
        if d[A[label][i]]==-1:
          d[A[label][i]]=dist
          que+=[A[label][i]]
    dist+=1
  return(d)

N=int(input())
ab=[]
for i in range(N-1):
  ab.append(list(map(int, input().split())))
A=[ [] for i in range(N) ]
for i in range(N-1):
  A[ab[i][0]-1]+=[ab[i][1]-1]
  A[ab[i][1]-1]+=[ab[i][0]-1]
 
 
dist1=BFS(0,A,N)
dist2=BFS(N-1,A,N)
Fe=0
Su=0
for i in range(N):
  if dist1[i]<=dist2[i]:
    Fe+=1
  else:
    Su+=1
if Fe>Su:
  print("Fennec")
else:
  print("Snuke")

Measured memory_bytes: 49556
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cassert>
#include <cinttypes>

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

const ll INF = 1e18 + 10;

int main() {
  string n;

  cin >> n;

  if (n[0] != n[2]) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;

  }
  return 0;
}

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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n;

int main() {
  cin >> n;
  vector<vector<char>> a(n, vector<char>(n));
  range(i, 0, n) {
    range(j, 0, n) cin >> a[i][j];
  }
  int res = 0;
  range(dif, 1 - n, n) {
    bool ok = true;
    range(x, 0, n) {
      range(y, 0, n) {
        // sx - sy + x - y = 2 * dif
        // sx + sy = x + y
        // sx = y + dif
        // sy = x - dif
        int sx = ((y + dif) % n + n) % n;
        int sy = ((x - dif) % n + n) % n;
        ok &= a[x][y] == a[sx][sy];
      }
    }
    if(ok) {
      int s = abs(dif);
      // x - y = dif
      // x >= dif x < n
      res += n - s;
    }
  }
  cout << res;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    map<ll, ll> cnt;
    rep(i, n){
        ll in; cin >> in;
        cnt[in]++;
    }
    ll ans = 0;
    for(auto p: cnt) if(p.second%2 != 0) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 6528
#include <iostream>

using namespace std;

int make_year(char *s){
    return (s[0]-'0') * 1000 + (s[1]-'0') * 100 + (s[2]-'0') * 10 + (s[3]-'0');
}

int make_month(char *s){
    return (s[5]-'0') * 10 + (s[6]-'0');
}

int make_day(char *s){
    return (s[8]-'0') * 10 + (s[9]-'0');
}

int main(){
    char s[10];
    cin >> s;
    int year = make_year(s);
    int month = make_month(s);
    int day = make_day(s);
    if(year > 2019 || (year == 2019 && month > 4)) cout << "TBD" << endl;
    else cout << "Heisei" << endl;
    return 0;
}

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

int findNumOfDigits(ll x){
  int cnt = 0;
  while(x > 0){
    x /= 10;
    cnt++;
  }
  return cnt;
}

int main(){
  ll n;
  cin >> n;
  int ans = findNumOfDigits(n);
  for(int i = 1; i <= sqrt(n); ++i){
    if(n % i == 0){
      int a_digit = findNumOfDigits(i);
      int b_digit = findNumOfDigits(n / i);
      int maxv = max(a_digit, b_digit);
      ans = min(maxv, ans);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#ifndef YK_INCLUDE
#include <bits/stdc++.h>
#endif //! YK_INCLUDE
int main() {
    std::cin.tie(nullptr); std::ios::sync_with_stdio(false);
    
    int S;
    std::cin >> S;
    int former=S/100;
    int latter=S%100;
    bool yymm = false;
    bool mmyy = false;
    
    yymm = 1<=latter&&latter<=12;
    mmyy = 1<=former&&former<=12;
    
    std::cout <<
    ((yymm&&mmyy)?"AMBIGUOUS"
    :(yymm)?"YYMM"
    :(mmyy)?"MMYY"
    :"NA")
    << std::endl;
}

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

using namespace std;

typedef long long ll;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"

const int N = 1e6;

int a[1 + N];

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

    ll n;
    cin >> n;
    if (n % 2) {
        cout << 0;
        return 0;
    }
    ll ans = 0;
    ll p = 10;
    while (n / p > 0) {
        ans += n / p;
        p *= 5;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'

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

    string a,b;

    cin >> a >> b;

    for(int i = 0;i < a.length();i++)
    {
        if(a==b){ cout << "Yes\n"; return 0; }
        string b = a;
        a = b.substr(0,b.size()-1);
        a = b[b.size()-1]+a;
    }

    cout << "No";
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
ll n,a,b,m;
map<ll,ll>mp;
int main(){
    cin>>n;
    mp.clear();
    for(int i=1;i<=n;i++){
        cin>>a;
        mp[a]++;
    }
    ll sum = 0;
    for(int i=1;i<=100000;i++){
        if(mp[i]){
            sum+=i*mp[i];
        }
    }
    cin>>m;
    while(m-->0){
        cin>>a>>b;
        sum-=mp[a]*a;
        sum+=mp[a]*b;
        mp[b]+=mp[a];
        mp[a]=0;
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 9888
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int C[10][10];
	int H,W;
	cin>>H>>W;
	fx(10){
		fy(10){
			cin>>C[x][y];
		}
	}
	
	fx(10){
		fy(10){
			fz(10){
				C[y][z]=min(C[y][z],C[y][x]+C[x][z]);
			}
		}
	}
	int ans=0;
	fx(H){
		fy(W){
			int k;
			cin>>k;
			if(k!=-1){
				ans+=C[k][1];
			}
		}
	}
	ce(ans)
  
}

Measured memory_bytes: 256
string = 'abcdefghijklmnopqrstuvwxyz'
table = []
for i in string:
    table.append(i)

def encode(string,a,b):
    data = list(string)
    s = []
    flag = 0
    for c in data:
        try:
            i = table.index(c)
            tmp = (a*i+b)%26
            s[-1:] += table[tmp]
        except:
            s.append(' ')
    s = ''.join(s)
    return s

n = int(input())
for x in range(n):
    code = str(input())
    for a in range(26):
        for b in range(26):
            s = encode(code,a,b)
            if 'that' in s:
                print(s)
                break
            elif 'this' in s:
                print(s)
                break

Measured memory_bytes: 7612
N,M=map(int,input().split())
A=list(map(int,input().split()))

def gcd(a,b):
  if a<b:
    a,b=b,a
  while a%b>0:
    a,b=b,a%b
  return b

def lcd(a,b):
  return (a*b)//(gcd(a,b))

L=1
cur=-1
for i in range(len(A)):
  A[i]//=2
  p=A[i]
  c=0
  while p%2==0:
    p//=2
    c+=1
  if cur!=-1:
    if c!=cur:
      print(0)
      exit(0)
  cur=c
  L=lcd(L,A[i])

ans=M//(L*2)
ans+=(M%(L*2))//L
print(ans)


Measured memory_bytes: 14400
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define PI acos(-1.0)
#define random(x) rand() % x
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
const int MAX = 1e5 + 5;
const int Mod = 1e9 + 7;

vector<P> A;

int main()
{
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        P t;
        cin >> t.first;
        t.second = 1;
        A.push_back(t);
    }
    for(int i = 0; i < m; i++){
        P t;
        // cin >> t.first >> t.second;
        cin >> t.second >> t.first;
        A.push_back(t);
    }
    sort(A.rbegin(), A.rend());
    int tot = 0;
    LL ans = 0;
    for(int i = 0; i < A.size() && tot < n; i++){
        if (tot + A[i].second <= n){
            ans += 1LL * A[i].first * A[i].second ;
            tot += A[i].second;
        }
        else {
            ans += 1LL * (n - tot) * A[i].first;
            tot = n;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int n;
    std::cin >> n;
    std::vector<string> blue(n);
    for (int i = 0; i < n; i++) {
        std::cin >> blue[i];
    }
    int m;
    std::cin >> m;
    std::vector<string> red(m);
    for (int i = 0; i < m; i++) {
        std::cin >> red[i];
    }
    int ans=0;
    auto calc=[&](string s){
        int buf=0;
        for (string t:blue) {
            if(t==s)buf++;
        }
        for(string t:red){
            if(t==s)buf--;
        }
        return buf;
    };
    for(string t:blue){
        ans=max(ans,calc(t));
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>

using namespace std;

const int MAX = 1e5+1;

int T[MAX];
int N,L;
vector<int> V;

int rec(int n){
  // cout << "n " << n << endl;
  if(T[n] != -1) return T[n];
  int tmp = 0;
  if(0 <= n-1 && V[n-1] > V[n]) tmp = max(tmp,rec(n-1));
  if(n+1 < N && V[n] < V[n+1]) tmp = max(tmp,rec(n+1));
  tmp += L-V[n];
  return T[n] = tmp;
}

int main(){
 
  cin >> N >> L;
  V.resize(N);

  for(int i = 0; i < N; i++) cin >> V[i];
  memset(T,-1,sizeof(T));

  int ans = 0;
  for(int i = 0; i < N; i++) ans = max(ans,rec(i));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
int main(){
  int N,ans,i;cin>>N;int A[N];
  REP(i,N)cin>>A[i];ans=A[0];REP(i,N-1)ans=__gcd(ans,A[i+1]);
  if(ans==1){
    int x=1;vector<int>X;
    REP(i,N){
      int j=1;
      while(A[i]!=1){
        j++;
        if(j*j>A[i]){X.push_back(A[i]);break;}
        if(A[i]%j==0){
          X.push_back(j);
          while(A[i]%j==0)A[i]/=j;
        }
      }
      if(X.size()>78498)break;
    }
    if(X.size())sort(ALL(X));if(X.size()>1)REP(i,X.size()-1)if(X.at(i)==X.at(i+1))x=0;
    if(x==1)cout<<"pairwise coprime"<<endl;else cout<<"setwise coprime"<<endl;
  }
  else cout<<"not coprime"<<endl;
  return 0;
}

Measured memory_bytes: 7768
#include <iostream>
using namespace std;
bool ok(int n) {
    int a = n % 10;
    n /= 10;
    int b = n % 10;
    n /= 10;
    int c = n % 10;
    return (a == b && b == c);
}
int main(void) {
    int N;cin>>N;
    for (int i = N; i <= 999; i++) {
        if (ok(i)) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

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

bool chk(string s,int i){

        	int mid = i/2;

        	for(int start = 0;start<mid;start++)
        	{
        		 if(s[start]!=s[start+mid])
        		  return false; 
        	}
        	return true;

        }
int main(void)
{
    string s;
    cin>>s;
    int len = s.length();
    int res = 0;
   for(int i = len-1;i>=0;i--)
   {

        if(i%2==0 && chk(s,i))
           {
           	 res = i;
           	 break;
           }
   }

   cout<<res<<endl;

}

Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC080A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, a, b, x;

            var word = Console.ReadLine().Split(' ');
            n = int.Parse(word[0]);
            a = int.Parse(word[1]);
            b = int.Parse(word[2]);


            x = a * n;
            if (x > b)
                x = b;

          



            Console.WriteLine(x);

            Console.ReadKey();
        
        
        
         }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

int main() {
    int n; cin>> n;
    vector<ll> a(n);
    vector<ll> b(n + 1, 0);
    int mod = 1000000007;

    rep(i, n){
        cin>> a[i];
        b[i + 1] = b[i] + a[i];
    }

    ll ans = 0;
    rep(i, n){
        ll sum = (b[n] - b[i+1]) % mod;
        ans += a[i] * sum;
        ans %= mod;
    }
    cout<< ans << endl;
}


Measured memory_bytes: 6408
n, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(n)]


def recur(i, a, b, c):
    if i == n:
        if a < 1 or b < 1 or c < 1:
            return 10 ** 18
        return abs(a - A) + abs(b - B) + abs(c - C)

    return min([
        recur(i + 1, a, b, c),
        recur(i + 1, a + l[i], b, c) + (10 if a > 0 else 0),
        recur(i + 1, a, b + l[i], c) + (10 if b > 0 else 0),
        recur(i + 1, a, b, c + l[i]) + (10 if c > 0 else 0)
    ])


print(recur(0, 0, 0, 0))


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string.h>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    string s;
    cin >> s;
    if(s.back() == '1' || s[0] == '0'){
        cout << -1 << endl;
        return 0;
    }
    for(int i = 0; i < s.size() - 1; i++){
        if(s[i] != s[s.size() - i - 2]){
            cout << -1 << endl;
            return 0;
        }
    }
    vector<int> being_1;
    for(int i = int(s.size()) - 1; i >= 0; i--){
        if(s[i] == '1'){
            being_1.push_back(i + 1);
        }
    }
    int now = 0;
    for(int i = 1; i < s.size(); i++){
        cout << now + 1 << " " << i + 1 << endl;
        if(s[s.size() - i - 1] == '1'){
            now = i;
        }
    }
}


Measured memory_bytes: 2040
#include <stdio.h>
int main(void) {
	int n;
	scanf("%d",&n);
	n <= 100;
	int a[n];
	int i, j, k;
	for(i=0; i<=n; i++){
		scanf("%d",&a[i]);
	}
		for(j=0; j<n/2; j++){
		scanf("%d",&k);
			k = a[j];
			a[j] = a[n-j-1];
			a[n-j-1] = k;
		}
	for(k=0; k<n; k++){
		scanf("%d",&a[k]);
		if(k>0){
				printf(" ");
				printf("%d",a[k]);
			}
		else if(k==0){
				printf("%d",a[k]);
			}
	}
	printf("\n");
	return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
string s;
int main(){
	cin>>s; int x = 0;
	rep(i,s.size()){
		if(s[i]=='N')x|=1;
		if(s[i]=='S')x|=2;
		if(s[i]=='W')x|=4;
		if(s[i]=='E')x|=8;
	}
	if(x==0||x==3||x==12||x==15)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string day;
    int n;
    cin >> day;

    if (day == "SUN")
    {
        n = 7;
    }
    else if (day == "MON")
    {
        n = 6;
    }
    else if (day == "TUE")
    {
        n = 5;
    }
    else if (day == "WED")
    {
        n = 4;
    }
    else if (day == "THU")
    {
        n = 3;
    }
    else if (day == "FRI")
    {
        n = 2;
    }
    else if (day == "SAT")
    {
        n = 1;
    }
    cout << n << '\n';

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#define M 100

int main(void) {
  int A, B;
  (void)scanf("%d %d", &A, &B);
  A--; B--;

  printf("%d %d\n", M, M);
  for (int h = 0; h < M / 2; h++) {
    for (int w = 0; w < M; w++) {
      if (A > 0 && h % 2 == 0 && w % 2 == 0) {
        printf("."); A--;
      } else {
        printf("#");
      }
    }
    puts("");
  }
  for (int w = 0; w < M; w++) printf(".");
  puts("");
  for (int h = M / 2 + 1; h < M; h++) {
    for (int w = 0; w < M; w++) {
      if (B > 0 && h % 2 == 0 && w % 2 == 0) {
        printf("#"); B--;
      } else {
        printf(".");
      }
    }
    puts("");
  }

  return 0;
}


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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n;cin>>n&&n;){
		vi ps(n);
		rep(i,n) cin>>ps[i];
		cout<<accumulate(all(ps),0)-*max_element(all(ps))/2<<endl;;
	}
}


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

using namespace std;

int main(){
	int n, a;
	vector<int> v(100000);
	for(int i=0; i<100000; i++){
		v[i]=0;
	}

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

	vector<int> v2;
	for(int i=0; i<100000; i++){
		if(v[i]>1){
			for(int j=0; j<v[i]-1; j++){
				v2.push_back(i);
			}
		}
	}

	if(v2.size()&1){
		cout<<n-v2.size()-1<<endl;
	}else{
		cout<<n-v2.size()<<endl;
	}

	return 0;
}


Measured memory_bytes: 1276
s = list(input())
ans_l = []
for i in s:
    if len(ans_l) != 0:
        if i == "B":
            del ans_l[len(ans_l) - 1]
        else:
            ans_l.append(i)
    else:
        if i != "B":
            ans_l.append(i)

ans = ""
for j in ans_l:
    ans = ans + j

print(ans)

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    vector<ll> tmpa(n+1,0);
    for(i = 0;i < n;++i){
        tmpa.at(i+1) = tmpa.at(i) + a.at(i);
    }
    vector<ll> sum;
    for(i = 0;i < n;++i){
        for(j = i+1;j <= n;++j){
            ll tmp = tmpa.at(j) - tmpa.at(i);
            sum.push_back(tmp);
        }
    }
    ll ans = 0;
    for(i = 40;i >= 0;--i){
        ll cnt = 0;
        ll tmp = ans|(1LL << i);
        rep(j,sum.size()){
            if((sum.at(j) & tmp) == tmp) ++cnt;
        }
        if(cnt < k){
            continue;
        }else{
            ans |= (1LL << i);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6516
N = int(input())

import math

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

num = prime_factorize(math.factorial(N))
ans = 1
num_list = set(num)

mod = 10**9+7

for x in num_list:
    ans = ans*(num.count(x)+1)%mod
    
print(ans)

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

typedef long long ll;
unordered_map <ll,ll> m;
ll ans = 0;
ll N;
int main(){
	cin>>N;

  for (ll i=0;i<N;i++){
    ll a;
    cin>>a;
    m[a]++;
  }

  for (auto i: m){
    if (i.second > i.first){
        ans += min(i.second,i.second - i.first);
    }else if (i.second != i.first){
        ans += i.second;
    }else{}
    
  }
  cout<<ans;



}

Measured memory_bytes: 4260
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007

int main(){
    int N;
    cin>>N;
    vector<ll> A(N);
    for(int i=0;i<N;i++) cin>>A[i];
    sort(A.begin(),A.end(),greater<ll>());
    
    if(N%2==0){
        ll res=0;
        for(int i=0;i<N/2-1;i++) res+=A[i]*2;
        res+=A[N/2-1];
        res-=A[N/2];
        for(int i=N/2+1;i<N;i++) res-=A[i]*2;
        cout<<res<<endl;
    }
    else{
        ll res1=0;
        for(int i=0;i<N/2-1;i++) res1+=A[i]*2;
        res1+=A[N/2-1]+A[N/2];
        for(int i=N/2+1;i<N;i++) res1-=A[i]*2;
        
        ll res2=0;
        for(int i=0;i<N/2;i++) res2+=A[i]*2;
        res2-=A[N/2]+A[N/2+1];
        for(int i=N/2+2;i<N;i++) res2-=A[i]*2;
        cout<<max(res1,res2)<<endl;
    }
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <algorithm>

using namespace std;

int main(void){
  vector<int> hand;
  set<int> ans;
  deque<vector<int> > Q;
  char tmp;

  for(int i=0;i<10;i++){
    hand.push_back(0);
  }

  while(cin >> tmp){
    bool nothing = true;
    //in each case
    hand[tmp - '0']++;
    for(int i=0;i<12;i++){
      cin >> tmp;
      hand[tmp - '0']++;
    }

    for(int i=1;i<=9;i++){
      vector<int> tmp, work;
      int kind = 0;
      int sum = 0;
      if(hand[i] < 4){
	hand[i]++;
      }else{
	continue;
      }
      Q.clear();
      Q.push_back(hand);
      hand[i]--;
      while(!Q.empty()){
	tmp = Q.front(); Q.pop_front();

	/* ended or not*/
	kind = 0;
	sum = 0;
	for(int j=1;j<=9;j++){
	  sum += tmp[j];
	  if(tmp[j] != 0) kind++;
	}
	if(sum == 2 && kind == 1){
	  ans.insert(i);
	  break;
	}


	for(int j=1;j<=9;j++){
	  if(tmp[j] >= 3){// can be used as a head
	    tmp[j] -= 3;
	    if(find(Q.begin(), Q.end(), tmp) == Q.end()){
	      Q.push_back(tmp);
	    }
	    tmp[j] += 3;
	  }
	}
	
	for(int j=1;j<=7;j++){
	  if(tmp[j] >= 1 && tmp[j+1] >= 1 && tmp[j+2] >= 1){
	    tmp[j]--; tmp[j+1]--; tmp[j+2]--;
	    if(find(Q.begin(), Q.end(), tmp) == Q.end()){
	      Q.push_back(tmp);
	    }
	    tmp[j]++; tmp[j+1]++; tmp[j+2]++;
	  }
	}
      }
    }
    set<int>::iterator it = ans.begin();
    if(ans.size() == 0){
      cout << 0 << endl;
    }else{
      for(int i=0;i<ans.size()-1;++it){
	cout << *it << " ";
	i++;
      }
      cout << *it << endl;
    }
    hand.clear();
    for(int i=0;i<10;i++){
      hand.push_back(0);
    }
    ans.clear();
  }  
}

Measured memory_bytes: 0
import java.math.*;
import java.util.*;
  


public class Main {
	
	
	
	public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N=scan.nextInt(),W=scan.nextInt();
        int dp[]=new int[W+1],v[]=new int[N],w[]=new int[N];
        for(int i=0;i<N;i++) {
        	v[i]=scan.nextInt();
        	w[i]=scan.nextInt();
        }
        for(int i=0;i<N;i++) {
        	for(int j=w[i];j<=W;j++) {
        		dp[j]=Math.max(dp[j], dp[j-w[i]]+v[i]);
        	}
        }
        System.out.println(dp[W]);
        
	}
	
	
	
}


Measured memory_bytes: 26964
#include<bits/stdc++.h>
#define M 1000000007

using namespace std;
typedef long long int ll;

void fun(ll temp[],ll m,ll q,vector<vector<ll> >v,ll &ans,ll ind,ll n,ll current)
{
    if(ind==n)
    {
        ll sum=0;
        for(ll i=0;i<q;i++)
        {
              if(temp[v[i][1]-1] - temp[v[i][0]-1] == v[i][2])
                sum+=v[i][3];
        }
        ans = max(ans,sum);
        return;
    }
    else
    {
        for(ll i=current;i<=m;i++)
        {
            temp[ind] = i;
            fun(temp,m,q,v,ans,ind+1,n,i);
        }
    }
}
int main()
{
ll n,m,q;
cin>>n>>m>>q;
vector<vector<ll>>v(q);

for(ll i=0;i<q;i++)
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    v[i].push_back(a);
    v[i].push_back(b);
    v[i].push_back(c);
    v[i].push_back(d);
}
  ll ans  = -1;
  ll temp[n+1]={0};
  fun(temp,m,q,v,ans,0,n,1);
  cout<<ans<<endl;
}


Measured memory_bytes: 3672
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#pragma endregion

//#define __DEBUG__
#ifdef  __DEBUG__
#define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    REP(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
// pair出力
template<typename T, typename U>
ostream& operator << (ostream& os, pair<T, U>& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
// map出力
template<typename T, typename U>
ostream& operator << (ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set 出力
template<typename T>
ostream& operator << (ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#endif

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N, Z, W;
    cin >> N >> Z >> W;
    VI a(N);
    REP(i, N) {
        cin >> a[i];
    }
    if (N == 1) {
        cout << abs(W - a[N - 1]) << endl;
    }
    else {
        cout << max(abs(W - a[N - 1]), abs(a[N - 1] - a[N - 2])) << endl;
    }
    getchar(); getchar();
}

Measured memory_bytes: 256