akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template
int N, K;

bool complete(vector<int> &A) {
    rep(i, N) if(A[i] < N) return false;
    return true;
}

template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    rep(i, K) {
        if(complete(A)) break;
        vector<int> B(N + 1);
        rep(j, N) {
            B[max(0, j - A[j])] += 1;
            B[min(N, j + A[j] + 1)] -= 1;
        }
        rep(j, 1, N + 1) {
            B[j] += B[j - 1];
        }
        rep(j, N) A[j] = B[j];
    }
    
    
    voutput(A);
    
    return 0;
}


Measured memory_bytes: 5000
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R, V, E;

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

	cin >> N >> M;
	if (N <= 8 && M <= 8)cout << "Yay!\n";
	else cout << ":(\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define mp make_pair
#define REP(i,j,k)  for(int i=(j);i<=(k);++i)
#define REPD(i,j,k) for(int i=(j);i>=(k);--i)

const int maxn = 1e5+10;
long long a[maxn],sum[maxn],abssum[maxn];
int xs[maxn],nxt[maxn];
int n;

void init()
{
	char op[5];
	cin>>n>>a[1];
	sum[1]=abssum[1]=a[1];
	REP(i,2,n)
	{
		cin>>op>>a[i];
		if(op[0]=='-') xs[i]=-1;
		else xs[i]=1;
		abssum[i]=abssum[i-1]+a[i];
		sum[i]=sum[i-1]+xs[i]*a[i];
	}
	nxt[n]=n;
	REPD(i,n-1,2)
		if(xs[i+1]==-1) nxt[i]=i;
		else nxt[i]=nxt[i+1];
}

void solve()
{
	long long ans=sum[n];
	REP(i,2,n)
		if(xs[i]==-1)
			ans=max(ans,sum[i-1]-(abssum[nxt[i]]-abssum[i-1])+abssum[n]-abssum[nxt[i]]);
	cout<<ans<<endl;
}

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

Measured memory_bytes: 3328
from collections import defaultdict

n = int(input())
arr = list(map(int,input().split()))

dd = defaultdict(int)

for a in arr:
    dd[a]+=1

sum = sum(arr)

q = int(input())
for _ in range(q):
    b,c = map(int,input().split())


    if dd[b]>0:
        sum += dd[b]*(c-b)
        dd[c]+=dd[b]
        dd[b]=0

    print(sum)

Measured memory_bytes: 22500
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
  if(a<b) swap(a,b);
  if(a%b==0) return b;
  else return gcd(b,a%b);
}
int main(){
  int n,k,m=0;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    m=max(m,a[i]);
  }
  int g=gcd(a[0],a[1]);
  for(int i=2;i<n;i++){
    g=gcd(g,a[i]);
  }
  cout<<(m>=k&&k%g==0?"POSSIBLE":"IMPOSSIBLE");
}

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

using int64 = long long;

const int MAX_N = 200000;

int N;
int64 L;

int64 result = 0;

string s[MAX_N];
vector<int64> heights;

int64 calc_grundy(int64 x) {
    if (x == 0) return 0;

    int64 res = 1;
    while (x % 2 == 0) {
        x /= 2;
        res *= 2;
    }
    return res;
}

string prefix = "";

void dfs(int64 dep, int lb, int ub) {
    int num = ub - lb;
    if (num == 0) {
        result ^= calc_grundy(L + 1 - dep);
        return;
    } else if (num == 1 and prefix == s[lb]) return;
    /*
    } else if (num == 1) {
        int64 h = L - dep + 1;
        int64 sh = L - s[lb].size() + 1;

        // cerr << "h: " << h << " sh: " << sh << endl;

        for (int64 x = sh; x < h; x++) {
            result ^= calc_grundy(x);
            // heights.push_back(x);
        }
        return;
    }
    */
    prefix.push_back('1');
    int b = lower_bound(s + lb, s + ub, prefix) - s;
    prefix.pop_back();

    prefix.push_back('0');
    dfs(dep + 1, lb, b);
    prefix.pop_back();

    prefix.push_back('1');
    dfs(dep + 1, b, ub);
    prefix.pop_back();
}

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

    for (int i = 0; i < N; i++) {
        cin >> s[i];
    }
    sort(s, s + N);

    dfs(0, 0, N);

    /*
    for (auto h : heights) {
        // cerr << " == " << h << endl;
        result ^= calc_grundy(h);
    }
    */

    if (result) cout << "Alice" << endl;
    else cout << "Bob" << endl;

    return 0;
}

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    ll n, t; cin >> n >> t;

    vector<ll> time(n);
    for (ll i = 0; i < n; ++i) {
        cin >> time[i];
    }

    ll ans = t;

    for (ll i = 1; i < n; ++i) {
        if (time[i-1] + t <= time[i]) {
            ans += t;
        } else {
            ans += time[i] - time[i-1];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main(){
    input!{
        a: i64,
        b: i64
    }

    println!("{}", [a+a-1, a+b, b+b-1].into_iter().max().unwrap());
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(void) {
    int num,i,j,k,l,way;
    while(scanf("%d",&num) != EOF){
        way = 0;
        for(i = 0;i < 10;i++){
            for(j = 0;j < 10;j++){
                for(k = 0;k < 10;k++){
if(i + j + k <= num && i + j + k + 9 >= num) way++;
        }
            }
        }
        printf("%d\n",way);
    }
	return 0;
}

Measured memory_bytes: 596
n = input()

num = int(n)
kisu_array = []
yakusuu_array = []
kazu_list = 0
for i in range(1,num+1):
    if i%2 != 0:
        kisu_array.append(i)

for i in kisu_array:
    for j in range(1,i+1):
        if i% j == 0:
            yakusuu_array += "1"

            if len(yakusuu_array) == 8:
                kazu_list += 1
    yakusuu_array = []
                
print(kazu_list)

Measured memory_bytes: 38712
#include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace std;
    using namespace __gnu_pbds; 
    #define lli long long int
    #define fr(i,a,b) for(lli i=a;i<b;i++)
    #define bfr(i,a,b) for(lli i=a;i>=b;i--)
    #define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
    #define tc int t;cin>>t;while(t--)
    #define mod 1000000007LL
    #define mod2 998244353LL
    #define all(vec) vec.begin(),vec.end()  
    #define ld long double
    #define pb push_back

    #define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update> 


       int main()
    {
                           
             

         
                        
              fio   
             
              lli n,k;
              cin>>n>>k;
              lli a[n+1]={0};
              while(k--)
              {
                 lli x,g;
                 cin>>x;
                 fr(i,0,x){cin>>g;a[g]++;}
              }
              lli sum=0;
              fr(i,1,n+1)if(a[i]==0)sum++;
              cout<<sum;

return 0;}

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	int a,b;
	cin>>a>>b;
	cout<<a*b<<'\n';
	return 0;
}

Measured memory_bytes: 3652
import numpy as np
n = int(input())
L = [int(i) for i in input().split()]
T = [-1 for i in range(n)]

for i in range(n):
  T[L[i]-1] = i+1

for i in range(n-1):
  print("{0} ".format(T[i]), end="")
print(T[-1])


Measured memory_bytes: 23440
#include <stdio.h>

int main() {
  int N;
  int A[200000];
  scanf("%d", &N);
  int mx = -1, mx2 = -1;
  for (int i = 0; i < N; ++i) {
    scanf("%d", A + i);
    if (mx <= A[i]) {
      mx2 = mx;
      mx = A[i];
    } else if (mx2 < A[i]) {
      mx2 = A[i];
    }
  }
  for (int i = 0; i < N; ++i) {
    if (A[i] == mx) {
      printf("%d\n", mx2);
    } else {
      printf("%d\n", mx);
    }
  }
}

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

using namespace std;

using ll = long long;

const int mod = 998244353, N = (int)3e3 + 5, X = 2 * N;
int n, x, dp[N][X], C[N << 1][N << 1], ans;

int add(int _a, int _b) {
    _a += _b;
    if (_a >= mod) _a -= mod;
    return _a;
}
int mul(int _a, int _b) { return (int)( (ll)_a * _b % mod); }

int candyDivision(int _n, int _s) { return C[_n - 1][_s + _n - 1]; }

int main() {
    scanf("%d %d", &n, &x);

    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= (i << 1); ++j) if (dp[i][j]) {
            dp[i + 1][j + 1] = add(dp[i + 1][j + 1], dp[i][j]);
            dp[i + 1][j + 2] = add(dp[i + 1][j + 2], dp[i][j]);
        }
    }

    for (int i = 0; i < (N << 1); ++i) C[0][i] = C[i][i] = 1;
    for (int j = 1; j < (N << 1); ++j) {
        for (int i = 1; i < j; ++i) C[i][j] = add(C[i - 1][j - 1], C[i][j - 1]);
    }

    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j < x; ++j) if (dp[i][j]) {
            ans = add(ans, mul(dp[i][j], candyDivision(i + 1, n - i) ) );
        }
    }

    for (int i = 1; ; ++i) {
        int rem = x - 1 - 2 * i;
        if (rem > 0) {
            int n_2 = i << 1;
            if (n_2 > n) break ;
            for (int j = 0; j <= n - n_2; ++j) ans = add(ans, mul(dp[j][rem], candyDivision(n_2 + j + 1, n - n_2 - j) ) );
        }
        else {
            if (!(x & 1) ) break ;
            int n_2 = (x >> 1) + i;
            if (n_2 > n) break ;
            ans = add(ans, candyDivision(n_2 + 1, n - n_2) );
        }
    }

    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 211584
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    string S;
    cin >> S;
    ll count=0;
    for(ll i=0;i<S.size()/2; i++)
    {
        cerr << S[i] << ":" << S[S.size()-1-i] << endl;
        if(S[i]!=S[S.size()-1-i]) count++;
    }
    cout << count << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

int main(){
    unsigned long long N;
    cin >> N;
    vector<unsigned long long> A(N+1);
    unsigned long long sum = 0;
    for(int i = 0; i < N+1;i++){
        cin >> A[i];
        sum += A[i];
    }

    unsigned long long k =1;
    unsigned long long check = 0;
    for(int i = 0; i < N+1;i++){
        if(k < A[i]){
            check = -1;
            break;
        }
        k = 2*(k - A[i]);
    }
    if(check == -1){
        cout <<  -1 << endl;
    }
    //cout << sum << endl;
    unsigned long long node_sum = 1;
    unsigned long long node = 1;
    if(check != -1){
        sum -= A[0];
        if(N > 0){
            for(int i = 1;i < N+1;i++){
                node_sum *= 2;
                if(node_sum > sum){
                    node_sum = sum;
                }
                sum -= A[i];
                node += node_sum;
                node_sum -= A[i];
            }
        }
        cout << node << endl;
    }
}

Measured memory_bytes: 3996
s = input()

moji  = list(s)
ans = 0
for n in range(len(moji) // 2):
  parts  = "".join(moji[:n+1])
  check = "".join([parts,parts])
  if check == "".join(moji[:(n+1)*2]) and len(check) != len(s):
    #print("".join(moji[:(n+1)*2]))
    ans = (n+1)*2
    
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < (int)n;i++)
#define repb(i, n) for(int i = (int)n;i >= 0;i--)
#define reps(i, m, n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i, m, n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
using namespace std;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
int main(int argc, char const *argv[]) {
    int a,b,h;
    cin>>a>>b>>h;
    cout<<(a+b)*h/2<<endl;  
    return 0;
}



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

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

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

const int N = 5e3 + 5;

long long dp[N], n, a, b, P[N], S[N][N];

int calc(int L, int R, int l, int r) {
	L = max(L, 1); l = max(l, 1);
	return S[R][r] - S[L - 1][r] - S[R][l - 1] + S[L - 1][l - 1];
}

int main() {
	cin >> n >> a >> b;
	for(int i = 1; i <= n; ++ i) cin >> P[i], S[P[i]][i] = 1;
	S[n + 1][n + 1] = 1;
	P[n + 1] = n + 1;
	for(int i = 1; i <= n + 1; ++ i) {
		for(int j = 1; j <= n + 1; ++ j)
		S[i][j] = S[i - 1][j] + S[i][j - 1] + S[i][j] - S[i - 1][j - 1];
	}
	for(int i = 0; i <= n + 1; ++ i) dp[i] = 1e18;
	dp[0] = 0;
	for(int i = 0; i <= n; ++ i) {
		for(int j = i + 1; j <= n + 1; ++ j) if(P[j] > P[i]) {
			// [P[i] + 1, P[j] - 1], [1, i - 1], [j + 1, n]
			int now = calc(P[i] + 1, P[j] - 1, i + 1, j - 1);
			if(now) continue;
			dp[j] = min(dp[j], dp[i] + calc(1, P[i], i + 1, j - 1) * b + calc(P[j], n, i + 1, j - 1) * a);
		}
	}
	cout << dp[n + 1] << endl;
}

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

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

	string ret;
	if (d == 25) {
		ret = "Christmas";
	}
	else if (d == 24) {
		ret = "Christmas Eve";
	}
	else if (d == 23) {
		ret = "Christmas Eve Eve";
	}
	else if (d == 22) {
		ret = "Christmas Eve Eve Eve";
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    cout << (n % 2 ? 2 * n : n) << endl;
}

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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=a;i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ull=unsigned long long;

template<int i,class T>
void print_tuple(ostream&,const T&){
}

template<int i,class T,class H,class ...Args>
void print_tuple(ostream&os,const T&t){
	if(i)os<<",";
	os<<get<i>(t);
	print_tuple<i+1,T,Args...>(os,t);
}

template<class ...Args>
ostream& operator<<(ostream&os,const tuple<Args...>&t){
	os<<"{";
	print_tuple<0,tuple<Args...>,Args...>(os,t);
	return os<<"}";
}

void print(ll x,int suc=1){
	cout<<x;
	if(suc==1)
		cout<<endl;
	if(suc==2)
		cout<<" ";
}

ll read(){
	ll i;
	cin>>i;
	return i;
}

vi readvi(int n,int off=0){
	vi v(n);
	rep(i,n)v[i]=read()+off;
	return v;
}

template<class T>
void print(const vector<T>&v,int suc=1){
	rep(i,v.size())
		print(v[i],i==int(v.size())-1?suc:2);
}

string readString(){
	string s;
	cin>>s;
	return s;
}

template<class T>
T sq(const T& t){
	return t*t;
}

//#define CAPITAL
void yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void no(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

constexpr ll ten(int n){
	return n==0?1:ten(n-1)*10;
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

int topbit(signed t){
	return t==0?-1:31-__builtin_clz(t);
}
int topbit(ll t){
	return t==0?-1:63-__builtin_clzll(t);
}
int popcount(signed t){
	return __builtin_popcount(t);
}
int popcount(ll t){
	return __builtin_popcountll(t);
}
bool ispow2(int i){
	return i&&(i&-i)==i;
}

bool inc(int a,int b,int c){
	return a<=b&&b<=c;
}

template<class t> void mkuni(vc<t>&v){
	sort(all(v));
	v.erase(unique(all(v)),v.ed);
}

ll rand_int(ll l, ll r) { //[l, r]
    static random_device rd;
    static mt19937 gen(rd());
    return uniform_int_distribution<ll>(l, r)(gen);
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	int n;cin>>n;
	vi a=readvi(n);
	if(a==vi(n,0))
		yes();
	if(n%3)no();
	
	sort(all(a));
	rep(k,3)
		if(a[n/3*k]!=a[n/3*(k+1)-1])no();
	if((a[0]^a[n/3])==a[n/3*2])
		yes();
	no();
}


Measured memory_bytes: 1792
import queue
def solved(n):
    if n <= 9:
        return n
    nums = queue.Queue()
    for i in range(1, 10):
        nums.put(i)
    cnt = 9
    for i in range(cnt, n):
        i_num = nums.get()
        ini_num = i_num % 10
        for j in range(max(0, ini_num - 1), min(10, ini_num + 2)):
            nums.put(i_num * 10 + j)
            cnt += 1
            if cnt == n:
                return i_num * 10 + j
k = int(input())
num = queue.Queue()
print(solved(k))

Measured memory_bytes: 49000
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; ll m; cin >> n >> m;
    REP(i, m){
        ll a; cin >> a;
        n -= a;
    }
    n = max(ll(-1), n);
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

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

    std::vector<std::string> strvec;
    int n, l;
    cin >> n >> l;
    std::string pushed_str;
    for (int i = 0; i < n; i++) {
        cin >> pushed_str;
        strvec.push_back(pushed_str);
    }
    std::sort(strvec.begin(), strvec.end());
    std::string result;
    for (auto itr : strvec) {
        result += itr;
    }
    cout << result << endl;

    return 0;
}


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


void solve(long long N, std::vector<long long> A){
    ll ans = 0;
    REP(i, N){
        ans += A.at(i) / 2;
        A.at(i) = A.at(i) % 2;
        if(i < N - 1 && A.at(i) > 0 && A.at(i + 1) > 0){
            ans++;
            A.at(i) = 0;
            A.at(i + 1)--;
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll a,b,n;cin>>a>>b>>n;
    ll x=min(n,b-1);
    ll buf=a*x/b;
    cout<<buf<<endl;
}

Measured memory_bytes: 3568
n=int(input())
p=list(map(int,input().split()))
ans=0
if p[0]==1:
    t=p[0]
    p[0]=p[1]
    p[1]=t
    ans+=1
if p[-1]==n:
    t=p[-1]
    p[-1]=p[-2]
    p[-2]=t
    ans+=1

for i in range(1,n-1):
    if p[i]==(i+1) and p[i+1]==(i+2):
        t=p[i]
        p[i]=p[i+1]
        p[i+1]=t
        ans+=1
    else:
        if p[i]==(i+1):
            t=p[i]
            p[i]=p[i-1]
            p[i-1]=t
            ans+=1

print(ans)


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

int main(){
int e;
while(cin >> e,e){
int ans = 1000000000;
for(int z=0;z*z*z<=e;z++)
for(int y=0;y*y+z*z*z<=e;y++)
ans = min(ans,(e-y*y-z*z*z) + y + z);
cout << ans << endl;
}
}

Measured memory_bytes: 1160
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		TreeSet<String> idSet = new TreeSet<String>();
		for (int i = 0; i < n; i++) {
			idSet.add(sc.next());
		}
		int m = sc.nextInt();
		int lock = 1;
		for (int i = 0; i < m; i++) {
			String s = sc.next();
			if (idSet.contains(s)) {
				if (lock == 1) {
					System.out.println("Opened by " + s);
					lock *= -1;
				} else {
					System.out.println("Closed by " + s);
					lock *= -1;
				}
			} else {
				System.out.println("Unknown " + s);
			}
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main(){
  int n, ac = 0, wa = 0, tle = 0, re = 0;
  string s;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> s;

    if(s == "AC"){
      ac++;
    } else if(s == "WA"){
      wa++;
    } else if(s == "TLE"){
      tle++;
    } else if(s=="RE"){
      re++;
    }
  }

  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}

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

ll mod = 998244353;
ll n;
ll d[100005];
ll mp[100005];

bool chk() {
  set<ll> st;
  ll mx=0;
  if(d[0]>0){return false;}
  for(ll i=1;i<n;i++){
    st.insert(d[i]);
    mx = max(mx, d[i]);
    if(d[i]==0){return false;}
  }
  ll p=1;
  for(auto v : st) {
    if(v!=p++){return false;}
  }
  if(mx>n-1){return false;}
  return true;
}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res % mod;
}
int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>d[i];
    mp[d[i]]++;
  }

  if(!chk()){
      cout<<0<<endl;return 0;
  }

  ll res=1;
  for(int i=1;i<=n;i++){
    if(mp[i]==0){
      break;
    }
    ll v = modpow(mp[i-1], mp[i], mod);
    res = res * v;
    res = res % mod;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80
using namespace std;                     //                       10333 ~2^13.33
using ll = long long;                    // seq 1 128 | factor   100333 ~2^16.61
using vl = vector<ll>;                   //   | grep -v ' .* '  1300111 ~2^20.31
using vvl = vector<vl>;                  //                    10300777 ~2^23.30
using pll = pair<ll,ll>;                 //                   100400999 ~2^26.58
using vb = vector<bool>;                 //                  1300400999 ~2^30.28
const ll oo = 0x3f3f3f3f3f3f3f3fLL;      //                 10200500333 ~2^33.25
const double eps = 1e-9;                 //                100200400777 ~2^36.54
#define sz(c) ll((c).size())             //               1200300700111 ~2^40.13
#define all(c) begin(c),end(c)           //              10200300500777 ~2^43.21
#define mp make_pair                     //             100200300400777 ~2^46.51
#define mt make_tuple                    //            1200300400600999 ~2^50.09
#define pb push_back                     //           10200300400600111 ~2^53.18
#define eb emplace_back                  //          100200300400600333 ~2^56.48
#define xx first                         //         1200300400500800999 ~2^60.06
#define yy second                       
#define has(c,i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (ll i=(a); i<(ll)(b); i++)       
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)
/// ({ ... }) avoids some problems: http://kernelnewbies.org/FAQ/DoWhile0
/// In non-contest code it is probably better to use: do { ... } while(0)
#define TR(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })
ll N,Q;
vl counter;
vl pending;
vvl adj;

void push(ll n, ll v, ll par){
    v+=pending[n];
    counter[n] = v;
    for(ll c: adj[n]){
        if(c == par) continue;
        push(c,v,n);
    }
}


int main() {
    cin >> N >> Q;
    counter = pending = vl(N,0);
    adj = vvl(N);
    FOR(i,0,N-1){
        ll a,b;
        cin >> a >> b;
        a--; b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    FOR(i,0,Q){
        ll p,x;
        cin >> p >> x;
        p--;
        pending[p]+=x;
    }
    push(0,0,-1);
    for(ll c : counter){
        cout << c <<" ";
    }
    cout << endl;
}


Measured memory_bytes: 25856
abcd = input()

answer = 0
for i in range(1 << len(abcd) - 1):
    formula = abcd[0]
    for j in range(len(abcd) - 1):
        if (i >> j) & 1:
            formula += '+'
        else:
            formula += '-'
        formula += abcd[j + 1]
    canditate = eval(formula)
    if canditate == 7:
        print(formula + '=7')
        exit()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,p,p1,p2;
 cin>>n>>m;
 p=m/4;
 p1=m/2;
 p2=m%4;
 if(p2%2==0)
 {
 p=p+(p2/2);
 }
 if(m%2==0 && p1>=n && p<=n)
 {
     cout<<"Yes";
 }
 else
 {
     cout<<"No";
 }

}


Measured memory_bytes: 3560
#pragma warning(disable:4996)
#include <stdio.h>

int main(void) {
	int a, b, ans = -10000;
	int ans_;
	scanf("%d%d", &a, &b);
	ans_ = a + b;
	if (ans < ans_) ans = ans_;
	ans_ = a - b;
	if (ans < ans_)ans = ans_;
	ans_ = a * b;
	if (ans < ans_)ans = ans_;

	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;

const int N = 2501;

struct edge {
    int a, b, cost;
    edge(int x, int y, int z) : a(x), b(y), cost(z) {}
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, m, p;
    cin >> n >> m >> p;
    vector<edge> e;
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        e.emplace_back(a - 1, b - 1, -c + p);
    }
    vector<int> d(n, INT32_MAX);
    d[0] = 0;
    for (int i=0; i<n-1; ++i)
        for (int j=0; j<m; ++j)
            if (d[e[j].a] < INT32_MAX)
                d[e[j].b] = min (d[e[j].b], d[e[j].a] + e[j].cost);
    int ans = d[n - 1];
    for (int i=0; i<n-1; ++i)
        for (int j=0; j<m; ++j)
            if (d[e[j].a] < INT32_MAX)
                d[e[j].b] = min (d[e[j].b], d[e[j].a] + e[j].cost);
    if (d[n - 1] < ans) {
        cout << -1;
    } else {
        cout << max(0, -ans);
    }
    return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<vector>
using namespace std;
#define N 100005
vector <int> r[N];
vector <int> q;
int n,m,a,b,h,c[N],x,y;
bool z=true;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d",&a,&b);
		r[a].push_back(b);
		r[b].push_back(a);
	}
	q.push_back(1);
	c[1]=1;

	for(h;h<q.size();h++){
		x=q[h];
		for(int i=0;i<r[x].size();i++){
			y=r[x][i];
			if(c[y]==0){
				c[y]=x;
				q.push_back(y);
			}
		}	
	}
	
	for(int i=2;i<=n;i++){
		if(c[i]==0){
			z=false;
			break;
		}
	}
	if(z){
		printf("Yes\n");
		for(int i=2;i<=n;i++){
			printf("%d\n",c[i]);
		}
	}else printf("No");
	
	return 0;
}

Measured memory_bytes: 10116
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    string S;
    cin >> N >> S;

    vector<int> east(N), west(N);

    west[0] = 0;
    REP(i, N - 1) {
        west[i + 1] = west[i] + int(S[i] == 'W');
    }

    reverse(ALL(S));
    east[0] = 0;

    REP(i, N - 1) {
        east[i + 1] = east[i] + int(S[i] == 'E');
    }

    reverse(ALL(east));
    

    int ans = inf;
    REP(i, N) {
        ans = min(ans, east[i] + west[i]);
    }

    print(ans);
    
}


Measured memory_bytes: 6092
import math

n = int(input())
i = 2
count = 0

def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

a = factorization(n) 
a_l = len(a)
#print(a)
ans = 0

for i in range(a_l):
  w = a[i][1]
  w_n = 1
  c_n = 0
  while True:
    if w < w_n:
      break
    else:
      w = w-w_n
      w_n = w_n + 1
      c_n = c_n + 1
  ans = ans + c_n
if n == 1:
  print(0)
else:
  print(ans)

Measured memory_bytes: 9508
N,M=map(int,input().split())
A=[0]*M;D=[False]*N;p=-1
for i in range(M):
  a,b=map(int,input().split())
  A[i]=[a,b]
if M==1:
  print("IMPOSSIBLE")
else:
  for i in range(M):
    if A[i][1]==N:
      D[A[i][0]]=True
  for i in range(M):
    if A[i][0]==1 and D[A[i][1]]==True:
      p=1
  print("POSSIBLE" if p==1 else "IMPOSSIBLE")

Measured memory_bytes: 39748
A = list(map(int, input().split()))

A.sort()

t1 = A[2] - A[1]
t2 = A[1] - A[0]

if t2 % 2 == 0:
    print(t1 + t2 // 2)

else:
    print(t1 + t2 // 2 + 2)

Measured memory_bytes: 8988
s = input()

n = len(s) // 2

words_left = s[:n]
words_right = s[n:]

count = 0
i = 0
while i < n:
    j = i * -1 - 1
    if words_left[i] != words_right[j]:
        count += 1
    else:
        pass
    i += 1
    
print(count)

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

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

  int n;
  cin >> n;

  vector<int> units;
  units.push_back(1);
  int u = 6;
  while (u <= n) {
    units.push_back(u);
    u *= 6;
  }
  u = 9;
  while (u <= n) {
    units.push_back(u);
    u *= 9;
  }
  sort(units.begin(), units.end());

  int dp[n + 1];
  for (int i = 1; i <= n; i++) dp[i] = 1000000;
  dp[0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int u : units) {
      if (u > i) break;
      dp[i] = min(dp[i], dp[i - u] + 1);
    }
  }

  cout << dp[n] << endl;

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const ll M=1000;
const ll val=(1000000000000000000)%mod;
int n;

vvi f(){
	vvi g(n);
	int m;
	cin>>m;
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		if(u>v) swap(u,v);
		g[u].push_back(v);
	}
	return g;
}

vl ff(vvi g){
	vl a(n),b(M);
	for(int i=n-1;i>=0;i--){
		set<int> st;
		for(auto j:g[i]) st.insert(a[j]);
		for(int j=0;;j++) if(st.find(j)==st.end()){
			a[i]=j;
			break;
		}
	}
	ll t=1;
	for(int i=0;i<n;i++){
		(t*=val)%=mod;
		(b[a[i]]+=t)%=mod;
	}
	return b;
}

int main(){
	cin>>n;
	vvi g1=f(),g2=f(),g3=f();
	vi used(n);
	vl a=ff(g2),b=ff(g3),c;
	while(used!=vi(n,1)){
		vi b(n);
		for(int i=n-1;i>=0;i--) if(!used[i]){
			bool flag=1;
			for(auto j:g1[i]) if(b[j]) flag=0;
			if(flag){
				b[i]++;
				used[i]++;
			}
		}
		ll t=1,s=0;
		for(int i=0;i<n;i++){
			(t*=val)%=mod;
			(s+=t*b[i])%=mod;
		}
		c.push_back(s);
	}
	ll res=0;
	for(int i=0;i<M;i++) for(int j=0;j<M;j++){
		int id=(i^j);
		if(id<c.size()) (res+=c[id]*a[i]%mod*b[j])%=mod;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 17992
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#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 all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

int N, M;
vector<string> A, B;
int f(int i, int j) {
	rep(k, 0, M)rep(l, 0, M) {
		if (A[i + k][j + l] != B[k][l]) return 0;
	}
	return 1;
}

signed main() {
	cin >> N >> M;
	A.resize(N); rep(i, 0, N) { cin >> A[i]; }
	B.resize(M); rep(i, 0, M) { cin >> B[i]; }
	rep(i, 0, N - M + 1)rep(j, 0, N - M + 1) {
		if (f(i, j)) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll i, temp,t, n, a[200600];
int main()
{
    //I am Monim, a tiny creature of Allah
    cin >> n;
    if(n>=400 && n<=599)
        cout << 8;
    else if(n>=600 && n<=799)
        cout << 7;
    else if(n>=800 && n<=999)
        cout << 6;
    else if(n>=1000 && n<=1199)
        cout << 5;
    else if(n>=1200 && n<=1399)
        cout << 4;
    else if(n>=1400 && n<=1599)
        cout << 3;
    else if(n>=1600 && n<=1799)
        cout << 2;
    else if(n>=1800 && n<=1999)
        cout << 1;
    return 0;
}



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

vector<int>to[200005],ans;
void dfs(int v,int p=-1){
    for(int u:to[v]){
        if(u==p)continue;
        ans[u]+=ans[v];
        dfs(u,v);
    }
}

int main(){
    int n,q;
    cin>>n>>q;
    rep(i,n-1){
        int a,b; cin>>a>>b;
        a--,b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(n);
    rep(i,q){
        int p,x; cin>>p>>x;
        p--;
        ans[p]+=x;
    }
    dfs(0);
    rep(i,n)cout<<ans[i]<<endl;
}

Measured memory_bytes: 23552
#include <stdio.h>

int K, T, a[112];
int max;

int main() {
	scanf("%d%d", &K, &T);
	for (int i = 0; i < T; ++i) { scanf("%d", &a[i]); }

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

	return 0;
}

Measured memory_bytes: 128
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int a,b; cin >> a >> b;
  if(a<=5){
    cout << 0 << endl;
  }else if(a<=12){
    cout << b/2 << endl;
  }else{
    cout << b << endl;
  }
  return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val as = List.fill(n)(sc.nextLong())
  val m = 1000000

  val c = Array.fill(m+1)(0)
  as.foreach(a => c(a.toInt) += 1)

  var pair = true
  for (i <- 2 to m) {
    var count = 0
    var k = 1
    while (i * k <= m) {
      count += c(i * k)
      k += 1
    }
    if (count > 1) {
      pair = false
    }
  }

  def gcd(a: Long, b: Long): Long = {
    if (b == 0) a else gcd(b, a % b)
  }

  if (pair) {
    println("pairwise coprime")
  } else if (as.reduceLeft[Long]{case (x, y) => gcd(x, y)} == 1) {
    println("setwise coprime")
  } else {
    println("not coprime")
  }
}


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

void solve(long long N, std::vector<long long> P)
{
  vector<pair<int, int>> vs;
  for (int i = 0; i < P.size(); i++)
    vs.push_back(make_pair(P[i], i));
  sort(vs.begin(), vs.end());
  set<int> idx;
  idx.insert(-2);
  idx.insert(-1);
  idx.insert(P.size());
  idx.insert(P.size() + 1);
  long long ans = 0;
  for (int i = P.size() - 1; i >= 0; i--)
  {
    if (i == P.size() - 1)
    {
      idx.insert(vs[i].second);
      continue;
    }
    int cur = vs[i].second;
    //cout << cur << endl;
    idx.insert(cur);
    auto it = idx.find(cur);
    auto right = idx.find(cur);
    auto left = idx.find(cur);
    right++, left--;

    long long right_range = *right;
    long long left_range = *left;
    right++, left--;
    long long hoge = abs(right_range - *right);
    long long fuga = abs(left_range - *left);
    if(*right!=P.size()+1)
    ans += hoge * abs(left_range - *it) * vs[i].first;
    if(*left!=-2)
    ans += fuga * abs(right_range - *it) * vs[i].first;
    //cout << *left << " " << left_range << " " << *it << " " << right_range << " " << *right << endl;
  }
  cout << ans << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long long> P(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &P[i]);
  }
  solve(N, std::move(P));
  return 0;
}


Measured memory_bytes: 6516
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;
 
long long f(string s) {
	int N = s.size();
	long long sum = 0;
	for (long long i = 0, j = 0; i < N; i = j) {
		while (j < N && s[i] == s[j])j++;
		sum += (j - i) / 2;
	}
	return sum;
}
 
int main() {
 
	string S;
	cin >> S;
 
	long long N = S.size();
 
	long long K;
	cin >> K;
 
	bool same = true;
	for (int i = 0; i < N; i++) if (S[0] != S[i]) same = false;
	if (same) {
		cout << (N * K) / 2 << endl;
		return 0;
	}
 
	long long d1 = f(S);
	long long d2 = f(S + S);
 
	long long a = d1;
	long long d = d2 - d1;
 
	cout << a + (K - 1) * d << endl;
 
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <map>

using namespace std;

int main()
{
    int N;
    if (scanf("%d", &N) < 1) return 0;

    map<int, int> m;

    for (int i = 0; i < N; i++)
    {
        int A;
        if (scanf("%d", &A) < 1) return 0;
        m[A]++;
    }

    printf("%lu\n", m.size() % 2 ? m.size() : m.size() - 1);
    return 0;
}


Measured memory_bytes: 4864
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <complex>
#include <iomanip>
#include <queue>
#include <bitset>
#include <numeric>
//定数
#define MOD 1000000007
//マクロ
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))

#define vsort(v) sort((v).begin(), (v).end());

typedef unsigned long long int ull;
typedef long long lint;

using namespace std;




int main(){
    lint A, B, K;

    //入力
    cin >> A >> B >> K;

    if(A>=K) {
        A-=K;
    } else {
        K-=A; A=0;
        B-=K;
    }
    if(B<0) B=0;

    cout << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
#define inf 1e18+9
using namespace std;
int n;
void solve(int i,int j,string st){
	// if(i<j)return;
	if(i==n){
		cout << st << endl;
		return;
	}
	for(int p=0;p<=j;p++){
		string t=st+(char)(p+'a');
		solve(i+1,j,t);
	}
	string t=st+(char)(j+1+'a');
	solve(i+1,j+1,t);
}
int32_t main(){
	if(fopen("input.txt", "r"))
	freopen("input.txt", "r", stdin),
	freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	cin >> n;
	solve(0,-1,"");
}

Measured memory_bytes: 1536
import java.util.*;
import java.io.*;

public class Main {
	public void run() throws Exception {
		FastReader file = new FastReader();
		int n = file.nextInt(), m = file.nextInt();
		ArrayList<Integer> x= new ArrayList();
		int sum = 0;
		for (int i = 0; i < n; i++) {
			x.add(file.nextInt());
			sum += x.get(i);
		}
		int tot = 4 * m;
		double cur = (double) sum / tot;
		int t = 0;
		for (int i = 0; i < x.size(); i++) {
			if (x.get(i) >= cur) t++;
		}
		System.out.println(t >= m ? "Yes" : "No");
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 21332
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}
		d, v := make([]int, 0), make([]int, 0)
		for i := 0; i < n; i++ {
			scanner.Scan()
			buf := strings.Split(scanner.Text(), " ")
			a, _ := strconv.Atoi(buf[0])
			b, _ := strconv.Atoi(buf[1])
			g := _gcd(a, b)
			a /= g
			b /= g
			d = append(d, a)
			v = append(v, b)
		}
		g := lcm(n, d)
		for i := 0; i < n; i++ {
			d[i] = (g/d[i])*v[i]
		}
		g = gcd(n, d)
		for i := 0; i < n; i++ {
			fmt.Println(d[i]/g)
		}
	}
}

func _gcd(a, b int) int {
	for b != 0 {
		r := a % b
		a, b = b, r
	}
	return a
}

func gcd(n int, a []int) int {
	if n == 1 {
		return a[0]
	}
	g := _gcd(a[0], a[1])
	for i := 2; i < n; i++ {
		if g == 1 {
			break
		}
		g = _gcd(g, a[i])
	}
	return g
}

func lcm(n int, a []int) int {
	if n == 1 {
		return a[0]
	}
	g := _gcd(a[0], a[1])
	c := a[0] / g * a[1]
	for i := 2; i < n; i++ {
		g = _gcd(c, a[i])
		c = c / g * a[i]
	}
	return c
}


Measured memory_bytes: 1484
h, w  = map(int, input().split())
s = [['_'] * w for _ in range(h)]
for i in range(h):
    arr = list(str(input()))
    for j in range(w):
        s[i][j] = arr[j]

flag = True
for i in range(1,h-1):
    for j in range(1,w-1):
        if s[i][j] == '#' and s[i-1][j] == '.' and s[i][j-1] == '.' and s[i+1][j] == '.' and s[i][j+1] == '.':
            flag = False

if s[0][0] == '#' and s[1][0] == '.' and s[0][1] == '.':
    flag = False
if s[-1][-1] == '#' and s[-2][-1] == '.' and s[-1][-2] == '.':
    flag = False
if s[0][-1] == '#' and s[1][-1] == '.' and s[0][-2] == '.':
    flag = False
if s[-1][0] == '#' and s[-2][0] == '.' and s[-1][1] == '.':
    flag = False
    
for i in range(1,h-1):
    if s[i][0] == '#' and s[i-1][0] == '.' and s[i+1][0] == '.' and s[i][1] == '.':
        flag = False
    if s[i][-1] == '#' and s[i-1][-1] == '.' and s[i+1][-1] == '.' and s[i][-2] == '.':
        flag = False

for i in range(1,w-1):
    if s[0][i] == '#' and s[0][i-1] == '.' and s[0][i+1] == '.' and s[1][i] == '.':
        flag = False
    if s[-1][i] == '#' and s[-1][i-1] == '.' and s[-1][i+1] == '.' and s[-2][i] == '.':
        flag = False        
    

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


Measured memory_bytes: 3192