akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<cstdio>
#include<math.h>
#include<bitset>
#include<algorithm>
#include<iomanip>
#include<list>
#include<set>
#include<utility>
using namespace std;

//repetition
//------------------------------------------

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
//#define INF (1 << 30)
#define pii pair<int, int>

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

static const int INF = 1000000010;
string s[510];


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

  if(a+b>=c){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



ll N,M;
vector<ll> X,Y;


int main(){

	scanf("%lld %lld",&N,&M);

	ll tmp;
	for(ll i = 0; i < N; i++){

		scanf("%lld",&tmp);
		X.push_back(tmp);
	}
	for(ll i = 0; i < M; i++){

		scanf("%lld",&tmp);
		Y.push_back(tmp);
	}
	sort(X.begin(),X.end());
	sort(Y.begin(),Y.end());

	ll sum_X = 0;
	ll minus,plus;

	for(ll i = 0; i < N; i++){

		sum_X += X[i]*i-X[i]*((N-1)-i);
	}
	sum_X %= MOD;

	ll sum_Y = 0;

	for(ll i = 0; i < M; i++){

		sum_Y += Y[i]*i-Y[i]*((M-1)-i);
	}
	sum_Y %= MOD;

	printf("%lld\n",(sum_X*sum_Y)%MOD);

	return 0;
}


Measured memory_bytes: 2548
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N, A, B = getNM()
V = sorted(getList(), reverse = True)

print(sum(V[:A]) / A)

dict = defaultdict(int)
for i in range(N):
    dict[V[i]] += 1

r = A
n = 0
for i in dict.items():
    if r - i[1] >= 0:
        r -= i[1]
    else:
        n = i[1]
        break

def cmb_1(n, r):
    r = min(n - r, r)
    if (r < 0) or (n < r):
        return 0
        
    if n == 0:
        return 1

    if r == 0:
        return 1

    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under

ans = 0
if r > 0 and V[0] == V[A - 1]:
    for i in range(r, B + 1):
        ans += cmb_1(n, i)
else:
    ans += cmb_1(n, r)

print(ans)

Measured memory_bytes: 77868
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
	unsigned long long n,a,b,x[100000]={0},ans;
	cin>>n>>a>>b;
	for(int i=0;i<n;i++) cin>>x[i];
	
	for(int i=1;i<n;i++){
		unsigned long long d=(x[i]-x[i-1])*a;
		if(d<=b){
			ans+=d;
		}else{
			ans+=b;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
/*
क्षमाशील हो रिपु-समक्ष
तुम हुये विनत जितना ही
दुष्ट कौरवों ने तुमको
कायर समझा उतना ही।
*/
#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 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;
//    #ifndef ONLINE_JUDGE
  //       freopen("input.txt",  "r",  stdin);
    //     freopen("output.txt", "w", stdout);
   // #endif
}
 
int M = 1e9 + 7;
int M1 = 998244353;
#define qqq 4000005
#define pi 3.14159265358979323851



int32_t main(){
    read();
    string str;
    cin>>str;
    mii freq;
    for(auto a:str)
        freq[a]++;
    if(freq.size()==1){
        cout<<"No";
    }else
        cout<<"Yes";
}  

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<sstream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=2000+10;
ll n,m;

int main(){
    scanf("%lld%lld",&n,&m);
    if(n==1)
    {
        if(m==1)
        {
            printf("1\n");
        }
        else
        {
            printf("%lld\n",m-2);
        }
    }
    else if(m==1)
    {
        if(n==1)
        {
            printf("1\n");
        }
        else
        {
            printf("%lld\n",n-2);
        }
    }
    else
    {
        printf("%lld\n",n*m-2*n-2*m+4);
    }
    return 0;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    n=parseInt(readline())
    a=[0 for i in 1:n]
    xy=[[-1 for i in 1:n] for j in 1:n]
    for i in 1:n
        a[i]=parseInt(readline())
        for j in 1:a[i]
            x,y=parseMap(split(readline()))
            xy[i][x]=y
        end
    end
    ans=0
    for i in 0:(1<<n)-1
        flg=true
        s=bits(i)
        s=s[length(s)-n+1:length(s)]
        for j in 1:n
            if s[j]=='1'
                for k in 1:n
                    if (xy[j][k]==0 && s[k]=='1') || (xy[j][k]==1 && s[k]=='0')
                        flg=false
                        break
                    end
                end
            end
        end
        if flg
            ans=max(ans,sum([parseInt(i) for i in s]))
        end
    end
    println(ans)
end
main()

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

using namespace std;

int solution_bottom_up(const vector<vector<int>>& s)
{
	vector<vector<int>> DP(s.size() + 1, vector<int>(3, 0));
	for (int i = 1; i <= (int)s.size(); i++) {
		for(int j = 0; j < 3; j++) {
			for(int k = 0; k < 3 ; k++) {
				if(j != k)
					DP[i][j] = max(DP[i][j], DP[i-1][k] + s[i-1][k]);
			}
		}
	}
	return max({DP[s.size()][0], DP[s.size()][1], DP[s.size()][2]});
}


int main()
{
	int N;
	cin >> N;
	vector<vector<int>> s(N, vector<int>(3));
	for(int i = 0; i < N; i++) {
		cin >> s[i][0] >> s[i][1] >> s[i][2];
	}
	//cout << "Recursive " << endl << sol_rec(s) << endl;
	cout << solution_bottom_up(s) << endl;

}

Measured memory_bytes: 11136
n=input()
while 1:
	p={}
	for i in range(n):
		t=raw_input().split()
		p[t[0]] = [3*int(t[1])+1*int(t[3]),-i]
	for k,v in sorted(p.items(),key=lambda x:x[1])[::-1]:
		print "%s,%d"%(k,v[0])
	n=input()
	if n==0:break
	print

Measured memory_bytes: 4220
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/

int main() {
	int N;
	cin >> N;
	vector<int>C(N-1);
	vector<int>S(N-1);
	vector<int>F(N-1);
	rep(i, N-1) {
		cin >> C[i] >> S[i] >> F[i];
	}
	int time = 0;
	for (int i = 0; i < N - 1; i++) {
		for (int j = i; j < N - 1; j++) {
			while (!(S[j] <= time && time % F[j] == 0)) {
				time++;
			}
			time += C[j];
		}
		cout << time << endl;
		time = 0;
	}
	cout << 0 << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
constexpr long long int MOD = 998244353;
constexpr long long int power(const long long int base, const int exp) {
	switch (exp) {
	case 0:return 1LL;
	case 1: return base % MOD;
	default: return power(base * base % MOD, exp >> 1)* power(base, exp & 1) % MOD;
	}
}
int main()
{
	int n, s; std::cin >> n >> s;
	std::vector<int> nums(n); for (auto& a : nums) std::cin >> a;
	std::vector<long long int> memo(s + 1, 0);
	memo[0] = power(2, n);
	constexpr long long int inv_2 = power(2, MOD - 2);
	for (const auto a : nums) {
			for (auto sum = s; sum >= a; --sum) {
				memo[sum] += memo[sum - a] * inv_2 % MOD;
				memo[sum] %= MOD;
			}
	}
	std::cout << memo.back() << '\n';
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vi vec[200001];
int x[200001]={};
int dp[200001];

int main() {
	ll a,b;
	cin>>a>>b;
	vector<ll> v;
	ll k=2;
	while(1){
		if(a%b>0){
			ll a1=b;
			b=a%b;
			a=a1;
		}else{
			break;
		}
	}
	while(k<1000001){
		bool flg=true;
		while(flg){
			if(b%k==0){
				v.push_back(k);
				b=b/k;
			}else{
				flg=false;
			}
		}
		k++;
	}
	if(b>1000000)v.push_back(b);
	if(v.size()==0){
		cout<<"1"<<endl;
		return 0;
	}
	ll m=v[0];
	ll r=2;
	rep(i,v.size()-1){
		if(m!=v[i+1]){
			m=v[i+1];
			r++;
		}
	}
	cout<<r<<endl;
	return 0;
}


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

int main(){
  int k,ans;
  string s;
  ans=0;
  cin>>s;
  k=s.size();
  ans+=(15-k);
  for(int i=0;i<k;i++){
    if(s.at(i)=='o'){
    ans+=1;
  }
  }
  if(ans>7){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 256
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
mod=10**9+7
inv_t=[0,1]
factorial=[1,1]
factorial_re=[1,1]
for i in range(2,N+1):
    inv_t.append(inv_t[mod%i]*(mod-mod//i)%mod)
for i in range(2,N+1):
    factorial.append(factorial[i-1]*i%mod)
    factorial_re.append(factorial_re[i-1]*inv_t[i]%mod)

ans=0
for i in range(N-K+1):
    if i==N-K:
        ans+=A[i]
        ans%=mod
        break
    ans+=A[i]*factorial[N-1-i]*factorial_re[K-1]*factorial_re[N-K-i]%mod
    ans%=mod
for i in range(N-K+1):
    if i==N-K:
        ans-=A[N-i-1]
        ans%=mod
        break
    ans-=A[N-i-1]*factorial[N-1-i]*factorial_re[K-1]*factorial_re[N-K-i]%mod
    ans%=mod
print(ans)


Measured memory_bytes: 71848
function smallLarge(){
    var Array = x.split(" ");
    var a = Array[0] -0;
    var b = Array[1] -0;
    if (a < b) console.log("a < b")
    if (a > b) console.log("a > b")
    if (a == b) console.log("a == b")
} 

var x = require('fs').readFileSync('/dev/stdin', 'utf8');

smallLarge(x)


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

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

	if (c - a - b > 0 && 4*a*b < (c-a-b)*(c-a-b)){
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */


int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int64_t n, a , b;
  cin >> n >> a >> b;

  const auto ub = a + b * (n - 1);
  const auto lb = b + a * (n - 1);
  cout << max((int64_t) 0, ub - lb + 1);

  return EXIT_SUCCESS;
}




Measured memory_bytes: 256
n,m = map(int,input().split())

s_L = []

for i in range(m):
    L = list(map(int,input().split()))
    a = min(L)
    b = max(L)

    if a == 1:
        s_L.append(b)
    elif b == n:
        s_L.append(a)

#print(s_L)
if len(set(s_L)) == len(s_L):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")



Measured memory_bytes: 74712
#include<stdio.h>
int main()
{
    int a,b,c;
    
    scanf("%d %d %d",&a,&b,&c);
    
    if(a<b && b<c){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    
    return 0;
}


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

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

  int Z = s.size();
  vector<int> v(Z, 0);
  v[0] = 1;
  if (1 < Z) v[1] = s.at(0) == s.at(1) ? 1 : 2;
  if (2 < Z) v[2] = s.at(1) == s.at(2) ? 2 : v[1] + 1;
  rep(i,3,Z-1) v[i] = s.at(i) == s.at(i-1) ? v[i-3] + 2 : v[i-1] + 1;

  cout << v.back() << endl;
  return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> d(n);
    vector<pair<int, int>> a;
    for (int i = 0; i < n; ++i) {
        cin >> d[i];
        a.push_back(make_pair(d[i], i));
    }
    vector<pair<int, int>> G[n];
    vector<int> u(m), v(m);
    for (int i = 0; i < m; ++i) {
        cin >> u[i] >> v[i];
        --u[i];
        --v[i];
        G[u[i]].push_back(make_pair(v[i], i));
        G[v[i]].push_back(make_pair(u[i], i));
    }
    sort(a.begin(), a.end());
    vector<int> c(n, -1);
    const int M = 1000000000;
    vector<int> ans(m, M);
    for (int i = 0; i < n; ++i) {
        if (c[a[i].second] != -1) continue;
        bool flag = false;
        int foo = -1, tmp = -1;
        for (int j = 0; j < (int)G[a[i].second].size(); ++j) {
            int y = G[a[i].second][j].first;
            if (c[y] != -1) {
                flag = true;
                if (a[i].first != d[y]) {
                    c[a[i].second] = c[y];
                    ans[G[a[i].second][j].second] = a[i].first - d[y];
                } else {
                    c[a[i].second] = c[y] ^ 1;
                    ans[G[a[i].second][j].second] = a[i].first;
                }
                break;
            } else {
                if (foo == -1 || d[foo] > d[y]) {
                    foo = y;
                    tmp = G[a[i].second][j].second;
                }
            }
        }
        if (flag == false) {
            if (d[foo] == a[i].first) {
                c[a[i].second] = 0;
                c[foo] = 1;
                ans[tmp] = d[foo];
                continue;
            } else {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    for (int i = 0; i < n; ++i)
        if (c[i] == 0) cout << 'W';
        else cout << 'B';
    cout << endl;
    for (int i = 0; i < m; ++i)
        cout << ans[i] << endl;
    return 0;
}



Measured memory_bytes: 14324
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        if(b>c&&c%Euclid(a,b)==0){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
        private static int Euclid(int n, int m) {
        int tmp;
        while (true) {
            if (n == 0) {
                return m;
            } else if (m == 0) {
                return n;
            }
            tmp = n;
            n = m;
            m = tmp;
            n = n % m;

        }

    }
}

Measured memory_bytes: 23892
n = int(input())
s = str(input())

r = 0
l = 0
for i in range(n):
    if r <= 0:
        if s[i] == ')':
            l += 1
        else:
            r += 1
    else:
        if s[i] == ')':
            r -= 1
        else:
            r += 1
result = '('*abs(l) + s + ')'*abs(r)

print(result)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<set>
#include<unordered_set>
#include<string>
#include<stack>
#include<algorithm>
#include<limits.h>

using namespace std;

class Dsu{
private:
    vector<int> parent;
    vector<int> sz;

public:
    Dsu(int n){
        parent = vector<int>(n);
        sz = vector<int>(n);
        for(int i = 0; i < n; ++i){
            this->parent[i] = i;
            this->sz[i] = 1;
        }
    }

    bool uni(int x,int y){
        int x1 = find(x);
        int y1 = find(y);
        if(x1 == y1) return true;
        if(sz[x1] > sz[y1]){
            parent[y1] = x1;
            sz[x1] += sz[y1];
        }else{
            parent[x1] = y1;
            sz[y1] += sz[x1];
        }
        return true;
    }

    int length(int x){
        return this->sz[x];
    }

    int find(int x){
        while(x != parent[x]){
            x = parent[x];
        }
        return x;
    }
};

void slove(){
    int n,m;
    int x,y;
    int ans = 0;
    cin>>n>>m;
    Dsu du(n);

    for(int i = 0; i < m; ++i){
        cin>>x>>y;
        du.uni(x-1,y-1);
    }
    for(int i = 0; i < n; ++i){
        int p = du.find(i);
        ans = max(ans,du.length(p));
    }
    cout<<ans<<endl;
}

int main(){
    slove();
}


Measured memory_bytes: 4816
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long M = sc.nextLong();
    if(N * 2 >= M){
      System.out.println(M / 2);
    }else{
      System.out.println(N + (M - N * 2)/ 4);
    }
  }
}

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

int main(){
    int n;
    cin >> n;
    set<pair<int,int>,greater<pair<int,int>>> ss;
    for(int i=0;i<(1<<n);++i){
        int s;
        cin >> s;
        ss.emplace(s, i);
    }
    vector<int> gen;
    gen.push_back(ss.begin()->first);
    ss.erase(ss.begin());
    for(int i=0;i<n;++i){
        for(int j=0;j<(1<<i);++j){
            int p = gen[j];
            auto c = ss.upper_bound({p,0});
            if(c==ss.end()){
                cout << "No" << endl;
                return 0;
            }
            gen.push_back(c->first);
            ss.erase(c);
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 13820
#include<stdio.h>

int main(void){
	unsigned long long n, m;
	unsigned long long ans = 1;
	scanf("%llu%llu", &n, &m);
	if(n > m + 1 || n < m - 1) printf("0\n");
	else if(n == m){
		for(unsigned long long i = 1; i <= n; i++) ans = ans * i % 1000000007;
		ans = ans * ans % 1000000007;
		ans = ans * 2 % 1000000007;
		printf("%llu\n", ans);
	}else{
		for(unsigned long long i = 1; i <= n; i++) ans = ans * i % 1000000007;
		for(unsigned long long i = 1; i <= m; i++) ans = ans * i % 1000000007;
		printf("%llu\n", ans);
	}
return 0;
}

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

const ll mod = 1e9 + 7;
int a[105];
ll DP[105][100005];
ll sum[100005];
int K;
int N;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> K;
    for(int i = 1; i <= N; ++i){
        cin >> a[i];
    }
    DP[0][0] = 1;
    for(int i = 1; i <= N; ++i){
        sum[0] = DP[i - 1][0];
        for(int j = 1; j <= K; ++j){
            sum[j] = (sum[j - 1] + DP[i - 1][j]) % mod;
        }
        for(int j = 0; j <= K; ++j){
            //DP[i][j] = DP[i - 1][j] + ... + DP[i - 1][max(0 , j - a[i])]
            if(j - a[i] > 0){
                DP[i][j] = (sum[j] - sum[j - a[i] - 1] + mod) % mod;
            }
            else{
                DP[i][j] = sum[j];
            }
        }
    }
    cout << DP[N][K] << endl;
}


Measured memory_bytes: 79360
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = inp()
aa = inpl()
aa.sort()
MAX = aa[-1]
dist = INF
for a in aa:
	tmp = abs(MAX/2-a)
	if tmp < dist:
		dist = tmp
		ans = a

print(MAX,ans)


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

long long dp[2005][2005];
int main() {
  int n;
  cin>>n;
  long long a[n];
  for (int i=0; i<n; i++) cin>>a[i];
  for (int i=0; i<n+1; i++) {
    for (int j=0; j<n+1; j++) {
      dp[i][j] = 0;
    }
  }
  pair<long long, int> pa[n];
  for (int i=0; i<n; i++) pa[i] = make_pair(a[i], i);
  sort(pa, pa + n);
  reverse(pa, pa + n);
  dp[1][0] = pa[0].first * pa[0].second;
  dp[0][1] = pa[0].first * (n - 1 - pa[0].second);
  for (int i=1; i<n; i++) {
    for (int j=1; j<=i+1; j++) {
      if (pa[i].second >= j - 1) {
        dp[j][i+1-j] = max(pa[i].first * (pa[i].second - j + 1) + dp[j-1][i+1-j], dp[j][i+1-j]);
      }
      if (n - j >= pa[i].second) {
        dp[i+1-j][j] = max(pa[i].first * (n - j - pa[i].second) + dp[i+1-j][j-1], dp[i+1-j][j]);
      }
    }
  }

  long long ans = 0;
  for (int i=0; i<=n; i++) {
    ans = max(dp[i][n-i], ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 35048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;
ll INF = 1e9+10;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
vector<pair<ll, ll> > pairs;

int get_lower_and_upper(int i_min, int i_max, ll *lower, ll *upper)
{
    *lower = pairs[i_max - 1].first;
    *upper = INF;
    for (int i = i_min; i < i_max; i++){
        if (*upper > pairs[i].second){
            *upper = pairs[i].second;
        }
    }
    return 0;
}

const int MAX_N = 1 << 17;


int n;
ll dat[2 * MAX_N - 1];

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

void update(int k, ll a){
    k += n - 1;
    dat[k] = a;
    while(k > 0){
        k = (k - 1)/2;
        dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
}
ll query(int a, int b, int k, int l, int r){

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

bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b)
{
    return (a.first < b.first || (a.first == b.first && a.second >= b.second));
}

int main()
{
    ll N, S, T;
    cin >> N;

    rep(i, N){
        cin >> S >> T;
        pairs.push_back(make_pair(S, T));
    }
    int final = pairs.size();
    // first�����������Asecond�����������Ƀ\�[�g
    sort(pairs.begin(), pairs.end(), cmp);
    
    //for (int b = 0; b < final; b++){
    //    fprintf(stderr, "%d, %d, %d\n", b, pairs[b].first,
    //        pairs[b].second);
    //}
    vector<ll> res(N);
    
    ll l0, u0, l1, u1;
    ll ans = 0, val;
    
    
    init(final);
    for (int b = 0; b < final; b++){    
        update(b, pairs[b].second);
    }
    for (int b = 1; b < final; b++){    
        //get_lower_and_upper(0, b, &cand0_lower, &cand0_upper);
        //get_lower_and_upper(b, final, &cand1_lower, &cand1_upper);
        l0 = pairs[b - 1].first;
        l1 = pairs[final - 1].first;
        u0 = query(0, b, 0, 0, n);
        u1 = query(b, final, 0, 0, n);
        
        val = max(0LL, u0 - l0 + 1) + max(0LL, u1 - l1 + 1);
        //fprintf(stderr, " %d: %d, %d, %d, %d (val =%d)\n", 
        //    b, l0, u0, l1, u1, val);
        if (ans < val){
            ans = val;
        }
        
        
    }
    
    ll maxl = 0;
    int max_b = -1;
    for (int b = 0; b < final; b++){
        if (maxl < pairs[b].second - pairs[b].first + 1){
            maxl = pairs[b].second - pairs[b].first + 1;
            max_b = b;
        }
    }
    l0 = 0;
    u0 = INF;
    for (int b = 0; b < final; b++){
        if (b != max_b){
            l0 = max(l0, pairs[b].first);
            u0 = min(u0, pairs[b].second);
        }
    }
    //fprintf(stderr,"max_b = %d, maxl = %d, %d, %d\n", max_b, maxl, u0, l0);
    val = maxl + max(0LL, u0 - l0 + 1);
    
    ans = max(ans, val);
    
    cout << ans << endl;
    return 0;    
}


Measured memory_bytes: 4592
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pii pair<int,int>
#define pll pair<lli,lli>
#define vi  vector<int>
#define vii vector<pair<int,int>>
#define vll vector<lli>
#define pb  push_back
#define mp  make_pair
#define ss  second
#define ff  first
#define all(x) sort(x.begin(),x.end())
map<int,int>m;
void solve()
{
    int n,k;cin>>n>>k;
    int x,y;cin>>x>>y;
    lli ans=min(n,k);
    ans=ans*x;
    if(k<n)
    {
        int res=n-k;
        ans+=res*y;
    }
    cout<<ans<<endl;

}

int main()
{
    solve();
}


Measured memory_bytes: 3584
using System;

namespace ConsoleApplicationSample
{
    class Program
    {
        static void Main(string[] args)
        {
            for(;;)
            {
                string[] scoreSet = Console.ReadLine().Split();
                int m = int.Parse(scoreSet[0]);
                int f = int.Parse(scoreSet[1]);
                int r = int.Parse(scoreSet[2]);

                if (m == -1 && f == -1 && r == -1) break;

                JudgeResult(m, f, r);
            }
        }

        private static void JudgeResult(int m, int f, int r)
        {
            char evaluation;
            int total = m + f;
            if (m == -1 || f == -1) evaluation = 'F';
            else if (total >= 80) evaluation = 'A';
            else if (total >= 65) evaluation = 'B';
            else if (total >= 50) evaluation = 'C';
            else if (total >= 30) if (r >= 50) evaluation = 'C';
                else evaluation = 'D';
            else evaluation = 'F';

            Console.WriteLine(evaluation);
        }
    }
}

Measured memory_bytes: 19628
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int n;
	while (cin >> n && n) {
		VVI a(n + 1, VI(n + 1));
		rep(i, n)rep(j, n)cin >> a[i][j];
		
		rep(i, n) {
			int sum = 0;
			rep(j, n)sum += a[j][i];
			a[n][i] = sum;
		}
		rep(i, n + 1) {
			a[i][n] = accumulate(all(a[i]), 0);
		}

		rep(i, n + 1){
			rep(j, n + 1)printf("%5d", a[i][j]);
			puts("");
		}
	}
}


Measured memory_bytes: 3052
//I am so vegetable
//#define err
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = acos(-1.0);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
void exgcd(ll a,ll b,ll &x,ll &y){
    if(!b){x=1;y=0;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }

const int N = 2e5+5;
int a[N];
int main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
    #ifdef err
	double be = clock();
    #endif
    int n;cin>>n;
    set<int>st;
    map<int,int>cnt;
    int c1 = 0;
    _for(i,0,n){
        cin>>a[i];
        ++cnt[a[i]];
        st.IN(a[i]);
        if(a[i]==1)++c1;
    }
    int ans = 0;
    if(c1>1)cout<<0;
    else if(n==1||c1==1)cout<<1;
    else{
        _for(i,0,n){
            int flag = 1;
            for(int j = 1;j*j<=a[i];++j){
                if(a[i]%j==0)
                if(st.CT(j)||(j!=1&&st.CT(a[i]/j))||(j==1&&cnt[a[i]]>1)){flag=0;break;}
            }
            if(flag)++ans;
        }
        cout<<ans;
    }
    #ifdef err
	double en = clock();
    cout<<"time: "<<fixed<<setprecision(8)<<en-be;
    #endif
	return 0;
}

Measured memory_bytes: 23084
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 


void solve(){
  int n;
  cin >> n;
  vector<string> v;
  for (int i = 0; i < n; i++){
	   string s;
	   cin >> s;
	   sort(s.begin(), s.end());
	   v.push_back(s);
   }
  int cnt = 0;
  sort(all(v));
  map<string, int> m;
  for(auto it : v) m[it]++;
  for (auto it : m) cnt += (it.s * (it.s - 1)) / 2;
  cout << cnt << endl;
  
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 12020
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int C[30];

int main(void) {

	string S;

	cin >> S;

	for (int i = 0; i < 4; i++) {
		C[S[i] - 'A']++;
	}

	int ans = 1;
	int sum = 0;
	for (int i = 0; i < 26; i++) {
		if (C[i] == 2) { sum++; }
		else if (C[i] == 1) { ans = -1; }
	}

	if (ans == 1 && sum==2) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b;
    scanf("%d %d",&a,&b);
    if((a>=-1000)&&(a<=1000)&&(b>=-1000)&&(b<=1000)){
        if(a>b){
            printf("a > b\n");
        }
        else if(a<b){
            printf("a < b\n");
        }
        else if(a==b){
            printf("a == b\n");
        }
    }
    return 0;
}

Measured memory_bytes: 580
'use strict'
function Main(input){
  input=input.split(/\s+/);
  for(let i=0;i<input.length;i++)
    input[i]=parseInt(input[i]);
  var N=input.shift();
  var C=input.shift();
  var D=[];
  for(let i=0;i<C;i++){
    D[i]=[];
    for(let j=0;j<C;j++)
      D[i][j]=input[C*i+j];
  }
  var c=[];
  for(let i=0;i<N;i++){
    c[i]=[];
    for(let j=0;j<N;j++)
      c[i][j]=input[C*C+N*i+j]-1;
  }
  var group=[[],[],[],];
  for(let i=0;i<N;i++)
    for(let j=0;j<N;j++)
      group[(i+j)%3].push(c[i][j]);
  var cost=[[],[],[]];//cost[i][j]でgroup[i]を色jに揃える違和感
  for(let i=0;i<3;i++)
    for(let j=0;j<C;j++){
      cost[i][j]=0;
      for(let k=0;k<group[i].length;k++){
        cost[i][j]+=D[group[i][k]][j];
      }
    }
  var bestColors=[[],[],[],];//各groupのbest3を出して全探索
  var bestScores=[[],[],[],];//bestColorsに対応するScore
  for(let i=0;i<3;i++)
    for(let j=0;j<3;j++){
      bestScores[i][j]=Math.min.apply(null,cost[i]);
      bestColors[i][j]=cost[i].indexOf(bestScores[i][j]);
      cost[i][bestColors[i][j]]=Infinity;
    }
  var candidates=[];
  var score=[];
  var color=[];
  for(let i=0;i<3;i++){
    color[0]=bestColors[0][i]
    score[0]=bestScores[0][i];
    for(let j=0;j<3;j++){
      color[1]=bestColors[1][j];
      if(color[0]===color[1])continue;
      score[1]=bestScores[1][j];
      for(let k=0;k<3;k++){
        color[2]=bestColors[2][k];
        if(color[0]===color[2]||color[1]===color[2])continue;
        score[2]=bestScores[2][k];
        candidates.push(score[0]+score[1]+score[2]);
      }
    }
  }
  var min=Math.min.apply(null,candidates);
  console.log(min);
}

var fs=require('fs');
var I=fs.readFileSync('/dev/stdin','utf8');
Main(I);

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


def solve(N: int, a: "List[int]"):
    answer = 0
    for i in range(N):
        while a[i]%2 == 0:
            answer += 1
            a[i] //= 2
    
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


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


Measured memory_bytes: 93296
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
// Compare vec[key] and something.
bool BinarySearch_Comp(const int key, const std::vector<int64_t>& vec) {
  // cerr << "\033[93m"
  //      << "======="
  //      << "\033[m" << endl;
  int64_t target = vec[key];
  // cerr << "\033[93m" << target << "\033[m" << endl;
  for (int i = 0; i < key; i++) {
    target += vec[i];
  }
  // cerr << "\033[93m" << target << "\033[m" << endl;
  for (int i = key + 1; i < vec.size(); i++) {
    if (vec[i] <= target * 2) {
      target += vec[i];
      // cerr << "\033[93m"
      //      << "eat " << i << " size: " << target << "\033[m" << endl;
    } else {
      // cerr << "\033[93m"
      //      << "can't  eat"
      //      << "\033[m" << endl;
      return false;
    }
  }
  return true;
}

// Return index number whose element is the LOWER limit returning true in
// BS_Comp().
int BinarySearch_LowerLimit(const std::vector<int64_t>& vec) {
  int left  = -1;
  int right = vec.size();
  int mid;
  while (right - left > 1) {
    mid = left + (right - left) / 2;
    if (BinarySearch_Comp(mid, vec)) {
      right = mid;
    } else {
      left = mid;
    }
  }
  return right;
}

void OutputError(std::string s) {
  cerr << "\033[93m" << s << "\033[m" << endl;
  return;
}

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  std::vector<int64_t> a;
  for (int i = 0; i < n; i++) {
    int m1;
    cin >> m1;
    a.push_back(m1);
  }
  std::sort(a.begin(), a.end());
  int limit = BinarySearch_LowerLimit(a);
  cout << n - limit << endl;

  return 0;
}


Measured memory_bytes: 2032
#include<stdio.h>
#include<string.h>
main(){
  char n[1000]={0},n_new[1000]={0},initial[1000]={0};
  int m,h,i,j,k,count;
  while(1){
    scanf("%999s",n);
    if(n[0]=='-')
      break;
    scanf("%d",&m);
    count=strlen(n);
    for(k=0;k<m;k++){
      scanf("%d",&h);
      for(i=h,j=0;i<count;i++,j++)
        n_new[j]=n[i];
      for(i=0;i<h;i++,j++)
        n_new[j]=n[i];
      strcpy(n,n_new);
    }   
    for(i=0;i<count;i++)
      printf("%c",n_new[i]);
    printf("\n");
  }
  return 0;
}


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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

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

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

int w, a, b;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  int a,b,c;cin >> a >> b >> c;
  int ma = max({a,b,c}),sum = a+b+c;
  if((3*ma-sum)%2==0) cout << (3*ma-sum)/2 << endl;
  else cout << ((3*ma-sum)/2)+2 << endl;
  return 0;
}


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

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int a,b,c;
		cin>>a>>b>>c;
		a*=a;
		b*=b;
		c*=c;
		if(a+b==c||a==b+c||a+c==b){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3068
import scala.collection.mutable
object Main extends App {
  import scala.io.StdIn._
  val Array(n, t, s, e) = readLine.trim.split(' ').map(_.toInt)
  val islands = Array.fill(n){Nil: List[(Int, Int)]}
  for (_ ← 1 until n){
    val Array(a, b, w) = readLine.trim.split(' ').map(_.toInt)
    islands(a - 1) ::= (b - 1, w)
    islands(b - 1) ::= (a - 1, w)
  }
  val bridgeFromS = Array.fill(n){-1}
  val queue = mutable.Queue[Int](s - 1)
  while(queue.nonEmpty) {
    val current = queue.dequeue()
    for ((next, _) ← islands(current) if next != s - 1 && bridgeFromS(next) == -1) {
      queue.enqueue(next)
      bridgeFromS(next) = current
    }
  }
  val bridgeWToE = Array.fill(n){0}
  val bridgeToE = Array.fill(n){-1}
  queue.enqueue(e - 1)
  while(queue.nonEmpty) {
    val current = queue.dequeue()
    for ((next, w) ← islands(current) if next != e - 1 && bridgeToE(next) == -1) {
      bridgeToE(next) = current
      bridgeWToE(next) = w
      queue.enqueue(next)
    }
  }
  val maxDamage = Array.fill(n){0}
  var canCollect = true
  for (current ← 0 until n if canCollect) {
    if (current == s - 1){
      canCollect = islands(current).filter(_._1 != bridgeToE(current)).map{case (i, w) ⇒ w - islands(i).length * t.toLong}.sorted.zipWithIndex.map{case (m, r) ⇒ m - r * t.toLong}.forall(_ > 0) && ((s == e) || bridgeWToE(current) > (islands(current).length - 1) * t.toLong)
    }else if (current == e - 1) {
      canCollect = islands(current).filter(_._1 != bridgeFromS(current)).map{case (i, w) ⇒ w - (islands(i).length + 1) * t.toLong}.sorted.zipWithIndex.map{case (m, r) ⇒ m - r * t.toLong}.forall(_ > 0)
    }else if (bridgeFromS(current) == bridgeToE(current)) {
      canCollect = islands(current).filter(_._1 != bridgeFromS(current)).map{case (i, w) ⇒ w - (islands(i).length + 1) * t.toLong}.sorted.zipWithIndex.map{case (m, r) ⇒ m - r * t.toLong}.forall(_ > 0)
    }else {
      canCollect = islands(current).filter(b ⇒ b._1 != bridgeFromS(current) && b._1 != bridgeToE(current)).map{case (i, w) ⇒ w - islands(i).length * t.toLong}.sorted.zipWithIndex.map{case (m, r) ⇒ m - (r + 1) * t.toLong}.forall(_ > 0) && bridgeWToE(current) > (islands(current).length - 1) * t.toLong
    }
  }
  println(
    if (canCollect) "Yes" else "No"
  )
}



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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<lint>> v(N, vector<lint>(3, -1));
    rep(i, N) rep(j, 3) cin >> v[i][j];

    lint ma = 0;
    for (int bit = 0; bit < (1 << 3); bit++) {
        vector<lint> A(N, 0);
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < 3; j++) {
                if (bit & (1 << j)) {
                    A[i] += v[i][j];
                } else {
                    A[i] -= v[i][j];
                }
            }
        }
        sort(all(A));
        reverse(all(A));
        lint sum = 0;
        for (int i = 0; i < M; i++) {
            sum += A[i];
        }
        ma = max(ma, sum);
    }
    cout << ma << endl;
    return 0;
}

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

using namespace std;

#define int long long
#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(), a.end()

const int N = 1005, mod = 1e9 + 7;
int a, b, c, d, gt[N], dp[N][N], n;

int pw(int x, int i){
	int b = 1;
	for(; i; i >>= 1, x = x * x % mod) if(i & 1) b = b * x % mod;
	return b;
}
int p(int n, int k){
	return (gt[n] * pw(gt[n - k], mod - 2) % mod) % mod;
}
main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> a >> b >> c >> d;
	gt[0] = 1;
	for(int i = 1; i <= n; ++i) gt[i] = gt[i - 1] * i % mod;
	for(int i = 0; i <= n; ++i) dp[0][i] = 1;
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= n; ++j){
			dp[i][j] = dp[i][j - 1]; if(a <= j && j <= b){
				for(int k = c; k <= d; ++k){
					if(i - j * k < 0) break;
					dp[i][j] = (dp[i][j] + dp[i - j * k][j - 1] * p(n - i + j * k, j * k) % mod * pw(gt[k], mod - 2) % mod * pw(pw(gt[j], k), mod - 2) % mod) % mod;
					dp[i][j] %= mod;
				}
			}
		}
	}
	cout << dp[n][n];
}

Measured memory_bytes: 8192