akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n = ii()
    L = lmi()
    print('Yes') if sum(L) - max(L) > max(L) else print('No')


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    vector<int>l(N);
    for (int i = 0; i < N; i++)
    {
        cin >> l[i];
    }
    sort(l.begin(),l.end(),greater<int>());
    int sum=0;
    for (int i = 0; i < K; i++)
    {
        sum+=l.at(i);
    }
    cout<<sum;
}

Measured memory_bytes: 764
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> h(n);
    for (int i = 0; i < n; ++i)
        cin >> h[i];

    vector<int> dp(n, INT_MAX);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; ++i) {
        int cost1 = dp[i - 1] + abs(h[i] - h[i - 1]);
        int cost2 = dp[i - 2] + abs(h[i] - h[i - 2]);
        dp[i] = min(cost1, cost2);
    }
    cout << dp[n - 1] << '\n';
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
int main(){
  ll k;cin>>k;
  string a;
  cin>>a;
  ll b=a.size(),c=0;
  for(ll i=0;i<b;i++){
    if(a.at(i)=='R'){c++;}
  }
  ll d=0;
  for(ll i=0;i<c;i++){
    if(a.at(i)=='R'){d++;}
  }
  cout << c-d<<endl;
}

Measured memory_bytes: 3720
from collections import Counter
h, w = map(int, input().split())
A = []
for i in range(h):
    A.extend(list(input()))
cA = Counter(A)

l1 = h*w%2
l2 = (h//2)*(w%2) + (w//2)*(h%2)
l3 = (h//2)*(w//2)
if l1:
    for key, val in cA.items():
        if val%2==1:
            cA[key] -= 1
            break
for _ in range(l2):
    for key, val in cA.items():
        if val%4==2:
            cA[key] -= 2
            break
print('Yes' if sum(val%4 for val in cA.values()) == 0 else 'No')

Measured memory_bytes: 9460
#include <bits/stdc++.h>
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 111;
int occ[26];
int h, w;

int main() {
    ios::sync_with_stdio(false);
    cout.precision(10);
    cin >> h >> w;
    for(int i = 1; i <= h; i++) {
        string s;
        cin >> s;
        for(int j = 0; j < s.size(); j++) {
            occ[s[j] - 'a']++;
        }
    }
    int n1 = 0, n2 = 0, n4 = 0;
    for(int i = 0; i < 26; i++) {
        if(occ[i] % 2) {
            n1++;
            occ[i]--;
        } 
        if(occ[i] % 4) {
            n2++;
            occ[i] -= 2;
        }
        n4 += occ[i] / 4;
    }
    bool ok = true;
    bool hh = h % 2, ww = w % 2;
    if(!hh && !ww) {
        if(n2 || n1) {
            ok = false;
        }
    } else if(hh && ww) {
        if(n1 != 1) {
            ok = false;
        }
        int needed = h / 2 + w / 2;
        while(n4 && n2 < needed) {
            n4--;
            n2 += 2;
        }
        if(n2 != needed) {
            ok = false;
        }
    } else {
        if(ww) {
            swap(w, h);
        }
        int needed = w / 2;
        while(n4 && n2 < needed) {
            n4--;
            n2 += 2;
        }
        if(n2 != needed) {
            ok = false;
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int a,b;
int main(void)
{
	scanf("%d %d",&a,&b);
	if(a==b){
	printf("a == b\n");
	}else{
		if(a<b){
		printf("a < b\n");
		}else{
			printf("a > b\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int main() {
  int l, n;
  cin >> n >> l;
  string s[110];
  for (int i = 0; i < n; i++) cin >> s[i];
  sort(s, s + n);
  string res = {};
  for (int i = 0; i < n; i++) res += s[i];
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

int n;
vector<double> A;

int main() {
  cin >> n;
  A.resize(n);
  rep(i, n) { cin >> A[i]; }

  double ans = 0;
  rep(i, n) { ans += (1 / A[i]); }
  ans = 1 / ans;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
// template<class T> T gabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    string s;
    cin >> s;
    i64 ans = 0;
    for (int t = 0; t < (1 << (s.size() - 1)); ++t) {
        i64 x = 0, res = 0;
        for (int i = 0; i < s.size(); ++i) {
            x = 10 * x + (s[i] - '0');
            if (!(t & (1 << i))) {
                res += x;
                x = 0;
            }
        }
        ans += res;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <limits>
#include <queue>
#include <map>
#include <ctime>

using namespace std;

#define rip(i,n,s) for (int i=(s);i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
typedef pair<long long,int> P;
int main(){
    int n;
    cin >> n;
    vector<vector<P> > da(n,vector<P>(0));
    rip(i,n,0){
        int u,k;
        cin >> u >> k;
        rip(j,k,0){
            long long c;
            int v;
            cin >> v >> c;
            da[u].push_back(make_pair(c,v));
        }
    }
    priority_queue<P,vector<P>,greater<P> > q;
    vector<long long> ans(n,0);
    rip(i,da[0].size(),0){
        q.push(da[0][i]);
    }
    while (!q.empty()){
        P x=q.top();
        q.pop();
        if(ans[x.second]==0 && x.second!=0){
            ans[x.second]=x.first;
            rip(i,da[x.second].size(),0){
                q.push(make_pair(x.first+da[x.second][i].first,da[x.second][i].second));
            }
        }
    }
    rip(i,n,0){
        cout << i << ' ' << ans[i] << endl;
    }
}


Measured memory_bytes: 3248
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let a: Vec<u64> = sc.vec(n);
    let b: Vec<u64> = sc.vec(n);

    let mut ans = 0;
    for i in 1..31 {
        let mask = (1 << i) - 1;
        let d = 1 << (i - 1);
        let mut b: Vec<_> = b.iter().map(|&b| b & mask).collect();
        b.sort();

        let mut count = 0;
        for a in a.iter().map(|&a| a & mask) {
            let t1 = b
                .binary_search_by_key(&(d * 2 + 1), |&b| (a + b) * 2 + 2)
                .err()
                .unwrap();
            let t2 = b
                .binary_search_by_key(&(2 * d * 2 + 1), |&b| (a + b) * 2 + 2)
                .err()
                .unwrap();
            let t3 = b
                .binary_search_by_key(&(3 * d * 2 + 1), |&b| (a + b) * 2 + 2)
                .err()
                .unwrap();
            let t4 = n;
            let x = t2 - t1 + t4 - t3;
            count += x;
        }
        if count % 2 == 1 {
            ans += d;
        }
    }

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

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, ans = 0, x;
  cin >> n;
  unordered_map<ll, ll> mp;
  for (int i = 1; i <= n; ++i) scanf("%lld", &x), ans += mp[i - x], mp[i + x]++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 18736
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<stdlib.h>
#include<math.h>
using namespace std;
//#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007
typedef struct node * nodept;

struct node{
    int key = -1;
    node *par;
    node *right;
    node *left;
};

nodept nil, root;

void init(){
    nil = (nodept)malloc(sizeof(node));
    nil->par = nil;
    nil->left = nil;
    nil->right = nil;
    
    root = nil;
}

void insert(int key){
    nodept z;
    z = (nodept)malloc(sizeof(node));
    z->key = key;
    z->par = nil;
    z->right = nil;
    z->left = nil;
    
    nodept y = nil;
    nodept x = root;

    while(x != nil){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }
        else {
            x = x->right;
        }
    }

    z->par = y;

    if(y == nil){
        root = z;
    }
    else if(z->key < y->key){
        y->left = z;
    }
    else {
        y->right = z;
    }
}

void indfs(nodept v){
    if(v == nil)return;
    if(v->left != nil){
        indfs(v->left);
    }
    printf(" %d", v->key);
    if(v->right != nil){
        indfs(v->right);
    }
}

void predfs(nodept v){
    if(v == nil)return;
    printf(" %d", v->key);
    if(v->left != nil){
        predfs(v->left);
    }
    if(v->right != nil){
        predfs(v->right);
    }
}

signed main(){
    int M;
    cin >> M;
    init();
    for(int i = 0; i < M; i++){
        char query[10];
        cin >> query;
        if(query[0] == 'i'){
            int key;
            cin >> key;
            insert(key);
        }
        else {
            indfs(root);
            printf("\n");
            predfs(root);
            printf("\n");
        }
    }


    return 0;
}

/*



*/


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

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	string s;
	if (a <= b) {
		for (int i = 0; i < b; i++) s.push_back(a + '0');
	}
	if (a > b) {
		for (int i = 0; i < a; i++) s.push_back(b + '0');
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3516
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
using namespace std;
ll a[114514], b[114514], c[114514], n, memo = 0;
signed main() {
	ll cnt = 0, ans = 0, p = 0;
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];
	rep(i, n) {
		if (a[i] < b[i])cnt += b[i] - a[i];
		else if (a[i] == b[i])p++;
	}
	rep(i, n) {
		if (a[i] > b[i]) {
			c[memo] = a[i] - b[i];
			memo++;
		}
	}
	sort(c, c + memo);
	reverse(c, c + memo);
	rep(i, memo) {
		if (cnt) {
			cnt -= c[i];
			cnt = max(cnt, (ll)0);
			ans++;
		}
		else break;
	}
	if (cnt)puts("-1");
	else cout << ans + n - memo - p << endl;
	ggr
}


Measured memory_bytes: 2176
# coding: utf-8
# Your code here!

h,w,n = [int(i) for i in input().split()]
h0,w0 = [int(i) for i in input().split()]

s = input()
t = input()

rs = reversed(s)
rt = reversed(t)

lw,rw=1,w
lh,rh=1,h

ok=1
for tak,ao in zip(rs,rt):
    if ao == "L":
        if rw<w:
            rw += 1
    if ao == "R":
        if lw>1:
            lw -= 1
    if ao == "U":
        if rh < h:
            rh += 1
    if ao == "D":
        if lh > 1:
            lh -= 1
#    print(lw,lh,rw,rh)
    if tak == "L":
        lw += 1
    if tak == "R":
        rw -= 1
    if tak == "U":
        lh += 1
    if tak == "D":
        rh -= 1
#    print(lw,lh,rw,rh)
    if lw > rw or lh > rh:
        ok=0
        break

if not (lw <= w0 <= rw and lh < h0 <= rh):
    ok=0

if ok == 1:
   print("YES")
else:
   print("NO")

Measured memory_bytes: 48172
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    n,k=MI()
    height=LI()
    ans=inf
    for x in product([0,1],repeat=n):
        if sum(list(x))<k:
            continue
        mx=0
        res=0
        for i in range(n):
            if x[i]==1:
                if height[i]<=mx:
                    res+=mx-height[i]+1
                    #print(mx-height[i]+1)
                    mx+=1
                else:
                    res+=0
                    mx=max(mx,height[i])
            else:
                mx=max(mx,height[i])
        #print(res)
        ans=min(ans,res)
    print(ans)            
                
                
    
        
        
        
        




if __name__=="__main__":
    main()


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


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

	string ans = "No";
	if ((a == b && a != c) || (a == c && a != b) || (b == c && c != a)) {
		ans = "Yes";
	}

	cout << ans << endl;
}


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

using namespace std;
typedef long long ll;

int main(){
    ll h, w;
    cin >> h >> w;
    vector<vector<ll>> m(h, vector<ll>(w, 0));
    vector<ll> wsum(h, 0);
    vector<ll> hsum(w, 0);
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            char c;
            cin >> c;
            if(c == '#'){
                m.at(i).at(j) = 1;
                wsum.at(i) += 1;
                hsum.at(j) += 1;
            }
        }
    }

    for(int i = 0; i < h; ++i){
        if(wsum.at(i) == 0){ continue; }
        for(int j = 0; j < w; ++j){
            if(hsum.at(j) == 0){ continue; }
            if(m.at(i).at(j)){
                cout << '#';
            }else{
                cout << '.';
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 384
from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
# from math import *
from collections import defaultdict as dd, deque
def data(): return sys.stdin.readline()
def mdata(): return map(float, data().split())
out = sys.stdout.write
# sys.setrecursionlimit(100000)
INF = int(1e9)
mod = int(1e9) + 7

n = int(data())
P = list(mdata())
dp = [0.0] * (n // 2 + 2)
dp[1] = float(1)
for i in range(n):
    p=P[i]
    for j in range(len(dp) - 1, 0, -1):
        dp[j] = dp[j - 1] * (1 - p) + dp[j] * (p)
print(sum(dp))


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

// using mint = modint1000000007;
// using mint = modint998244353;

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

void solve() {
    bool x;
    cin >> x;
    print(not x);
}

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


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

int main()
{

int A,B,K,c;
cin >> K  >> A >> B;

for (int i=1; i < (B / K)+1  ; i++)
{
  c = K*i;
  if ((c >= A) && (c <= B) )
      {
        cout << "OK" << endl;
        return 0;
      }
      }      
cout << "NG" << endl;

}

Measured memory_bytes: 3632
using System;

namespace MyProgram{
    class AtCoder{
        static void Main(string[] args){
            int N = int.Parse(Console.ReadLine());
            int[] d = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            Array.Sort(d);
            int K = d[N/2]-d[N/2-1];
            Console.WriteLine(K);
        }
    }
}

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

// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

#define St first
#define Nd second
#define Pb push_back
#define Mp make_pair
#define print_pair(p) cout<<p.St<<" "<<p.Nd
#define endl "\n"

#define REP(i,a,b) for(int i = a; i <= b; i++)
#define REV(i,a,b) for(int i = a; i >= b; i--)

#define AritSum(a,d,n) ((n)*(2*(a)+((n)-1)*(d)))/2
#define Log(base, num) log2(num)/log2(base)


// ************* MAIN *******************

int N,M, temp;
void solve() {
    cin>>N>>M;
    REP(i,0,M-1) {
        cin>>temp;
        N-=temp;
    }
    cout << max(-1, N) << endl;
}
/*
g++ -std=c++14 -Wall -Wextra -O2 Test.cpp -o Test
*/
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T=1;
    // cin>>T;
    for (int t = 1; t <= T; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3596
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	map< string , vector<int> > list;
	set<string> namelist;
	char cself[256];
	int iself;
	while(scanf("%s %d",cself,&iself) != EOF){
		list[cself].push_back(iself);
		namelist.insert(cself);
	}
	vector<int>::iterator it;
	set<string>::iterator nit;
	
	//sort(namelist.begin(),namelist.end());
	
	bool f;
	
	for(nit = namelist.begin();nit != namelist.end();nit++){
		printf("%s\n",(*nit).c_str());
		f = false;
		sort(list[*nit].begin(),list[*nit].end());
		for(it = list[*nit].begin();it < list[*nit].end();it++){
			if(f){
				printf(" ");
			}
			printf("%d",*it);			
			f = true;
		}
		printf("\n");
	}
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    string s;
    cin>>s;
    map<string,ll> mp;
    mp["SUN"]=7;
    mp["MON"]=6;
    mp["TUE"]=5;
    mp["WED"]=4;
    mp["THU"]=3;
    mp["FRI"]=2;
    mp["SAT"]=1;
    cout<<mp[s]<<endl;
    return  0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
        static Scanner sc = new Scanner(System.in);
        static void myout(Object t){System.out.println(t);}//standard output
        static void myerr(Object t){System.err.println(t);}//standard error
        static String getStr(){return sc.next();}
        static int getInt(){return Integer.parseInt(getStr());}
        static long getLong(){return Long.parseLong(getStr());}
        static boolean hasNext(){return sc.hasNext();}
        static char[] mySplit(String str){return str.toCharArray();}
        public static void main(String[] args){
          PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
          int X = getInt();
          int Y = getInt();
          int A = getInt();
          int B = getInt();
          int C = getInt();
          ArrayList<Integer> alist = new ArrayList<Integer>();
          ArrayList<Integer> blist = new ArrayList<Integer>();
          ArrayList<Integer> clist = new ArrayList<Integer>();
          for(int i = 0; i < A; i++){
            alist.add(getInt());
          }
          for(int i = 0; i < B; i++){
            blist.add(getInt());
          }
          for(int i = 0; i < C; i++){
            clist.add(getInt());
          }
          
          Collections.sort(alist,Collections.reverseOrder());
          Collections.sort(blist,Collections.reverseOrder());
          Collections.sort(clist,Collections.reverseOrder());
          for(int i = 0; i < X; i++){
            pq.add(alist.get(i));
          }
          for(int i = 0; i < Y; i++){
            pq.add(blist.get(i));
          }
          for(int i = 0; i < C; i++){
            int pqMin = pq.poll();
            int cMax = clist.get(i);
            if(pqMin < cMax){
              pq.add(cMax);
            }else{
              pq.add(pqMin);
            }
          }
          long output = 0;
          while(!pq.isEmpty()){
            output += pq.poll();
          }
          myout(output);
        }
        //Method addition frame start

        //Method addition frame end
}


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

int main() {
  int N,M,X;
  int sol = Ldef;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N,vector<int> (M));
  
  rep(i,N)
  {
    cin >> C.at(i);
    rep(j,M)
    {
      cin >> A.at(i).at(j);
    }
  }
  for(int i = 0;i < (1 << N);i++)
  {
    bitset<12> s(i);
    int sum = 0;
    vector<int> buf(M);
    rep(j,N)
    {
      if(s.test(j))
      {
        sum += C.at(j);
        rep(k,M)
        {
          buf.at(k) += A.at(j).at(k);
        }
      }
    }
    if(sum < sol)
    {
      bool ans = true;
      rep(j,M)
      {
        if(buf.at(j) < X)
        {
          ans = false;
          break;
        }
      }
      if(ans)
      {
        sol = sum;
      }
    }
  }
  if(sol == Ldef)
  {
    sol = -1;
  }
  cout << sol << endl;
  

}


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

// dp[i] := iにいるときの最小コスト
ll dp[101010];

int main() {
    int n;
    cin >> n;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    fill(dp, dp+n+1, 1e10);
    dp[0] = 0;
    for (int i=0; i<n-1; ++i) {
        dp[i+1] = min(dp[i+1], dp[i] + abs(h[i]-h[i+1]));
        if (i+2<n) dp[i+2] = min(dp[i+2], dp[i] + abs(h[i]-h[i+2]));
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if (a + b >= c - 1) printf("%d\n", b + c);
	else printf("%d\n", b + c - (c - 1 - a - b));
	return 0;
}


Measured memory_bytes: 256
n,k,q = map(int,input().split())
a = [input() for i in range(q)]
b = [0 for i in range(n)]
if k > q:
    for i in range(n):
        print("Yes")
else:
    for i in range(q):
        b[int(a[i])-1] += 1
    for i in range(n):
        if b[i] > q - k:
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 11016
m,d=input().split(" ")
m=int(m)
d=int(d)
ans=0
for i in range(m):
    for j in range(d):
        if len(str(j+1))>=2:
            k=j+1
            k=str(k)
            if int(k[0])>=2 and int(k[1])>=2 and (i+1)==(int(k[0])*int(k[1])):
                ans+=1
print(ans)

Measured memory_bytes: 3064
N, C = map(int, raw_input().split())
D = []
c = []
for i in range(C):
  D.append(map(int, raw_input().split()))
for i in range(N):
  c.append(map(int, raw_input().split()))

res = [[0] * C for i in range(3)]
for i in range(N):
  for j in range(N):
    res[(i+j)%3][c[i][j]-1] += 1
small = 250000000
for i in range(C):
  for j in range(C):
    for k in range(C):
      if i == j or i == k or j == k:
        continue
      total = 0
      for m in range(C):
          total += res[0][m] * D[m][i]
          total += res[1][m] * D[m][j]
          total += res[2][m] * D[m][k]
      if total < small:
        small = total
print(small)


Measured memory_bytes: 4608
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

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

//#define MOD 1000000007LL
#define MOD 998244353LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;

vector<vector<int>> v(10, vector<int>(10, 0));
int n;

void solve2(int l,int sum) {
	for (int i = 0; i <= 9; i++) if (sum * 10 + i <= n) {
		v[l][i]++;
		solve2(l, sum * 10 + i);
	}
}

void solve() {
	for (int i = 1; i <= min(n,9LL); i++) {
		solve2(i, i);
		v[i][i]++;
	}
	int res = 0;
	for (int i = 1; i <= 9; i++)for (int j = 1; j <= 9; j++) {
		//cout << i << " " << j << " " << v[i][j] << endl;
		res += v[i][j] * v[j][i];
	}

	cout << res << endl;
}




signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	solve();
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int h, w, n;
	scanf("%d %d %d", &h, &w, &n);
	int ctr=0, tot=0;
	while(1){
		if(((1*w)>=(1*h)) && tot<n){
			ctr++;
			tot+=(1*w);
		}
		else if(((1*h)>(1*w)) && tot<n){
			ctr++;
			tot+=(1*h);
		}
		else{
			break;
		}
	}
	printf("%d", ctr);
	return 0;
}

Measured memory_bytes: 1696
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int dig_sum = 0;
    int m = n;
    while(m > 0){
        dig_sum += m % 10;
        m /= 10;
    }
    if(n % dig_sum == 0){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<ll int,ll int>
#define PI 2*acos(0)
#define INF 1e8
using namespace std;
const ll int p=1000000007;
const ll int mx=1000006;
vector<ll > prime;
bool mark[mx];
ll int mod(ll int a,ll int b)
{
    ll int m=a%b;
    if(m<0) m=(b<0)?(m-b):(m+b);
    return m;
}
ll maxpow(ll n)
{
    return (n & (~(n-1)));
}
bool isPrime(ll n)
{
    if(n<2) return false;
    if(n==2) return true;
    if(n%2==0) return false;
    for(ll i=3;i*i<=n;i+=2){
        if(n%i==0) return false;
    }
    return true;
}
void init()
{
    mark[1]=1;
    int i,j,limit=sqrt(mx*1.0)+2;
    prime.push_back(2);
    for(i=4;i<mx;i+=2) mark[i]=1;
    mark[2]=0;
    for(i=3;i<mx;i+=2){
        if(!mark[i]){
            prime.push_back(i);
            if(i<=limit){
                for(j=i*i;j<mx;j+=2*i){
                    mark[j]=1;
                }
            }
        }
    }
}
/*
ll maxdiv(ll n)
{
    ll i,ans=1;
    for(i=0;i<prime.size();i++){
        if(n%prime[i]==0){
            ans=n/prime[i];break;
            //return ans;
        }
    }
    return ans;
}*/
ll lcm(ll a,ll b)
{
    ll ans=a*b;
    return (ans/__gcd(a,b));
}
// ax+by and a>b
ll gcd(ll a,ll b,ll &x,ll &y)
{
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll d=gcd(b,mod(a,b),x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return d;
}
ll abso(ll a)
{
    if(a>=0) return a;
    return -a;
}
vector<ll>factors[mx];
ll cnt[mx];
//factor[x] stores the prime factors of x;
//cnt[x] will calculate how many inputs have a common factor
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    init();
    ll n,i,j,x;
    //for(i=0;i<prime.size();i++) cout<<prime[i]<<"\n";
    for(i=0;prime[i]<=1000000;i++){
        for(j=prime[i];j<=1000000;j+=prime[i]){
            factors[j].push_back(prime[i]);
        }
    }
    cin>>n;
    for(i=0;i<n;i++){
        cin>>x;
        for(j=0;j<factors[x].size();j++){
            cnt[factors[x][j]]++;
        }
    }
    ll ans=0;
    for(i=0;prime[i]<=1000000;i++){
        ans=max(ans,cnt[prime[i]]);
    }
    if(ans<=1){
        //ans will be 0 if all elements are 1;and 1 if at least one element has a prime factor
        cout<<"pairwise coprime";
        return 0;
    }
    else if(ans==n){
        // it means all the elements have an common element
        cout<<"not coprime";
        return 0;
    }
    else cout<<"setwise coprime";
    return 0;
}
//1028C


Measured memory_bytes: 82476
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

template <class T> inline bool chmin(T &a, const T &b) {
  return (a > b) ? a = b, true : false;
}

template <class T> inline bool chmax(T &a, const T &b) {
  return (a < b) ? a = b, true : false;
}

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  int N;
  std::cin >> N;
  std::vector<int> a(N + 1, -1);
  for (int i = 1; i <= N; ++i)
    std::cin >> a[i];

  std::vector<int> res(N + 1, -1);

  for (int i = N; i >= 1; --i) {

    int sum = 0;
    for (int k = 2; k <= N; ++k) {
      if (k * i > N)
        break;
      sum += res[k * i];
    }

    res[i] = (a[i] + sum) % 2;

  }

  // for (int i = 1; i <= N; ++i)
  //   std::cout << res[i] << std::endl;
  int M = 0;
  for (int i = 1; i <= N; ++i)
    if (res[i] == 1)
      M += 1;

  std::cout << M << std::endl;
  for (int i = 1; i <= N; ++i)
    if (res[i] == 1)
      std::cout << i << std::endl;


  return 0;
}


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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

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

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s = to_string(n);
    bool zero = true;
    rep (i, s.length()) {
        if (i == 0) {
            if (s[i] != '1') {
                zero = false;
                break;
            }
        } else if (s[i] != '0') {
            zero = false;
            break;
        }
    }
    int su = 0;
    if (not zero) {
        repall (c, s)
            su += c - '0';
    } else {
        su = 10;
    }
    print(su);

    return 0;
}


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

int main() {
  long int A, B, N;
  double LOG;
  scanf("%ld", &N);

  LOG = log10(N);

  long int sum = 0; 
  while (N != 0) { 
    if (LOG == (int)LOG){
      sum = 10;
      break;
    }
    sum += N % 10; 
    N = N/10; 
  } 

  printf("%ld\n", sum);
}


Measured memory_bytes: 512
x, y = map(int, input().split())
c = 0
if (x==1)and(y==1):
  c = 1000000
elif (1<=x<=3)and(1<=y<=3):
  c = (4-x)*100000+(4-y)*100000
elif 1<=x<=3:
  c = (4-x)*100000
elif 1<=y<=3:
  c = (4-y)*100000
print(c)
  

Measured memory_bytes: 3060
import sys
from operator import itemgetter

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

s = input()
ct = 0
for c in s:
    if c == 'o':
        ct += 1

if 8 - ct <= 15 - len(s):
    print("YES")
else:
    print("NO")


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

using namespace std;

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

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

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxn = 100000;

int n;
int a[maxn + 5];

map<int, int> pos;

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d", &n);
	REP(i, 0, n) scanf("%d", a + i);
	REP(i, 0, n) pos[a[i]] = i;
	sort(a, a + n);
	int cnt = 0;
	REP(i, 0, n) if ((pos[a[i]] ^ i) & 1) ++cnt;
	printf("%d\n", cnt >> 1);
	return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>  // std::unique
#include <cmath>
using namespace std;

using ll = long long;

// 素数判定
template <typename T>
bool IsPrimeNumber(T value) {

	for (int i = 2; i * i <= value; ++i) {
		if ((value % i) == 0) {
			return true;
		}
	}
	return false;
}

// 桁数判定
template <typename T>
T GetFigureLength(T value) {
	T figure = 1;
	while (value >= 10) {
		value /= 10;
		++figure;
	}
	return figure;
}

int main(void) {
	ll n;

	cin >> n;

	ll figureLength = 1000000000000;
	for (ll i = 1; i * i <= n; ++i) {
		if ((n%i) == 0) {
			ll a = GetFigureLength(i);
			ll b = GetFigureLength(n / i);

			figureLength = min(figureLength, max(a, b));
		}
	}
	auto output = figureLength;
	cout << output;
}


Measured memory_bytes: 256
sx,sy,tx,ty = map(int, input().split())

w = tx - sx
h = ty - sy

route = ''

route += 'R'*w + 'U'*h
route += 'L'*w + 'D'*h
route += 'D' + 'R'*(w+1) + 'U'*(h+1) + 'L'
route += 'U' + 'L'*(w+1) + 'D'*(h+1) + 'R'

print(route)

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

int main() {
  int n;
  cin >> n;
  int a[n];
  for(int i=0; i<n; i++) {
    cin >> a[i];
    a[i]/=10;
  }
  for(int k=0; k<2; k++) {
    int x=0;
    for(int i=0; i<n; i++) {
      if(x<i) {
        cout << "no" << endl;
        return 0;
      }
      x=max(x,i+a[i]);
    }
    reverse(a,a+n);
  }
  cout << "yes" << endl;
  return 0;
}


Measured memory_bytes: 4256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`

	4
	20 18 2 18

		`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	n := nextInt()
	a := nextInts(n)

	sort.Sort(sort.Reverse(sort.IntSlice(a)))

	ans := 0
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			ans += a[i]
		} else {
			ans -= a[i]
		}
	}

	fmt.Fprintln(out, ans)
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


Measured memory_bytes: 640
N = int(input())
a = list(map(int,input().split()))
ans = 0
for i in a:
    if i%2 == 0:
        c = 0
        for l in range(30):
            i /= 2
            c += 1
            if i%2 != 0:
                ans += c
                break
print(ans)

Measured memory_bytes: 4148