akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

/*
  階乗計算（MODで割った余りで返す）
*/

class Factorial {
    private:
        vector<ll> fac;
    public:
        Factorial();
        Factorial(ll n_max);
        void initialization(ll n_max);
        ll getFactorial(ll n);
};

Factorial::Factorial() {}
Factorial::Factorial(ll n_max) {
    fac.clear();
    fac.push_back(1);
    fac.push_back(1);
    for (ll i = 2; i <= n_max; i++) {
        fac.push_back(fac[i-1] * i % MOD);
    }
}
void Factorial::initialization(ll n_max) {
    fac.clear();
    fac.push_back(1);
    fac.push_back(1);
    for (ll i = 2; i <= n_max; i++) {
        fac.push_back(fac[i-1] * i % MOD);
    }
}
ll Factorial::getFactorial(ll n) {
    return fac[n];
}

/*
  MOD計算
*/
// 割り算のための逆元を求める（mod m での a の逆元）
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u % m;
}

/*
    順列と組み合わせ (P, C, H)
*/

class PCH {
    private:
        Factorial fact;
    
    public:
        PCH(ll n_max);
        ll P(ll n, ll r);
        ll C(ll n, ll r);
        ll H(ll n, ll r);
};
PCH::PCH(ll n_max) {
    fact.initialization(n_max);
}
ll PCH::P(ll n, ll r) {
    return fact.getFactorial(n) % MOD * modinv(fact.getFactorial(n - r), MOD) % MOD;
}

ll PCH::C(ll n, ll r) {
    return fact.getFactorial(n) % MOD * modinv(fact.getFactorial(r), MOD) % MOD * modinv(fact.getFactorial(n - r), MOD) % MOD;
}

ll PCH::H(ll n, ll r) {
    return C(n - 1 + r, r);
}

ll sum(ll i) {
  ll ans = (1 + i) * i / 2;
  ans %= MOD;
  return ans;
}

int main() {
  
  ll N, M, K;
  cin >> N >> M >> K;

  PCH pch(N * M);

  ll ans = 0;

  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= M; j++) {
      ans += M * (sum(i - 1) + sum(N - i)) % MOD;
      ans += N * (sum(j - 1) + sum(M - j)) % MOD;
      ans %= MOD;
    }
  }

  ans *= pch.C(N * M - 2, K - 2);
  ans %= MOD;

  ans *= modinv(2, MOD);
  ans %= MOD;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 5352
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, a, b;
	cin >> n >> a >> b;
	int ans = n * a;
	cout << min(ans, b) << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

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

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

int main(void){
    string s; cin >> s;
    ll ans = 0;
    ll n = s.size();
    REP(i, (n + 1)/2){
        ans += (s[i] != s[n-1-i]);
    }
    cout << ans << endl;
    return 0;
}

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

//const int INF = 1001001001;
//const ll INF = 1000000000000000000;

double dist(pair<int,int> a, pair<int,int> b){
	double dx, dy;
	dx = a.first - b.first;
	dy = a.second - b.second;
	return sqrt(dx*dx + dy*dy);
}

int main() {
	int n;
	cin >> n;
	vector<pair<int,int>> loc(n);
	rep(i,n) {
		int x, y;
		cin >> x >> y;
		loc[i] = {x, y};
	}

	vector<int> one_case(n);
	rep(i,n) one_case[i] = i;
	double ans = 0;
	int pat = 0;
	do {
		pat++;
		rep(i,n - 1) ans += dist(loc[one_case[i]], loc[one_case[i + 1]]);
	} while(next_permutation(one_case.begin(), one_case.end()));
	cout << fixed << setprecision(7) << ans/pat << endl;
	return 0;
} 


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

// mod付きコンビネーション
const int MAX = 1100000;
const int MOD = 1000000007;

Int fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

// 二項係数計算
Int COM(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;
}

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    COMinit();
    vector<Int> b(n + 1, 0);
    for (Int i = 1; i <= n; i++) {
        b[i] = inv[i];
    }
    for (Int i = 0; i < n; i++) {
        b[i + 1] += b[i];
        b[i + 1] %= mod;
    }
    Int res = 0;
    for (Int i = 0; i < n; i++) {
        res += a[i] * (b[i + 1] + b[n - i] - 1) % mod;
        res %= mod;
    }
    dump(res * fac[n] % mod);
    return 0;
}

Measured memory_bytes: 27648
#include <iostream>
#include <math.h>
#include<iomanip>
using namespace std;

int main(){
	double m=0,U,u=0,s,c=0,n,x[110],y[110];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x[i];
	}
	for(int i=0;i<n;i++){
		cin>>y[i];
	}
	for(int i=0;i<n;i++){
		m+=fabs(x[i]-y[i]);
	}
	cout<<fixed<<setprecision(6)<<m<<endl;
	for(int i=0;i<n;i++){
		u+=(x[i]-y[i])*(x[i]-y[i]);
	}
	U=sqrt(u);
	cout<<fixed<<setprecision(6)<<U<<endl;
	u=0;
	for(int i=0;i<n;i++){
		u+=(x[i]-y[i])*(x[i]-y[i])*fabs((x[i]-y[i]));
	}
	s=pow(u,1.0/3.0);
	cout<<fixed<<setprecision(6)<<s<<endl;
	c=fabs(x[0]-y[0]);
	for(int i=0;i<n-1;i++){
		if(c<fabs(x[i+1]-y[i+1]))c=fabs(x[i+1]-y[i+1]);
	}
	cout<<fixed<<setprecision(6)<<c<<endl;
	return 0;
}

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

int main() {
bool a[1300000]={0};
a[1]=1;
for(int i=2;i<650001;i++){
	if(a[i]==1) continue;
	int j=2*i;
	while(j<1300000){
		a[j]=1;
		j=j+i;
	}
}
int k;
while(cin>>k && k){
int ans;
if(a[k]==0) ans=0; 
else{
	int l=k+1,m=k-1;
	while(a[l]==1) l++;
	while(a[m]==1)  m--;
	ans=l-m;
}
cout<<ans<<endl;

}



	return 0;
}

Measured memory_bytes: 2432
#include <stdio.h>

void insertionSort(int A[],int N);
  
int main(){
  int i,j;
  int A[1000];
  int N;

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

  
  return 0;


}

void insertionSort(int A[],int N)
{
  int i,k;
  int v,j;
   for(k = 0; k < N; k++){
     if(k>0) printf(" ");
      printf("%d",A[k]);
   }
   printf("\n");
  for(i = 1; i < N; i++){
    v = A[i];
    j = i - 1;

    while( j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    for(k = 0; k < N; k++){
      if(k>0) printf(" ");
      printf("%d",A[k]);
      /*     printf(" ");*/
    }
    printf("\n");
  }
}
  



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

long long h, res = 0, now = 1;

int main() {
  cin >> h;
  while(h > 0) {
    res += now;
    h >>= 1;
    now *= 2;
  }

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

Measured memory_bytes: 256
/* ex 5_4
   person_A */

#include <stdio.h>
#include <string.h>


int main(void){
    int counter=0,result=0;
    char *ptr;
    char sequence[11];
    ptr= sequence;
    //文字列の入力
    scanf("%s", sequence);
    //1文字ずつ見ていく
    while(*ptr){
        switch(*ptr){
            //'A','C','G','T'が続けば、counterにそれを記録
            case 'A': case 'C': case 'G': case 'T':
                counter++;
                break;
            //それ以外の文字であれば、counterを確認しresultに最大値を記録
            default:
                if(counter>result){
                    result=counter;
                }
                //counterを初期化
                counter=0;
                break;
        }
        ptr++;
    }
    //最後にもう一度確認
    if(counter>result){
        result=counter;
    }
    //結果の出力
    printf("%d\n",result);
    return 0;
}

Measured memory_bytes: 1728
#include <stdio.h>

int main(void)
{
	int H, W;
	int i, j;
	for(; ; ) {
		scanf("%d%d", &H, &W);
		if(H==0 && W==0) break;
		for(j=0; j<W; j++) {
			putchar('#');
		}
		putchar('\n');
			for(i=0; i<H-2; i++) {
				putchar('#');
				for(j=0; j<W-2; j++) {
					putchar('.');
				}
				putchar('#');
			putchar('\n');
			}
		for(j=0; j<W; j++) {
			putchar('#');
		}
		putchar('\n');
	putchar('\n');
	}
	
	return 0;
}


Measured memory_bytes: 572
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
 
using namespace std;

vector<int> adj[200001];
int vis[200001];
priority_queue<pair<ll,ll> > pq;

void dfs(int x,int k){
	vis[x] =1;
	for(auto v: adj[x]){

		if(vis[v] == 0){
			dfs(v,k+1);
			if(adj[v].size() == 1){
				pq.push({k,0});
				cout<<"leaf :"<<k<<"\n";
			}
		}
		
	}
}


void solve(){

	int r; cin>>r;
	float pi = 3.14159;
	cout<<2*pi*r;

}





int main()
{ 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//cout<<fixed<<setprecision(12);
	//memset(dp,-1,sizeof(dp));
	
	int t =1; 
	//cin>>t;



	for(int i=1; i<=t; i++){
		solve();
		cout<<"\n";
	}




	return 0;

	}




Measured memory_bytes: 8496
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!
    val cArray = s.toCharArray()
    val eMax = cArray.sumBy { if (it == 'E') 1 else 0 }
    var eCount = 0
    var wCount = 0
    val turnNumList = mutableListOf<Int>()
    for (c in cArray) {
        if (c == 'E') eCount++
        turnNumList.add(wCount + eMax - eCount)
        if (c == 'W') wCount++
    }
    println(turnNumList.min())
}

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

#define rep(i, n) for(lli i = 0; i < (lli)(n); i++)

const lli MOD = 1000000007LL;

lli modpow(lli a, lli n){
    lli res = 1;

    for(lli ai = a; n; n>>=1){
        if(1&n) res = (res*ai)%MOD;
        ai=(ai*ai)%MOD;
    }
    return res;
}

lli inv(lli n){
    return modpow(n, MOD-2);
}

lli modperm(lli n, lli k){
    lli res = 1;
    rep(i, k){
        res = (res*(n-i))%MOD;
    }
    return res;
}

lli modcomb(lli n, lli k){
    return (modperm(n, k)*inv(modperm(k, k)))%MOD;
}

lli posmod(lli n){
    lli res = n;
    res %= MOD;
    if(res < 0) res += MOD;
    return res;
}
int s, w;

int main(void){
    cin >> s >> w;
    if(s <= w) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}


Measured memory_bytes: 3544
#include <iostream>
#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 <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

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

  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] * 4 * m >= s) cnt++;
  }

  if (cnt >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

int main(){
	int n;
	cin >> n;
	string s1;
	string s2;
	cin >> s1 >> s2;
	vector<int> num;
	int r = 0;
	while(r < n){
		if(s1[r] == s2[r]){
			num.push_back(1);
			r++;
		} else {
			num.push_back(2);
			r += 2;
		}
	}
	LL ans = 0;
	for(int i = 0; i < num.size(); i++){
		if(i == 0){
			if(num[i] == 1){
				ans = 3;
			} else {
				ans = 6;
			}
			continue;
		}
		if(num[i] == 1 && num[i-1] == 1){
			ans *= 2;
		} else if(num[i] == 1 && num[i-1] == 2){
			ans *= 1;
		} else if(num[i] == 2 && num[i-1] == 1){
			ans *= 2;
		} else if(num[i] == 2 && num[i-1] == 2){
			ans *= 3;
		}
		ans %= 1000000007;
	}
	cout << ans << endl;
}


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

int main() {
  int n,a,sum,min=32;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    sum=0;
    while(a%2==0){
      a/=2;
      sum++;
    }
    if(min>sum)
      min=sum;
  }
  cout<<min<<endl;
}


Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 2;
const int INF = 1LL << 55;

/* ---------- Functions */
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

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

    int N;
    cin >> N;
    vector<int> A(N);
    string str;
    cin >> str;
    for (int i = 0; i < N; i++) {
        A[i] = str[i] - '0';
    }

    // Small case
    if (N <= 5000) {
        for (int len = N-1; len >= 1; len--) {
            for (int i = 0; i < len ;i++) {
                A[i] = abs(A[i] - A[i+1]);
            }
        }
        cout << A[0] << endl;
        return 0;
    }

    vector<int> B(N-1);
    for (int i = 0; i < N-1; i++) {
        B[i] = abs(A[i] - A[i+1]);
    }

    int zero_cnt = 0;
    int one_cnt = 0;
    int two_cnt = 0;
    for (int b : B) {
        if (b == 2) two_cnt++;
        else if (b == 1) one_cnt++;
        else zero_cnt++;
    }

    if (one_cnt == 0 && zero_cnt > 0 && two_cnt > 0) {
        for (int i = 0; i < N-1; i++) B[i] /= 2;
        int cnt = 0;
        for(int k = 0; k <= N-2; k++) {
            unsigned n = N-2;
            unsigned kk = k;
            if (((~n) & kk) == 0) {
                cnt += B[k];
                cnt %= MOD;
            }
        }
        if (cnt == 1) cout << 2 << endl;
        else cout << 0 << endl;
        return 0;
    }

    int cnt = 0;
    for (int k = 0; k <= N-2; k++) {
        unsigned n = N-2;
        unsigned kk = k;
        if (((~n) & kk) == 0) {
            cnt += B[k];
            cnt %= MOD;
        }
    }
    cout << cnt << endl;

    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int cnt_0 = 0, cnt_1 = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '0')
            cnt_0++;
        else
            cnt_1++;
    }
    cout << 2 * min(cnt_0, cnt_1) << endl;
    return 0;
}

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

int main()
{
    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int ans = 60*h2 + m2 - 60*h1 - m1 - k;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
ll Xor(ll n){
  ll k=n/2;
  if(n%2==1&&k%2==0){
    return 1;
  }
  else if(n%2==0&&k%2==0){
    return n;
  }
  else if(n%2==1&&k%2==1){
    return 0;
  }
  else{
    return n^1;
  }
}
int main(){
  ll a,b;
  cin>>a>>b;
  if(a>0) a--;
  COUT(Xor(b)^Xor(a));
}

Measured memory_bytes: 384
#include<bits/stdc++.h>   
#include<tr1/unordered_map>
#define ll long long int  
#define mkp make_pair 
#define mod 1000000007 
#define maxn 1000002 
#define ff first
#define ss second 
using namespace std;      
bool isprime(ll n){    
    if(n==2||n==1)return true;
   if(n==0||n%2==0)return false; 
    
   for(int i=3;i*i<=n;i+=2)   
         if(n%i==0)return false; 
    return true;
}
int main(){    
  ios_base::sync_with_stdio(false);  
    
  cin.tie(NULL);      
    int n; 
  cin>>n; 
  ll arr[n];   
  ll s=0; 
  ll s1=0;
  for(int i=0;i<n;++i){  
       cin>>arr[i]; 
       s+=arr[i];  
       ll temp=((arr[i]%mod)*(arr[i]%mod))%mod;
       s1=(s1%mod+temp%mod)%mod;
    } 
  s=((s%mod)*(s%mod))%mod; 
  ll res=((s-s1)%mod+mod)%mod; 
  res=(res*500000004)%mod;
  cout<<res<<"\n";
  return 0;
}

Measured memory_bytes: 5200
A, B, C = map(int, input().split())
A, B, C = sorted([A, B, C])

ans = 0
if (B - A) % 2 == 0:
    ans = (B - A) // 2
    ans += C - B
elif (C - A) % 2 == 0:
    ans = (C - A) // 2
    # if (C - B) % 2 == 0:
    #     ans += (C - B) // 2
    # else:
    #     ans += (C + 1 - B) // 2
    ans += (C - B) // 2 + 2
else:  # (C - B) % 2 == 0
    ans = (C - B) // 2
    # ans += (C + 1 - A) // 2
    ans += (C - A) // 2 + 2
print(ans)


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

char s[200010], t[200010];

int main()
{
	int h, w, n, sr, sc; 
	scanf("%d%d%d", &h, &w, &n);
	scanf("%d%d", &sr, &sc);
	scanf("%s%s", s, t);
	int l = 0, r = w + 1, u = 0, d = h + 1;
	for(int i = n - 1; i >= 0; i--)
	{
		if(l + 1 >= r || u + 1 >= d) return 0 * puts("NO");
		if(t[i] == 'L') r = std::min(r + 1, w + 1);
		if(t[i] == 'R') l = std::max(l - 1, 0);
		if(t[i] == 'U') d = std::min(d + 1, h + 1);
		if(t[i] == 'D') u = std::max(u - 1, 0);
		if(s[i] == 'L') l++;
		if(s[i] == 'R') r--;
		if(s[i] == 'U') u++;
		if(s[i] == 'D') d--; 
	}
	if(sc <= l || sc >= r) return 0 * puts("NO");
	if(sr <= u || sr >= d) return 0 * puts("NO");
	puts("YES");
}

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

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, pll> ppll;

#define MOD 1000000007
#define f(a, b, c) for (ll(a) = (b); (a) < (c); ++(a))
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define rep(i, n) f(i, 0, n)
#define ff first
#define ss second
#define pb push_back
#define all(v) v.begin(), v.end()
#define wh(t) while (t--)
#define inf (ll)1e18
#define modd 998244353
#define pp(var) cout<<var<<"\n";
#define pm(var1, var2) cout<<var1<<" "<<var2<<"\n";
#define pv(i,v) rep(i,v.size()) cout<<v[i]<<" "; pp("");
#define pa(i,n,v) rep(i,n) cout<<v[i]<<" "; pp("");
#define K 1001
const ll N = 1e7 + 5;

ll binpow(ll a, ll n)
{
	ll i = 1;
	while (n > 0)
	{
		if (n & 1)
			i = (i * a) % MOD;
		a = (a * a) % MOD;
		n = n >> 1;
	}
	return i % MOD;
}

ll isprime(ll n)
{
	if (n == 0 || n == 1)
		return n;
	if (n % 2 == 0)
		return (ll)2;
	if (n % 3 == 0)
		return (ll)3;
	else
	{
		for (ll i = 5; i * i <= n; i += 6)
		{
			if (n % i == 0)
				return i;
			if (n % (i + 2) == 0)
				return (i + 2);
		}
		return n;
	}
}

int main() {
	fast;
	ll l, r, n, m, i, j, k, x, y, t, q;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	cin >> n;
	map<ll, ll> mp;
	rep(i, n) {
		cin >> j;
		mp[j]++;
	}
	ll ans = 0;
	for (auto it : mp) {
		ans += it.ff * it.ss;
	}
	cin >> q;
	wh(q) {
		ll b, c;
		cin >> b >> c;
		if (mp.find(b) != mp.end()) {
			ans -= mp[b] * b;
			ll add = mp[b];
			mp.erase(b);
			ans += c * add;
			mp[c] += add;
		}
		pp(ans);
	}
}			

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    f64 T, X; cin >> T >> X;
    cout << setprecision(6) << T / X << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

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

    if(s == "hi")print("Yes");
    else if(s == "hihi")print("Yes");
    else if(s == "hihihi")print("Yes");
    else if(s == "hihihihi")print("Yes");
    else if(s == "hihihihihi")print("Yes");
    else print("No");
    
}

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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
//int dx[] = { 1, 0 };
//int dy[] = { 0, 1 };
#define mod7 1e9+7;
#define mod9 1e9+9;
const ll INFLL = 999999999999999;

//int nextInt(){
//	int a;	cin >> a;return a;
//}
//string next(){
//	string s;cin >> s;return s;
//}
//char nextChar(){
//	char c;cin >> c;return c;
//}
int s2i(string str) {int ret;stringstream ss; ss << str;ss >> ret;return ret;}

void solve(){
	string s;
	cin >> s;
	int num = s2i(s);
	int sum = 0;
	rep(i,s.length()){
		sum += (int)(s[i]-'0');
	}
	if(num % sum == 0){
		P("Yes");
	}else{
		P("No");
	}
}

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


Measured memory_bytes: 256
n = int(input())
li = [list(map(int,input().split())) for i in range(n)]

li.sort(key=lambda x: x[1])
limit = 0
asum = 0
output = 'Yes'
for i in range(n):
  limit = li[i][1]
  asum += li[i][0]
  if asum > limit:
    output = 'No'
    break

print(output)

Measured memory_bytes: 54508
#![allow(unused_imports)]

//input
use proconio::input;
use proconio::marker::{Bytes, Chars};
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;
//use std::collections::BinaryHeap;

use std::cmp::*;

fn main() {
    input! {
        n: usize,
        m: usize,
        h: [u64;n],
        ab: [(usize,usize);m],
    }

    let mut flag = vec![true; n];
    for i in 0..m {
        if h[ab[i].0 - 1] == h[ab[i].1 - 1] {
            flag[ab[i].0 - 1] = false;
            flag[ab[i].1 - 1] = false;
        }
        if h[ab[i].0 - 1] < h[ab[i].1 - 1] {
            flag[ab[i].0 - 1] = false;
        }
        if h[ab[i].0 - 1] > h[ab[i].1 - 1] {
            flag[ab[i].1 - 1] = false;
        }
    }
    let mut ans = 0u64;
    for i in 0..n {
        if flag[i] {
            ans += 1;
        }
    }
    println!("{}", ans)
}

Measured memory_bytes: 6644
def solve():
    lim_u = 0
    lim_b = h
    lim_l = 0
    lim_r = w
    for s, t in zip(ss[::-1], ts[::-1]):
        if t == 'U':
            if lim_b < h:
                lim_b += 1
        elif t == 'D':
            if lim_u > 0:
                lim_u -= 1
        elif t == 'L':
            if lim_r < w:
                lim_r += 1
        else:
            if lim_l > 0:
                lim_l -= 1
        if s == 'U':
            lim_u += 1
        elif s == 'D':
            lim_b -= 1
        elif s == 'L':
            lim_l += 1
        else:
            lim_r -= 1

        if lim_u >= lim_b or lim_l >= lim_r:
            return False

    return lim_u < sr <= lim_b and lim_l < sc <= lim_r


h, w, n = list(map(int, input().split()))
sr, sc = map(int, input().split())
ss = input()
ts = input()
print('YES' if solve() else 'NO')


Measured memory_bytes: 4020
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

li subsolve(const vector<li>& subcs, const li k) {
    li ans = -9223372036854775800LL;
    const li len = subcs.size();
    li cycle = 0;
    for (int i = 0; i < len; ++i) {
        cycle += subcs[i];
    }
    const li loop_sum = cycle * (k / len);
    if (cycle >= 0 && k / len >= 1) {
        const li extra = k % len;
        ans = max(ans, loop_sum);
        if (k / len - 1 >= 1) {
            ans = max(ans, loop_sum - cycle);
        }
        for (int fr = 0; fr < len; ++fr) {
            li subsum = subcs[fr];
            for (int use = 1; use <= len; ++use) {
                if (use <= extra) {
                    ans = max(ans, loop_sum + subsum);
                }
                ans = max(ans, loop_sum - cycle + subsum);
                subsum += subcs[(fr + use) % len];
            }
        }

    } else {
        for (int fr = 0; fr < len; ++fr) {
            li subsum = subcs[fr];
            for (int use = 1; use <= min(len, k); ++use) {
                ans = max(ans, subsum);
                subsum += subcs[(fr + use) % len];
            }
        }

    }
    return ans;
}

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

    li n, k;
    cin >> n >> k;
    vector<li> ps(n);
    for (int i = 0; i < n; ++i) {
        cin >> ps[i];
        ps[i]--;
    }
    vector<li> cs(n);
    for (int i = 0; i < n; ++i) {
        cin >> cs[i];
    }

    li ans = -9223372036854775800LL;
    vector<bool> visit(n);
    for (int fr = 0; fr < n; ++fr) {
        if (visit[fr]) {
            continue;
        }
        li pos = fr;
        vector<li> chain;
        vector<li> subcs;
        while (true) {
            chain.push_back(pos);
            subcs.push_back(cs[pos]);
            visit[pos] = true;
            pos = ps[pos];
            if (visit[pos]) {
                break;
            }
        }

        ans = max(ans, subsolve(subcs, k));
    }

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

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

#define sswap(x, y) { x+=y; y=x-y; x-=y; }
#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
	unsigned long long n, k;
	cin >> n >> k;
	cout << min(n%k, k-n%k) << ende;
  return 0;
}


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

def judge(A_list):
  if 1 in A_list:
    return(False)
  else:
    return(True)
A_01 = list(map(lambda x: x%2, A))
A_list = list(map(lambda x: x/2, A))
count = 0
while judge(A_01):
  count += 1
  A_01 = list(map(lambda x: x%2, A_list))
  A_list = list(map(lambda x: x/2, A_list))
print(count)
  

Measured memory_bytes: 3064
N=int(input())

ANS=[[0]*N for i in range(N)]

def line(L,i):
    if len(L)<=1:
        return

    
    for k in range(len(L)):
        for l in range(k+1,len(L)):
            if k%2!=l%2:
                ANS[L[k]][L[l]]=i

    M=[L[i] for i in range(0,len(L),2)]
    N=[L[i] for i in range(1,len(L),2)]

    line(M,i+1)
    line(N,i+1)

line(list(range(N)),1)


for i in range(N-1):
    print(*ANS[i][i+1:])

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

int n, k;
 
const int  mod = 1000000007;
struct mint{
    ll x;
    mint (ll x=0) : x((x%mod+mod)%mod){}//カッコの中で初期化している
    mint& operator+=(const mint a){//operatorは構造体同士の比較に用いられる
        if((x +=a.x)>=mod) x-=mod;
        return *this;//thisとは現在のオブジェクトのこと
    }
    mint& operator-=(const mint a){
        if((x +=mod-a.x)>=mod) x-=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x*=a.x)%=mod;
        return *this;
    }
    mint operator+(const mint a){
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a){
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a){
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const{
        if(!t) return 1;
        mint a=pow(t>>1);
        a*=a;
        if(t&1) a*=*this;
        return a;
    }
    mint inv() const{
        return pow(mod-2);//逆元
    }
    mint&operator/=(const mint a) {
        return (*this)*=a.inv();
    }
    mint&operator/(const mint a) const{
    mint res(*this);
    return res/=a;
    }
};

ll f(int i){
    return (((ll)i-1)*(ll)i)/2;
}
ll g(int i){
    return i*(ll)n-f(i);
}

ll h(int i){
    return g(i)-f(i)+1;
}

int main(void){
    cin>>n>>k;
    mint ans = 0;
    for(int i = k;i<=n+1;i++){
        ans += h(i);
    }
    cout<<ans.x<<endl;
    return 0;
}

Measured memory_bytes: 3652
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include <bits/stdc++.h>
using namespace std;
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define wuyt main
typedef long long ll;
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
//#define getchar()(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();
if(c == '-')Nig = -1,c = getchar();
while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
return Nig*x;}
#define read read()
const ll inf = 1e15;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;
#define start int wuyt()
#define end return 0
int ans,num,k;
vector< set<int> > ss(40);
start{
    string s;
    int n;
    cin>>n>>s;
    for(int i=0;i<26;i++)
        ss[i]={n};
    for(int i=0;i<n;i++)
        ss[s[i]-'a'].insert(i);
    int t=read;
    while(t--)
    {
        cin>>num;
        char sss;
        if(num==1){
           /// k=read;
            cin>>k>>sss;
            k--;
            if(s[k]!=sss) ss[s[k]-'a'].erase(k);
            s[k]=sss;
            ss[sss-'a'].insert(k);
        }
        else{
            ans=0;
            int l=read,r=read;
            l--;
            r--;
            for(int j=0;j<26;j++)
                if(*ss[j].lower_bound(l)<=r)
                    ans++;
            printf("%d\n",ans);
        }
    }
    end;
}


Measured memory_bytes: 24196
from collections import deque
import copy
H, W = map(int, input().split())
maze = [list(input()) for _ in range(H)]

# すべての.についてスタート地点と仮定してBFS
def bfs(i, j):
    dq = deque()
    maze_c = copy.deepcopy(maze)
    maze_c[i][j] = 0
    dq.appendleft([i, j])
    res = 0
    while len(dq) > 0:
        ni, nj = dq.pop()
        if maze_c[ni][nj] == "#":
            continue
        for di, dj in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            if ni + di < 0 or nj + dj < 0 or ni + di >= H or nj + dj >= W:
                continue
            if maze_c[ni + di][nj + dj] == ".":
                maze_c[ni + di][nj + dj] = maze_c[ni][nj] + 1
                res = max(res, maze_c[ni + di][nj + dj])
                dq.appendleft([ni + di, nj + dj])
    return res

ans = 0
for i in range(H):
    for j in range(W):
        if maze[i][j] == ".":
            ans = max(ans, bfs(i, j))
print(ans)

Measured memory_bytes: 9492
#include <stdio.h>
#include <stdlib.h>

#define STUDENT_MAX 10001  /* 生徒数最大値 + 1 */
#define TIME_RANGE  721    /* 時間範囲(1260 - 540 + 1) */
#define TIME_IDX_SHIFT 540

int Login_sts[STUDENT_MAX][TIME_RANGE];
volatile int Login_cnt[STUDENT_MAX];
int Login_time[STUDENT_MAX];

int main(void){
	int N; /* PC数 */
	int M; /* 生徒数 */
	int r; /* 記録数 */
	int t; /* 時刻 */
	int n; /* PC */
	int m; /* 生徒 */
	int s; /* login/logout */
	int q; /* 質問数 */
	int t_s; /* 範囲(開始) */
	int t_e; /* 範囲(終了) */

	int i,j,ans;

	while(1){
		scanf("%d %d",&N,&M);
		if((N == 0) && (M == 0))break;
		/* Init */
		for(i = 0;i < STUDENT_MAX;i++){
			for(j = 0;j < TIME_RANGE;j++){
				Login_sts[i][j] = 0;
				Login_cnt[i] = 0;
			}
		}
		/* Input */
		scanf("%d",&r);
		for(i = 0;i < r; i++){
			scanf("%d %d %d %d",&t,&n,&m,&s);
			if(s == 1){ /* login */
				if(Login_cnt[m] == 0){
					Login_time[m] = t;
				}
				Login_cnt[m]++;
			}else{  /* logout */
				Login_cnt[m]--;
				if(Login_cnt[m] == 0){
					for(j = (Login_time[m] - TIME_IDX_SHIFT);j < (t- TIME_IDX_SHIFT);j++){
						 Login_sts[m][j] = 1;
					}
				}
			}
		}

		/* Output */
		scanf("%d",&q);
		for(i = 0;i < q; i++){
			ans = 0;
			scanf("%d %d %d",&t_s,&t_e,&m);
			for(j = (t_s - TIME_IDX_SHIFT);j < (t_e - TIME_IDX_SHIFT);j++){
				ans += Login_sts[m][j];
			}
			printf("%d\n",ans);
		}
	}


	return 0;
}



Measured memory_bytes: 29932
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;


namespace atcorder2
{
    class Program
    {
        public static long Read()
        {

            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

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

       
         public static long GCM(long x,long y)
        {
            if (x < y)  GCM(y, x);


            while (y > 0)
            {
                var z = y;
                y = x % y;
                x = z;
            }
            
            return x;
        }



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

      
            var abc = Reads();
            var a = abc[0];
            var b = abc[1];
            var c = abc[2];
            if (a > b && a % b == 0)
            {
                WriteLine(c == 0 ? "YES" : "NO");
            }
            else
            {
                WriteLine(c % GCM(a, b) == 0 ? "YES" : "NO");
            }
           







            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 13396
n,x = map(int,input().split())
a = list(map(int,input().split()))
d = []
for i in range(n-1):
  d.append(a[i] + a[i+1])
d.append(a[n-1])
ans = 0
for i in range(n-1):
  now = d[i] - x
  if now > 0:
    ans += now
    if a[i+1] >= now:
      d[i] -= now
      d[i+1] -= now
    else:
      d[i] -= now
      d[i+1] -= a[i+1]
print(ans)

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


int main() {
	unordered_set<char> chrset;
	char chr;
	string result = "yes";
	while (cin >> chr) {
		if (!chrset.insert(chr).second) {
			result = "no";
			break;
		}
	}
	cout << result << endl;
}

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


typedef long long ll;
typedef unsigned long long ull;

const int maxn = 1e5+1;
int p[maxn], sz[maxn], n, m;
int pa(int id)
{
  return id==p[id]?id:p[id]=pa(p[id]);
}
inline void merge(int x, int y)
{
  x = pa(x);
  y = pa(y);
  if (x != y)
    {
      p[x] = y;
      sz[y] += sz[x];
    }
}

inline void init()
{
  for (int i = 1; i <= n; ++i)
    p[i] = i, sz[i] = 1;
}

int main()
{
  scanf("%d %d", &n, &m);
  init();
  for (int i = 1; i <= m; ++i)
    {
      int u, v;
      scanf("%d %d", &u, &v);
      merge(u, v);
    }
  ll size = min(sz[pa(1)], sz[pa(2)]);
  ll left = n-size;
  printf("%lld\n", left*(left-1)/2+size*(size-1)/2-m);

}


Measured memory_bytes: 2560
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int p = sc.nextInt();
    int q = sc.nextInt();
    int r = sc.nextInt();
    int ma = Math.max(p,q);
    ma = Math.max(ma,r);
    System.out.println(p+q+r-ma);
  }
}


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

int main() {
  long long N, H, ans=0, sum=0; 
  cin >> N >> H;
  vector<long long> a(N), b(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i) >> b.at(i);
  }
  
  sort(a.begin(),a.end(),greater<long long>());
  sort(b.begin(),b.end(),greater<long long>());
  for(int i=0;i<N;i++){
    if(b.at(i) < a.at(0)) break;
    if(H<=0) break;
    H = H - b.at(i);
    ans++;
  }
  
  if(H<=0){
  }
  else {
    while(H>0){
      H = H - a.at(0);
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
while True:
  n=int(input())
  if n==0:
    break
  m=10000
  M=0
  sum=0
  for i in range(n):
    s=int(input())
    m=min(m,s)
    M=max(M,s)
    sum=sum+s
  print((sum-M-m)//(n-2))


Measured memory_bytes: 5596
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,i,s=0;
	for(i=0;i<10;i++){
		scanf("%d",&a);
		s+=a;
	}
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 2664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
    IOS();
    ll k,x;
    cin >> k >> x;
    for (ll i=x-k+1;i<=x+k-1;i++) cout << i << " \n"[i==x+k-1];
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  map<int,int> num;

  int M = -1;
  rep(i,n){
    int tmp; cin >> tmp;
    M = max(tmp,M);
    num[tmp]++;
  }

  int ans = num[0]+num[1]+num[2];
  int sum = ans;
  for(int i = 1;i<=M;i++){
    
    sum = sum-num[i-1]+num[i+2];
    ans = max(ans,sum);
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 8312
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    rrep(i, n){
        if(i%3==0 || i%5==0) continue;
        ans += i;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3588
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define LL long long
using namespace std;
const LL Maxn = 300010;
const LL Mod = 998244353;
LL a[Maxn], n, K;
LL b[Maxn], c[Maxn], cl, pos[Maxn], pi[Maxn], len[Maxn];
bool v[Maxn];
LL jc[Maxn], inv[Maxn];
LL t[Maxn];
LL _max(LL x, LL y) { return x > y ? x : y; }
int main() {
	LL i, j, k;
	scanf("%lld", &n);
	jc[0] = 1;
	for(i = 1; i <= n; i++) jc[i] = jc[i-1]*i%Mod;
	inv[0] = inv[1] = 1;
	for(i = 2; i <= n; i++) inv[i] = inv[Mod%i]*(Mod-Mod/i)%Mod;
	for(i = 2; i <= n; i++) inv[i] = inv[i-1]*inv[i]%Mod;
	for(i = 0; i < n; i++) scanf("%lld", &a[i]);
	for(i = 0; i < n; i++){
		if(a[i] != a[(i+n-1)%n]){
			if(v[a[i]] == true){ printf("0\n"); return 0; }
			v[a[i]] = true;
		}
	}
	for(i = 0; i < n; i++){
		if(a[i] != a[(i+n-1)%n]){
			if(a[i] == 1) break;
		}
	}
	for(j = 0; j < n; j++) b[j] = a[(i+j)%n];
	K = 0;
	while(b[K] == 1) K++;
	if(K == n){ printf("%lld\n", jc[n]); return 0; }
	c[++cl] = 1; pi[cl] = 0;
	t[1] = 1;
	for(i = K; i < n; i++){
		c[++cl] = b[i]; pi[cl] = i;
		t[b[i]] = cl;
		j = i;
		while(b[i] == b[j]) j++;
		if(j-i > K){ printf("0\n"); return 0; }
		i = j-1;
	}
	LL ans = 1;
	pos[1] = 0;
	for(i = 2; i <= cl; i++){
		if(c[i-1] > c[i]){
			if(c[i%cl+1] > c[i]){
				if(pi[i] != (pi[i%cl+1]+n-K)%n){ printf("0\n"); return 0; }
			}
			pos[i] = pi[i];
		} else {
			if(c[i%cl+1] > c[i]){
				pos[i] = (pi[i%cl+1]+n-K)%n;
				if(pos[i] <= pos[i-1]){ printf("0\n"); return 0; }
			} else {
				pos[i] = -1;
				LL l = _max(pos[i-1]+1, (pi[i%cl+1]+n-K)%n), r = pi[i];
				ans = ans*(r-l+1)%Mod;
			}
		}
	}
	LL sy = 0;
	for(i = n; i >= 1; i--){
		if(t[i] == 0){ sy++; continue; }
		LL x = t[i];
		LL frt = x-1 <= 0 ? x+cl-1 : x-1;
		LL p = 0;
		if(pos[x] == -1) p = (pos[x%cl+1]+n-pos[frt]-2)%n;
		else if(c[frt] < c[x]) p = (pos[x]+n-pos[frt]-1)%n;
		else if(c[x%cl+1] < c[x]) p = (pos[x%cl+1]+n-pos[x]-1)%n;
		if(p > sy){ printf("0\n"); return 0; }
		ans = ans*jc[sy]%Mod*inv[sy-p]%Mod;
		sy -= p;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 21632
#include <stdio.h>
#include <math.h>
int main() {
    int a, b, c, k;
    scanf("%d%d%d%d",&a,&b,&c,&k);
    if (k-a <= 0) printf("%d",k);
    else if (k-a-b <= 0) printf("%d",a);
    else printf("%d",a-(k-a-b));
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using ll = long long;

int main(void){
	int n=0;
	cin >> n;
	
	vector<ll> a(n,0),b(n,0);
	rep(i,n){
		cin >> a[i] >> b[i];
	}
	
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	
	int aa=0,bb=0;
	int ans = 0;
	
	if((n%2)==1){
		aa = a[(n-1)/2];
		bb = b[(n-1)/2];
		ans = (bb - aa) + 1;
	} else {
		aa = a[n/2]+a[n/2-1];
		bb = b[n/2]+b[n/2-1];
		ans = bb - aa + 1;
	}
	cout << ans << endl;
}



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

using namespace std;

const long long int MOD = 1000000007;

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

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

	cin >> N >> M >> K >> L >> R;
	int ans = 0;
	if (N < 0) {
		ans += abs(N)*K;
		N = 0;
	}
	if (!N) {
		ans += L;
	}
	ans += (M - N)*R;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3100