akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cmath>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;


const int BIG_NUM = 1e8;
const ll INF = 1000000000000000000;

const int MAX_A = 1000000;

int main() {
	int n;
	cin >> n;
	
	set<int> s;
	for (int i = 1; i <= MAX_A; i++) {
		s.insert(i);
	}

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

	int cnt = 0;
	for (auto it = s.begin(); it != s.end(); it++) {
		if (m[*it] == 0) {
			continue;
		}

		for (int i = 2 * (*it); i <= MAX_A; i += *it) {
			s.erase(i);
		}

		if (m[*it] == 1) {
			cnt++;
		}

	}

	cout << cnt << endl;
	
}

Measured memory_bytes: 97336
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int i = 2;
        long ans = n;
        long sum;
        String a;
        String b;
        long p;

        while(i <= n-i){
            sum = 0;
            a = String.valueOf(i);
            b = String.valueOf(n-i);
            p = Long.valueOf(a+b);

            while(p > 0){
                sum = sum + (p%10);
                p = (p - (p % 10)) / 10;
            }

            if(sum <= ans){
                ans = sum;
            }
            i++;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 38368
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
    
if __FILE__ == $0
  while line = STDIN.gets
    tokens = line.chomp!.split.map!(&:to_i)
    w, h, x, y, r = tokens[0], tokens[1], tokens[2], tokens[3], tokens[4]

    if w * x > 0 && h * y > 0
      if w.abs >= x.abs + r && h.abs >= y.abs + r
        puts "Yes"
      else
        puts "No"
      end
    else
      puts "No"
    end
  end
end

Measured memory_bytes: 8668
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(s, i, n) for (i = s; i < n; i++)
using namespace std;

long long A[200002], B[200002], N, M, K;

int main()
{
    long long i, j;
    cin >> N >> M >> K;
    rep0(i, N) {cin >>j; A[i+1]=A[i]+j;}
    rep0(i, M) {cin >>j; B[i+1]=B[i]+j;}

    long long ans = 0,t=0;
    j = M;
    
    rep0(i,N+1){
        if(A[i]>K)break;
        while(A[i]+B[j]>K){
            --j;
        }
        ans=max(ans,j+i);
    }

    cout << ans << endl;
    return 0;
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
using tp = tuple<ll, ll, ll>;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

//グラフ関連
struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a * c, a * d, b * c, b * d}) << en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
int main(void){
   int n, i, m, e, j;
   scanf("%d", &n);
   while ( n ) {
   for ( i = 0; i < n; i++ ) {
      scanf("%d %d %d", &m, &e, &j);
      if ( m == 100 || e == 100 || j == 100 || ( m + e ) / 2 >= 90 || ( m + e + j ) / 3 >= 80) printf("A\n");
      else if ( ( m + e + j ) / 3 >= 70 ) printf("B\n");
      else if ( ( m + e + j ) / 3 >= 50 ) {
         if ( m >= 80 || e >= 80 ) printf("B\n");
         else printf("C\n");
      }else printf("C\n");
   }
   scanf("%d", &n);
   }
   return 0;
}

Measured memory_bytes: 1824
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main(){
    double a,b;
    cin>>a>>b;
    double h,m;
    cin>>h>>m;
    double kaku=6*m-(60*h+m)/2;
    if(kaku<0)kaku+=360;
    kaku=min(kaku,360-kaku);
    printf("%.10lf\n",sqrt(a*a+b*b-2*a*b*cos(kaku*3.141592652589/180.0))*1.00000000024);
    return 0;
}

Measured memory_bytes: 4228
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <string>
#include <numeric>

typedef long long ll;
using namespace std;

int main(){
	ll n,x,ans=0;
	cin >> n>>x;
	ll a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a+n);
	while(1){
		if(a[ans]<=x){
			if(ans==(n-1)){
				if(a[ans]==x){
					ans++;
					break;
				}
				else{
					break;
				}
			}
			else{
				x-=a[ans];
			    ans++;
			}
		}
		else{
			break;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	int n;
    cin>>n;
    
    double ans=ceil(n/1.08);
    
    if(floor(ans*1.08)==n) cout<<ans<<endl;
    else cout<<":("<<endl;
}

Measured memory_bytes: 3764
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;
typedef long long ll;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

char s[20]; int n;

int main() {
    scanf("%s",s+1); n=strlen(s+1);
    ll ans=0;
    for (re int i=0;i<1<<(n-1);++i) {
        ll now=s[1]-'0';
        for (re int j=2;j<=n;++j) {
            if (i&(1<<(j-2))) ans+=now,now=s[j]-'0';
            else now=now*10+s[j]-'0';
        }
        ans+=now;
    }
    printf("%lld\n",ans);
    return 0;
}
//qwq

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for(int i = 0; i < (n); ++i)
//#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINT(fm, ...) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout << "DEBUG PRINT ";std::printf(fm, __VA_ARGS__);}while(0)
#define DEBUG_VAL(a, b) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout <<"DEBUG VAL " << a << ":" << b << endl;}while(0)
#else
#define DEBUG_PRINT(...)do{}while(0);
#define DEBUG_VAL(a, b)do{}while(0);
#endif

using namespace std;
using namespace atcoder;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
    int n, m;
    cin >> n >> m;
    dsu d(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        d.merge(a, b);
    }
    
    cout << d.groups().size()-1 << endl;

}

Measured memory_bytes: 9012
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    REP(i,n)cin >> a[i];
    int answer = 0;
    REP(i,n){
        if(i%2==0 and a[i]%2==1){
            answer++;
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long int
#define MAXN 100001
#define ii pair<int,int>

using namespace std;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;

vii g[MAXN];
int vis[MAXN];
int color[MAXN];

void dfs(int u, int p){
    vis[u] = 1;
    int c = 1;
    for(int i = 0; i < g[u].size(); i++){
        if(g[u][i].s == p) continue;
        if(color[p] == c) c++;
        color[g[u][i].s] = c;
        c++;
        if(!vis[g[u][i].f]){
            dfs(g[u][i].f, g[u][i].s);
        }        
    }
}


int main(){
    memset(vis, 0 , sizeof vis);
    memset(color, 0, sizeof color);
    int k = 0;
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n-1;i ++){
        int l, r;
        scanf("%d %d", &l, &r);
        g[l].pb(mp(r,i));
        g[r].pb(mp(l,i));
        if(g[l].size() > k)
            k = g[l].size();
        if(g[r].size() > k){
            k = g[r].size();
        }

    }
    color[1] = 1;
    printf("%d\n", k);
    dfs(1, -1);
    for(int i = 0; i < n-1; i++){
        printf("%d\n",color[i]);
    }
    return 0;
}


Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin>>n;
    ll h[n],f[n];
    for(ll i=0;i<n;i++) cin>>h[i];
    for(int i=0;i<n;i++){
        if(i==0){
            f[0]=0;
            continue;
        }
        if(i==1){
            f[1]=abs(h[0]-h[1]);
        }
        f[i]=min(abs(h[i]-h[i-1])+f[i-1],abs(h[i]-h[i-2])+f[i-2]);
    }
    cout<<f[n-1];
}

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


int main(){
    int64_t a,b,k,ans1,ans2;
    cin >> a >> b >> k;
    if(a > k){
        ans1 = a - k;
        ans2 = b;
    }
    else if(k - a < b){
        ans1 = 0;
        ans2 = b - k + a;
    }
    else{
        ans1 = 0;
        ans2 = 0;
    }
    cout << ans1 << " " << ans2 << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
#include<string.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
int main() {
	char s[100],*p,key[2];
	int i;
	const char root[6][4] = { "AXY","XQZ","ZWB","WBY","YXQ","BYX" };
	
	while (fscanf(stdin, "%[^\n]*s", s)) {
		getchar();
		if (strcmp(s, "#") == 0)break;
		p = s;
		i = 0; *key = 'A';
		while(*p){
			*key = root[i][*p - '0' + 1];
			if (*key == 'Q') break;
			if (*key == 'A') i = 0;
			else if (*key == 'X') i = 1;
			else if (*key == 'Z') i = 2;
			else if (*key == 'W') i = 3;
			else if (*key == 'Y') i = 4;
			else if (*key == 'B') i = 5;
			p++;
		}
		if (*key == 'B') puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 524
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    if (N >= 3 && M >= 3) {
        cout << (N - 2) * (M - 2) << endl;
    } else if (N == 2 || M == 2) {
        cout << 0 << endl;
    } else if (N == 1 && M == 1) {
        cout << 1 << endl;
    } else {
        cout << max(N, M) - 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i=1;
	int x;
	
	while(1){
		
		scanf("%d\n",&x);
		
		if(x != 0){
			printf("Case %d: %d\n",i++,x);
		}else if(x == 0){
			break;
		}
		
		}
		return 0;
}

Measured memory_bytes: 604
import java.util.*;

class Main
{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int w = sc.nextInt();
        int sum = 0;
        int [] v = new int[n];
        long [] w1 = new long[n];
        for(int i = 0; i < n; i++)
        {
            w1[i] = sc.nextInt();
            v[i] = sc.nextInt();
            sum += v[i];
        }
        long [] dp = new long[sum + 1];
        for(int j = 0; j <= sum; j++)
            dp[j] = 100000000000000L;
        dp[0] = 0;
        for(int i = 0; i < n; i++)
        {
            for(int j = sum; j >= v[i]; j--)
                dp[j] = Math.min(dp[j - v[i]] + w1[i], dp[j]);
        }
        int ans = 0;
        for(int i = 1; i <= sum; i++)
        {
            if(dp[i] <= w)
                ans = i;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 24148
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <array>
#include <utility>
#include <valarray>

using namespace std;

using ll = long long;

// 二項係数（組み合わせ数）n!/(r!(n-r)!)を計算して返す（メモ化）
template <typename T> // 返り値とテーブルの型
class Binomial {
    std::vector<std::vector<T>> table;
public:
    Binomial(int max) : table(std::max(max - 3, 0)) // max:テーブルのサイズ
    {
        // n >= 4 && 2 <= r <= n / 2
        for (int n = 4; n <= max; ++n) table[n - 4].resize(n / 2 - 1, 0);
    }

    T operator () (int n, int r)
    {
        if (n < 0 || r < 0 || r > n){ // nかrが範囲外の場合
            return 0;
        }else if (r == 1 || r == n - 1){ // 再帰の終わり
            return n;
        }else if (r == 0 || r == n){
            return 1;
        }else{ // n >= 4 &&  2 <= r <= (n - 2)
            if (r > n / 2) r = n - r; // nCr == nCn-r
            // n >= 4 && 2 <= r <= n / 2
            if (n > table.size() + 3) return this->operator()(n - 1, r - 1) + this->operator()(n - 1, r);
            // 4 <= n <= max && 2 <= r <= n / 2
            auto& val = table[n - 4][r - 2];
            if (val == 0){ // 二項係数を再帰的に計算する
                val = this->operator()(n - 1, r - 1) + this->operator()(n - 1, r);
            }
            return val;
        }
    }
};

int main()
{
    int N, A, B;
    scanf("%d %d %d\n", &N, &A, &B);
    vector<ll> v; v.reserve(N);
    for (int i = 0; i < N; ++i){
        ll vi;
        scanf("%lld", &vi); getchar();
        v.emplace_back(vi);
    }
    sort(v.begin(), v.end(), greater<ll>());
    ll sum = 0;
    ll before = -1;
    ll num_elem = 1;
    for (int i = 0; i < A; ++i){
        sum += v[i];
        if (v[i] == before){
            ++num_elem;
        }else{
            before = v[i];
            num_elem = 1;
        }
    }
    printf("%lf\n", static_cast<double>(sum) / A);
    ll num_outer = 0;
    for (int i = A; i < N; ++i){
        if (v[i] == before){
            ++num_outer;
        }else{
            break;
        }
    }
    Binomial<ll> nCr(N);
    if (num_elem == A){
        ll result = 0;
        for (int select = A; select <= min(static_cast<ll>(B), A + num_outer); ++select){
            result += nCr(A + num_outer, select);
        }
        printf("%lld\n", result);
    }else{
        printf("%lld\n", nCr(num_elem + num_outer, num_elem));
    }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 26 17:29:23 2020

@author: divyarth
"""

import sys
import heapq
import math

#sys.setrecursionlimit(100000)
#input=sys.stdin.readline
#print=sys.stdout.write

from collections import deque
from collections import defaultdict
from collections import Counter

modH=int(10**9)+7
I=lambda : list(map(int,input().split(' ')))
def PRINT(lst,sep=' '): print(sep.join(map(str,lst)))


n=int(input())    
print('ACL'*n)


Measured memory_bytes: 65056
#include <iostream>
#include <string>//
#include <vector>//
#include <map>
#include <cstdlib>
#include <numeric>
#include <algorithm>//ソート等に使用
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <thread>///////////////////
#include <queue>//幅優先等のキュー
#include <stack>
#include <bitset>

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

#define MOD 1000000007
//#define MOD 998244353
//#define MAX 

using namespace std;

using ll = long long int;
using ld = long double;
using std::swap;

vector<int> v;
vector<long long int> vll;
//vector<vector<int>> vec(50, vector<int>(4, 0));
vector<vector<int>> vv;
vector<char> vc;
vector<string> vs;




int main() {
	string S;
	cin >> S;
	int cnt = 0;
	rep(i, 0, 2) {
		if (cnt == 0 && S.substr(i, 1) == "R")++cnt;
		else if (S.substr(i, 1) == "R" && S.substr(i - 1, 1) == "R")++cnt;
	}
	cout << cnt << '\n';
	return 0;
}

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

const int nax = 1e5 + 5;
vector<int> adj[nax];
int in_degree[nax], dist[nax];
bool vis[nax];

void dfs(int a){
    vis[a] = true;
    for(int x: adj[a]){
        dist[x] = max(dist[x], dist[a] + 1);
        --in_degree[x];
        if(in_degree[x]==0)
            dfs(x);
    }
}

int main(){
    int n, m, x, y;
    cin >> n >> m;
    while(m--){
        cin >> x >> y;
        adj[x].push_back(y);
        ++in_degree[y];
    }
    for(int i = 1; i <= n; i++){
        if(!vis[i] && in_degree[i]==0)
            dfs(i);
    }
    int answer = 0;
    for(int i = 1; i <= n; i++){
        answer = max(answer, dist[i]);
    }
    cout << answer;
}


Measured memory_bytes: 14504
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <numeric>
#include <algorithm>

using namespace std;

int main() {
  int N, K;
  std::cin >> N >> K;
  std::vector<int> p(N, 0);
  for (int i = 0; i < N; ++i) {
    std::cin >> p[i];
  }
  int sum_p = std::accumulate(p.begin(), p.begin() + K, 0);
  int max_sum_p = sum_p;
  for (int i = K; i < N; ++i) {
    sum_p += p[i] - p[i - K];
    if (max_sum_p < sum_p) {
      max_sum_p = sum_p;
    }
  }

  std::cout << std::fixed << std::setprecision(10) << (max_sum_p + K) / 2.0 << std::endl;

  return 0;
}


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

int main()
{
  char c;
  cin>>c;
  if(c>='A' && c<='Z')
    cout<<'A'<<endl;
  else if(c>='a' && c<='z')
    cout<<'a'<<endl;
  return 0;
}

Measured memory_bytes: 3608
N = int(input())
li = [ int(it) for it in input().split() ]

sign = 1
for it in li:
  if (it<0):
    sign*=-1
    
li=[ abs(it) for it in li ]
li.sort()
if (sign==1):
  print (sum(li))
else:
  print (sum(li[1:])-li[0])


Measured memory_bytes: 14284
N = int(input())
A = [0] + list(map(int,input().split())) + [0]
B = [abs(A[i] - A[i+1]) for i in range(N+1)]
S = sum(B)
for i in range(N):
    print(S - B[i] - B[i+1] + abs(A[i] - A[i+2]))

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

int main(){

int N;
  cin >> N;
  
  vector<int> vec(N);
  for (int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  int alice, bob;
  alice = 0;
  bob = 0;
  
  for(int i=0; i<N; i++){
    alice += vec.at(i);
    i++;
    if(i == N){
      break;
    }
     else{
       bob += vec.at(i);
     }
}
  cout << alice - bob << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void) {
    int a,b,c,k;
    scanf("%d %d %d %d",&a,&b,&c,&k);
    if(a>=k)
    printf("%d",k);
    int count=0;
    if(a<k) {
    if(b>=k-a)
    {
        printf("%d",a);
    }
    if(b<k-a) {
        printf("%d",a-(k-a-b));
    }
    
    }
    return 0;
}



Measured memory_bytes: 1732
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int L=1e5+10;
int N;
LL A[L];
vector<int> es[L];
bool ok=true;
LL f(int r,int p)
{
	int c=0;
	LL s=2*A[r];
	for(auto e:es[r]){
		if(e==p)continue;
		LL v=f(e,r);
		if(v>A[r]){
			ok=false;
		}
		s-=v;
		c++;
	}
	if(c==0){
		return A[r];
	}
	if(s<0||s>A[r]){
		ok=false;
	}
	return s;
}
int main() {
	cin >> N;
	for(int i=1;i<=N;i++){
		cin >> A[i];
	}
	for(int i=1;i<N;i++){
		int a,b;
		cin >> a >> b;
		es[a].push_back(b);
		es[b].push_back(a);
	}
	int r=0;
	for(int i=1;i<=N;i++){
		if(es[i].size()==1){
			r=i;
			break;
		}

	}
	LL v=f(es[r][0],r);

	if(v==A[r]&&ok){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}

	return 0;
}



Measured memory_bytes: 14336
import java.util.*;

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

	public Main() {
		new AOJ0009().doIt();
	}
	
	class AOJ0009{
		void doIt(){
			boolean[] prime = new boolean[999999+1];
			int n = prime.length;
			Arrays.fill(prime, true);prime[0] = false;prime[1] = false;
			for(int i=2;i<n;i++)if(prime[i])for(int s=i+i;s<n;s+=i)prime[s]=false;
			while(in.hasNext()){
				int cnt = 0;
				int t = in.nextInt();
				for(int i=0;i<=t;i++)if(prime[i])cnt++;
				System.out.println(cnt);
			}
		}
	}
	
}

Measured memory_bytes: 22880
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
int main(){
    int H,W;
    string a[100];
    cin >> H >> W;
    REP(i,H) cin >> a[i];
    REP(i,W+2) cout << '#';
    cout << endl;
    REP(i,H) cout << '#' << a[i] << '#' << endl;
    REP(i,W+2) cout << '#';
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
//            while (true)
                solve(in);
        }
    }

    private static void solve(Scanner in) {
        int n = in.nextInt();
        int[] R = new int[n];
        for (int i = 0; i < n; i++) {
            R[i] = in.nextInt();
        }
        int min = Integer.MAX_VALUE;
        int diff = Integer.MIN_VALUE;
        for (int i = 0; i < n; i++) {
            if (diff < R[i] - min) {
                diff = R[i] - min;
            }
            if (min > R[i]) {
                min = R[i];
            }
        }
        System.out.println(diff);
    }
}

Measured memory_bytes: 100636
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int a, b, c, d, p;
  cin >> a >> b >> c >> d >> p;
  int ans1 = a * p;
  int ans2 = b + max(0, p - c) * d;
  cout << min(ans1, ans2) << endl;
  return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    ll n,k;cin>>n>>k;
    vl x(n),y(n),xarray,yarray;
    rep(i,n){
        cin>>x[i]>>y[i];
        xarray.push_back(x[i]);
        yarray.push_back(y[i]);
    }
    sort(xarray.begin(),xarray.end());
    sort(yarray.begin(),yarray.end());
    ll ans=(xarray[n-1]-xarray[0])*(yarray[n-1]-yarray[0]);
    //cout<<ans<<endl;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            rep(K,n){
                for(int l=K+1;l<n;l++){
                    ll cnt=0;
                    ll lx=xarray[i],rx=xarray[j];
                    ll by=yarray[K],uy=yarray[l];
                    rep(t,n){
                        if(lx<=x[t]&&x[t]<=rx&&by<=y[t]&&y[t]<=uy) cnt++;
                    }
                    //cout<<i<<" "<<j<<" "<<cnt<<" "<<(rx-lx)*(uy-by)<<endl;
                    if(cnt>=k) ans=min(ans,(rx-lx)*(uy-by));
                    //cout<<ans<<endl;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int k;
    cin >> k;
    int a,b;
    cin >> a >> b;
    
    for(int i = a;i<= b;i++){
        if(i % k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    
    cout << "NG" << endl;
}


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

using namespace std;


#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 2e6 + 1, MOD = 1e9 + 7, mod = 998244353, INF = 3e17;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;


signed main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);
   int n;
   cin >> n;
   vi a(n + 1);
   for (int i = 0; i < n; i++) {
      cin >> a[i];
   }
   int kol = 0;
   a[n] = -1;
   for (int i = 1; i < n; i++) {
      if (a[i] == a[i - 1]) kol++, a[i] = -2;
   }
   cout << kol;

}


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int64_t i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int64_t i=(a),_b=(b);i>=_b;--i)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

const ll md = 1000000007;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    ll n;
    cin >> n;
    map<ll, ll> M;
    ll sum = 0;
    REP(i, n) {
    	ll x;
    	cin >> x;
    	sum += x;
    	M[x]++;
    }
    int q;
    cin >> q;
    while (q--) {
    	ll b, c;
    	cin >> b >> c;
    	auto it = M.find(b);
    	if (it == M.end()) {
    		cout << sum << "\n";
    	} else {
    		auto p = *it;
    		sum -= p.first * p.second;
    		sum += c * p.second;
    		cout << sum << "\n";
    		M.erase(it);
    		M[c] += p.second;
    	}
    }

}

Measured memory_bytes: 7612
#include<bits/stdc++.h>
using namespace std;
#define sc(x) scanf("%d",&x)
#define sc2(x,y) scanf("%d%d",&x, &y)
#define sc3(x,y,z) scanf("%d%d%d",&x, &y, &z)
#define pr(a) printf("%d\n",a)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define ll long long
#define F first
#define S second
#define inf INT_MAX
const int N = 1e5 + 5;
int n, m, x, y, k, ans;
int a[15], sum;
int main(){

	string s;
	cin >> s;
	n = s.size();
	for (int i = 0; i < n; i++){
		if (s[i] == 'A'){
			x = i;
			break;
		}
	}
	for (int i = n-1; i>=0; i--){
		if (s[i] == 'Z'){
			y = i;
			break;
		}
	}
	pr(y - x + 1);
	return 0;
}





Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;
typedef long double LD;
#define x first
#define y second
#define mp(a, b) make_pair(a, b)
#define read(a) scanf("%d", &a)


LL n, x, ans = 0;

void sol(LL a, LL b) {
	if (a > b) {
		if (a % b == 0) {
			ans += 2 * a - b;
			return;
		}
		ans += 2 * (a / b) * b;
		sol(a % b, b);
	}
	else if (a == b) {ans += a; return;}
	else if (a < b) {
		if (b % a == 0) {
			ans += 2 * b - a;
			return;
		}
		ans += 2 * (b / a) * a;
		sol(a, b % a);
	}
}

int main() {
	cin >> n >> x;
	ans = n;
	sol(x, n - x);
	printf("%lld\n", ans);
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 998244353;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


const ll MAX_N=300010;

ll n,dat[2*MAX_N-1];
void init(int n_){
  n=1;
  while(n<n_)
    n*=2;
  for (int i = 0; i < 2*n-1; i++) {
    dat[i]=-LLINF;
  }
}

void update(ll k, ll a){
  k+=n-1;
  dat[k]=a;
  while(k>0){
    k = (k-1)/2;
    dat[k] = max(dat[k*2+1], dat[k*2+2]);
  }
}


ll query(ll a, ll b, ll k, ll l, ll r){
  if(r<=a || b<=l)
    return -LLINF;

  if(a<=l && r<=b)
    return dat[k];
  else{
    ll vl = query(a,b,k*2+1, l, (l+r)/2);
    ll vr = query(a,b,k*2+2, (l+r)/2, r);
    return max(vl,vr);
  }
}


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

  ll N;
  cin>>N;
  init(N);
  vpl p(N);
  REP(i,N)cin>>p[i].FI>>p[i].SE;
  sort(p.begin(), p.end());
  vll v(N);
  REP(i,N)v[i]=p[i].FI;

  //bit set
  REP(i,N){
    ll index = N-1-i;
    ll l=index;
    ll value = p[index].FI+p[index].SE;
    ll r = lower_bound(v.begin(), v.end(), value)-v.begin();

    ll max_i = query(l,r,0,0,n);
    if(max_i==-LLINF)
      update(l, l);
    else
      update(l, max_i);
  }


  ll dp[N][2];
  REP(i,N)REP(j,2)dp[i][j]=LLINF;

  for(ll i=N-1; i>=0; i--){
    if(i==N-1)
      dp[i][0]=dp[i][1]=1;
    else{
      dp[i][0]=(dp[i+1][0]+dp[i+1][1])%MOD;

      ll l=i;
      ll value = p[i].FI+p[i].SE;
      ll r = lower_bound(v.begin(), v.end(), value)-v.begin();
      ll t = query(l,r,0,0,n);

      if(t==l)
        dp[i][1]=dp[i][0];
      else
        dp[i][1]=dp[t][1];
    }
  }
  ll ans = (dp[0][0]+dp[0][1])%MOD;
  cout<<ans<<endl;
}


Measured memory_bytes: 12160
#include<stdio.h>
#include<string.h>
int main(){
  int a,s,i,j,n,sum;
  char x[1001];
  while(1){
    sum=0;
    scanf("%s",x);
    if(strcmp(x,"0")==0){
      break;
    }
    for(i=0;x[i]!='\0';i++){
      n=x[i]-'0';
      sum+=n;
    }
    printf("%d\n",sum);
  }
  return (0);
}

Measured memory_bytes: 536
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int N;
    cin >> N;
    int maxH = 0;
    int cnt = 0;
    rep(i, N) {
        int Hi;
        cin >> Hi;
        if (Hi >= maxH) {
            cnt += 1;
        }
        maxH = max(Hi, maxH);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
char field[1010][1010];
int score[1010][1010][4] = {0};//0 j 1 o 2 i
int main()
{
    char E[2][2];
    int x,y,cou = 0,ans = 0,mx,my;
    int dx[] = {0,1,0,1},dy[] = {0,0,1,1};
    scanf("%d%d",&y,&x);
    for(int i = 0; i < y; i++)
    {
        scanf(" %c",&field[0][i]);
        for(int j = 1; j < x; j++)
                scanf("%c",&field[j][i]);
    }
    for(int i = 0; i < 2; i++)
    {
        scanf(" %c",&E[0][i]);
        for(int j = 1; j < 2; j++)
                scanf("%c",&E[j][i]);
    }
    for(int i = 0; i < y ; i++)
        for(int j = 0; j < x ; j++)
        {
            for(int k = 0; k < 4; k++)
            {
                if(field[j + dx[k]][i + dy[k]] == E[dx[k]][dy[k]])
                        cou++;
                else
                {
                    mx = j + dx[k];
                    my = i + dy[k];
                }
            }
            if(cou == 3)
            {
                if(E[mx - j][my - i] == 'J')score[mx][my][0]++;
                else if(E[mx - j][my - i] == 'O')score[mx][my][1]++;
                else score[mx][my][2]++;
            }
            else if(cou == 4)
            {
                ans++;
            for(int k = 0; k < 4; k++)
                score[j + dx[k]][i + dy[k]][3]--;
            }
            cou = 0;
        }
    for(int l = 0; l < 3; l++)
        for(int i = 0; i < y; i++)
            for(int j = 0; j < x; j++)
            {
                cou = max(cou,score[j][i][l] + score[j][i][3]);
            }
    printf("%d\n",ans + cou);
    return 0;
}

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

bool isLeepYear(int year) {
	return year%4==0 && (year%100!=0 || year%400==0);
}

int days[] =  { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int sdays[] = { 0, 31, 59, 90,120,151,181,212,243,273,304,334,365};
int FromNewYear(int year, int month, int day) {
	int count = 0;
	count += sdays[month-1];
	if(isLeepYear(year) && month>2) count += 1;
	count += day;
	return count;
}

int DaysInYear(int year) {
	return (isLeepYear(year) ? 366 : 365);
}

int main() {
	int y1, m1, d1, y2, m2, d2, ans;
	while(cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2) {
		ans = 0;
		if(y1==-1 || m1==-1 || d1==-1 || y2==-1 || m2==-1 || d2==-1) break;
		for(int y = y1+1; y<y2; ++y) {
			ans += DaysInYear(y);
		}
		if(y1!=y2) {
			ans += DaysInYear(y1)-FromNewYear(y1, m1, d1);
			ans += FromNewYear(y2, m2, d2);
		}else {
			ans += FromNewYear(y2, m2, d2) - FromNewYear(y1, m1, d1);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       
      



        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            
            var n = Read();
            var memo = new long['z' - 'a' + 1];
            var ans = new long['z' - 'a' + 1];
            for (int i = 0; i < 'z' - 'a' + 1; i++)
            {
                ans[i] = long.MaxValue;
            }
            for (int i = 0; i < n; i++)
            {
                var s = Console.ReadLine();
                for (int j = 0; j < 'z'-'a'+1; j++)
                {
                    memo[j] = 0;
                    for (int k = 0; k < s.Length; k++)
                    {
                        if (s[k] == (char)(j+'a')) memo[j]++;
                    }
                    if (ans[j] > memo[j]) ans[j] = memo[j];
                }
            }
            var res = "";
            for (int j = 0; j < 'z'-'a'+1; j++)
            {      
                for (int k= 0; k < ans[j]; k++)
                {
                    res += ((char)(j + 'a')).ToString();
                }
            }

            Console.WriteLine(res);


                Console.Out.Flush();
        }
    }
}




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

class UnionFind {
public:
    UnionFind(int64_t n) {
        //parが負の場合、このグループに属する要素数 * (-1)を示す
        par_.resize(n, -1);
    }

    //根を求める
    int64_t root(int64_t x) {
        return (par_[x] < 0 ? x : par_[x] = root(par_[x]));
    }

    //xとyの属する集合を併合
    void unite(int64_t x, int64_t y) {
        x = root(x);
        y = root(y);
        if (x == y) {
            return;
        }

        //要素数を足す(負の数だがそのまま足せば良い)
        par_[x] += par_[y];

        //yをxに繋げる
        par_[y] = x;
    }

    //xとyが同じ集合に属するか否かを判定
    bool same(int64_t x, int64_t y) {
        return (root(x) == root(y));
    }

    //xと同じ集合に属する要素数を返す
    int64_t size(int64_t x) {
        x = root(x);
        return -par_[x];
    }
private:
    vector<int64_t> par_;
};

int main() {
    int64_t N, M, K;
    cin >> N >> M >> K;
    vector<int64_t> A(M), B(M), C(K), D(K);
    for (int64_t i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
    }
    for (int64_t i = 0; i < K; i++) {
        cin >> C[i] >> D[i];
        C[i]--; D[i]--;
    }

    vector<int64_t> degree(N, 0);

    UnionFind uf(N);
    for (int64_t i = 0; i < M; i++) {
        uf.unite(A[i], B[i]);
        degree[A[i]]++;
        degree[B[i]]++;
    }

    vector<int64_t> ans(N);
    for (int64_t i = 0; i < N; i++) {
        ans[i] = uf.size(i) - degree[i] - 1;
    }

    //ブロック同士を削除
    for (int64_t i = 0; i < K; i++) {
        if (uf.same(C[i], D[i])) {
            ans[C[i]]--;
            ans[D[i]]--;
        }
    }

    for (int64_t i = 0; i < N; i++) {
        cout << ans[i] << " \n"[i == N - 1];
    }
}

Measured memory_bytes: 6656
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def bs(ar,eq,n) en=(eq==1 ? :>= : :>); ar.bsearch_index{|x|x.send(en,n)} end
def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
a,b=gsmi
w=a-2*b
puts w>0 ? w : 0

Measured memory_bytes: 1788
S=input()
N=len(S)
a=0
b=0
c=0
flag=0
for i in range(N):
    if S[i]=="a":
        a=a+1
    elif S[i]=="b":
        b=b+1
    else:
        c=c+1
l=[a,b,c]
l.sort()
if N<=2:
    if len(set(list(S)))==N:
        flag=1
elif (len(set(list(S)))<3):
    flag=0
else:
    if (l[0]==l[2])or(l[0]==l[2]-1):
        flag=1

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



Measured memory_bytes: 46320
#include <stdio.h>
#define N 100

void print_numrow(int A[], int n) {
    int i;

    for (i = 0; i < n; i++) {
        if (i == n - 1) {
            printf("%d\n", A[i]);
        } else {
            printf("%d ", A[i]);
        }
    }
}

int main(void) {
    int i, j, n, v;
    int A[N];

    scanf("%d", &n);
    for (i = 0; i < N; i++) A[i] = 0;
    for (i = 0; i < n; i++) scanf("%d", &A[i]);

    print_numrow(A, n);
    for (i = 1; i < n; i++) {
        v = A[i];
        j = i - 1;
        while ((j >= 0) && (A[j] > v)) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        print_numrow(A, n);
    }

    return 0;

}

Measured memory_bytes: 600
# problem Bt
n = int(input())

w = []
for cnt in range(n):
    w.append(input())

first = w[0][0]
new_w = []
res = True
for i in range(n):
    if w[i][0] != first or w[i] in new_w:
        res = False
        break
    new_w = w[0:i+1]
    first = w[i][-1]

if res:
    print('Yes')
else:
    print('No')
    


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

inline int read()
{
	int ret=0; char c=getchar();
	while(c<48||c>57)c=getchar();
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}
int n,a,b;
int main()
{
	n=read(); a=read(); b=read();
	printf("%d",min(n*a,b));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ld long double
typedef pair<ll,ll> P;
#define boost ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);
int main()
{
    string s1,s2;
    cin>>s1;
    cin>>s2;
    ll i,n=s1.size(),m=s2.size(),j;
    ll DP[n+1][m+1];
    memset(DP,0,sizeof(DP));
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(s1[i-1]==s2[j-1])
            {
                DP[i][j]=DP[i-1][j-1]+1;
            }
            else
            DP[i][j]=max(DP[i-1][j],DP[i][j-1]);
        }
    }
    //now printing the DP string//
    string s;
    i=n,j=m;
    while(i>0 && j>0)
    {
        if(s1[i-1]==s2[j-1])
        {s=s+s1[i-1];i--;j--;}
        else if(DP[i-1][j]>DP[i][j-1])
        {i--;}
        else
        {j--;}
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
}


Measured memory_bytes: 70656
#!/usr/bin/env python3
#ABC136 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

s = input()
n = len(s)
x = []
for i in range(n-1):
    if s[i] == 'R' and s[i+1] == 'L':
        x.append(i)

ans = [0]*n
for i in range(n):
    if s[i] == 'R':
        tmp = bisect.bisect_left(x,i)
        tmp = x[tmp]
        #print((10**100 - (tmp-i)) % 2)
        ans[(10**100 - (tmp-i)) % 2 + tmp] += 1
    else:
        tmp = bisect.bisect_right(x,i)
        tmp = x[tmp-1]
        #print((10**100 - (i-tmp+1)) % 2)
        ans[(10**100 - (i-tmp)) % 2 + tmp] += 1
print(*ans)


Measured memory_bytes: 52956
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define M 1000000007
#define ff first
#define ss second
#define pb push_back  
#define INF 10000000000

 

 int main(){
   ios::sync_with_stdio(0);
   cin.tie(0); cout.tie(0);
  string s;
  cin>>s;
  ll n = s.length(),i;
  for(i=0;i<n;i++){
  	cout<<'x';
  }
}

Measured memory_bytes: 256
from fractions import gcd

n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
if max(a) < k:
    print("IMPOSSIBLE")
    exit()
x = a[0]
for i in range(1,n):
    x = gcd(x, a[i])

for i in range(n):
    if (a[i] - k) % x == 0:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")


Measured memory_bytes: 88172
#include <stdio.h>
#include <bits/stdtr1c++.h>

#define MAX 4010
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)
#define dbg(x) cout << #x << " = " << x << endl

using namespace std;

const unsigned long long base = 666666667;

int n, m, freq[MAX];
char A[MAX], B[MAX];
tr1::unordered_map <unsigned long long, int> mp;

void insert(int n, char str[MAX], int len, int mask){
    clr(freq);
    for (int i = 0; i < len; i++) freq[str[i] - 97]++;
    for (int i = 0; (i + len) <= n; i++){
        unsigned long long h = 0;
        for (int k = 0; k < 26; k++) h = h * base + freq[k] + 143;
        mp[h] |= mask;

        freq[str[i] - 97]--;
        if ((i + len) < n) freq[str[i + len] - 97]++;
    }
}

bool check(int len){
    mp.clear();
    insert(n, A, len, 1);
    insert(m, B, len, 2);
    for (auto it: mp){
        if (it.second == 3) return true;
    }
    return false;
}

int ar[20000][3130];

int main(){
    int i, j, k, l, len, res;
clr(ar);

    while (scanf("%s %s", A, B) != EOF){
        n = strlen(A);
        m = strlen(B);
        for (res = 0, len = min(n, m); len >= 1; len--){
            if (check(len)){
                res = len;
                break;
            }
        }

        printf("%d\n", res);
    }
    return 0;
}

Measured memory_bytes: 248064
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define MAX 500000

int L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

void merge(int A[], int n, int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  // std::cout << "left: " << left << " right: " << right << '\n';
  for (int i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
  for (int i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
  L[n1] = R[n2] = INF;
  int i = 0, j = 0;
  for (int k = left; k < right; k++) {
    cnt++;
    if (L[i] <= R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[], int n, int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
  return;
}

int main(int argc, char const *argv[]) {
  int A[MAX], n, i;
  cnt = 0;

  std::cin >> n;

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

  mergeSort(A, n, 0, n);

  for (int i = 0; i < n; i++) {
    if (i) {
      std::cout << " ";
    }
    std::cout << A[i];
  }
  std::cout << '\n';

  std::cout << cnt << '\n';
  return 0;
}



Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	int c = 0;
	cin >> s;
	for (char x : s) {
		if (x == 'x') c++;
	}
	if (c > 7) puts("NO");
	else puts("YES");
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  ll n, k;
  cin >> n >> k;

  ll c_od = 0;
  ll c_ev = 0;

  if (k & 1)
  {
    // 奇数
    c_od = n / k;
  }
  else
  {
    // 偶数
    ll cnt = n / (k / 2);
    c_od = (cnt + 1) / 2;
    c_ev = cnt / 2;
  }
  cout << c_od * c_od * c_od + c_ev * c_ev * c_ev;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3640