akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>

#define MOD 1000000007


using namespace std;

long long int modpow(long long int a, int n) {

	if (n == 0)return 1;
	if (n == 1) return a;

	long long int wk = modpow(a, n / 2);

	long long int ret = 0;
	if (n % 2 == 0) {
		ret = 1;
	}
	else {
		ret = a;
	}

	return (((ret * wk) % MOD) * wk) % MOD;

}

long long int gcd(long long int a, long long int b) {
	long long int tmp;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r = a % b;

	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long int lcm(long long int a, long long int b) {

	long long int wk_int;

	wk_int = (a * b) % MOD;
	
	long long int ret;

	ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD;

	return ret;

}

bool isPrime(int n) {
	if (n == 1)return false;
	if (n == 2)return true;

	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}

	return true;
}








int main()
{
	
	int n, p;
	cin >> n >> p;

	int wk;
	bool oddflg = false;

	for (int i = 0; i < n; i++) {
		cin >> wk;
		if (wk % 2 == 1)oddflg = true;
	}
	
	long long int ans = 0;

	if (!oddflg && p == 0) {
		ans = pow(2, n);
	}
	else if (!oddflg && p == 1) {
		ans = 0;
	}
	else {
		ans = pow(2, n - 1);
	}

	cout << ans << endl;



	return 0;

}



Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//-----------------------------------------
int main(void){
    ll N;cin>>N;
    if(N%10==3)cout<<"bon";
    else if(N%10==0||N%10==1||N%10==6||N%10==8)cout<<"pon";
    else cout<<"hon";
    cout<<"\n";
}

Measured memory_bytes: 3636
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/
ll times[200002];

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

	ll N, C;
	
	cin >> N >> C;

	rep(i, N)
	{
		ll s,t,c;
		cin >> s >> t >> c;
		for (int j = 2*s-1; j < 2*t; j++)
		{
			times[j] |= (1<<(c-1));
		}
	}

	int max = 0;
	rep(i, 200002)
	{
		int tmp = __builtin_popcountl(times[i]);
		if (tmp > max)
		{
			max = tmp;
		}
	}

	cout << max << endl;

	
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k;
  cin >>a>>b>>k;
  int cnt=0;
  int ans;
  for(int i=min(a,b);i>=1;i--){
  if(a%i==0 && b%i==0)cnt++;
  if(cnt==k){ans=i;
             break;}
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009
// for ref

#include <iostream>
#include <cstring>
#include <cmath>
#define Rep(i, b, e)\
    for (int i = (int)b; i < (int)e; i++)

using namespace std;

const int MAXN = 999999;
bool isPrime[MAXN];

int countPrime(int n) {
    memset(isPrime, true, sizeof isPrime);
    Rep(i, 0, 1000)
        isPrime[i] = true;

    isPrime[0] = false;
    isPrime[1] = false;
    // isPrime[2] = true;
    // isPrime[3] = true;

    // Rep(i, 2, sqrt(n)+1) {
        //Rep (k, 2, sqrt(n)+1) {
    Rep(i, 2, n) {
        Rep(k, 2, n) {
            if (i*k > n)
                break;
            isPrime[i*k] = false;
        }
    }

    int primeCount = 0;
    int j = 0;
    // while (primeCount < n) {     // GS q
    while (j <= n) {
        if (isPrime[j]) {
            // cout << primeCount << " th prime\t";
            // cout << j << endl;
            primeCount++;
        }
        j++;
    }

    return primeCount;
}

int num;

int main()
{
    while (cin >> num) {
        cout << countPrime(num) << endl;
    }
 //   cout << "Hello world!" << endl;
    return 0;
}

Measured memory_bytes: 2144
def d_handstand2():
    N = int(input())

    c = [[0] * 10 for _ in range(10)]
    for k in range(1, N + 1):
        c[int(str(k)[0])][int(str(k)[-1])] += 1
    return sum([c[i][j] * c[j][i] for i in range(10) for j in range(10)])

print(d_handstand2())

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	char str[1000][1000]; 
	int a,b;
	scanf("%d %d",&a,&b)!=EOF;
	int x,t,i,j;
	getchar();
	for(i=0;i<a;i++){scanf("%s",&str[i]);}
	for(x=0;x<b+1;x++){
		printf("#");
	}
	printf("#\n");
	for(j=0;j<a;j++){printf("#");
	printf("%s",str[j]);
	printf("#\n");
	}
	for(t=0;t<=b+1;t++){
		printf("#");
	}
	printf("\n");
	return 0;	

}

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

#define ine long long

using namespace std;

int32_t main()
{
	int n,k;
	cin >> n >> k;

	n = pow(2,n);

	if(k == 0)
	{
		for(int i=0;i<n;i++)
			cout << i << " " << i << " ";

		return 0;
	}

	if(k >= n || (n == 2 && k == 1))
	{
		cout << -1 << endl;
		return 0;
	}

	cout << k << " ";

	for(int i=0;i<n;i++)
	{
		if(i != k)
			cout << i << " ";
	}

	cout << k << " ";

	for(int i=n-1;i>=0;i--)
	{
		if(i != k)
			cout << i << " ";
	}
}


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

int main() {
  int n = 3;
  vector<int> arr(n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  int k;
  cin >> k;
  sort(arr.begin(), arr.end());
  cout << arr[2] * static_cast<int>(pow(2, k)) + arr[0] + arr[1]  << endl;
}


Measured memory_bytes: 256
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

//#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
#define WFA(d,v) REP(i,v)REP(j,v)REP(k,v)d[j][k]=min(d[j][k],d[j][i]+d[i][k])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)
#define mp make_pair


int main(){

  CIN(n,m);V a(m);V b(m);V c(m);
  REP(i,m){cin>>a[i]>>b[i]>>c[i];a[i]--;b[i]--;}

  vector<V> vec(n,V(n,INF));
  REP(i,m){vec[a[i]][b[i]]=c[i];vec[b[i]][a[i]]=c[i];}
  REP(i,n)vec[i][i]=0;
  WFA(vec,n);
  
  vector<bool> saitan(m,false);

  REP(i,m){
    REP(j,n){
      REP(k,n){
        if(vec[a[i]][j]+vec[b[i]][k]+c[i] == vec[j][k])saitan[i]=true;
      }
    }
  }
  COUT(count(ALL(saitan),false));

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
  int N,K;
  cin >> N >> K;
  
  vector<int>ball(N);
  
  for(int i=0;i<N;i++){
    cin >> ball[i];
  }
  
  vector<int>number(N + 1,0);
  
  for(int i=0;i<N;i++){
    number[ball[i]]++;
  }
  
  sort(number.begin(),number.end(),greater<int>());
  
  int ans = 0;
  
  if(N == K)
    cout << 0 << endl;
  else{
    for(int i=K;i<N;i++){
    ans += number[i];
    }
  
  cout << ans << endl;
  }
  
  return 0;
}

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

long long gcm(long long m, long long n) {
    if (m < n) {
        gcm(n , m);
    }

    long long t;

    while (t = m % n ) {
        m = n;
        n = t;
    }

    return n;
}

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

    long long G = gcm(C, D);
    long long L = (C * D) / G;

    long long ans_B = B - (B / C) - (B / D) + (B / L);
    long long ans_A = (A - 1) - ((A - 1) / C) - ((A - 1) / D) + ((A - 1) / L);

    cout << ans_B - ans_A << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    string S;
    cin >> S;
    
    int flag = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == S[i + 1]){
            flag = 1;
            break;
        }
    }
    if(flag == 1){
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }
}


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

ll comb(int num) {
	ll res = ll(num) * ll(num -1LL) / 2LL; 
	return res;
}
 
struct UnionFind {
	vector<int> data;

	UnionFind(int sz) {
		data.assign(sz, -1);
	}

	ll unite(int x, int y) {
		x = find(x), y = find(y);
		ll prev = comb(size(x)) + comb(size(y));
		if (x == y) return 0;
		if (data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return(comb(size(x))-prev);
	}

	int find(int k) {
		if(data[k] < 0) return(k);
		return data[k] = find(data[k]);
	}

	int size(int k)	{
		return -data[find(k)];
	}

	// int total() {
	// 	int res = 0;
	// 	for(const auto& d: data) {
	// 		if (d < -1) res += -d*(-d-1)/2;
	// 	}
	// 	return res;
	// }
};

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

	int N, M; cin >> N >> M;
	UnionFind uf(N);

	vector<pair<int, int>> edges(M);
	int x, y;
	rep(i, M) {
		cin >> x >> y;
		--x; --y;
		edges[i] = make_pair(x, y);
	}

	reverse(all(edges));

	vector<ll> cnt(M, 0);
	rep(i, M) {
		pair<int, int> p = edges[i];
		cnt[i] = uf.unite(p.first, p.second);
		// cnt[i] = uf.total();
	}

	reverse(all(cnt));
	
	ll current = 0;
	FOR(i, 0, M) {
		current += cnt[i];
		cout << current << endl; 
	}
}


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

using namespace std;

int flip(int n) {
    vector<int> digits;
    while (n > 0) {
        digits.push_back(n % 3);
        n /= 3;
    }
    reverse(digits.begin(), digits.end());
    int res = 0;
    for (int d: digits) {
        res *= 3;
        if (d == 1) {
            res += 2;
        } else if (d == 2) {
            res += 1;
        }
    }
    return res;
}
int pow(int a, int n) {
    int res = 1;
    for (int i = 0; i < n; ++i)
        res *= a;
    return res;
}
int main() {
    assert(flip(0) == 0);
    assert(flip(1) == 2);
    assert(flip(2) == 1);
    assert(flip(46) == 65);
    assert(flip(65) == 46);
    assert(pow(3, 3) == 27);
    assert(pow(3, 0) == 1);
    int n;
    cin >> n;
    string s;
    cin >> s;
    const int low_bits = min(max(n / 2 + 1, 1), 6);
    const int high_bits = n - low_bits;
    const int n_low = pow(3, low_bits);
    const int n_high = pow(3, high_bits);
    vector<int> salsa(pow(3, max(low_bits, high_bits)));
    for (int i = 0; i < (int) salsa.size(); ++i) {
        salsa[i] = flip(i);
    }
    vector<int> low(n_low);
    vector<vector<int>> kick(n_low);
    iota(low.begin(), low.end(), 0);
    int f = 0;
    for (char c: s) {
        if (c == 'S') {
            ++f;
            for (int i = 0; i < (int) low.size(); ++i) {
                low[i] = salsa[low[i]];
            }
        } else {
            for (int i = 0; i < (int) low.size(); ++i) {
                ++low[i];
                if (low[i] == (int) low.size()) {
                    kick[i].push_back(f);
                    low[i] = 0;
                }
            }
        }
    }
    for (int i = 0; i < pow(3, n); ++i) {
        int a = i / low.size();
        int b = i % low.size();
        int prev_f = 0;
        for (int i = 0; i < (int) kick[b].size(); ++i) {
            if ((kick[b][i] - prev_f) % 2 > 0) {
                a = salsa[a];
            }
            a = (a + 1) % n_high;
            prev_f = kick[b][i];
        }
        if ((f - prev_f) % 2 > 0) {
            a = salsa[a];
        }
        cout << a * n_low + low[b] << " ";
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 5680
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int p[n];
    for(int i=0;i<n;i++)
    cin>>p[i];
    sort(p,p+n);
    int sum=0;
    for(int i=0;i<n-1;i++)
    sum+=p[i];
    sum+=p[n-1]/2;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
	N, X = map(int, input().split())
	L = list(map(int, input().split()))
	ans = 1
	h = 0
	for i in range(N):
		h += L[i]
		if h <= X:
			ans += 1
		else:
			break
	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 3060
n=int(input())
print(0)
z=input()[0]
if z=="V":
    exit()
def f(i):
    print(i)
    s=input()[0]
    if s=="V":
        exit()
    if i%2==0:
        if s==z:
            return False
        else:
            return True
    else:
        if s==z:
            return True
        else:
            return False
f(n-1)
left=0
right=n-1
while right-left>1:
    mid=(left+right)//2
    if f(mid):
        right=mid   #ここがleftならansもleft。
    else:
        left=mid
exit()

Measured memory_bytes: 3660
#mod = 10**9 + 7
#n, m = map(int, input().split())
#a = []
#for _ in range(m):
#    x = int(input())
#    if len(a) > 0 and x == a[-1] + 1:
#        print(0)
#        exit()
#    a.append(x)
#j = 0
#dp = [0] * (n+1)
#dp[0] = 1
#for i in range(n):
#    if j < m and i >= a[j]:
#        j += 1
#    if j < m and i+1 == a[j]:
#        pass
#    else:
#        dp[i+1] += dp[i]
#        dp[i+1] %= mod
#    if j < m and i+2 == a[j]:
#        pass
#    elif i+2 <= n:
#        dp[i+2] += dp[i]
#        dp[i+2] %= mod
#print(dp[-1])
mod = 10**9 + 7
n, m = map(int, input().split())
ok = [True]*(n+1)
for _ in range(m):
    a = int(input())
    ok[a] = False
dp = [0] * (n+1)
dp[0] = 1
for i in range(n):
    if ok[i+1]:
        dp[i+1] += dp[i]
        dp[i+1] %= mod
    if i+2 <= n and ok[i+2]:
        dp[i+2] += dp[i]
        dp[i+2] %= mod
print(dp[-1])

Measured memory_bytes: 71560
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

int N;

signed main()
{
	cin >> N;

	vector<int> a(N);
	rep(i, N) {
		cin >> a[i];
		a[i] -= i + 1;
	}

	sort(all(a));

	if (N % 2 == 1) {
		int b = a[N / 2];
		int ans = 0;
		rep(i, N) ans += abs(a[i] - b);
		cout << ans << endl;
	} else {
		int ans = LLONG_MAX/3;
		rep(k, 2) {
			int b = a[N / 2 - k];
			int v = 0;
			rep(i, N) v += abs(a[i] - b);
			ans = min(ans, v);
		}
		cout << ans << endl;
	}
}



Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define YES(n) cout << (n?"YES":"NO")<<endl;
#define Yes(n) cout << (n?"Yes":"No")<<endl;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    Yes(A + B >= C);
}

Measured memory_bytes: 256
def isPrime(p):
    if p == 1:
        return False
    elif p == 2:
        return True
    else:
        i = 2
        while p >= i*i:
            if p%i == 0:
                return False
            i += 1
        return True

N = int(input())
ans = 0
for i in range(N):
    a = int(input())
    if isPrime(a):
        ans += 1
print(ans)


Measured memory_bytes: 5612
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		
		while(true) {
			int n=in.nextInt(),l=in.nextInt(),r=in.nextInt();
			if(n==0)break;
			
			List<Integer> A=new ArrayList<>();
			for(int i=0;i<n;i++) {
				A.add(in.nextInt());
			}
			
			int cnt=0;
			
			for(int i=l;i<=r;i++) {
				int j;
				for(j=0;j<A.size();j++) {
					if(i%A.get(j)==0) {
						if((j+1)%2==1)cnt++;
						break;
					}
				}
				
				if(j==A.size() && A.size()%2==0)cnt++;
			}
			
			System.out.println(cnt);
		}
		
		
	}

}



Measured memory_bytes: 32224
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	int N, D, X;
	int A[100];

	cin >> N >> D >> X;
	for (int i = 0; i < N; i++)
		cin >> A[i];

	int ans = X;
	for (int i = 1; i <= D; i++) {
		for (int j = 0; j < N; j++) {
			if ((i - 1) % A[j] == 0) {
				ans++;
			}
		}
	}

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  int M = 3600;
  FOR(a, 1, M+1) FOR(b, 1, M+1){
    if(a*N+b*N-4*a*b == 0) continue;
    double c = 4.0/N-1.0/a-1.0/b;
    c = 1/c;
    c = (int)c;
    if(c < 0) continue;
    if(c > M) continue;
    if((4*a*b*c) == ((a*b+b*c+c*a)*N)){
      cout << a << " " << b << " " << c << endl;
      return 0;
    }
    c++;
    if((4*a*b*c) == ((a*b+b*c+c*a)*N)){
      cout << a << " " << b << " " << c << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
///

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll N = 750002;
const int mod = 1000000007;
const long long int inf = INT64_MAX;
#define pp pair<ll,ll>

typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++)    
void fastIO(void);
 
void decimal(int);
ll modmulti(ll, ll);
ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);

int main()
{  
  ll n;
  cin>>n;
  ll a[n];
  rep(i,n) cin>>a[i];
  ll cost = 0;
  rep(i,n){
     for(ll j=i+1;j<n;j++){
        cost+=a[i]*a[j];
     }
  }

  
   cout<<cost<<endl;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b){
   return ((a%mod)*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   return ((a%mod)+(b%mod)+mod)%mod;
}
ll modpower(ll a, ll n){
   if(n==0)
      return 1;
   ll result = 1;
   while(n>0){
      if(n%2==1)
         result = modmulti(result,a);
      a = modmulti(a,a);
      n = n/2;
   }
   return result;
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}
 

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

int main() {
  int x, y;
  while (std::cin >> x >> y) {
    if (x == 0 && y == 0) {
      return 0;
    }
    if (x > y) {
      std::swap(x, y);
    }
    std::cout << x << " " << y << std::endl;
  }
}



Measured memory_bytes: 3072
import java.util.Scanner;

public class Main{

	public static final double EPS = 1e-8;

	public static class P implements Comparable<P>{
		public double x;
		public double y;
		public P(double x, double y) {
			this.x = x;
			this.y = y;
		}
		//ÀWª¶ºÉ éÙÇ\[gñÉ¨¢ÄOÉé
		public int compareTo(P o) {
			if(equals(o))return 0;
			if(Math.abs(x-o.x)<EPS){
				return y-o.y<0?1:y-o.y>0?-1:0;
			}
			return x-o.x<0?1:x-o.x>0?-1:0;
		}
		public boolean equals(P o){
			return Math.abs(x-o.x)<EPS && Math.abs(y-o.y)<EPS;
		}
	}

	/**
	 * s->txNg
	 * @author y-koashi
	 *
	 */
	public static class Vec{
		public P s;
		public P t;
		public double dx;
		public double dy;
		public Vec(P s, P t) {
			this.s = s;
			this.t = t;
			dx = t.x-s.x;
			dy = t.y-s.y;
		}
		/**
		 * àÏ
		 */
		public double dotProduct(Vec o){
			return dx*o.dx + dy*o.dy;
		}
		/**
		 * OÏ
		 */
		public double crossProduct(Vec o){
			return dx*o.dy - dy*o.dx;
		}
		/**
		 * xNgoÆ¼ðµÄ¢é©
		 * ð_ðÁÄ¢éKvÍÈ¢
		 * @param o
		 * @return
		 */
		public boolean isOrthogonal(Vec o){
			return dotProduct(o)==0;
		}


	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
//			for(int i=0;i<8;i++);
//			System.out.println();
			P p1 = new P(sc.nextDouble(), sc.nextDouble());
			P p2 = new P(sc.nextDouble(), sc.nextDouble());
			P p3 = new P(sc.nextDouble(), sc.nextDouble());
			P p4 = new P(sc.nextDouble(), sc.nextDouble());
			Vec v1 = new Vec(p1, p2);
			Vec v2 = new Vec(p3, p4);
			if(v1==null||v2==null)System.out.println("WRONG");else
			System.out.println(v1.isOrthogonal(v2)?"YES":"NO");
		}
	}
}

Measured memory_bytes: 12000
#include<stdio.h> 
int main() 
	{ 
		long int s,k,i,j,z,count=0;
	 scanf("%ld%ld",&k,&s); 
		for(i=0; i<=k; i++)
		{
		for(j=0; j<=k; j++)
			 { z=s-i-j;
					if(z>=0 && z<=k)
					 { count++; }
				 }
					
					}
				 printf("%ld",count);
					return 0;
				 } 


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {
    int H, W; cin >> H >> W;
    string f[H]; for (int i = 0; i < H; i++) cin >> f[i];
    int dp[H][W];
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) dp[i][j] = 1<<30;
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++)
            if (f[i][j] == '#') dp[i][j] = 0;
    for (int i = 1; i < H; i++)
        for (int j = 0; j < W; j++)
            dp[i][j] = min(dp[i][j], dp[i-1][j]+1);
    for (int i = H-2; i >= 0; i--)
        for (int j = 0; j < W; j++)
            dp[i][j] = min(dp[i][j], dp[i+1][j]+1);
    for (int i = 0; i < H; i++)
        for (int j = 1; j < W; j++)
            dp[i][j] = min(dp[i][j], dp[i][j-1]+1);
    for (int i = 0; i < H; i++)
        for (int j = W-2; j >= 0; j--)
            dp[i][j] = min(dp[i][j], dp[i][j+1]+1);
    int ans = 0;
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++)
            ans = max(ans, dp[i][j]);
    cout << ans << endl;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string S;
    cin >> S;
    ll maxv = 0;
    ll dp[5100][5100] = {};
    REP(i,N){
        REPP(j,i+1,N){
            if(S[i] == S[j]) dp[i+1][j+1] = max(dp[i][j]+1,dp[i+1][j+1]);
            maxv = max(maxv,min(j-i,dp[i+1][j+1]));
        }
    }
    /*REP(i,N+1){
        REPP(j,i,N+1){
            maxv = max(maxv,min(j-i,dp[i][j]));
        }
    }*/
    cout << maxv << endl;
}

Measured memory_bytes: 203520
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  double x[n],r[n];
  for(int i=0;i<n;i++) cin>>x[i]>>r[i];
  double L=0,R=1e9;
  for(int i=0;i<200;i++){
    double M=(L+R)/2;
    double lb=0,ub=1e9;
    for(int j=0;j<n;j++){
      if(r[j]<=M){
    //lb=max(lb,x[j]-r[j]);
    //ub=min(ub,x[j]+r[j]);
    lb=ub+1;
    break;
      }else{
    double tmp=sqrt(r[j]*r[j]-M*M);
    //cout<<tmp<<endl;
    lb=max(lb,x[j]-tmp);
    ub=min(ub,x[j]+tmp);
      }
    }
    //cout<<M<<":"<<lb<<" "<<ub<<endl;
    if(lb<=ub) L=M;
    else R=M;
  }
  printf("%.12f\n",R);
  return 0;
}

Measured memory_bytes: 4780
#include <iostream>

void Swap(int& t_a, int& t_b)
{
	int temp = t_a;
	t_a = t_b;
	t_b = temp;
}

int main()
{
	int X, Y, Z = 0;
	std::cin >> X >> Y >> Z;

	Swap(X, Y);
	Swap(X, Z);

	std::cout << X << " " << Y << " " << Z << "\n";

	return 0;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;
  std::vector<ll> v(n);

  bool zero=false;
  ll sum=0;
  ll mn=(1ll<<50);
  ll cnt=0;
  for(int i=0;i<n;i++){
    cin>>v[i];
    sum+=abs(v[i]);
    mn = min(mn, abs(v[i]));
    if(v[i]<0)cnt++;
    if(v[i]==0){
      zero=true;
    }
  }
  if(zero || ((cnt % 2) ==0)){
    cout<<sum<<endl;
  }else{
    cout<<sum-2*mn<<endl;
  }

  return 0;
}


Measured memory_bytes: 1024
#import<iostream>
#import<vector>
using namespace std;typedef pair<int,int>P;main(){int n,R,p,x,y,s,t,v,w,i;for(;cin>>t>>n>>R,t;cout<<p<<endl){vector<P>A[252][252],*a;for(;t--;A[1+x/40][1+y/40].push_back(P(x,y)))cin>>x>>y;for(p=0;n--;)for(cin>>s>>t,v=3;v--;)for(w=0;w<3;w++)for(a=A[s/40+v]+t/40+w,i=a->size();i--;p+=x*x+y*y<=16*R*R)x=s-(*a)[i].first,y=t-(*a)[i].second;}}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for(int i = 0; i+2 < n; ++i) {
    if(s.substr(i, 3) == "ABC") {
		ans++;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll; 
const int N = 1e5+5;
const ll M = 1e9+7;

int main()
{	
	int n;
	scanf("%d",&n);
	n %= 1000;
	if(n) printf("%d\n",1000-n);
	else printf("0\n"); 
	return 0;
}

Measured memory_bytes: 3824
n, m = map(int, input().split())
xy = []
for _ in range(m):
    x, y = map(int, input().split())
    xy.append((x, y))
reds = [False]*n
reds[0] = True
balls = [1]*n
for x, y in xy:
    if reds[x-1] and balls[x-1]>1:
        reds[y-1] = True
    elif reds[x-1]:
        reds[y-1] = True
        reds[x-1] = False
    balls[x-1] -= 1
    balls[y-1] += 1
print(sum(reds))

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

int main()
{
        int r, c, r_tmp=0, c_tmp=0;

        cin >> r >> c;

        int a[r][c];
        int r_sum[r], c_sum[c];

        for(int i = 0; i < r; i++) {
                for(int j = 0; j < c; j++) {
                        cin >> a[i][j];
                        r_tmp += a[i][j];
                }
                r_sum[i] = r_tmp;
                r_tmp = 0;
        }

        for(int i = 0; i < c; i++) {
                for(int j = 0; j < r; j++) {
                        c_tmp += a[j][i];
                }
                c_sum[i] = c_tmp;
                c_tmp = 0;
        }

        for(int i = 0; i < r; i++) {
                for(int j = 0; j < c; j++) {
                        cout << a[i][j] << ' ';
                }
                cout << r_sum[i] << endl;
        }

        for(int j = 0; j <= c; j++) {
                if(j == c) {
                        cout << c_tmp << endl;
                } else {
                        c_tmp += c_sum[j];
                        cout << c_sum[j] << ' ';
                }
        }

        return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
using in6 = int64_t;
using ind = double;
using vi = vector<in6>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<in6,in6>;
using psi = pair<string,in6>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

in6 n;
int x[10], y[10];

ind dist(int i, int j) {
  ind dx = x[i] - x[j];
  ind dy = y[i] - y[j];
  return pow(dx*dx+dy*dy,0.5);
}

ind factrial(ind x) {
  ind ret = 1;
  while(x) {
    ret *= x;
    x --;
  }
  return ret;
}

int main() {
  kyun;
  cin >> n;
  repa(i,1,n+1) cin >> x[i] >> y[i];
  vi start(n);
  rep(i,n) start[i] = i+1;
  ind ans = 0;
  do {
    rep(i,n-1) ans += dist(start[i],start[i+1]);
} while(next_permutation(all(start)));
  dset(10);
  
  cout << ans / factrial(n);
  hinata;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <stdio.h>
#include <bits/stdc++.h>
#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
// tree<key, mapped = null_type, cmp = less<key>, rb_tree_tag, tree_order_statistics_node_update> name; order_of_key find_by_order

using namespace std;

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fs first
#define sc second
#define abs(a) ((a) < 0 ? -(a) : (a))
#define sqr(a) ((a) * (a))

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

inline pair<pair<bool, bool>, pair<string, bool> > useinout();

#ifdef SOL
double starttime;
#endif

void initialization() {
#ifdef SOL
	starttime = 1000. * clock() / CLOCKS_PER_SEC;
	if (useinout().fs.fs)
		freopen("input.txt", "r", stdin);
	if (useinout().fs.sc)
		freopen("output.txt", "w", stdout);
#else
	srand(__rdtsc());
	const string file = useinout().sc.fs;
	if (!file.empty()) {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	} else
	if(useinout().sc.sc) {
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
#endif
}

int solution();

void finish(int exitval) {
	fflush(stdout);
#ifdef SOL
	fprintf(stderr, "\n-----------------\nexit value: %d\ntime: %.3lf ms\n-----------------\n", exitval, 1000. * clock() / CLOCKS_PER_SEC - starttime);
#endif
}

int main() {
	initialization();
	finish(solution());
	return (0);
}

const double eps = 1e-9;
const int mod = (int) 1e+9 + 7;
const double pi = acos(-1.);
const int maxn = 200100;

vector<pair<int, int> > vc;

int solution() {

	long double dec = 20. - pi * 10. / 2.;
	int x1, y1, x2, y2;
	scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
	int mx = 1, my = 1;
	if(x1 > x2) {
		mx = -1;
		x1 *= mx;
		x2 *= mx;
	}
	if(y1 > y2) {
		my = -1;
		y1 *= my;
		y2 *= my;
	}
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		x *= mx, y *= my;
		if(x1 <= x && x <= x2 && y1 <= y && y <= y2) {
			vc.pb(mp(x, y));
		}
	}
	sort(vc.begin(), vc.end());
	vector<int> p;
	n = vc.size();
	for(int i = 0; i < n; i++) {
		int pos = lower_bound(p.begin(), p.end(), vc[i].sc) - p.begin();
		if(pos == p.size()) {
			p.pb(0);
		}
		p[pos] = vc[i].sc;
	}
	long double ans = (x2 - x1 + y2 - y1) * 100. - p.size() * 1. * dec;
	if(p.size() == min((x2 - x1 + 1), (y2 - y1 + 1))) {
		ans += pi * 10. - 20. + dec;
	}
	printf("%.15lf", (double)ans);

	return (0);
}

inline pair<pair<bool, bool>, pair<string, bool> > useinout() {
	return (mp(mp(1, 0), mp("", 0)));
}

//by Andrey Kim


Measured memory_bytes: 3568
def main():
    mod = 10**9 +7
    n,k = map(int,input().split())
    ans = 0
    for i in range(k,n+2):
        a = i*(i-1)//2
        b = i*(2*n-i+1)//2
        ans += (b-a+1)
    print(ans%mod)
if __name__ == '__main__':
    main()

Measured memory_bytes: 9136
//
// Created by Takaaki Hirano on 2018/09/01.
//
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;
int N, K;
long long ans = 0;

void solve() {
    unordered_map<long long, long long> mp;
    // あまりを保持しておく
    for (int i = 1; i <= N; ++i) mp[i % K]++;

    // 全てのaに対して
    for (int a = 1; a <= N; ++a) {
        // aに対するb, cのあまり（等しくなる）
        int b = (K - a % K) % K;
        int c = (K - a % K) % K;

        // 場合の数を数えるためにあまりの場合の数を求める．
        if ((b + c) % K == 0) ans += mp[b] * mp[c];
    }

    printf("%lli\n", ans);
}

int main() {
    cin >> N >> K;
    solve();
    return 0;
}

Measured memory_bytes: 4388
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define ull unsigned long long
#define min(a,b) (a)<(b)?(a):(b)
#define max(a,b) (a)>(b)?(a):(b)

int main(){
	ull N,A,B,count;
	scanf("%llu %llu %llu",&N,&A,&B);
	count = (N/(A+B))*A;
	count += min( N%(A+B),A );
	printf("%llu",count);
	return 0;
}


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

int main(void){
    long long int n,i,ans,flag_ans0,flag_ans1;
    flag_ans0 = 10;
    flag_ans1 = 10;
    ans = 1;

    cin >> n;

    vector<long long int>  a(n);


    for(i=0; i<n; i++){
        cin >> a.at(i);
        if(a.at(i) == 0){
            flag_ans0 = 0;
        }
    }

    if(flag_ans0 != 0){
        for(i=0; i<n; i++){
            ans *= a.at(i);
            if(ans > 1000000000000000000){
                flag_ans1 = -1;
            }
        }
    }

    if(flag_ans0 == 0){
        cout << 0 << endl;
    }else if(flag_ans1 == -1  || ans <= 0){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 4048
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int A; int B; int C;
	while(~scanf("%d%d%d", &A, &B, &C)) {
		int xs[3] = { A, B, C };
		sort(xs, xs + 3);
		ll ans;
		if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
			ans = 0;
		} else {
			ans = (ll)xs[0] * xs[1];
		}
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 256
let () =
  Scanf.scanf "%d %d" @@ fun n k ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  let dp = Array.make (k+1) 0 in
  for i = 1 to k do
    dp.(i) <-
      1 - Array.fold_left (fun s w -> if w <= i then min s dp.(i-w) else s) 1 a
  done;
  print_endline [|"Second"; "First"|].(dp.(k))


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define sort_(a) sort(a.begin(), a.end())
#define sum(a) accumulate(a.begin(), a.end(), 0)
#define rep(i, n) for (int i = 0; i < n; ++i)
typedef long long unsigned int ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  map<char, string> S{};
  cin >> S['a'] >> S['b'] >> S['c'];
  char s, s_;
  s = S['a'][0];
  S['a'].erase(0, 1);
  locale l = locale::classic();
  while (1) {
    if (S[s].empty()) {
      cout << toupper(s, l) << endl;
      return 0;
    }
    s_ = S[s][0];
    S[s].erase(0, 1);
    s = s_;
  }
  return 0;
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}

bool cmp(const pair<ll,ll>& lv,const pair<ll,ll>& rv){
  return lv.second>rv.second;
}

main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);
  
  ll n;
  cin>>n;
  vector<ll> a(n);
  cin>>a;
  
  map<ll,ll> ecnt,ocnt;
  rep(i,n){
    if(i&1)ocnt[a[i]]++;
    else ecnt[a[i]]++;
  }
  vector<pair<ll,ll>> x,y;
  for(const auto& elm:ecnt)x.emplace_back(elm);
  for(const auto& elm:ocnt)y.emplace_back(elm);
  sort(x.begin(),x.end(),[](const pair<ll,ll> a,const pair<ll,ll> b){return a.second>b.second;});
  sort(y.begin(),y.end(),[](const pair<ll,ll> a,const pair<ll,ll> b){return a.second>b.second;});
  ll m=n/2;
  x.emplace_back(0,0);
  y.emplace_back(0,0);
  if(x[0].first==y[0].first){
    ll s=x[0].second+y[1].second;
    ll t=y[0].second+x[1].second;
    cout<<(n-max(s,t))<<endl;
  }
  else{
    cout<<(n-x[0].second-y[0].second)<<endl;
  }


}


Measured memory_bytes: 9592
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cinttypes>
#include <cassert>
#include <cinttypes>

using namespace std;

#if defined(_MSC_VER)
#pragma warning(disable: 4996)  // VSでscanfを使う．
#endif

int main() {
  int n, a, b, c, d;
  string s;
  
  cin >> n >> a >> b >> c >> d;
  cin >> s;

  n = min(n, max(c, d));

  a--;
  b--;
  c--;
  d--;

  for (int i = a; i < n - 1; i++) {
    if (s[i] == '#' && s[i + 1] == '#') {
      cout << "No" << endl;
      return 0;
    }
  }

  if (c < d) {
    cout << "Yes" << endl;
    return 0;
  }

  bool flag = false;
  for (int i = a; i < min(c, d); i++) {
    if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') {
      if (i + 3 < n && s[i + 3] == '#' && i + 2 == b) {
        continue;
      }
      flag = true;
      break;
    }
  }

  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;

int a,b;

bool pd(int x,int y){
	for(int i=1;i<=3;i++){
		if((x*y*i)%2==1)return 1;
	}
	return 0;
}

int main(){
	scanf("%d%d",&a,&b);
	if(pd(a,b)){
		printf("Yes");
	}
	else printf("No");
	return 0;
}

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

public class Main{
  //static[] A;
  public static int judge = 0;
  public static int count = 0;

  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    //int n = scan.nextInt();
    String l = scan.nextLine();
    int n = Integer.parseInt(l);
    Card[] cards = new Card[n];
    //BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

    for(int i=0 ; i<n ; i++){
      //String[] st = bf.readLine().split(" ");
      //StringTokenizer sss = new StringTokenizer(bf.readLine());
      //String[] st = sss.nextToken();
      //int a = Integer.parseInt(sss.nextToken());
      String line = scan.nextLine();
      cards[i] = new Card(line.substring(0, 1), Integer.parseInt(line.substring(2)), i);
      //cards[i] = new Card(st[0], a, i);
    }

    quicksort(cards, 0, n-1);

    for(int i=0 ; i<n-1 ; i++){
      if(cards[i].num == cards[i+1].num && cards[i].ord > cards[i+1].ord){
        judge++;
        break;
      }
    }

    if( judge>0 ){
      System.out.println("Not stable");
    }
    else{
      System.out.println("Stable");
    }

    for(int i=0 ; i<n ; i++){
      StringBuffer S = new StringBuffer();
      S.append(cards[i].str);
      S.append(" ");
      S.append(cards[i].num);
      System.out.println(S);
    }
  }

public static int partition(Card[] c, int p, int r){
    int x, i, j, t;
    x = c[r].num;
    i = p-1;
    Card S = new Card(null, 0, 0);
    for(j=p ; j<r ; j++){
      if(c[j].num <= x){
        i++;
        S = c[i];
        c[i] = c[j];
        c[j] = S;
      }
    }
    S = c[i+1];
    c[i+1] = c[r];
    c[r] = S;
    return i+1;
  }

public static void quicksort(Card[] c , int p, int r){
    if( p<r ){
      int q = partition(c, p, r);
      quicksort(c, p , q-1);
      quicksort(c, q+1 , r);
    }
  }
}

class Card{
  String str;
  int num;
  int ord;

  public Card(String str, int num, int ord){
    super();
    this.str = str;
    this.num = num;
    this.ord = ord;
  }
}



Measured memory_bytes: 158416
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

c_1 = list(map(int, readline().split()))
c_2 = list(map(int, readline().split()))
c_3 = list(map(int, readline().split()))
c = [c_1, c_2, c_3]
a = [min(c_1), min(c_2), min(c_3)]
b = [c_1[0] - a[0], c_2[1] - a[1], c_3[2] - a[2]]
for i in range(3):
    for j in range(3):
        if a[i] + b[j] != c[i][j]:
            print('No')
            exit()
print('Yes')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+7;
int n,m,a[N],h[N];
set<int>ans;
void check(int p)
{
    for(int i=0;i<p-1;i++)h[i]=0;
    for(int i=0,x;i<=n;i++)x=i%(p-1),h[x]=(h[x]+a[i])%p;
    for(int i=0;i<p-1;i++)if(h[i])return;
    ans.insert(p);
}
int main()
{
    scanf("%d",&n);
    for(int i=n;i>=0;i--)scanf("%d",&a[i]),m=__gcd(m,abs(a[i]));
    for(int i=2;i*i<=m;i++)
    if(m%i==0)
    {
        ans.insert(i);
        while(m%i==0)m/=i;
    }
    if(m!=1)ans.insert(m);
    for(int i=2;i<=n;i++)
    if(a[0]%i==0)
    {
        int flag=1;
        for(int j=2;j*j<=i;j++)if(i%j==0){flag=0;break;}
        if(flag)check(i);
    }
    for(auto x:ans)
    {
      if (a[0]%x) assert(0);
      printf("%d\n",x);
    }
}

Measured memory_bytes: 384
import math
from itertools import combinations

N = int(input())
xy = [tuple(map(int,input().split())) for _ in range(N)]

roots = list(combinations(range(0,N),2))

sum_r = 0
for t, nt in roots:
  sum_r += math.sqrt((xy[t][0] - xy[nt][0])**2 + (xy[t][1] - xy[nt][1])**2)
  
res = 2*sum_r/N
print(res)

Measured memory_bytes: 9012
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int a,b;
  cin>>a>>b;
  cout<<max(0,a-2*b)<<endl;
  return 0 ;
}


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

string alp = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

int na = 62;
int L = 128;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    priority_queue<pair<int, string>, vector<pair<int, string>>, greater<pair<int, string>>> pq;
    vector<int> cnt(na);
    int sum = 0;
    rep(i, na) {
        string s = "";
        rep(j, L) s += alp[i];
        cout << "? " << s << endl;
        cout.flush();
        int a;
        cin >> a;
        cnt[i] = L - a;
        sum += L - a;
    }
    rep(i, na) {
        string t = "";
        rep(j, cnt[i]) t += alp[i];
        if(cnt[i] > 0) pq.push(mp(t.size(), t));
    }
    while(pq.size() > 1) {
        string s = pq.top().second; pq.pop();
        string t = pq.top().second; pq.pop();
//        cerr << s << "," << t << endl;
        string u = s;
        int cur = 0;
        rep(i, t.size()) {
            rep(j, cur, u.size() + 1) {
                string v = u.substr(0, j) + t[i] + u.substr(j, u.size() - j);
                cout << "? " << v << endl;
                cout.flush();
                int c;
                cin >> c;
                if (c == sum - v.size()) {
                    u = v;
                    cur = j + 1;
                    break;
                }
            }
        }
        pq.push(mp(u.size(), u));
    }
    
    cout << "! " << pq.top().second << endl;
    
    
    return 0;
}


Measured memory_bytes: 3776