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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	string s;
	cin >> s;
	vector<int>kosuu(2.0);
	rep(i, s.size()) {
		if (s[i] == '0')kosuu[0]++;
		else kosuu[1]++;
	}
	print(min(kosuu[1], kosuu[0]) * 2);
}

Measured memory_bytes: 512
// #include <iostream>
#include <bits/stdc++.h>
// https://beta.atcoder.jp/contests/arc098/submissions/2567080
// https://beta.atcoder.jp/contests/arc098/submissions/2563485

using namespace std;

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

    long n;
    cin >> n;
    // char s[n];
    string s;
    // scanf("%s", &s);
    cin >> s;
    long right_e = 0;
    // for (long i = 0; i < n; i++) if (s[i] == 'E') right_e++;
    for (long i = 1; i < n; i++) right_e += (s[i] == 'E');
    // for (long i = 1; i < n; i++) if (s[i] == 'E') right_e++;
    long min_count = right_e;
    long left_w = 0;
    for (long i = 1; i < n; i++) {
    // for (long i = 1; i < n; i++) {
    //     if (!min_count) break;
        right_e -= s[i] == 'E';
        right_e += s[i - 1] == 'W';
        min_count = min(min_count, right_e + left_w);
        //     if (s[i] == 'E') {
        //     right_e--;
        // } else {
        //     right_e++;
        // }
        // if (s[i ] == 'W') right_e++;
        // if (s[i -1] == 'W') left_w++;
        // min_count = min(min_count, right_e);
    }
    cout << min_count << '\n';
    
    return 0;
}

Measured memory_bytes: 720
#include <stdio.h>
//#include <math.h>
int main(){
	int n,ans=100000,i;
	scanf("%d",&n);
	for(i=0; i<n; i++){
		ans*=1.05;
		if(ans%1000>0){
			ans-=ans%1000;
			ans+=1000;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  int64_t N;
  cin >> N;
  vector<int64_t> lucas(N + 1);
  lucas.at(0) = 2;
  lucas.at(1) = 1;
  
  for (int i = 0; i < (int)lucas.size() - 2; i++) {
    lucas.at(i + 2) = lucas.at(i) + lucas.at(i + 1);
  }
  
  cout << lucas.at(N) << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;
// Binary Indexed Tree (Fenwick Tree)
template<typename T> struct BIT {
  int n; vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) d[i] += x;
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) x += d[i];
    return x;
  }
  T sum(int l, int r) { return sum(r-1) - sum(l-1); }
};

vector<int> g[200005];
vector<int> in,out;
void dfs(int u=0, int p=-1){
  static int idx = 0;
  in[u] = idx;
  ++idx;
  for(int v:g[u]){
    if(v!=p) dfs(v,u);
  }
  out[u] = idx;
}

int main() {
  auto f = [](ll x){return x*(x+1)/2;};
  int n;
  cin >> n;
  vector<int> c(n);
  rep(i,n) cin >> c[i];
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    --a; --b;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  in = out = vector<int>(n);
  dfs();

  vector<int> us[n];
  rep(i,n) us[c[i]-1].emplace_back(i);
  rep(i,n) sort(us[i].begin(),us[i].end(),[&](int l,int r){ return in[l] > in[r]; });
  BIT<int> bit(n);
  rep(i,n) bit.add(i,1);

  rep(i,n){
    vector<P> temp;

    ll ans = f(n);
    for(int u:us[i]){
      int cnt = 1;
      for(int v:g[u]){
        if(in[v]<in[u]) continue;
        int ni = bit.sum(in[v],out[v]);
        ans -= f(ni);
        cnt += ni;
      }
      bit.add(in[u],-cnt);
      temp.emplace_back(in[u],cnt);
    }
    ans -= f(bit.sum(0,n));
    cout << ans << endl;

    for(auto p:temp) bit.add(p.first,p.second);
  }
}


Measured memory_bytes: 30572
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n,ans;
int main(){
	scanf("%lld",&n);
    printf("%lld",3*n*n);
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = BigInteger.Parse(Console.ReadLine());
            Console.WriteLine((N*(N-1))/2);
        }
    }
}

Measured memory_bytes: 13524
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <map>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int N, A, B;
    cin >> N >> A >> B;
    vector<int> vec(N);
    REP(i, N) cin >> vec[i];
    
    // calculation
    sort(vec.begin(), vec.end());
    int max_num = N/3, low = 0, middle = 0, up = 0;
    REP(i, N) {
        if (vec[i] <= A) {
            low++;
        } else if (A+1 <= vec[i] && vec[i] <= B){
            middle++;
        } else if (B+1 <= vec[i]) {
            up++;
        }
    }
    
    if (low == 0 || middle == 0 || up == 0) {
        cout << 0 << "\n";
    } else {
        cout << min(low, min(middle, up)) << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(n);
	LL minVal = LONG_MAX, negatives = 0, sum = 0;
	rep(i, 0, n) {
		sll(num);
		minVal = min(minVal, abs(num));
		if(num < 0)	negatives++;
		sum += abs(num);
	}
	if(negatives%2 == 1)	sum -= 2*minVal;
	pll(sum); nl;
}


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

if n == 1 or n == 2:
    print(0)
else:
    ans = 0
    for i in range(n):
        for j in range(i + 1,n):
            for k in range(j+1,n):
                len.sort()
                if len[i] == len[j] or len[j] == len[k]:
                    continue
                if len[j] - len[i] < len[k] and len[j]  + len[i] > len[k]:
                    ans = ans + 1
                else :
                    continue
    print(ans)

Measured memory_bytes: 9216
/// Kazuki Hoshino


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

int n, k, mn=inf, a[101010];

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
cin >> n >> k;

rep(i, 1, n){
cin >> a[i];
if(a[i]==1)mn=i;
}

rep(i, 0, 100000){
if(i*k-i+1 >= n){
    cout << i << endl;
    return 0;
}
}




return 0;}


Measured memory_bytes: 640
#include<stdio.h>

int main() {
	int n, i, j;
	int R[200000];
	int max, min;

	scanf("%d", &n);

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

	max = R[1] - R[0];
	min = R[0];

	for (j = 1; j < n; j++) {
		if (R[j] - min > max) max = R[j] - min;
		if (min > R[j]) min = R[j];
	}

	printf("%d\n", max);

	return 0;
}

Measured memory_bytes: 1376
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int x;
  cin >> x;
  int ans = 0;
  rep(i, a+1){
    rep(j, b+1){
      rep(k, c+1){
        int now = i*500 + j*100 + k*50;
        if(now == x) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int[] A = Console.ReadLine().Split().Select(x => Convert.ToInt32(x)).ToArray();
            int[,] P = new int[2, n];

            P[0, n - 1] = n - 1;
            int sl = 0;
            for (int i = n - 2; i >= 0; --i)
                if (A[i] >= A[i + 1])
                {
                    P[0, i] = i + 1;
                    P[1, i] = P[1, i + 1] + 1;
                    sl = Math.Max(sl, P[1, i]);
                }
            Console.WriteLine(sl);
        }
    }
}


Measured memory_bytes: 26972
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define MAX 2000005
#define MOD 1000000007
#define endl "\n"
lli arr[MAX];
stack  <lli> z;
stack <lli> o;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	lli n;
	cin>>n;
	lli ans = n + n*n + n*n*n;
	cout<<ans<<endl;
}

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

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

  vector<string> S(N);

  for(int i=0; i<N; i++)
    cin >> S.at(i);

  sort(S.begin(), S.end());

  int y=0;

  vector<string> word(300000);

  vector<int> count(300000);

  int n = 0;
  for(int i=0; i<N; i++){
    if(i == N-1 && S.at(i-1)==S.at(i)){
      count.at(n)++;
      word.at(y)=S.at(i);
    }
    else if(i == N-1 && S.at(i-1)!=S.at(i)){
      n++;
      count.at(n)++;
      y++;
      word.at(y)=S.at(i);        
    }
    else if( S.at(i)==S.at(i+1) )
      count.at(n)++;
    else{
      count.at(n)++;
      n++;
      word.at(y)=S.at(i);
      y++;
    }
  }
    int MAX = 0;
    for(int i = 0;i<count.size();i++){
        if(MAX < count.at(i)){
            MAX = count.at(i);
        }
    }
    vector<int> answer(count.size());
    for(int i = 0;i<count.size();i++){
        if(count.at(i) == MAX){
            answer.at(i)++;
        }
    }
    int length = 0;
    for(int i = 0;i<answer.size();i++){
        if(answer.at(i) == 1) length++;
    }
    vector<string> pq(length);
    int j = 0;
    for(int i = 0;i<answer.size();i++){
        if(answer.at(i) == 1){
            pq.at(j) = word.at(i);
            j++;
        }
    }
    sort(pq.begin(),pq.end());
    for(int i = 0;i<length;i++)
        cout << pq.at(i) << endl;
}

Measured memory_bytes: 20480
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}

ll N;
ll cnt = 0;

ll dfs(ll n, ll flag){
    if(n <= N){
        if(flag == 7)cnt++;
        dfs(n*10+3, flag | ll(1));
        dfs(n*10+5, flag | ll(2));
        dfs(n*10+7, flag | ll(4));
    }else{
        return 0;
    }
}

int main(){
    cin >> N;
    dfs(0,0);
    cout << cnt << endl;
}

Measured memory_bytes: 256
#https://atcoder.jp/contests/abc117/submissions/4165407
n,k=map(int,input().split())
a=list(map(int,input().split()))
t,ans=2**40,0
while t:
    c=sum([(a[i]&t)//t for i in range(n)])
    if k<t or c*2>=n:
        ans+=t*c
    else:
        ans+=t*(n-c)
        k -= t
    t //= 2

print(ans)


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

int main(){
    cout << fixed << setprecision(12);
    int n,k;
    while( cin >> n >> k ){
        double arr[n+3];
        arr[0] = 0.0;
        for( int i = 1; i <= n; i++ ){
            double a; cin >> a;
            double sum = (a*(a+1))/(2.0);
            arr[i] = sum/a;
            ///cout << arr[i] << endl;
        }
        double ans = 0.0;
        for( int i = 1; i <= n; i++ ){
            arr[i] += arr[i-1];
            ///cout << arr[i] << " ";
        }
        for( int i = 1; i <= n-k+1; i++ ){
            double temp = arr[i+k-1]-arr[i-1];
            ans = max( ans, temp );
        }
        cout << ans << endl;
    }
}
/*
7 2
0 1 0 0 0 1 0
*/


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >> n;
  int k=ceil(log2((double) n));
  //  cout << k << endl;
  rep(i,n-1){
    for(int j=i+1;j<n;j++){
      rep(l,k){
	//	cout << (i&(1<<l)) << " " << (j&(1<<l)) << endl;
	if((i&(1<<l)) != (j&(1<<l)) ){
	  cout << l+1 << " ";
	  break;
	}
      }
    }
    cout << "" << endl;
  }
  

  
  return 0;
    

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000000000
#define EPS 0.00000000001
typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    ll n,h;
    cin>>n>>h;
    vector<pair<ll,ll>> x(n);
    rep(i,n){
        cin>>x[i].first>>x[i].second;
    }
    sort(rall(x));
    ll amaxmemo=x[0].first;
    rep(i,n){
        swap(x[i].first,x[i].second);
    }
    sort(rall(x));
    bool flag=false;
    ll ans=0;
    rep(i,n){
        if(amaxmemo<=x[i].first){
            h-=x[i].first;
            ans++;
        }
        else{
            break;
        }

        if(h<=0){
            break;
        }
    }

    if(h<=0){
        cout<<ans<<endl;
    }
    else{
        cout<<ans+(h+amaxmemo-1)/amaxmemo<<endl;
    }



}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <stdlib.h>
using namespace std;


#define inf (int)(1e9)

int main(){
	int N, M, i, j, k, l, ans = 0;
	cin>>N>>M;
	int a[55],b[55],e[55][55];
	for(i = 0; i < M; i++){
		cin>>a[i]>>b[i];
		a[i]--;
		b[i]--;
	}
	for(l = 0; l < M; l++){
		for(int i = 0;i<N;i++)
            for(int j = 0;j<N;j++)
                e[i][j] = inf;
		for(i = 0; i < M; i++){
			if(i != l){
				e[a[i]][b[i]] = 1;
				e[b[i]][a[i]] = 1;
			}
		}
		for(k = 0; k < N; k++){
			for(i = 0; i < N; i++){
				for(j = 0; j < N; j++){
					if(e[i][j] > e[i][k] + e[k][j]){
						e[i][j] = e[i][k] + e[k][j];
					}
				}
			}
		}
		if(e[a[l]][b[l]] == inf){
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>k;i--)
using namespace std;
int main(){
    long long a,b,c,ans;
    cin>>a>>b>>c;
    if(a%2==0||b%2==0||c%2==0){
        cout<<0<<endl;
    }
    else{
        ans=a*b;
        ans=min(ans,b*c);
        ans=min(ans,c*a);
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3568
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        double ret = 0;
        for (int i = 1; i <= n; i++) {
            double tmp = 1.0 / n;
            int now = i;
            while (now < k) {
                now *= 2;
                tmp /= 2;
            }
            ret += tmp;
        }
        System.out.println(ret);
        sc.close();
    }
}

Measured memory_bytes: 20948
#include<bits/stdc++.h>
#define mem(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair <int,int> PAIR;
const int maxn = 2e5 + 7;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;
ll a[maxn];

int main(){	
	int n;
	ll res = 0;
	scanf("%d",&n);
	for(int i = 1;i <= n;++i) scanf("%lld",&a[i]),res ^= a[i];
	for(int i = 1;i <= n;++i) printf("%lld%c",res^a[i],i == n ?'\n' :' ');
	return 0;
}

Measured memory_bytes: 5360
fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    val S = readInputLine().toCharArray()

    var ans = 0

    for (i in '0'..'9') {
        var pos1 = 0
        var ok = false
        for (c in 0 until S.size) {
            if (S[c] == i) {
                ok = true
                pos1 = c + 1
                break
            }
        }
        if (!ok) {
            continue
        }
        for (j in '0'..'9') {
            var pos2 = 0
            ok = false
            for (c in pos1 until S.size) {
                if (S[c] == j) {
                    ok = true
                    pos2 = c + 1
                    break
                }
            }
            if (!ok) {
                continue
            }
            for (k in '0'..'9') {
                ok = false
                for (c in pos2 until S.size) {
                    if (S[c] == k) {
                        ok = true
                        break
                    }
                }
                if (ok) {
                    ans++
                }
            }
        }
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  getline(cin, s);
  for (int i = 0; i < (int)s.size(); i++) {
    cout << (char)(islower(s[i]) ? toupper(s[i]) : s[i]);
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3216
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int S=scan.nextInt();
        int W=scan.nextInt();
        if(W>=S){
            System.out.println("unsafe");
        }
        else{
            System.out.println("safe");
        }
    }
}

Measured memory_bytes: 26980
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<deque>
#include<queue>
#include<cassert>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<28
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
static const int dx[7] = {0,1,1,0,-1,-1,0};
static const int dy[2][7] = {{1,0,-1,-1,-1,0,0},{1,1,0,-1,0,1,0}};//even,odd
static const int dif = 150;

int main(){
  int d[400][400][7];
  bool bmap[400][400];
  rep(i,400){
    rep(j,400){
      rep(k,7){
	d[i][j][k] = INF;
      }
      bmap[i][j] = false; 
    }
  }

  P s,g,l;
  int n,ans = -1;
  scanf("%d %d %d %d",&s.F,&s.S,&g.F,&g.S);
  scanf("%d",&n);
  rep(i,n){
    int x,y;
    scanf("%d %d",&x,&y);
    x += dif; y += dif;
    bmap[y][x] = true;
  }
  scanf("%d %d",&l.F,&l.S);
  queue<PP> que;
 
  que.push(PP(s,P(0,0)));
  d[s.S+dif][s.F+dif][0] = 0;

  deque<PP> deq;
  deq.push_front(PP(s,P(0,0)));
   
 while(!deq.empty() ){
    PP p = deq.front(); deq.pop_front();
    if(p.F == g){
      ans = p.S.S;
      break;
    }
    int burden = abs(p.F.F*p.F.S*p.S.F)%6,dir = (p.S.F+1)%6;
    rep(i,7){
      int nx = p.F.F+dx[i],ny = p.F.S+dy[p.F.F&1][i];
      if(bmap[ny+dif][nx+dif])continue;
      if(ny<-l.S || nx<-l.F || l.S<ny || l.F<nx)continue;
      
      if(i == burden){
	if(d[ny+dif][nx+dif][dir] > p.S.S){
	  d[ny+dif][nx+dif][dir] = p.S.S;
	  deq.push_front(PP(P(nx,ny),P(dir,p.S.S)));
	}
      }
      else{
	if(d[ny+dif][nx+dif][dir] > p.S.S+1){
	  d[ny+dif][nx+dif][dir] = p.S.S+1;
	  deq.push_back(PP(P(nx,ny),P(dir,p.S.S+1)));
	}
      }
    }
  }
  



  
  /*
  while(!que.empty()){
    PP pp = que.front();que.pop();
    if(pp.F == g){
      ans = min(ans,pp.S.S);
      continue;
    }
 
    int burden = abs((pp.F.F-dif)*(pp.F.S-dif)*pp.S.F)%6,dir = (pp.S.F+1)%6;
    
    rep(i,7){
      int nx = pp.F.F+dx[i],ny = pp.F.S+dy[(pp.F.F-dif)%2][i];
      int Dcost = i==burden+1? pp.S.S:pp.S.S+1;
    

     
      if( (nx*nx<=l.F*l.F) && (ny*ny<=l.S*l.S) && !bmap[ny][nx] && (ans > pp.S.S) && d[ny][nx][dir] > Dcost){
	//cout << "in! nx = " << nx-dif << ",ny = " << ny-dif  << ", Dcost = " << Dcost<< endl;
	d[ny][nx][dir] = Dcost;
	que.push(PP(P(nx,ny),P(dir,Dcost)));
      }
    }
    
  }
*/
  cout << ans << endl;
  //if(ans != INF)printf("%d\n",ans);
  //else printf("-1\n");
  return 0;
}

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

int main() {
  char c;
  cin >> c;

  if ( c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}


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

int main(){

    ll n,k,d;
    
    cin >> n >> k ;
    bool ans[n] = {false};
    rep(i,k){
        ll d;
        cin >> d;
        rep(j,d){
            ll a;
            cin >> a;
            ans[a-1] = true;
        }
    }

    ll count = 0;
    rep(i,n){
        if(ans[i] == false){
            count++;
        }
    }

    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 3636
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    }
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt), * )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(a:i32, b:i32);
    let mut ans = 1;
    for i in 0..b {
        if ans >= b {
            println!("{}", i);
            break;
        }
        ans += a - 1;
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define INF 1000000000
#define MOD 1000000007

int main(){
  int Q;
  cin>>Q;
  vector<ll> A(Q),B(Q);
  for(int i=0;i<Q;i++){
    cin>>A.at(i)>>B.at(i);
  }

  for(int i=0;i<Q;i++){
    ll a=min<ll>(A.at(i),B.at(i));
    ll b=max<ll>(A.at(i),B.at(i));
    if(a==b||b-a==1){
      cout<<2*(a-1)<<endl;
    }else{
      ll ans=0;
      ll left=a+1;
      ll right=b;
      while(left+1<right){
        ll center=(left+right)/2;
        if(center*center<a*b){
          left=center;
        }else{
          right=center;
        }
      }
      if(left*left<a*b){
        ans=min<ll>(2*(left-a-1),2*(b-left-1))+1;
      }
      left=a+1;
      right=b;
      while(left+1<right){
        ll x=(left+right)/2;
        if(x*(x+1)<a*b){
          left=x;
        }else{
          right=x;
        }
      }
      if(left*(left+1)<a*b){
        ans=max<ll>(ans,2*min<ll>(left-a,b-right));
      }
      cout<<2*(a-1)+1+ans<<endl;
    }
  }
}


Measured memory_bytes: 256
x, n = map(int, input().split())
ok = [True for _ in range(102)]
for p in list(map(int, input().split())):
    ok[p] = False
left, right = 0, 0
while ok[x - left] is False:
    left += 1
while ok[x + right] is False:
    right += 1

if left <= right:
    print(x - left)
else:
    print(x + right)


Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define all(v) v.begin(),v.end()
using namespace std;

signed main(){
    int n;
    cin>>n;
    vi a(n);
    rep(i,n)cin>>a[i];
    int m;
    cin>>m;
    vi b(m);
    rep(i,m)cin>>b[i];
    int c=0;
    rep(i,m)c+=binary_search(all(a),b[i]);
    cout<<(c==m)<<endl;
    return 0;
}


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

string s;

int main() {
	cin >> s;
	int n = s.size();
	if (n < 4) {
		cout << "No" << endl;
	}
	else {
		if (s[0] == 'Y' && s[1] == 'A' &&
			s[2] == 'K' && s[3] == 'I') {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}

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

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

    int a, b, c;
    cin >> a >> b >> c;

    swap(a, b);
    swap(a, c);

    cout << a << " " << b << " " << c << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

typedef long long INT;
int main(){
    INT N,M;
    std::cin >> N >> M;
    INT l,i=0,X[M];
    while(std::cin >> l){
        X[i] = l;
        i++;
        if(i>=M)break;
    }

    std::sort(X,X+M,std::greater<INT>());

    INT dif[M-1];
    for(INT i = 1;i<M;i++){
        dif[i-1]=std::abs(X[i-1]-X[i]);
    }

    std::sort(dif,dif+(M-1),std::greater<INT>());
    INT sum = 0;


    for(INT i = N-1;i<M-1;i++){
        sum+=dif[i];
    }

    std::cout << sum << std::endl;

    return 0;
}

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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;

  if (K <= A)
    cout << K << endl;
  else if (K <= A + B)
    cout << A << endl;
  else
    cout << A - (K - A - B) << endl;

  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  vector<ll> l(87);
  l[0] = 2;
  l[1] = 1;
  for (int i = 2; i < l.size(); i++) {
    l[i] = l[i - 1] + l[i - 2];
  }

  int n;
  cin >> n;
  cout << l[n] << endl;
  return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

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


struct Combination {

	vector<ll> fact, rfact;

	Combination(ll sz) : fact(sz + 1), rfact(sz + 1) {

		fact[0] = 1;
		for (ll i = 1; i < fact.size(); i++) {
			fact[i] = fact[i - 1] * i % MOD;
		}
		//逆元
		rfact[sz] = inv(fact[sz]);
		for (ll i = sz - 1; i >= 0; i--) {
			rfact[i] = rfact[i + 1] * (i + 1) % MOD;
		}
	}

	ll inv(ll x) {
		//modpow
		return pow(x, MOD - 2);
	}
	ll pow(ll x, ll n) {
		//累乗
		ll ret = 1;
		while (n > 0) {
			if (n & 1) (ret *= x) %= MOD;
			(x *= x) %= MOD;
			n >>= 1;
		}
		return (ret);
	}
	ll P(ll n, ll r) {
		//順列
		if (r < 0 || n < r) return (0);
		return (fact[n] * rfact[n - r] % MOD);
	}

	ll C(ll p, ll q) {
		//組み合わせ
		if (q < 0 || p < q) return (0);
		return (fact[p] * rfact[q] % MOD * rfact[p - q] % MOD);
	}

	ll H(ll n, ll r) {
		//重複組み合わせ
		if (n < 0 || r < 0) return (0);
		return (r == 0 ? 1 : C(n + r - 1, r));
	}
};


/******************************************************************************************/

template<typename T>
T LIS(vector<T>& a) {/*長さに対する最小の最終要素*/

	T siz = a.size();
	vector<T> dp(a.size() + 10, INF);

	for (T i = 0; i < siz; i++) {
		*lower_bound(dp.begin(), dp.begin() + siz, a[i]) = a[i];
	}
	return lower_bound(dp.begin(), dp.begin() + siz, INF) - dp.begin();
}



int main() {

	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	cout << LIS(a) << endl;

	

	return 0;
}


Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        int[] B = new int[n-1];
        for(int i = 0; i < n-1; i++) B[i] = Integer.parseInt(sc.next());
        ans += B[0] + B[n - 2];
        for(int i = 1; i < n - 1; i++) ans += Math.min(B[i - 1], B[i]);
        System.out.println(ans);
    }
}


Measured memory_bytes: 23892
def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    G = [[] for _ in range(n)]
    for _ in range(m):
        a, b = map(int, input().split())
        a, b = a-1, b-1
        G[a].append(b)
        G[b].append(a)
    f = [True]*n
    for i in range(n):
        if not f[i]:
            continue
        x = h[i]
        for v in G[i]:
            if h[i] < h[v]:
                f[i] = False
            elif h[i] == h[v]:
                f[i] = False
                f[v] = False
            else:
                f[v] = False
    ans = 0
    for i in range(n):
        if f[i]:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 30164
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); while(true){ int a = sc.nextInt(); int b = sc.nextInt(); if( a == 0 && b == 0 ) break; if( a > b){a^=b;b^=a;a^=b;} System.out.println(a+" "+b); } } }


Measured memory_bytes: 35100
N, M = [int(x) for x in input().split(' ')]

L = 0
R = N
for i in range(M):
  l,r = [int(x) for x in input().split(' ')]
  if L < l:
    L = l
  if r < R:
    R = r

cnt = 0
if L <= R:
  cnt = R - L + 1
print(cnt)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=3.1415926535897932384626433832795;
const ll INF = 1LL<<62;
const ll MINF = -1LL<<62;

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)

int main() {
	IO;
	ll n;
	cin>>n;
	cout<<(n-1)*(n)/2<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>

int main(int argc, char *argv[]) {
	int num_of_ball = 0;
	int num_of_paint = 0;
	std::cin >> num_of_ball;
	std::cin >> num_of_paint;

	// (K - 1)^(N - 1)
	uint32_t left_combo = 1;
	for (int i = 0; i < num_of_ball - 1; i++) {
		left_combo *= (num_of_paint - 1);
	} 

	std::cout << num_of_paint * left_combo << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  long long a=0,cou=0,n=0,sum=0,min,max=-1000000;
  min=1000000;
  scanf("%lld",&n);
  for(cou=0;cou<n;cou++){
    scanf("%lld",&a);
    sum=sum+a;
    if(a<min){
      min=a;
    }
    if(max<a){
      max=a;
    }
  }
  printf("%lld %lld %lld\n",min,max,sum);
  return 0;
}
 
   

Measured memory_bytes: 1028
using static System.Console;

namespace AC_Field
{
    class AtCoder
    {
        static void Main()
        {
            string[] inp = ReadLine().Split(' ');
            int n, d, m;
            n = int.Parse(inp[0]);
            d = int.Parse(inp[1]);
            m = d * 2 + 1;

            WriteLine(n%m==0 ? n/m : n/m+1);
        }
    }
}


Measured memory_bytes: 13140
function parseInput(input) {
  const values = []
  input.split('\n').forEach(row => {
    const list = row.split(' ')
    list.forEach(v => values.push(v))
  })

  return values
}

function getInput() {
  return parseInput(require('fs').readFileSync('/dev/stdin', 'utf8'))
}

function spend(Xi, P) {
  return Math.pow(Xi - P, 2)
}

;(function main() {
  const input = getInput()
  const N = +input[0]

  var min = Number.MAX_SAFE_INTEGER
  for (var p = 1; p <= 100; p++) {
    var s = 0
    for (var i = 1; i <= N; i++) {
      s += spend(+input[i], p)
    }

    if (min > s) {
      min = s
    }
  }

  console.log(min)
})()


Measured memory_bytes: 21192
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



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

  int n;
  cin >> n;

  int m = n % 10;
  if (m == 3) cout << "bon";
  else if (m == 0 || m == 1 || m == 6 || m == 8) cout << "pon";
  else cout << "hon";
  cout << '\n';




  
  return 0;
}

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

using namespace std;

int mat[302][302];
struct Edge {
	int c, u, v;
	bool operator<(const Edge &E)const{
		return c < E.c;
	}
};
int main(int argc,char *argv[]) {

	int N;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			cin >> mat[i][j];
		}
	}
	int a = 0;
	for (int k = 0; k < N; ++k) {
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				if(mat[i][k] + mat[k][j] < mat[i][j]){
					a = 1;
				}
			}
		}
	}
	if(a == 1){
		cout << -1 << endl;
	}else{
		long long S = 0;
		vector<Edge> E;
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				if(i == j)continue;
				S += mat[i][j];
				E.push_back({mat[i][j], i, j});
			}
		}
		sort(E.rbegin(), E.rend());
		for(Edge e : E){
			for (int k = 0; k < N; ++k) {
				if(k != e.u && k != e.v){
					if(mat[e.u][k] + mat[k][e.v] == mat[e.u][e.v]){
						S -= mat[e.u][e.v];
						break;
					}
				}
			}
		}
		cout << S / 2 << endl;
	}
	
	
}
	


Measured memory_bytes: 2296
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n,d,x; cin>>n>>d>>x;
    d--;
    rep(i,n){
        int a; cin>>a;
        x+=d/a+1;
    }
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {

	 List<Integer> solve(int start,int arrival){
		final int[] busLine={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9};
		int len=busLine.length;
		List<Integer> route=new ArrayList<Integer>();
		boolean riding=false;
		for(int i=0;i<len;++i){
			if(busLine[i]==start){
				route.clear();
				riding=true;
			}
			route.add(busLine[i]);
			if(riding&&busLine[i]==arrival){
				break;
			}
		}
		return route;
	}
	
	void io(){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		for(int i=0;i<n;++i){
			boolean first=true;
			for(int route:solve(s.nextInt(),s.nextInt())){
				if(first){
					first=false;
				}
				else{
					System.out.print(" ");
				}
				System.out.print(route);
			}
			System.out.println();
		}
		s.close();
	}

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

}

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

int main(){
  int N,M; cin >> N >> M;
  if(N>=M){
    cout << 0 << endl;
    return 0;
  }
  
  vector<int> X(M);
  for(int i=0; i<M; i++) cin >> X[i];
  sort(X.begin(),X.end());
  
  vector<int> diff(M-1);
  for(int i=0; i<M-1; i++) diff[i]=X[i+1]-X[i];
  sort(diff.begin(),diff.end());
  
  int sum=0;
  for(int i=0; i<M-N; i++) sum+=diff[i];
  
  cout << sum << endl;
}

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

using namespace std;
using ll = long long;

void dfs(const vector<vector<bool>> &field, vector<vector<bool>> &visit, int x, int y, int w, int h) {
    visit[y][x] = true;
    for (int dx = -1; dx <= 1; dx++) {
        for (int dy = -1; dy <= 1; dy++) {
            if (dx == 0 && dy == 0)
                continue;
            int nx = x + dx;
            int ny = y + dy;

            if (0 <= nx && nx < w && 0 <= ny && ny < h && field[ny][nx] && !visit[ny][nx]) {
                dfs(field, visit, nx, ny, w, h);
            }
        }
    }
}

void solve() {
    int w, h;
    cin >> w >> h;
    if (w == 0 && h == 0)
        exit(0);

    vector<vector<bool>> field(h, vector<bool>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int c;
            cin >> c;
            if (c)
                field[i][j] = true;
            else
                field[i][j] = false;
        }
    }

    int ans = 0;
    vector<vector<bool>> visit(h, vector<bool>(w, false));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (field[i][j] && !visit[i][j]) {
                dfs(field, visit, j, i, w, h);
                ans++;
            }
        }
    }

    cout << ans << endl;
}

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

    while (true)
        solve();

    return 0;
}



Measured memory_bytes: 3396
import java.util.Scanner;
class Main{
    public static void main(String[] a){
    	
    	Scanner scan = new Scanner(System.in);
    	while (scan.hasNext()){ 
    	int n = 0;
    	n = scan.nextInt();
    	if(n  == 0){
    		break;
    	} 
    	int result = 0;
    	for(long i = 5; i <= n;i*=5){
    		result += n/i; 	
    	
    	}
    	System.out.println(result);

    }
 }
}

Measured memory_bytes: 26208
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int N = sc.nextInt();
    long A = sc.nextLong();
    long B = sc.nextLong();
    
    if (A <= B) {
      if (N >= 2) {
        long max = A + B + B * (N - 2);
        long min = A + B + A * (N - 2);
        
        System.out.println((max - min + 1));
      } else if (N == 1) {
        System.out.println(A != B ? 0 : 1);
      }
    } else {
      System.out.println(0);
    }
  }

}


class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 22484