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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int n;
		cin >> n;
		vector<long long> a(n, 0);
		for(int i=0; i<n; i++)cin >> a[i];
		long long ret = 0;
		long long f = 0;
		for(int i=0; i < 60; i++){
			int x = 0;
			for(int j=0; j < n; j++){
				if(a[j] & (1ll<<i))x++;
			}
			if(x % 2 == 1)ret |= 1ll << i;
			else if(x != 0)f |= (1ll << i);
		}
		for(int i=0; i < n; i++)a[i] &= f;
		sort(a.begin(), a.end(), greater<long long>());
		for(int i=60; i >=0; i--){
			int idx = -1;
			for(int j=0; j < n; j++){
				if((a[j] & (1ll << i)) && a[j] < (1ll << (i+1))){
					idx = j;
					break;
				}
			}
			if(idx == -1)continue;
			for(int j=0; j < n; j++){
				if(j!= idx && (a[j] & (1ll<<i))){
					a[j] ^= a[idx];
				}
			}
		}
		long long ret2 = 0;
		for(int i=0; i < n; i++)ret2 ^= a[i];
		cout << ret2*2 + ret << "\n";

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	string s;  
	cin>>s; ll sum=0;
	for(int i=0;i<s.size();i++)
	{
		sum+=((s[i]-'1')+1);
		if(sum%9==0)
		{
			sum=0;
		}
	}
	if(sum==0)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	
		
	

  return 0;

}

    






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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll pow(ll x, ll y, ll mod) {
    if (y == 0) {
        return 1;
    }
    if (y % 2 == 0) {
        return pow(x * x % mod, y / 2, mod) % mod;
    } else {
        return x * pow(x, y - 1, mod) % mod;
    }
}

void Main() {
    int N;
    cin >> N;
    ll mod = 998244353L;
    vector<ll> D(N);
    rep(i, N) cin >> D[i];
    ll ans = 1;

    if (D[0] != 0) {
        cout << 0 << '\n';
        return;
    }

    map<ll, ll> counter;
    rep(i, N) {
        counter[D[i]]++;
    }

    if (counter[0] != 1) {
        cout << 0 << '\n';
        return;
    }

    ll max_num = *max_element(D.begin(), D.end());
    ll prev = -1;
    rep2(i, 1, max_num + 1) {
        ll d = counter[i];
        if (i == 1) {
            if (d == 0) {
                cout << 0 << '\n';
                return;
            }
        } else {
            if (d == 0) {
                cout << 0 << '\n';
                return;
            } else {
                ans *= (ll) pow(prev, d, mod);
                ans %= mod;
            }
        }
        prev = d;
    }
    cout << ans % mod << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 7296
using System;
using System.Collections.Generic;
using System.Linq;

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var hen = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var list = new List<int>();
            list.AddRange(hen);

            var m = list.Max();
            list.Remove(m);

            var sum = 0;
            foreach(var ch in list)
            {
                sum += ch;
            }

            if (m < sum)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
            
        }
        
    }
}


Measured memory_bytes: 13152
#include<bits/stdc++.h>
    #include <ext/pb_ds/tree_policy.hpp> 
    #include <functional> // for less 
    using namespace __gnu_pbds; 
    using namespace std;
    //typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;    
    #define ll            long long
    #define pb            push_back
    #define ppb           pop_back
    #define si            set <ll>
    #define endl          '\n'
    #define fr            first
    #define sc            second
    #define mii           map<ll ,ll >
    #define msi           map<string,ll >
    #define mis           map<ll , string>
    #define rep(i,a,b)    for(ll  i=a;i<b;i++)
    #define all(v)        v.begin(),v.end()
    //#define sort(v)       sort(all(v))
    #define pii           pair<ll ,ll >
    #define vi            vector<ll >
    #define vii           vector<pair<ll , ll >>
    #define vs            vector<string>
    #define sz(x)         (ll)x.size()
    #define M             1000000007
    #define bs            binary_search
    #define rev(a)        reverse(all(a));
    #define sp(n)         setprecision(n)
    #define spl           " "
    #define arr(a,n)      rep(i,0,n) cin>>a[i]
    #define mod           998244353
    #define print_vector(a)  for(auto t:a) cout<<t<<" ";cout<<endl;
    #define print_arr(a,n)   rep(i,0,n) cout<<a[i]<<" "; cout<<endl;        
    #define show(a,n)     for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
    #define N             100000000
    #define debug(x)      cout << #x << " is " << x << endl;
    #define time          cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    #define INF           1ll<<31
    #define M_PI 3.14159265358979323846
    using namespace std;
    ll min(ll a,ll b)
    {
        return a>b?b:a;
    }
    ll max(ll a,ll b)
    {
        return a>b?a:b;
    }
    const ll maxn=2e5+500;
    void solve()
    {
        ll n;
        cin>>n;
        vii a(n);
        rep(i,0,n)
        {
            cin>>a[i].fr;
            a[i].sc=i+1;
        }
        sort(a.begin(),a.end(),greater<pii>());
        vector<std::vector<ll>> dp(n+1,vector<ll>(n+1,0));
        rep(i,1,n+1)
        {   
            rep(j,0,i)
            {
                ll l=j;
                ll r=i-1-j;
                dp[l+1][r]=max(dp[l+1][r],dp[l][r]+abs(l+1-a[i-1].sc)*a[i-1].fr);
                dp[l][r+1]=max(dp[l][r+1],dp[l][r]+abs(n-r-a[i-1].sc)*a[i-1].fr);
                r=j;
                l=i-1-j;
                dp[l+1][r]=max(dp[l+1][r],dp[l][r]+abs(l+1-a[i-1].sc)*a[i-1].fr);
                dp[l][r+1]=max(dp[l][r+1],dp[l][r]+abs(n-r-a[i-1].sc)*a[i-1].fr);
            }
        }
        ll ans=0;
        rep(i,0,n+1)
        {
            ans=max(ans,dp[i][n-i]);
        }
        cout<<ans<<endl;
        

       

    }
    signed main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        ll t=1;
        //cin>>t;
        while(t--) solve();
    }


Measured memory_bytes: 34560
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <map>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;

int main()
{
	vi isprime(100000, 1);
	isprime[0] = isprime[1] = 0;
	reep(i, 2, 500){
		if(isprime[i]){
			for(int j=i*2; j<100000; j+=i)
				isprime[j] = 0;
		}
	}

	vi prime;
	rep(i, isprime.size())
		if(isprime[i])
			prime.push_back(i);

	int n;
	while(scanf("%d", &n) != EOF){
		vi::iterator itr = lower_bound(prime.begin(), prime.end(), n);
		printf("%d %d\n", *(itr-1), *(itr+binary_search(prime.begin(), prime.end(), n)));
	}

	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void){
	int i,j,k,X,cnt=0;
	
	scanf("%d %d %d",&i,&j,&k);
	for(X=i;X<=j;X++){
		if(k%X==0)
			cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <iomanip>
#include<queue>
#include<set>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
//#define INF 1844674407370955161
typedef long long int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}


int N;
string S;
vector<vector<int>> li;
vector<int> siz;
bool judge(int len){
	map<string,int> s;
	string now=S.substr(0,len);
	REP(i,0,N-len+1){
		if(s.find(now)!=s.end()){
			int t=s.find(now)->second;
			if(t+len<=i){
				return true;
			}
		}else{
			s[now]=i;
		}
		now=S.substr(i+1,len);
	}
	return false;
}



template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}
int main()
{
	int N,M;
	cin>>N>>M;
	WeightedGraph<ll > g(N);
	REP(i,1,N){
		g[i].emplace_back(i-1,0);
	}
	REP(i,0,M){
		int a,b;
		ll c;
		cin>>a>>b>>c;
		a--;b--;
		g[a].emplace_back(b,c);
		g[b].emplace_back(a,c);
	}
	ll dist =dijkstra(g, 0)[N-1];
    if(dist == numeric_limits< ll >::max()) puts("-1");
    else cout<<dist<<endl;
  	

	return 0;
}

Measured memory_bytes: 13048
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        int res = 0;
        for(int i = a; i<=b; i++) {
            String s1 = Integer.toString(i);
            String s2 = new StringBuilder(s1).reverse().toString();
            if(s1.equals(s2)) res++;
        }

        System.out.println(res);
    }

}


Measured memory_bytes: 38740
#include <iostream>
#include <vector>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;

const int MAX_N = 100005;
int a[MAX_N];
int N;

void solve()
{
	sort(a, a+N);
	ll ans = 0;
	for(int i=0;i<N;++i){
		if(!i || a[i]>a[i-1]){ 
			ll total = (i==0? a[i] : a[i]-a[i-1]);
			if(total%2) ans ^= (N-i);
		}
	}
	if(!ans) cout << "second" << endl;
	else cout << "first" << endl;
}

int main()
{
	cin >> N;
	for(int i=0;i<N;++i) cin >> a[i];
	solve();
	return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n;
    cin >> n;
    vector< int > v;
    for( int i = 0; i < n; ++i ) {
        int a;
        cin >> a;
        v.pb(a);

    }

    int mx = v[0];
    int cnt = 1;
    for( int i = 1; i < n; ++i ) {
        if( mx > v[i] ) ++cnt;
        mx = min(mx, v[i]);
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

 
int main(){  
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(),a.end());
  if(a[0]%2==a[1]%2 && a[1]%2==a[2]%2){ cout << (a[2]+a[2]-a[1]-a[0])/2<< endl; return 0;}

  if(a[0]%2==a[1]%2){a[0]++; a[1]++;}
  if(a[0]%2==a[2]%2){a[0]++; a[2]++;}
  if(a[1]%2==a[2]%2){a[1]++; a[2]++;}
  cout << (a[2]+a[2]-a[1]-a[0])/2+1 << endl; return 0;
}

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

int main() {
 	long long n, m, sum = 0;
  	cin >> m >> n;
  	long long a[n];
  	for(long long i = 0; i < n; i++) {
		cin >> a[i];
      	sum += a[i];
    }
  	if(sum > m) {
     	cout << -1 << endl;
    }
  	else {
      	cout << m - sum << endl;
    }
  	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
// using ll = boost::multiprecision::int128_t;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;


int main() {
  cout << "? " << ll(1e+10) << "\n" << flush;
  char c; cin >> c;

  // N = 10^k の場合
  if (c == 'Y') {
    int i = 1;
    ll n = 10;
    for (; i < 11; ++i) {
      cout << "? " << (n-1) << "\n" << flush;
      char c; cin >> c;
      if (c == 'Y') {
        cout << "! " << (n/10) << "\n" << flush;
        return 0;
      }
      n *= 10;
    }
  }

  // 以下 N = 10^k でない場合
  // N の桁数を調べて d とする
  int d = 0;
  ll n = 1;
  for (; d < 10; ++d) {
    cout << "? " << n << "\n" << flush;
    char c; cin >> c;
    if (c == 'N') break;
    n *= 10;
  }

  // ここまでは正しいことを確認済み (これより下のみを書き換えたら AC した)


  // 上位 d-1 桁を上から順に特定
  ll ans = 0;
  rep(i, d-1) {
    int ok = 0;
    int ng = 10;
    while (abs(ok-ng) > 1) {
      int md = (ok+ng)/2;
      ll n = 10 * ans + md;
      cout << "? " << n << "\n" << flush;
      char c; cin >> c;
      if (c == 'Y') ok = md;
      else ng = md;
    }
    ans = 10 * ans + ok;
  }

  // 最後の 1 桁を特定
  rep(i, 10) {
    if (d == 1 && i == 0) continue;
    ll n = (10 * ans + i) * 10;
    cout << "? " << n << "\n" << flush;
    char c; cin >> c;
    if (c == 'Y') {
      cout << "! " << (n/10) << "\n" << flush;
      return 0;
    }
  }
}


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

int main(){
    int n, m, in;
    cin >> n >> m;
    vector<int> ns(0);
    ll ans = 0;
    rep(i, n){
        cin >> in;
        ans += in;
        while(in != 0){
            ns.push_back(in-in/2);
            in /= 2;
        }
    }
    sort(ns.begin(), ns.end());
    reverse(ns.begin(), ns.end());
    for(int i=0; i<m; i++){
        if(ns.size() == i) break;
        ans -= ns.at(i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 18792
#include <iostream>
#include <string>
#include <deque>
#include <algorithm>

using namespace std;

int binarySearch(int n, deque<int> s, int q, deque<int> t) {
    int result = 0;
    for (const int i : t) {
        if (binary_search(s.begin(), s.end(), i)) {
            ++result;
        }
    }
    return result;
}

int main(int argc, char* argv[]) {
    deque<int> s;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        s.push_back(x);
    }
    deque<int> t;
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int x;
        cin >> x;
        t.push_back(x);
    }
    cout << binarySearch(n, s, q, t) << endl;

    return 0;
}



Measured memory_bytes: 4156
#include <bits/stdc++.h>
using namespace std ;
#define An setprecision(16) 
int main(){
    int A[3];
    cin >> A[0]>>A[1]>>A[2];
    sort(A,A+3);
    int count =0;
    while(A[1]<A[2]){
        A[0]++;A[1]++;count++;
    }
    while(A[0]<A[1]){
        A[0]+=2;count++;
    }
    if(A[0]==A[1]){
        cout << count << endl;
    }else{
        count++;
        cout << count <<endl;
    }

}

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

const int N = 8000000;

int main() {
    int m, n;
    while (cin >> m >> n, m or n) {
        bool flag[N];
        rep(i, N) flag[i]=false;
        int cnt=0;
        int mm=m;
        rep(i, n) {
            for (; flag[m]; ++m) {}
            flag[m] = true;
            for (int j=m*2; j<N; j+=m) {
                flag[j] = true;
            }
            ++m;
        }
        for (int i=m; i<N; ++i) {
            if (!flag[i]) {
                cout << i << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 10896
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

vector<int> erat(int n) {
    vector<int> primes(n);
    for (int i = 2; i < n; ++i) primes[i] = i;
    for (int i = 2; i*i < n; ++i)
        if (primes[i])
            for (int j = i*i; j < n; j+=i) primes[j] = 0;
    // ?´???°?????????vector???????´?????????´????????\?????????????????? (0 ??§??????????´??????¨??????)
    primes.erase(remove(primes.begin(), primes.end(), 0), primes.end());
    return primes;
}

vector<int> primes;

signed main() {
    primes = erat(100010);
    int m, a, b;
    while(cin >> m >> a >> b, m||a||b) {
        int lim = upper_bound(primes.begin(), primes.end(), m) - primes.begin();
        // printf("debug: lim = %lld\n", lim);
        int ma = 0, idx_a, idx_b;
        for(int i=0; primes[i]*primes[i]<primes[lim]; i++) {
            for(int j=i; primes[i]*primes[j] <= m && j<lim; j++) {
                int p = primes[i], q = primes[j];
                if(a*q > b*p) break;
                // printf("p = %lld, q = %lld\n", p, q);
                if(ma < p*q) {
                    ma = p*q;
                    idx_a = p, idx_b = q;
                }
            }
        }
        printf("%lld %lld\n", idx_a, idx_b);
    }
    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  int sum = 0;
  rep(i, N) {
    cin >> A.at(i);
    sum += A.at(i);
  }
  sort(A.begin(), A.end());
  if (A.at(N - M) * 4 * M < sum) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define sum accumulate
#define keta fixed<<setprecision
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 998244353LL;
int main(){
	int n;
	std::cin >> n;
	vector<ll>a(n);
	rep(i,n)std::cin >> a[i];
	sort(all(a));
	std::cout << a[0]<<" "<<a[n-1]<<" "<<sum(all(a),0ll) << std::endl;
}


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

typedef long long ll;

const int Maxn = 300005;
const int mod = 998244353;

int n;
char str[Maxn];
int res = 1;

int main()
{
    scanf("%d", &n);
    scanf("%s", str);
    int R = 0, G = 0, B = 0;
    int RG = 0, GB = 0, RB = 0;
    for (int i = 1; i <= n; i++)
        res = ll(res) * i % mod;
    for (int i = 0; i < 3 * n; i++)
        if (str[i] == 'R')
            if (GB > 0) { res = ll(res) * GB % mod; GB--; }
            else if (G > 0) {
                res = ll(res) * G % mod; G--;
                RG++;
            } else if (B > 0) {
                res = ll(res) * B % mod; B--;
                RB++;
            } else R++;
        else if (str[i] == 'G')
            if (RB > 0) { res = ll(res) * RB % mod; RB--; }
            else if (R > 0) {
                res = ll(res) * R % mod; R--;
                RG++;
            } else if (B > 0) {
                res = ll(res) * B % mod; B--;
                GB++;
            } else G++;
        else if (str[i] == 'B')
            if (RG > 0) { res = ll(res) * RG % mod; RG--; }
            else if (R > 0) {
                res = ll(res) * R % mod; R--;
                RB++;
            } else if (G > 0) {
                res = ll(res) * G % mod; G--;
                GB++;
            } else B++;
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 512
open Printf
open Scanf

let () =
  let n, q = scanf "%d %d " (fun x y -> (x, y)) in
  let bl = 300 in
  let ar = Array.make n 2147483647 in
  let blk = Array.make (n / bl + 1) None in
  let wb i = match blk.(i) with
      None -> ()
    | Some v -> let rec iter j =
                  let m = i * bl + j in
                  if j = bl || m = n then blk.(i) <- None
                  else begin
                      ar.(m) <- v;
                      iter (j+1)
                    end in
                iter 0 in
  let find i = match blk.(i / bl) with
      None -> ar.(i)
    | Some v -> v
  in
  let update s t x =
    let rec iter i =
      if i >= t then ()
      else begin
          if i mod bl = 0 && i + bl <= t then begin
              blk.(i / bl) <- Some x;
              iter (i+bl)
            end
          else begin
              begin
                match blk.(i / bl) with
                  None -> ()
                | Some v -> wb (i / bl)
              end;
              ar.(i) <- x;
              iter (i+1)
            end
        end in
    iter s in
  let rec loop i =
    if i = 0 then ()
    else begin
        let com = scanf "%d " (fun x -> x) in
        begin
          if com = 0 then
            let s, t, x = scanf "%d %d %d " (fun x y z -> (x, y+1, z)) in
            update s t x
          else
            let j = scanf "%d " (fun x -> x) in
            find j |> printf "%d\n"
        end;
        loop (i-1)
      end in
  loop q

Measured memory_bytes: 6936
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let N = scan.word::<usize>();

    println!("{}", if N % 1000 == 0 { 0 } else { 1000 - (N % 1000) });
}


Measured memory_bytes: 2128
import sys
import itertools as it

input = sys.stdin.readline

N, M, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

AS = list(it.accumulate([0]+A))
BS = list(it.accumulate([0]+B))
max_value = 0
for i in range(N+1):
    if AS[i] > K:
        continue
    ok, ng = 0, M+1
    while ng - ok > 1:
        mid = (ok + ng) // 2
        time = AS[i] + BS[mid]
        if time <= K:
            ok = mid
        else:
            ng = mid
    num = i + ok
    if num > max_value:
        max_value = num
print(max_value)

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    cin >> a >> b;
    if(a>8||b>8) cout << ":(" << "\n";
    else cout << "Yay!" << "\n";

    return 0;
}

Measured memory_bytes: 3628
cont = True

while cont:
    data = input().split(" ")
    a = int(data[0])
    b = int(data[2])
    op = data[1]
    if op == "?":
        cont = False
    elif op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    else:
        print(int(a/b))

Measured memory_bytes: 7588
from itertools import combinations as comb
import copy

N = int(input())
if N == 1:
    print(1)
else:
    xy = [[int(_) for _ in input().split()] for _ in range(N)]
    xy = sorted(xy, key=lambda x: (x[0],x[1]))
    ans = 50
    cand = list(comb(xy, 2))
    pq = set()
    
    for i in cand:
        pq.add((i[1][0]-i[0][0], i[1][1]-i[0][1]))
    
    
    for i in pq:
        p = i[0]
        q = i[1]
        tmpxy = copy.deepcopy(xy)
        tmp = 0
        while len(tmpxy) > 0:
            tmp += 1
            s = tmpxy.pop(0)
            while [s[0]+p, s[1]+q] in tmpxy:
                tmpxy.remove([s[0]+p, s[1]+q])
                s[0] += p
                s[1] += q
        
        if tmp < ans:
            ans = tmp
    
    print(ans)

Measured memory_bytes: 3688
/*
क्षमाशील हो रिपु-समक्ष
तुम हुये विनत जितना ही
दुष्ट कौरवों ने तुमको
कायर समझा उतना ही।
*/
#include<bits/stdc++.h>
using namespace std;
 
#define int                 long long int
#define ull                 unsigned int
#define ld                  long double
#define pb                  push_back
#define ff                  first
#define ss                  second
#define S(arr)              sort(arr.begin(),arr.end());
#define all(p)              p.begin(), p.end()
#define RS(arr)             sort(arr.rbegin(),arr.rend());
#define R(arr)              reverse(arr.begin(),arr.end());
#define pii                 pair <int, int>
#define vpi                 vector <pii>
#define vi                  vector <int>
#define vld                 vector <ld>
#define vvi                 vector <vector <int>>
#define vvpi                vector <vector <pii>>
#define vs                  vector <string>
#define si                  set <int>
#define spi                 set <pii>
#define setbits(x)          __builtin_popcountll(x)
#define zrobits(x)          __builtin_ctzll(x)
#define mii                 map <int, int>
#define mci                 map<char, int>
#define mpi                 map <pii, int>
#define T                   int tcf;cin>>tcf;while(tcf--)
#define que_max(t)          priority_queue <t>
#define que_min(t)          priority_queue <t, vector<t>, greater<t>>
#define endl                "\n"
#define dba(a, l, r)        for(auto x:a)cout<<x<<" ";cout<<endl;
#define db1(x)              cout << #x " = " << x << endl;
#define db2(x,y)            cout << #x " = " << x << " " << #y " = " << y << endl;
#define db3(x,y,z)          cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define db4(x,y,z,w)        cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << " " << #w " = " << w << endl;
#define db5(x,y,z,w,v)      cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << " " << #w " = " << w << " " << #v " = " << v << endl;
#define db6(x,y,z,w,v,a)    db3(a, y, x)db3(w, v, a)
#define p2d(v)              for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)              for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppi(v)              for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;

// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;  
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//  // *( hsh.find_by_order(k) ) kth smallest, from 0
//  // hsh.order_of_key(k) num of ele str less than k
//  // change less to less_equal for multiset pbds
 
void read(int n=10){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<setprecision(n)<<fixed;
   
}
 
int M = 1e9 + 7;
int M1 = 998244353;
#define qqq 4000005
#define pi 3.14159265358979323851



int32_t main(){
    read();
    int n;
    cin>>n;
    vi arr(n);
    vvi graph(n+1);
    for(int i=1;i<n;i++){
        cin>>arr[i];
        graph[arr[i]].pb(i+1);
    }
    for(int i=1;i<=n;i++)
        cout<<graph[i].size()<<endl;
}  

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    for (int i=0; i<s.length(); i+=2)
    {
      cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
#include "atcoder/all"
typedef long long int ll;
using namespace std;
using namespace atcoder;
int main() {
    int t;
    cin >> t;
    vector<ll> ans;
    for (int i = 0; i < t; i++) {
        ll n, m, a, b;
        cin >> n >> m >> a >> b;
        ans.push_back(floor_sum(n, m, a, b));
    }
    for (int i = 0; i < t; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4344
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let n: usize = read_line().trim().parse().unwrap();
    let mut h: Vec<i32> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let mut ans = true;

    for i in (0..n-1).rev() {
        if h[i] - h[i+1] > 1 {
            ans = false;
            break;
        } else if h[i] - h[i+1] > 0 {
            h[i] -= 1;
        }
    }


    if ans {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

void add(long& res, int left_sum, string str_right_most) {
    res += left_sum + stol(str_right_most);
    if (str_right_most.size() > 1) {
        for (int i = 1; i < str_right_most.size(); i++) {
            string str1 = str_right_most.substr(0, i);
            string str2 = str_right_most.substr(i);
            add(res, left_sum + stoi(str1), str2);
        }
    }
}

int main() {
    string s;
    cin >> s;

    long res = 0;

    add(res, 0, s);

    cout << res << endl;
    return 0;
}

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

long long countOfSubarrays(vector<int> &arr)
{
    int n = arr.size();
    vector<vector<int>> bitPos(20, vector<int>(n));
    for (int bit = 0; bit < 20; bit++)
    {
        for (int i = 0; i < arr.size(); i++)
        {
            bitPos[bit][i] = ((arr[i] >> bit) & 1);
        }
    }

    vector<vector<int>> dp(n, vector<int>(20));
    vector<int> maxRange(n, n);
    for (int bit = 0; bit < 20; bit++)
    {
        int lastIdx = n;
        
        for (int i = n - 1; i >= 0; i--)
        {
            if (bitPos[bit][i])
            {
                dp[i][bit] = lastIdx;
                lastIdx = i;
            }
            else
            {
                if (i == n - 1)
                    dp[i][bit] = n;
                else
                {
                    dp[i][bit] = dp[i + 1][bit];
                }
            }
            maxRange[i] = min(maxRange[i], dp[i][bit]);
        }
   }
    long long reqCnt = 0;
    for (int i = 0; i < n; i++)
    {
        reqCnt += maxRange[i] - i;
    }

   return reqCnt;
}

void solve()
{

    int n;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    long long ans = countOfSubarrays(arr);
    cout << ans << endl;
}
int main()
{
    solve();
}


Measured memory_bytes: 43888
#include<iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
    int N;
    cin >> N;
    int H[N];
    int ans = 0;

    for(int i = 0; i < N; i++){
        cin >> H[i];
        int j = 0;
        while(j <= i){
            if(H[j] > H[i]) break;
            if(j == i) ans++;
            j++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
denq = []
for _ in range(m):
    ks = tuple(map(lambda x: int(x)-1, input().split()))
    denq.append(ks[1:])
P = tuple(map(int, input().split()))

ans = 0
for i in range(2**n):
    kk = [0] * m
    switch_states = [(i>>j)&1 for j in range(n)]
    for idq, dq in enumerate(denq):
        counts = 0
        for s in dq:
            counts += switch_states[s]
        if counts%2 != P[idq]:
            break
    else:
        ans += 1
print(ans)


Measured memory_bytes: 70896
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            // 写経…
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = l[0], B = l[1], C = l[2], D = l[3], E = l[4], F = l[5];
            var water = 0;
            var sugar = 0;

            for (var a = 0; a * A * 100 <= F; a++)
            {
                for (var b = 0; (a * A + b * B) <= F; b++)
                {
                    var wTmp = a * A + b * B;

                    for (var c = 0; c * C <= E * wTmp; c++)
                    {
                        for (var d = 0; c * C + d * D <= E * wTmp; d++)
                        {
                            var sTmp = c * C + d * D;

                            if (F < wTmp * 100 + sTmp) break;
                            if (p(sugar, water * 100) <= p(sTmp, wTmp * 100))
                            {
                                water = wTmp;
                                sugar = sTmp;
                            }
                        }
                    }
                }
            }

            Console.WriteLine($"{water*100+sugar} {sugar}");
        }

        static double p(double s, double w)
        {
            if (s + w == 0) return 0;
            else return 100 * s / (s + w);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define M_PI 3.14159265358979323846
int const N=200009;
vector<int>adj[N];
bool visited[N];
vector<int> bin;
int dp[N];

void dfs(int v)
{
  visited[v]=1;
  for(int u:adj[v])
  {
    if(!visited[u])dfs(u);
  }
  bin.push_back(v);
}
int main()
{
// clock_t begin = clock();
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
tani_nachi_ke  

int n,m;
cin>>n>>m;
int aa,bb;
for(int i=0; i<m; i++)
{
  cin>>aa>>bb;
  aa--,bb--;
  adj[aa].push_back(bb);
}
for(int i=0; i<=n-1; i++)
{
  if(!visited[i])dfs(i);
}

reverse(bin.begin(),bin.end());
int ans=0;
for(int v:bin)
{
  for(int u:adj[v])
  {
    if(dp[u]<dp[v]+1)dp[u]=dp[v]+1;
    ans=max(dp[u],ans);
  }
}
cout<<ans<<endl;

// #ifndef ONLINE_JUDGE 
// clock_t end = clock();
// cout<<endl<<double(end - begin) / CLOCKS_PER_SEC*1000<<" ms";
// #endif 
// return 0;
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){

	int N, A, B; cin >> N >> A >> B;

	int d = B - A;
	if(d%2 == 0) cout << "Alice" << endl;
	else cout << "Borys" << endl;


	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int unsigned long long
int a[100005];
signed main(){
	int n,prod=1;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]==0){
			cout<<'0';
			return 0;
		}
	}
	for(int i=0;i<n;i++){
		if(a[i]<=1000000000000000000/prod)
			prod*=a[i];
		else{
			cout<<"-1";
			return 0;
		}
	}
	cout<<prod;
    return 0;
}

Measured memory_bytes: 4344
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8
@njit((i8[:],i8[:],i8[:],i8[:]), cache=True)
def main(lis_h,lis_w,bomb_h,bomb_w):
  bomb = {}
  for h,w in zip(bomb_h,bomb_w):
    bomb[(h,w)] = 1
  max_h = np.where(lis_h==lis_h.max())[0]
  max_w = np.where(lis_w==lis_w.max())[0]
  ans = lis_h.max()+lis_w.max()
  for h in max_h:
    for w in max_w:
      if (h,w) not in bomb:
        return ans
  return ans-1

H, W, M = map(int, input().split())
bombh = np.zeros(M, np.int64)
bombw = np.zeros(M, np.int64)
lis_h = np.zeros(H, np.int64)
lis_w = np.zeros(W, np.int64)
for i in range(M):
    h,w = map(int, input().split())
    h -= 1
    w -= 1
    bombh[i], bombw[i] = h,w
    lis_h[h] += 1
    lis_w[w] += 1
max_h = np.where(lis_h==lis_h.max())
max_w = np.where(lis_w==lis_w.max())
print(main(lis_h,lis_w,bombh,bombw))


Measured memory_bytes: 140656
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int a, b, c;
    cin >> a >> b >> c;
    if(b-a == c-b) cout << "YES" << std::endl;   
    else cout << "NO" << std::endl;
    return 0;
}

Measured memory_bytes: 768
use proconio::fastout;
use whiteread::parse_line;

#[fastout]
fn main() {
    let (x, y, z): (usize, usize, usize) = parse_line().unwrap();
    if x == y && y == z {
        println!("1");
    } else if x == y || y == z || z == x {
        println!("2");
    } else {
        println!("3");
    }
}


Measured memory_bytes: 2152
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] a = new int[3];
    a[0] = sc.nextInt();
    a[1] = sc.nextInt();
    a[2] = sc.nextInt();
    Arrays.sort(a);
    System.out.println(a[2] - a[1] + a[1] - a[0]);
  }
}

Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n,k[1000];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>k[i];
  }
  sort(k,k+n);
  
  cout<<k[n-1]-k[0]<<endl;
}

Measured memory_bytes: 256
//created by missever

#include<bits/stdc++.h>
#define MAX 1000000007
using namespace std;
typedef long long LL;

const int maxn = 1e5 + 5;
vector<int> g[maxn];

int dfs(int u,int fa) {
    int t = 0;
    int k[4];
    k[0] = k[1] = k[2] = k[3] = 0;
    for(auto v:g[u]) {
        if(v == fa) continue;
        t++;
        k[dfs(v,u)]++;
    }
    if(t == 0) return 1;
    if(k[3]) return 3;
    if(k[2] == t) return 1;
    if(k[1] > 1) return 3;
    if(k[1] == 1) return 2;
    return 0;
}

int main() {
    int n,i,u,v;
    scanf("%d",&n);
    for(i = 1; i < n; i++) {
        scanf("%d%d",&u,&v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for(i = 1; i <= min(n,100); i++) {
        u = dfs(i,0);
        if(u == 1 && g[i].size() == 1) u = 3;
        if(u == 3)
        {
            printf("First\n");
            return 0;
        }
    }
    printf("Second\n");
    return 0;
}


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

char field[21][21];
char visit[21][21];
int dx[]= {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int W, H;
void dfs(int y, int x) {
    visit[y][x] = 1;
    rep(i, 4) {
        int ny = y+dy[i];
        int nx = x+dx[i];
        if(field[ny][nx] == '.' && visit[ny][nx] == 0 &&
               nx >= 0 && nx < W && ny >= 0 && ny < H) {
            dfs(ny, nx);
        }
    }
}
int main(void){
    while(cin >> W >> H && W) {
        int y, x;
        rep(i, H) rep(j, W){
            cin >> field[i][j];
            if(field[i][j] == '@') y = i, x = j;
        }
        memset(visit, 0, sizeof(visit));
        dfs(y, x);
        int ans = 0;
        rep(i, H) rep(j, W){
            ans += visit[i][j];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1168
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
typedef pair<LL, LL> P;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,m,i,j;
	cin>>n;
	m=n*3;
	int a[m]={},a1[n]={},a2[n]={},a3[n]={};
	FOR(i,0,m){
		//cin>>a[i];
		if(i<m/3)cin>>a1[i];
		else if(i<m*2/3)cin>>a2[i-m/3];
		else cin>>a3[i-m*2/3];
	}
	//sort(a1,a1+n);
	//sort(a3,a3+n);
	priority_queue<int,vector<int>,greater<int>> q1;
	priority_queue<P,vector<P>,greater<P>> q33;
	long pll=0,mnn=0;
	FOR(i,0,n){
		pll+=a1[i];
		//mnn+=a3[i];
		q1.push(a1[i]);
		q33.push(P(a2[i],i));
		q33.push(P(a3[i],n+i));
	}
	int loc[2*n]={};
	FOR(i,0,n){
		P p=q33.top();
		mnn+=p.ST;
		loc[p.ND]=p.ST;
		q33.pop();
	}
	long max=pll-mnn;
	//cout<<pll<<" "<<mnn<<" "<<max<<endl;
	long pl=pll,mn=mnn;
	FOR(i,0,n){

		//priority_queue<int,vector<int>,greater<int>> q1(q11);
		if(loc[i]!=0){
			while(!q33.empty()){
			P p=q33.top();
			q33.pop();
			if(p.ND<=i)continue;
			mn+=p.ST-a2[i];
			loc[p.ND]=p.ST;
			loc[i]=0;
			break;
		}
		}

		q1.push(a2[i]);
		int tmp=q1.top();
		q1.pop();
		pl+=a2[i]-tmp;

		if(max<pl-mn)max=pl-mn;
	}
	cout<<max<<endl;

    return 0;
}


Measured memory_bytes: 9328
#include<bits/stdc++.h>
using namespace std;
 
int n, k;
int A[120];
vector<int> G[100050];
int grundy[100050];

int solve(int x)
{
	assert(x >= 0);
	if(~grundy[x]) return grundy[x];
	set<int> S;
	for(int i = 0; i < n; i++)
		if(x - A[i] >= 0)
			S.insert(solve(x - A[i]));		
	int m = 0;
	while(S.count(m)) m++;
	return grundy[x] = m;
}

int main()
{
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> A[i];
	memset(grundy, -1, sizeof(grundy));	
	puts(solve(k) ? "First" : "Second");

	return 0;	
}


Measured memory_bytes: 15488
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
 
public class Main {
    public static void main(String[] args) {
        printAnswer();
    }
 
    private static void printAnswer() {
        Logger logger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
 
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            List<Integer> trainList = new ArrayList<>();
            String dataset = br.readLine();
            int p = 0;
            
            while (dataset != null) {
                int integer = Integer.parseInt(dataset);
                if(integer != 0){
                    trainList.add(integer);
                    p++;
                }else{
                    System.out.println(trainList.get(p-1));
                    trainList.remove(p-1);
                    p--;
                }
                dataset = br.readLine();
            }
        } catch (IOException e) {
            logger.info("Error:  Reading input data is failed.");
        }
    }
}

Measured memory_bytes: 24624