akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

struct UnionFind {
	vector<int> parent;
	int size;
	UnionFind(int n) :parent(n, -1), size(n) {}
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x == y)return false;
		if (size_of(x) < size_of(y))swap(x, y);
		parent[x] += parent[y]; parent[y] = x; size--;
		return true;
	}
	bool same(int x, int y) { return root(x) == root(y); }
	int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
	int size_of(int x) { return -parent[root(x)]; }
};


signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<int>x(N), y(N); rep(i, 0, N) { cin >> x[i] >> y[i]; }

	auto f = [&](int p, int q) {
		UnionFind uf(N);
		map<pii, int>mp;
		rep(i, 0, N) {
			mp[pii(x[i], y[i])] = i;
		}
		rep(i, 0, N) {
			int xx = x[i] + p;
			int yy = y[i] + q;
			if (mp.count(pii(xx, yy))) {
				int j = mp[pii(xx, yy)];
				uf.unite(i, j);
			}
		}
		return uf.size;
	};

	int ans = N;
	rep(i, 0, N) {
		rep(j, 0, N) {
			int p = x[i] - x[j];
			int q = y[i] - y[j];
			if (p == 0 and q == 0)continue;
			chmin(ans, f(p, q));
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: int, B: int, C: int, K: int):
    k = 0
    while A >= B:
        k += 1
        B *= 2
    while B >= C:
        k += 1
        C *= 2
    return YES if k <= K else NO

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    print(solve(A, B, C, K))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


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

using namespace std;

#undef LOCAL
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool x) { return (x ? "T" : "F"); }
string to_string(const char* s) { return to_string((string)s); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename V>
string to_string(V v) {
    bool f = true; string res = "[";
    for (const auto& x: v) {
        if (!f) res += ", ";
        f = false;
        res += to_string(x); } res += "]";
    return res;
}
void debug() { cerr << endl; }
template <typename H, typename... T>
void debug(H h, T... t) { cerr << " " << to_string(h); debug(t...); }
#ifdef LOCAL
#define dbg(args...) cerr<<"("<<#args<<") =", debug(args)
#else
#define dbg(args...) 2019
#endif

void solve() {
    int n, s,t;
    cin >> n >> s >> t;
    s--;t--;
    vector<vector<int>> g(n);
    for (int _ = 1; _ < n; _++) {
        int x,y;
        cin >> x >> y;
        x--;y--;
        g[x].emplace_back(y);
        g[y].emplace_back(x);
    }
    vector<int> path;
    function<bool(int,int)> get_path = [&](int u,int p){
        path.push_back(u);
        if (u == s) return true;
        for (int v: g[u])if(v!=p){
            if (get_path(v,u)) return true;
        }
        path.pop_back();
        return false;
    };
    get_path(t, -1);
dbg(path);
    int m = path.size();
    int res = (m-1)/2;
    vector<bool> trk(n);
    
    int len = (m+1)/2;
    int root = path[len];
    for (int i = 0; i < len; i++) {
        trk[path[i]] = true;
    }
    function<bool(int,int)> dfs = [&](int u,int depth){
        trk[u] = true;
        int cnt = 0;
        bool has_leaf = false;
        for (int v:g[u])if(!trk[v]){
            cnt++;
            has_leaf |= dfs(v,depth+1);
        }
        if (cnt==0) return true;
        else {
            if (has_leaf) {
                res = max(res, len + depth);
            }
            return false;
        }
    };
    dfs(root, 0);
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 12800
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    H, W, N = map(int, sys.stdin.readline().split())
    nb = [0] * 10
    bm = dict()
    bb = set()

    for lp in range(N):
        a, b = map(int, sys.stdin.readline().split())
        a, b = a-1, b-1
        res = search(H, W, bm, bb, a, b)

        if 1 <= a <= H-2 and 1 <= b <= W-2:
            bm[a,b] = 1 + res
        
        bb.add((a,b))

    # debug(bm, locals())
    for i in bm.values():
        nb[i] += 1

    nb[0] = (H-2)*(W-2) - sum(nb)

    print(*nb, sep='\n')

def search(H, W, bm, bb, a, b):
    res = 0
    dx = (1, 0, -1, 0, 1, 1, -1, -1)
    dy = (0, 1, 0, -1, 1, -1, 1, -1)

    for j in range(8):
        if (a + dx[j], b + dy[j]) in bb:
            res += 1

        if a + dx[j] < 1 or a + dx[j] > H - 2:
            continue
        if b + dy[j] < 1 or b + dy[j] > W - 2:
            continue

        if (a + dx[j], b + dy[j]) not in bm:
            bm[a + dx[j], b + dy[j]] = 0

        bm[a + dx[j], b + dy[j]] += 1

    return res

if __name__ == '__main__':
    solve()

Measured memory_bytes: 179656
//from PKU1125
main(){
    int i,n,k,a,b,A,B,dist[101][101];
    scanf("%d%d",&n,&k);
        /*initialize*/
        memset(dist,11,sizeof(dist));
        for(i=1;i<=n;i++)dist[i][i]=0;
        for(;k;k--){
            scanf("%d,%d,%d,%d",&a,&b,&A,&B);
            dist[a][b]=A,dist[b][a]=B;
        }
 
        {/*warshall-floyd*/
            int k,i,j;
            for(k=1;k<=n;k++)
                for(i=1;i<=n;i++)
                    for(j=1;j<=n;j++)
                        if(dist[i][j]>dist[i][k]+dist[k][j])
                            dist[i][j]=dist[i][k]+dist[k][j];
        }
 
        {/*query*/
            scanf("%d,%d,%d,%d",&a,&b,&A,&B);
            printf("%d\n",A-B-dist[a][b]-dist[b][a]);
        }
    exit(0);
}              

Measured memory_bytes: 644
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int a, b, ans = 0;
	cin >> a >> b;
	ans += max(a, b);
	if(a > b){
		a--;
	} else {
		b--;
	}
	ans += max(a, b);
	cout << ans << endl;

	return 0;
}

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

using namespace std;

int n;
int a[200005];
int mx, mi, mx2;

int main()
{
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
        if(a[i] >= mx) mx = a[i], mi = i;
    }
    for(int i = 0; i < n; i++)
    {
        if(a[i] >= mx2 && i != mi) mx2 = a[i];
    }
    for(int i = 0; i < n; i++)
    {
        if(i == mi) printf("%d\n", mx2);
        else printf("%d\n", mx);
    }
    return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;
const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
int n;

int main(){
       cin >> n;
       if(n == 25){
              cout << "Christmas\n"; 
       } 
       else if(n == 23){
              cout << "Christmas Eve Eve\n";
       }
       else if(n == 24){
              cout << "Christmas Eve\n";
       }
       else if(n == 22){
              cout << "Christmas Eve Eve Eve\n";
       }
}

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

int main(){
  string s;cin >>s;
  int ans = 0;
  int stack = 0;
  for(int i=0; i<s.size(); i++){
    if(s.at(i)=='S'){
      stack++;
    }else{
      if(stack==0){
        ans++;
      }else{
        stack--;
      }
    }
  }
  cout << ans*2 <<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  vector<vector<long>> data(S.size() + 1, vector<long> (13));
  long sub;
  data.at(0).at(0) = 1;
  for(int i = 0; i < S.size(); i++){
    if(S.at(i) != '?'){
      sub = S.at(i) - '0';
      for(int j = 0; j < 13; j++){
        data.at(i + 1).at((j * 10 + sub) % 13) += data.at(i).at(j); 
      }
    } else {
      for(int j = 0; j < 13; j++){
        for(int k = 0; k < 10; k++){
          data.at(i + 1).at((j * 10 + k) % 13) += data.at(i).at(j);
        }
      }
    }
    for(int j = 0; j < 13; j++){
        data.at(i + 1).at(j) %= 1000000007;
      }
  }
  cout << data.at(S.size()).at(5) << endl;
  return 0;
}

Measured memory_bytes: 13696
#include <iostream>
#include <string>
#include <algorithm>

const int MAX = 25 + 5;
const int NIL = -1;

struct Node {
	int parent = NIL;
	int left = NIL;
	int right = NIL;
};

Node T[MAX];
int H[MAX];
int D[MAX];

int sibling(int nd) {
	if (T[nd].parent != NIL) {
		if (T[T[nd].parent].left != nd) return T[T[nd].parent].left;
		else return T[T[nd].parent].right;
	}
	return -1;
}

void set_depth(int nd, int d) {
	D[nd] = d;
	if (T[nd].left != NIL) {
		set_depth(T[nd].left, d + 1);
	}
	if (T[nd].right != NIL) {
		set_depth(T[nd].right, d + 1);
	}
}

int height(int nd) {
	int l = -1, r = -1;
	if (T[nd].left != NIL) {
		l = height(T[nd].left);
	}
	if (T[nd].right != NIL) {
		r = height(T[nd].right);
	}
	return H[nd] = std::max(l, r) + 1;
}

int deg(int nd) {
	int d = 0;
	if (T[nd].left != NIL) ++d;
	if (T[nd].right != NIL) ++d;
	return d;
}

std::string node_type(int nd) {
	if (T[nd].parent == NIL) return "root";
	else if (T[nd].left == NIL && T[nd].right == NIL) return "leaf";
	else return "internal node";
}

void print(int nd) {
	std::cout << "node " << nd << ": parent = " << T[nd].parent << ", sibling = "
		<< sibling(nd) << ", degree = " << deg(nd) << ", depth = " << D[nd]
		<< ", height = " << H[nd] << ", " << node_type(nd) << std::endl;
}

int main()
{
	int n;
	std::cin >> n;
	for (int i = 0; i != n; ++i) {
		int id, l, r;
		std::cin >> id >> l >> r;
		T[id].left = l;
		T[id].right = r;
		if (l != NIL) T[l].parent = id;
		if (r != NIL) T[r].parent = id;
	}

	int r = 0;
	for (int i = 0; i != n; ++i) {
		if (T[i].parent == NIL) r = i;
	}

	set_depth(r, 0);
	height(r);

	for (int i = 0; i != n; ++i) {
		print(i);
	}

	return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> V;
const long long MOD=1000000007LL;
const long long INFL=1LL << 60;
const int INF=1<<29;


int main() {
    int N,K;
    string S;
    cin >>N>>K;
    cin >>S;
    if(S[K-1]=='A')S[K-1]='a';
    if(S[K-1]=='B')S[K-1]='b';
    if(S[K-1]=='C')S[K-1]='c';
    cout <<S<<endl;
    return 0;
}

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll X; cin >> X;
  if (X <= 3) {
    cout << 1 << endl;
    return 0;
  }else {
    ll ans = 0;
    for (ll b = 2; b <= X; b++) {
      ll y = b * b;
      for ( ; y <= X; y *= b) {
	ans = max(ans, y);
      }
    }
    cout << ans << endl;
    return 0;
  }

  return 0;
}



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

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

    map<string, int> s_map;
    string temp;

    for (int i=0; i<N; i++){
        cin >> temp;
        s_map[temp]++;
    }

    int max_num = 0;
    for (auto p: s_map){
        if (max_num < p.second){
            max_num = p.second;
        }
    }

//    sort(s_map.begin(), s_map.end());

    for (auto p: s_map){
        if (max_num == p.second){
            cout << p.first << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 25216
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i+=2){
        cout << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
    using namespace std;
    typedef long long LL;
     
    int main (){
        string s;
        cin >> s;
        int count=1;
        char t=s[0];
        for(int i=1;i<s.length();i++){
            if(t==s[i]) count++;
            else{
                count=1;
                t=s[i];
            }
            if(count==3){
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
        return 0;
    }

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

int dim[20];
ll f[20][12];
int dfs(int x, int st, int op)  // op=1 =;op=0 <
{
  if (!x) return 1;
  if (!op && ~f[x][st]) return f[x][st];
  int maxx = op ? dim[x] : 9, ret = 0;
  for (int i = 0; i <= maxx; i++) {
    if (st!=11 && abs(st - i) >= 2) continue;
    if (st == 11 && i == 0)
      ret += dfs(x - 1, 11, op && (i == maxx));
    else
      ret += dfs(x - 1, i, op && (i == maxx));
  }
  if (!op) f[x][st] = ret;
  return ret;
}
void solve(ll K)
{
    ll l = 0,r = 1e18;
    while(l<r)
    {
        ll mid = (l+r)/2;
        ll tmp = mid;
        dim[0] = 0;
        while(tmp)
        {
            dim[++dim[0]] = tmp % 10;
            tmp /= 10;
        }
        memset(f, -1, sizeof f);
        ll ret = dfs(dim[0],11,1)-1;
        //cout<<mid<<" "<<ret<<endl;
        if(ret >= K)
        {
            r = mid;
        }else
        {
            l = mid+1;
        }
    }
    cout<<r<<endl;
}


int main()
{
    ll K;
    cin >> K;
    solve(K);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ull unsigned long long
#define mp make_pair
#define F first
#define S second
#define mod 1000000007


ll dp[100005];

int main()
{
    ll n,W;

    cin >> n >> W;

    ll wi,vi;
    for(int i=0;i<n;i++)
    {
        cin >>  wi >> vi;
        for(ll w_cur = W-wi; w_cur >= 0; w_cur--)
        {
            dp[w_cur + wi] = max(dp[w_cur + wi], dp[w_cur] + vi);
        }
    }

    ll ans = 0;
    for(auto l: dp)
        ans = max(ans, l);
    
    cout << ans << endl;

}


Measured memory_bytes: 1024
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, parser) => {
        $next
    };

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        n: usize,
        k: usize,
    }

    let m = n % k;
    let m2 = (m as i64 - k as i64).abs() as usize;

    if m < m2 {
        println!("{}", m);
    } else {
        println!("{}", m2);
    }
}


Measured memory_bytes: 4352
// ConsoleApplication1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
#define show(ans) cout << ans << endl
const long MOD = 1000000007;

int main() {
	string s;
	cin >> s;
	long ans = 1e5;
	//rep(i, s.length-2) {
	//	long num = stoll(s.substr(i, 3));
	//	ans = min(ans, num);
	//}
	long tmp = s.length() -2;
	for (long i = 0; i < tmp; i++) {
		long num = stoll(s.substr(i, 3));
		ans = min(ans, abs(num - 753));
	}

	show(ans);

	return 0;

}
// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[N];
    rep(i, N) cin >> a[i];

    int Alice = 0;
    int Bob = 0;
    sort(a, a+N, greater<int> ());
    rep(i, N) {
        if (i % 2 == 0) Alice += a[i];
        else Bob += a[i];
    }
    cout << Alice - Bob << endl;

    return 0;
}


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

using namespace std;

#define ll long long
#define pi pair<int, int>
#define mkp make_pair
#define pb push_back
#define fr first
#define sc second
#define endl '\n'

const int mxn = 1e6 + 5;
const ll MOD =  1e9 + 7;
int arr[mxn];
vector<int> graph[mxn];
int n, m, k;
ll l, r;
string s;

ll POW(ll A,ll B,ll R=1)
{while(B){if(B&1)R=R*A%MOD;A=A*A%MOD;B>>=1;}return R;}

void read(){
    cin >> n;
    for(int i = 0, u, v; i < n; i++){
        cin >> arr[i];
    }
}


void solve(){
    ll ans = 0;
    map<int, int> mp;
    for(int i = 0; i < n; i++){
        ans += mp[i - arr[i]];
        mp[i + arr[i]]++;
    }
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    //cin >> T;
    while(T--) read(), solve();
    return 0;
}


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

static const int MAX=100;
static const long long INFTY=(1LL<<32);

int n;
long long d[MAX][MAX];

void floyd()
{
    //????????????
    for(int k=0;k<n;k++)
    {
        for(int i=0;i<n;i++)
        {
            if(d[i][k]==INFTY) continue;
            for(int j=0;j<n;j++)
            {
                if(d[k][j]==INFTY) continue;
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
}

int main()
{
    int e;
    cin>>n>>e;
    //init
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
            d[i][j]=((i==j)?0:INFTY);
    }
    int s,t,dt;
    for(int i=0;i<e;i++)
    {
        cin>>s>>t>>dt;
        d[s][t]=dt;
    }
    //begin
    floyd();
    //print
    //check the negative cycle
    bool negative=false;
    for(int i=0;i<n;i++) if(d[i][i]<0) {negative=true;break;}
    if(negative) cout<<"NEGATIVE CYCLE"<<endl;
    else
    {
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                if(j) cout<<' ';
                if(d[i][j]==INFTY) cout<<"INF";
                else cout<<d[i][j];
            }
            cout<<endl;
        }
    }
    return 0;

}

Measured memory_bytes: 3144
O = list(input())
E = list(input())

answer = []
for o, e in zip(O.copy(), E.copy()):
  answer.append(o)
  answer.append(e)
  O.pop(0)
  E.pop(0)

if len(O) == 0 and len(E) == 0:
  print(''.join(answer))
else: 
  answer.append(O[0])
  print(''.join(answer))


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

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--)

template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') ch = getchar(), f = -1;
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

template <typename Tp> void out(Tp x) {
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
	return;
}

template <typename Tp> Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;}
template <typename Tp> Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;}
template <typename Tp> bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);}

const int MAXN = 200010;

struct Obj {
	int L, R;
} num[MAXN];

int n, m;
int maxx[MAXN << 2], tag[MAXN << 2];

bool cmp(const Obj &x, const Obj &y) {return x.L < y.L || x.L == y.L && x.R > y.R;}

void build(int now, int l, int r)
{
	if (l == r) {
		maxx[now] = -(m - (l - 1) + 1);
		return;
	}
	int mid = (l + r) >> 1;
	build(now << 1, l, mid); build(now << 1 | 1, mid + 1, r);
	maxx[now] = Max(maxx[now << 1], maxx[now << 1 | 1]);
}

void pushdown(int now)
{
	if (!tag[now]) return;
	maxx[now << 1] += tag[now]; tag[now << 1] += tag[now];
	maxx[now << 1 | 1] += tag[now]; tag[now << 1 | 1] += tag[now];
	tag[now] = 0;
}

void modify(int now, int l, int r, int x, int y, int z)
{
	if (x <= l && r <= y) {
		maxx[now] += z; tag[now] += z; return;
	}
	pushdown(now);
	int mid = (l + r) >> 1;
	if (x <= mid) modify(now << 1, l, mid, x, y, z);
	if (mid < y) modify(now << 1 | 1, mid + 1, r, x, y, z);
	maxx[now] = Max(maxx[now << 1], maxx[now << 1 | 1]);
}

int query(int now, int l, int r, int x, int y)
{
	if (x <= l && r <= y) return maxx[now];
	pushdown(now);
	int mid = (l + r) >> 1;
	if (y <= mid) return query(now << 1, l, mid, x, y);
	if (mid < x) return query(now << 1 | 1, mid + 1, r, x, y);
	return Max(query(now << 1, l, mid, x, y), query(now << 1 | 1, mid + 1, r, x, y));
}

using std::vector;

vector<int>V[MAXN];

int main()
{
	in(n); in(m);
	FOR(i, 1, n) {
		in(num[i].L), in(num[i].R);
		V[num[i].L].push_back(num[i].R);
	}

	build(1, 1, m + 2);

	int he = n - m;
	
	FOR(i, 0, m) {
		for (int j = 0; j < V[i].size(); j++) {
			modify(1, 1, m + 2, 1, V[i][j] + 1, 1);
		}
		chkmax(he, query(1, 1, m + 2, i + 2, m + 2) - i);
	}

	assert(he >= 0);
	printf("%d\n", he);
	
	return 0;
}


Measured memory_bytes: 16384
#include <iostream>
#include <map>
#define ll long long
using namespace std;

int main()
{
    int n, m, x, y;
    cin >> n >> m;
    int counter=0;
    int h[n],a[n];
    for(int i=1; i<=n; i++){
        cin >> h[i];
        a[i]=1;
    }
    for(int i=1 ;i<=m; i++){
        cin >> x;
        cin >> y;
        if(h[x]<=h[y]){
            a[x]=0;
        }
        if(h[y]<=h[x]){
            a[y]=0;
        }

    }
    for(int i=1; i<=n; i++){
        if(a[i]==1){
            counter++;
        }
    }
    cout << counter;
    return 0;
}


Measured memory_bytes: 4376
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


ll mp[Max];


void primefact(ll n)
{

    ll cnt=0;

    while(n%2==0)
    {
        n/=2;
        cnt++;
    }

    mp[2]=max(mp[2],cnt);

    cnt=0;


    for(ll i=3; i<=sqrt(n); i+=2)
    {
        cnt=0;

            while(n%i==0)
            {
                n/=i;

                cnt++;
            }

            mp[i]=max(mp[i],cnt);

    }

    if(n>2)
        mp[n]=max(mp[n],1ll);
}
ll power(ll x, ll y)
{
    if (y == 0)
        return 1;
    else if (y%2 == 0)
        return power(x, y/2)*power(x, y/2);
    else
        return x*power(x, y/2)*power(x, y/2);
}
int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0,dasdasdads;

      bool flag=false;

      string str;


        cin>>n;

        ll ara[n+2];

        input(ara,n);

        sum=accumulate(ara,ara+n,0);


        cout<<sum-n<<endl;













}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
const int MAXN = (1 << 20);
const int64_t mod = (int64_t)1e9 + 7;
const int64_t inf = (int64_t)1e16 + 42;

struct matrix
{
	int n;
	vector<vector<int64_t> > t;

	matrix(int _n, int64_t val) {n = _n; t.assign(n, vector<int64_t>(n, val)); }
	matrix(int _n) {n = _n; t.assign(n, vector<int64_t>(n, 0)); }

	int size() { return n; }

	matrix operator * (matrix b)
	{
		matrix c = matrix(n, 0);
		for(int i = 0; i < n; i++)
			for(int k = 0; k < n; k++)
				for(int j = 0; j < n; j++)
					c.t[i][j] = (c.t[i][j] + t[i][k] * b.t[k][j]) % mod;
		return c;
	}

	matrix operator ^ (matrix b)
	{
		matrix c = matrix(n, inf);
		for(int i = 0; i < n; i++)
			for(int k = 0; k < n; k++)
				for(int j = 0; j < n; j++)
					c.t[i][j] = min(c.t[i][j], t[i][k] + b.t[k][j]);
		return c;
	}
};

vector<int64_t> mult(matrix a, vector<int64_t> b)
{
    vector<int64_t> c(b.size(), 0);
    for(int i = 0; i < a.size(); i++)
        for(int j = 0; j < a.size(); j++)
            c[i] = (c[i] + a.t[i][j] * b[j]) % mod;
    return c;
}

matrix pow_min(matrix base, int p)
{
	if(p == 1) return base;

	if(p % 2 == 0)
	{
		matrix d = pow_min(base, p / 2);
		return d ^ d;
	}

	return base ^ pow_min(base, p - 1);
}

matrix pow(matrix base, int p)
{
	if(p == 1) return base;

	if(p % 2 == 0)
	{
		matrix d = pow(base, p / 2);
		return d * d;
	}

	return base * pow(base, p - 1);
}

void print(matrix mat)
{
	for(int i = 0; i < mat.n; i++)
		for(int j = 0; j < mat.n; j++)
			if(mat.t[i][j] < inf) cout << mat.t[i][j] << " \n"[j == mat.n - 1];
			else cout << "inf" << " \n"[j == mat.n - 1];

	cout << endl;
}

int n, m;
int x[MAXN];

void read()
{
    cin >> n >> m;
    for(int i = 1; i <= m; i++)
        cin >> x[i];
    x[0] = 0;
    x[m + 1] = n;
}

void solve()
{
    matrix base = matrix(3, 0);

    base.t[0][0] = 1;
    base.t[0][1] = 1;
    base.t[1][0] = 1;
    base.t[1][1] = 2;
    base.t[1][2] = 2;
    base.t[2][0] = 1;
    base.t[2][1] = 1;
    base.t[2][2] = 1;

    vector<int64_t> res(3, 0);
    res[0] = 0;
    res[1] = 1;
    res[2] = 1;

    for(int i = 1; i <= m; i++)
    {
        if(x[i] - x[i - 1] - 1 > 0) res = mult(pow(base, x[i] - x[i - 1] - 1), res);
        int64_t dp = res[0], sum = res[2], val = res[1];
        res[0] = (dp + val) % mod;
        res[1] = (2 * sum + val) % mod;
        res[2] = (sum) % mod;
    }

    res = mult(pow(base, x[m + 1] - x[m]), res);
    cout << res[0] << endl;
}

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

	read();
	solve();
	return 0;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
S = input()
space_cnt = 3
for i in range(2 ** space_cnt):
    ops = ["-"] * space_cnt
    for j in range(space_cnt):
        if (i >> j) & 1:
            ops[j] = "+"
    formula = ""
    for j in range(space_cnt):
        formula += S[j]+ops[j]
    formula += S[-1]
    if eval(formula)==7:
        break
print(formula+"=7")


Measured memory_bytes: 9056
using namespace std;
#include <iostream>
#include <string>
#include <set>
#include <functional>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
bool is_pr[10000001];
bool ans[10000001]={};
int mans[10000001]={};
int d[]={0,-2,-6,-8};
int main()
{
	fill(is_pr,is_pr+10000001,true);
	for(int i=2;i<=4000;i++){
		if(is_pr[i])for(int j=2;j*i<=10000000;j++)is_pr[i*j]=false;
	}
	for(int i=13;i<=10000000;i++){
		bool tmp=true;
		for(int j=0;j<4;j++)tmp&=is_pr[i+d[j]];
		ans[i]=tmp;
	}
	for(int i=13;i<=10000000;i++){
		if(ans[i])mans[i]=i;
		else mans[i]=mans[i-1];
	}
	int num;
	while(cin>>num&&num){
		cout<<mans[num]<<endl;
	}
    return 0;
}

Measured memory_bytes: 59752
import Data.Char
f [a,b,c,d] n
 |a+b+c+d==n = show a++"+"++show b++"+"++show c++"+"++show d++"="++show n
 |a+b+c-d==n = show a++"+"++show b++"+"++show c++"-"++show d++"="++show n
 |a+b-c+d==n = show a++"+"++show b++"-"++show c++"+"++show d++"="++show n
 |a-b+c+d==n = show a++"-"++show b++"+"++show c++"+"++show d++"="++show n
 |a+b-c-d==n = show a++"+"++show b++"-"++show c++"-"++show d++"="++show n
 |a-b+c-d==n = show a++"-"++show b++"+"++show c++"-"++show d++"="++show n
 |a-b-c+d==n = show a++"-"++show b++"-"++show c++"+"++show d++"="++show n
 |otherwise = show a++"-"++show b++"-"++show c++"-"++show d++"="++show n
main=do
 s<-map digitToInt<$>getLine
 putStrLn$f s 7

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

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a.at(i);
	}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	int x = 0;
	int y = 0;
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			x += a.at(i);
		}
		else {
			y += a.at(i);
		}
	}
	cout << x - y << endl;
}

Measured memory_bytes: 3640
#二分探査
n=int(input())
C=list(input())
w=0
r=C.count('R')
ans=max(w,r)

for i in range(n):
  if C[i]=='W':
    w+=1
  if C[i]=='R':
    r-=1
  if ans>max(w,r):
    ans=max(w,r)
    
print(ans)


#以下のコードはO(n**2)なのでn<2*10**5では重すぎる
"""
n=int(input())
C=list(input()) #listにすると文字列が１文字ごとに１要素となる
cnt=0
flag1=False
flag2=True

for i in range(n):
  if C[i]=='W':
    for t in range(1,n-i):
      if C[-t]=='R':
        C[i]='R'
        C[-t]='W'
        cnt+=1
        flag2=False
        break
    if flag2:
      flag1=True
  if flag1:
    break

print(cnt)
"""

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

int main() {
  int n; 
  cin >> n;
  vector<int> a(n);
  vector<int> c(n);
  
  rep(i,n){
    cin >> a[i];
    a[i]--;
    c[a[i]]++;
  }
  
  ll kumi = 0;
  rep(i,n){
    ll x = c[i];
    kumi += x * (x - 1) / 2;
  }
  
  rep(k,n){
    cout << kumi - c[a[k]] + 1 << endl;
  }
} 



Measured memory_bytes: 4096
#include<stdio.h>
int main(void)
{
    char s[11];
    int i=0,j=0,x=0,y=0,tmp;
    scanf("%s",s);
    while(s[i]!='\0'){
        j=i; x=0;
        if((s[i]=='A')||(s[i]=='C')||(s[i]=='G')||(s[i]=='T'))
            while((s[j]=='A')||(s[j]=='C')||(s[j]=='G')||(s[j]=='T')){
                x++;
                j++;
            }
        if(y<x){
            tmp=x; x=y; y=tmp;
        }
        i++;
    }
    printf("%d\n",y);
    return 0;
}

Measured memory_bytes: 128
import math
A,B,H,M=map(int,input().split())

theta_hour=math.pi/6*H+math.pi/6*M/60
theta_minute=math.pi/30*M
x=A**2+B**2-2*A*B*math.cos(abs(theta_hour-theta_minute))

print(math.sqrt(x))



Measured memory_bytes: 9444
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 1000000007LL;
const int Maxn = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n,k;
	cin >> n >> k;
	cout << (k == 1 ? 0 : n-k) << '\n';
	return 0;
}
/*
1
5 1
20 21 22 23 24

1
4 2 
1 2 3 4

2 4 1 3

*/


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline 


n,k,*a = list(map(int,read().split()))
for i in range(n): a[i] -= 1


now = 0
cnt = 0
used = [-1]*n

while used[now] == -1:
    used[now] = cnt
    cnt += 1
    now = a[now]
    if cnt == k:
        print(now+1)
        exit()

c = cnt - used[now]
#print(used,cnt,c,now)

k -= used[now]
k %= c
print(used.index(k+used[now])+1)






Measured memory_bytes: 32572
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

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

    int A, B, K;
    cin >> A >> B >> K;
    FOR(i, A, B+1){
        if(i-A < K || B-i < K) cout << i << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  string s;
  cin >> s;
  if (s.length() == 3) {
    reverse(ALL(s));
  }

  cout << s << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[26];
long long int l,ans=1,p=0;
long long int n,k; 
int main()
{
    cin>>n>>k;
    while(n--)
    {
    	ans+=min(ans,k); 
	} 
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << (x) << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	int n;
	cin >> n;
	map<P, ll> mp;
	rep(i, n) {
		string s;
		cin >> s;
		int two = 0, five = 0;
		bool flag = false;
		int sz = s.size();
		rep(j, sz) {
			if (s[j] == '.') flag = true;
		}
		if (!flag) {
			int k = stoi(s);
			while (k % 2 == 0) {
				two++;
				k /= 2;
			}
			while (k % 5 == 0) {
				five++;
				k /= 5;
			}
		}
		else {
			string t = "";
			int check = 0;
			rep(j, sz) {
				if (s[j] == '.') check = 1;
				else {
					if (check) {
						two--;
						five--;
					}
					t += s[j];
				}
			}
			ll k = stoll(t);
			while (k % 2 == 0) {
				two++;
				k /= 2;
			}
			while (k % 5 == 0) {
				five++;
				k /= 5;
			}
		}
		mp[{two, five}]++;
	}
	ll ans = 0;
	for (int i = -10; i <= 30; i++) {
		for (int j = -10; j <= 30; j++) {
			for (int k = -10; k <= 30; k++) {
				for (int l = -10; l <= 30; l++) {
					if (i + k < 0 || j + l < 0) continue;
					if (i == k && j == l) ans += mp[{i, j}] * (mp[{i, j}] - 1);
					else ans += mp[{i, j}] * mp[{k, l}];
				}
			}
		}
	}
	cout << ans / 2 << '\n';
}

Measured memory_bytes: 3768
a,b,c=map(int,input().split())
d=list(input())
e=0
f=0
for i in range(len(d)):
    if d[i]=="a":
        if e<b+c:
            print("Yes")
            e+=1
        else:
            print("No")
    elif d[i]=="b":
        if e<b+c and f<c:
            print("Yes")
            e+=1
            f+=1
        else:
            print("No")
    else:
        print("No")

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

using namespace std;

//#define endl "\n"
#define rep(i,a,b) for(__typeof(b) i = a; i < b; ++i)


typedef long long ll;
typedef vector<ll> vl;


ll n;
vl rgb(3);

ll mem[3][30000000];

ll dp(ll at, ll sm)
{
	if(sm == n) return 1;
	if(at == 3) return 0;
    if(mem[at][sm] != -1) {return mem[at][sm];}
	ll ans = 0;
	rep(i,0,n/rgb[at]+1)
	{
        ans += dp(at+1, sm + i*rgb[at]);
	}
	return mem[at][sm] = ans;
}

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

	memset(mem, -1, sizeof(mem));

	cin >> rgb[0] >> rgb[1] >> rgb[2] >> n;
	cout << dp(0,0);

	return 0;
}


Measured memory_bytes: 703360
#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
#define NDEBUG
#endif
#include<bits/stdc++.h>
#define int long long
#define LL long long
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef pair<int,int>PII;typedef vector<int>VI;typedef vector<PII>VII;
template<typename T>void rd(T&x){int f=0,c;while(!isdigit(c=getchar()))f^=!(c^45);x=(c&15);while(isdigit(c=getchar()))x=x*10+(c&15);if(f)x=-x;}
template<typename T>void pt(T x,int c=-1){if(x<0)putchar('-'),x=-x;if(x>9)pt(x/10);putchar(x%10+48);if(c!=-1)putchar(c);}
const int N=200005;
int n,fa[N],st[N],top,ans[N];
struct data{
	int x,y,id;
	bool operator<(const data&k2)const{
		return x<k2.x;
	}
}a[N];
int fd(int k1){return fa[k1]==k1?k1:fa[k1]=fd(fa[k1]);}
signed main(){
	rd(n);
	rep(i,1,n){
		rd(a[i].x),rd(a[i].y),a[i].id=i;
		fa[i]=i;
	}
	sort(a+1,a+1+n);
	rep(i,1,n){
		int lst=0,fir=0;
		while(top&&a[i].y>a[st[top]].y){
			if(lst){
				fa[fd(a[lst].id)]=fd(a[st[top]].id);
			}else{
				fir=st[top];
			}
			lst=st[top--];
		}
		if(lst){
			fa[fd(a[i].id)]=fd(a[lst].id);
			st[++top]=fir;
		}
		if(!top||a[i].y<a[st[top]].y)st[++top]=i;
	}
	rep(i,1,n)++ans[fd(i)];
	rep(i,1,n)pt(ans[fd(i)],'\n');
	return 0;
}


Measured memory_bytes: 11448
import collections as col
n = int(input())
s = list(input())
passwd = set()
pre = col.Counter({'0':0,'1':0,'2':0,'3':0,'4':0,'5':0,'6':0,
                                '7':0,'8':0,'9':0})
post = col.Counter(s[1:])
for i in range(1,n-1):
    pre[s[i-1]] += 1
    post[s[i]] = max(0, post[s[i]]-1) 
    for c0 in pre:
        for c1 in post:
            if pre[c0] != 0 and post[c1] != 0:
                passwd.add(c0+s[i]+c1)
print(len(passwd))

Measured memory_bytes: 43120
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI=3.14159265358979323846;

int main() {
    int A, B, T;
    cin >> A >> B >> T;

    int lastT = T;
    int ans = 0;
    for (int i = 1; i < 100; i++) {
        lastT -= A;
        if (lastT < 0) {
            ans = (i - 1) * B;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

fn main() {
    input! {
        n:usize,x:usize,t:usize
    }
    println!("{}", t * ((n + x - 1) / x));
}


Measured memory_bytes: 2172
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	String[] input;
	int[] nums = new int[4];
	while (true) {
	    input = scan.nextLine().split(" ");
	    for (int i = 0; i < 4; i++) {
		nums[i] = Integer.parseInt(input[i]);
	    }
	    if (nums[0] == 0 && nums[1] == 0 && nums[2] == 0 && nums[3] == 0) {
		break;
	    }
	    solve(nums);
	}
    }
    
    public static void solve (int[] nums) {
	String[] operator = {"+", "-", "*"};
	int cal1, cal2, cal3, a, b, c, d;
	for (int i = 0; i < 4; i++) {
	    for (int j = 0; j < 4; j++) {
		for (int k = 0; k < 4; k++) {
		    for (int l = 0; l < 4; l++) {
			if (i == j || i == k || i == l || j == k || j == l || k == l) {
			    continue;
			}
			a = nums[i];
			b = nums[j];
			c = nums[k];
			d = nums[l];
			for (int op1 = 0; op1 < 3; op1++) {
			    for (int op2 = 0; op2 < 3; op2++) {
				for (int op3 = 0; op3 < 3; op3++) {
				    cal1 = calc(calc(a, b, op1), calc(c, d, op3), op2);
				    cal2 = calc(calc(calc(a, b, op1), c, op2), d, op3);
				    cal3 = calc(calc(a, calc(b, c, op2), op1), d, op3);
				    if (cal1 == 10) {
					System.out.printf("((%d %s %d) %s (%d %s %d))\n",
							  a, operator[op1], b, operator[op2], c, operator[op3], d);
					return;
				    }
				    if (cal2 == 10) {
					System.out.printf("(((%d %s %d) %s %d) %s %d)\n",
							  a, operator[op1], b, operator[op2], c, operator[op3], d);
					return;
				    }
				    if (cal3 == 10) {
					System.out.printf("((%d %s (%d %s %d)) %s %d)\n",
							  a, operator[op1], b, operator[op2], c, operator[op3], d);
					return;
				    }
				}
			    }
			}
		    }
		}
	    }
	}
	System.out.println("0");
    }

    public static int calc (int a, int b, int op) {
	if (op == 0) {
	    return a + b;
	} else if (op == 1) {
	    return a - b;
	} else if (op == 2) {
	    return a * b;
	}
	return 0;
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll N,M;
string s;
vector<ll> g[200010];
ll cnt[200010][2];
bool vis[200010];

int main(){
  cin>>N>>M;
  cin>>s;
  rep(i,M){
    ll a,b;
    cin>>a>>b;
    a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  rep(i,N){
    for(ll nv : g[i])cnt[i][s[nv]-'A']++;
  }

  queue<int> que;
  rep(i,N){
    if(cnt[i][0]==0||cnt[i][1]==0){
      vis[i]=true;
      que.push(i);
    }
  }
  while(que.size()){
    int v=que.front(); que.pop();
    int c=s[v]-'A';
    for(int nv : g[v]){
      if(vis[nv])continue;
      cnt[nv][c]--;
      if(cnt[nv][c]==0){
        que.push(nv);
        vis[nv]=true;
      }
    }
  }

  rep(i,N){
    if(!vis[i]){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 15492
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i=0; i<N; i++) {
            a[i] = sc.nextInt();
        }

        int ans = solve(N, a);
        System.out.println(ans);
    }

    private static int solve(int N, int[] a) {
        int diff = 0;

        Arrays.sort(a);
        for (int i=0; i<N; i++) {
            diff += i%2 == 0 ? a[N - i - 1] : -a[N - i - 1];
        }

        return diff;
    }
}


Measured memory_bytes: 21844