akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
#include <cstdint>

using u64 = std::uint_fast64_t;
#include <cstdint>

template <std::uint_fast64_t Modulus> class modint {

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
	*this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

void solve(void){

  int n;
  std::cin >> n;
  
  std::vector<u64> A(n);
  
  modint<1000000007> total = 0;
  modint<1000000007> ret = 0;
  for(int i=0; i<n; i++){
    std::cin >> A[i];
    total+= A[i];

    ret += (total - A[i]) * A[i];
    //std::cout << A[i] << " " << total.a << " " << ret.a << std::endl;
  }
  std::cout << ret.a << std::endl;
  
  return;
}
int main(void){
  solve();
  return 0;
}





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

using namespace std;

static const int MAX = 200000;

int main() {
    int R[MAX], n;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> R[i];
    }

    int maxv = -1000000000;
    int minv = R[0];

    for (int i = 1; i < n; ++i) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
}




Measured memory_bytes: 3900
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

class UnionFind {
public:
  // 親の番号を格納する。親だった場合は-(その集合のサイズ)
  vector<int> parent;

  // 作るときは parent の値を全て -1 にする
  // こうすると全てバラバラになる
  UnionFind(const int& n = 0) : parent(n, -1) {}

  // x がどのグループに属しているか調べる
  int find(const int& x) {
    if (parent[x] < 0) return x;
    return parent[x] = find(parent[x]);
  }

  // x と y をくっつける  O(log n)
  bool unite(int x, int y) {
    // x と y を直接くっつけるのではなく，root(x) に root(y) をくっつける
    x = find(x);
    y = find(y);
    if (x == y) return false;  // すでにくっついているからくっつけない

    // 大きい方(x) に小さい方(y)をくっつけたい 大小が逆だったらひっくり返す
    if (size(x) < size(y)) swap(x, y);

    parent[x] += parent[y];  // x のサイズを更新する
    parent[y] = x;  // y の親を x に変更する
    return true;
  }

  // 自分のいるグループの頂点数を調べる
  int size(const int& x) { return -parent[find(x)]; }

  // x と y が同じグループに属しているか否か
  bool same(const int& x, const int& y) { return find(x) == find(y); }
};

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

  int n, m, k;
  cin >> n >> m >> k;
  UnionFind uf(n);

  vector<int> ng(n, 0);

  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    uf.unite(a, b);
    ng[a]--;
    ng[b]--;
  }

  rep(i, k) {
    int c, d;
    cin >> c >> d;
    c--; d--;
    if (uf.same(c, d)) {
      ng[c]--;
      ng[d]--;
    }
  }

  rep(i, n) {
    cout << uf.size(i) - 1 + ng[i] << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    a[i]-=(i+1);
  }
  sort(a.begin(),a.end());
  int d=0;
  if(n%2!=0)d=a[n/2];
  else d=(a[n/2]+a[(n/2)-1])/2;
  long long ans=0;
  for(int i=0;i<n;i++)ans+=abs(a[i]-d);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4012
#include<iostream>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;
using namespace std;
int main(){
    ll H; cin >> H;
    ll ans = 0;
    ll cnt = 0;
    while(H != 0){
        //cout << H << " " << pow(2, cnt) << " " << cnt << endl;
        ans += pow(2, cnt);
        H /= 2;
        //cout << H << endl;
        cnt++;
    }
    cout << ans << endl;
    //cout << cnt-1 << endl;
}

Measured memory_bytes: 256
$n=<>;
for(glob<>){
	if(--$|){
		++$e{$_};
	}else{
		++$o{$_};
	}
}
@e=sort{$e{$b}-$e{$a}}keys%e;
@o=sort{$o{$b}-$o{$a}}keys%o;
if($e[0]==$o[0]){
	print$n-($e{$e[0]}+$o{$o[1]}>$e{$e[1]}+$o{$o[0]}?$e{$e[0]}+$o{$o[1]}:$e{$e[1]}+$o{$o[0]})
}else{
	print$n-($e{$e[0]}+$o{$o[0]})
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	int n;cin>>n;
	vector<string>s(n);
	int cnt=0,a=0,b=0,ba=0;
	rep(i,n){
		cin>>s[i];
		int x=s[i].size();
		if(s[i][0]=='B'&&s[i][x-1]!='A')b++;
		if(s[i][x-1]=='A'&&s[i][0]!='B')a++;
		if(s[i][0]=='B'&&s[i][x-1]=='A')ba++;
		rep(j,x-1){
			if(s[i][j]=='A'&&s[i][j+1]=='B')cnt++;
		}
	}
	int ans=0;
	if(ba>0){
		ans+=ba-1;
	}
	if(a!=0||b!=0){
		if(ba>0){ans++;}
	}
	ans+=min(a,b);
    ans+=cnt;
	cout<<ans;
}


Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N, K;
int imosb[2020][2020], imosw[2020][2020];
int bcnt, wcnt;

signed main() {
    cin >> N >> K;
    rep(i, N) {
        int x, y;
        char c;
        cin >> x >> y >> c;
        x %= 2 * K;
        y %= 2 * K;
        if (c == 'B') {
            bcnt++;
            imosb[x][y] += 1;
        } else if (c == 'W') {
            wcnt++;
            imosw[x][y] += 1;
        }
    }
    rep(i, 2 * K) {
        for (int j = 1; j < 2 * K; ++j) {
            imosb[i][j] += imosb[i][j - 1];
            imosw[i][j] += imosw[i][j - 1];
        }
    }
    for (int i = 1; i < 2 * K; ++i) {
        rep(j, 2 * K) {
            imosb[i][j] += imosb[i - 1][j];
            imosw[i][j] += imosw[i - 1][j];
        }
    }
    int ans = 0;
    rep(i, K) {
        rep(j, K) {
            int tmpb = 0, tmpw = 0;
            tmpb += imosb[2 * K - 1][2 * K - 1];
            tmpb -= imosb[i + K - 1][2 * K - 1];
            if (i)
                tmpb += imosb[i - 1][2 * K - 1];
            tmpb -= imosb[2 * K - 1][j + K - 1];
            tmpb += 2 * imosb[i + K - 1][j + K - 1];
            if (i)
                tmpb -= 2 * imosb[i - 1][j + K - 1];
            if (j)
                tmpb += imosb[2 * K - 1][j - 1];
            if (j)
                tmpb -= 2 * imosb[i + K - 1][j - 1];
            if (i && j)
                tmpb += 2 * imosb[i - 1][j - 1];

            tmpw += imosw[2 * K - 1][2 * K - 1];
            tmpw -= imosw[i + K - 1][2 * K - 1];
            if (i)
                tmpw += imosw[i - 1][2 * K - 1];
            tmpw -= imosw[2 * K - 1][j + K - 1];
            tmpw += 2 * imosw[i + K - 1][j + K - 1];
            if (i)
                tmpw -= 2 * imosw[i - 1][j + K - 1];
            if (j)
                tmpw += imosw[2 * K - 1][j - 1];
            if (j)
                tmpw -= 2 * imosw[i + K - 1][j - 1];
            if (i && j)
                tmpw += 2 * imosw[i - 1][j - 1];
            ans = max(ans, tmpb + wcnt - tmpw);
            ans = max(ans, tmpw + bcnt - tmpb);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 63744
#include <stdio.h>

int main(void){
  int n,a,aa[2000001],i;
  long int ans=0;
  scanf("%d",&n);
  for(i=1;i<n;i++){
    aa[i]=0;
  }
  for(i=1;i<=n;i++){
    scanf("%d",&a);
    if((i-a)>0){
      ans+=aa[i-a];
    }
    if((a+i)<n){
      aa[a+i]++;
    }
  }
  printf("%ld",ans);
  return 0;
}

Measured memory_bytes: 2524
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (1000000000)
#define MOD (1000000007)

int main(void)
{
    int n,l;
    scanf("%d %d",&n,&l);

    int s=0;
    int m=INT_MAX;
    for(int i=1;i<=n;i++)
    {
        s+=l+i-1;
        if(abs(m)>abs(l+i-1)) m=l+i-1;
    }
    s -=m;
    printf("%d\n",s);

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main()
{
	int in[11][11];
	int n;
	int nyu;

	scanf("%d",&n);

	while(n != 0){
		for(int i = 0; i <= n; i++){
			for(int j = 0; j <= n; j++){
				in[i][j] = 0;
			}
		}

		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				scanf("%d",&in[i][j]);
				in[i][n] += in[i][j];
			}
		}

		for(int i = 0; i < n; i++){
			for(int j = 0; j <= n; j++){
				in[n][j] += in[i][j];
			}
		}

		for(int i = 0; i <= n; i++){
			for(int j = 0; j <= n; j++){
				printf("%5d",in[i][j]);
			}
			printf("\n");
		}

		scanf("%d",&n);
	}

	return 0;
}

Measured memory_bytes: 1044
#include <stdio.h>

int main()
{
  int a, b, c;
  int x[3];

  int i, j;
  int tmp;

  scanf("%d%d%d", &a, &b, &c);

  x[0] = a;
  x[1] = b;
  x[2] = c;

  for (i = 0; i < 3; i++) {
    for (j = i + 1; j < 3; j++) {
      if (x[i] > x[j]) {
        tmp = x[i];
        x[i] = x[j];
        x[j] = tmp;
      }
    }
  }

  printf("%d %d %d\n", x[0], x[1], x[2]);

  return 0;
}

Measured memory_bytes: 596
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		Map<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			putCntMap(map, a[i]);
		}
		int size = map.keySet().size();
		if (size == 1) {
			int x = map.keySet().iterator().next();
			if (x == n - 1 || 2 * x <= n) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else if (size == 2) {
			Iterator<Integer> it = map.keySet().iterator();
			int m1 = it.next();
			int m2 = it.next();
			int x = Math.min(m1, m2);
			int y = Math.max(m1, m2);
			if (y - x != 1) {
				System.out.println("No");
			} else {
				int xc = map.get(x);
				int yc = map.get(y);
				if (xc < y) {
					if (2 * (y - xc) <= yc) {
						System.out.println("Yes");
					} else {
						System.out.println("No");
					}
				} else {
					System.out.println("No");
				}
			}
		} else {
			System.out.println("No");
		}
	}

	static void putCntMap(Map<Integer, Integer> map, Integer key) {
		if (map.containsKey(key)) {
			map.put(key, map.get(key) + 1);
		} else {
			map.put(key, 1);
		}
	}
}


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

int n;
int a1[110];
int a2[110];
int res = 0;

int main(){
  cin >> n;
  rep(i, n) cin >> a1[i];
  rep(i, n){
    cin >> a2[i];
    res += a2[i];
  }
  res += a1[0];
  //cout << res <<endl;
  int sum = res;
  rep(i, n-1){
    int d = a1[i+1] - a2[i];
    sum += d;
    res = max(res, sum);
  }
    
  cout << res << endl;
}

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

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
 os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os << "(" << P.first << "," << P.second << ")";}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif


#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"

const ll MAX = 1e4+15; 
set<ll> ans;
vll v;ll gc;
ll n;
ll pr[MAX];
void sieve(){
	// cout<<gc;
	ll i,j,k;
	for(i=2;i<=n+2;i++)pr[i] = i;
	for(i=2;i<=n+2;i++){
		if(pr[i]!=i)continue;
		ll a=0;bool is = true;
		for(j=0;j<i-1;j++){
			a=0;
			for(k=j;k<=n;k+=i-1){
				a+=v[k];
			}
			if(a<0) { a = i - (abs(a)%i); a%=i; }  
			// trace(j,a,v[0]);
			if(i==2){if(!(((v[0]%2)==0)&&((a%2)==0)))is = false; continue;}
			if(a%i){is= false;break;}
		}
		if(v[0]%i)is=false;
		if(is)ans.I(i);
		for(j=i+i;j<MAX;j+=i){
			pr[j] = min(pr[j],i);
		}
	}
	for(i=2;i*i<=gc;i++){
		if(gc%i)continue;
		while((gc%i)==0)gc/=i;
		ans.I(i);
	}
	if(gc!=1)ans.I(gc);
}
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	ll a,b,c,i,j,k;
	cin>>n;
	for(i=0;i<=n;i++){
		cin>>a;v.pb(a);
		if(i==0)b=abs(a);else b=__gcd(b,abs(a));
	}
	gc = b;
	reverse(v.begin(),v.end());
	sieve();
	for(auto z:ans)cout<<z<<"\n";
}


Measured memory_bytes: 512
using System;
class Program
 {
        static void Main(string[] args)
        {
    　　int a,b,c;
            string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            a = int.Parse(str[0]); //標準入力
            b = int.Parse(str[1]);  //数値で受け取りたい場合は変換する
            c = int.Parse(str[2]);
            int temp =0;

            temp = b;
            b = a;
            a = temp;

            temp = c;
            c = a;
            a = temp;

　　　　　　　Console.Write("{0} {1} {2}", a, b, c);//改行なし出力
        }
 }













Measured memory_bytes: 13268
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
#define INF -99999999 
using namespace std;



int main(){
    int K; cin >> K;
    if(K <= 9){
        cout << K << endl;
        return 0;
    }
    queue<ll> Q;
    for (int i = 1; i < 10; i++)
    {
        Q.push(i);
    }
    int cnt = 9;
    while(true){
    ll q = Q.front();
    Q.pop();
    if(q%10 == 0){
        Q.push(q*10);
        cnt++;
        if(cnt == K){
            cout << Q.back() << endl;
            return 0;
        }
        Q.push(q*10+1);
        cnt++;
        if(cnt == K){
            cout << Q.back() << endl;
            return 0;
        }
    }
    else if(q%10 == 9){
        Q.push(q*10+8);
        cnt++;
        if(cnt == K){
            cout << Q.back() << endl;
            return 0;
        }
        Q.push(q*10+9);
        cnt++;
        if(cnt == K){
            cout << Q.back() << endl;
            return 0;
        }
    }
    else{
        Q.push(q*10+q%10-1);
        cnt++;
        if(cnt == K){
            cout << Q.back() << endl;
            return 0;
        }
        Q.push(q*10+q%10);
        cnt++;
        if(cnt == K){
            cout << Q.back() << endl;
            return 0;
        }
        Q.push(q*10+q%10+1);
        cnt++;
        if(cnt == K){
            cout << Q.back() << endl;
            return 0;
        }
    }
    }
    
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

struct BIT {
    int sz;
    vector<int> bit;
    void init(int n) {
        sz = n;
        bit.assign(sz + 1, 0);
    }
    void add(int i, int x) {
        for(i++; i <= sz; i += i & -i)
            bit[i] += x;
    }
    int sum(int i) {
        int s = 0;
        for(; i > 0; i -= i & -i)
            s += bit[i];
        return s;
    }
} bit;

void no() {
    puts("No");
    exit(0);
}

int n;
int a[3][100009];
V<int> as, bs;
bool ac, bc;

bool f(vector<int> vec) {
    bit.init(n);
    ll cnt = 0;
    for(int v : vec) {
        cnt += bit.sum(v);
        bit.add(v, 1);
    }
    cnt += vec.size() * (vec.size() - 1) / 2;
    return cnt & 1;
}

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

    cin >> n;
    rep(i, 3) rep(j, n) {
        cin >> a[i][j];
        a[i][j]--;
    }
    rep(i, n) {
        int q = a[0][i] / 3;
        if(a[1][i] / 3 != q || a[2][i] / 3 != q) no();
        if(a[1][i] % 3 != 1) no();
        bool flip = (a[0][i] % 3 == 2);
        if((i ^ q) & 1) no();
        if(i & 1) {
            bs.push_back(q);
            bc ^= flip;
        } else {
            as.push_back(q);
            ac ^= flip;
        }
    }
    if(f(as) == bc && f(bs) == ac)
        puts("Yes");
    else
        no();

    return 0;
}

Measured memory_bytes: 2684
#include<iostream>

using namespace std;

int main() {
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	if (r <= x&&x <= w - r&&r <= y&&y <= h - r)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1000000000;
const LL MOD = 1000000007;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

int main() {
  int N;
  cin >> N;
  VD v(N);
  REP(i,N) {
    cin >> v.at(i);
  }
  SORT(v);
  REP(i,N-1) {
    v.at(i+1) = (v.at(i) + v.at(i+1)) / 2;
  }
  cout << fixed << setprecision(7) << v.at(N-1) << endl;
  return 0;
}
  

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

int a, b, c, d; 
int main()
{
 	cin >> a >> b >> c >> d;
	if((abs(a-b) <= d and abs(b-c) <= d) or abs(c-a) <= d) 
		cout << "Yes" << endl;
	else 
		cout << "No" << endl;

	return 0;
}


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

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

const int MAXN = 1e5;
int n, a[MAXN + 5];

int main() {
	read(n);
	for (int i = 1; i <= n; ++i) read(a[i]);
	sort(a + 1, a + n + 1, greater<int>());
	for (int i = 1; i <= n; ++i)
		if (i + 1 > a[i + 1]) {//找到以原点为左下角的最大正方形，其右上方顶点为 (i, i) 
			int j = 0;
			for (; a[j + i + 1] == i; ++j);
			if (((a[i] - i) & 1) || (j & 1)) puts("First");
			else puts("Second");
			break;
		}
	return 0;
}

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

using namespace std;




int main()
{
	int N , M;
	cin >> N >> M;
	vector<int> a(N + 1, 0);

	for (int i = 1; i <= M; i++)
	{
		int broken;
		cin >> broken;
		a[broken] = 1;
	}
	
	vector<long long> p(N + 1, 0);

	p[0] = 1;
	if (a[1] != 1)
	{
		p[1] = 1;
	}
	else
	{
		p[1] = 0;
	}
	
	for (int i = 2; i <= N; i++)
	{
		if (a[i] != 1)
		{
			p[i] = p[i - 1] + p[i - 2];
			p[i] %= 1000000007;
		}
		else
		{
			p[i] = 0;
		}
	}
	
	cout << p[N];
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-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 dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

ll calc(const vector<ll> &a, int k){
    ll ret=1ll;
    for (int i = 0; i < k; ++i) {
        (ret*=(a[i]+MOD))%=MOD;
    }
    if(ret<0) ret+=MOD;
    return ret;
}

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main() {
    int N,K; cin>>N>>K;
    vector<ll> pos,neg;
    bool zero=false;
    vector<ll> a(N);
    for (int i = 0; i < N; ++i) {
        cin>>a[i];
        if(a[i]>0) pos.push_back(a[i]);
        else if(a[i]==0) zero=true;
        else neg.push_back(a[i]);
    }


    if(pos.size()+neg.size()<K){
        cout<<0<<endl;
        return 0;
    }
    if(pos.empty()){
        if(K%2==0) sort(neg.begin(),neg.end());
        else{
            if(zero){
                cout<<0<<endl;
                return 0;
            }
            sort(neg.rbegin(),neg.rend());
        }
        ll ans = calc(neg,K);
        (ans+=MOD)%=MOD;
        cout<<ans<<endl;
        return 0;
    }

    if(N==K){
        ll ans=(calc(pos,pos.size())*calc(neg,neg.size()))%MOD;
        (ans+=MOD)%=MOD;
        cout<<ans<<endl;
        return 0;
    }

    sort(a.begin(),a.end(),[](const ll &x,const ll &y){
        return abs(x)>abs(y);
    });

    int negcnt=0;
    ll lastneg=INF,lastpos=INF;
    for(int idx=0;idx<K;++idx){
        if(a[idx]<0){
            negcnt++;
            lastneg=a[idx];
        }else{
            lastpos=a[idx];
        }
    }

    if(negcnt%2==0){
        ll ans=calc(a,K);
        (ans+=MOD)%=MOD;
        cout<<ans<<endl;
        return 0;
    }

    ll ans = calc(a,K);

    //neg ++
    ll idx0=1, idx1=1;
    for (int i = K; i < N; ++i) {
        if(a[i]<0){
            idx0=a[i];
            break;
        }
    }

    //pos++
    for (int i = K; i < N; ++i) {
        if(a[i]>0){
            idx1=a[i];
            break;
        }
    }

    if(lastpos!=INF&&abs(idx0*lastneg)>abs(idx1*lastpos)){
        (ans*=idx0)%=MOD;
        (ans*=modinv(lastpos))%=MOD;
        (ans+=MOD)%=MOD;
    }else{
        (ans*=idx1)%=MOD;
        (ans*=modinv(lastneg+MOD))%=MOD;
        (ans+=MOD)%=MOD;
    }

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


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

int main() {
  int n;
  string s;
  cin >>n>>s;
  
  int len = s.size();
  
  for(int i=0;i<len;i++){
    if(s.at(i)+n<='Z'){
      s.at(i) = s.at(i)+n;
    }
    else{
      s.at(i) = s.at(i)+n-26;
    }
  }
  
  cout << s <<endl;
  
}


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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt(); int k = sc.nextInt();
        int [] a = new int[k + 1];
        for (int i = 1; i <= k; i++) {
            a[i] = k / i;
        }
        long ans = 0; int mod = (int) 1e9 + 7;
        long [] amt = new long[k + 1];
        for (int i = k; i >= 1; i--) {
            long put = pow(a[i], n, mod);
            for (int j = 2 * i; j <= k; j += i) {
                put = (put - amt[j]) % mod;
                if (put < 0) put += mod;
            }
            amt[i] = put;
            ans = (ans + (i * amt[i]) % mod) % mod;
        }
        out.println(ans);
        out.close();
    }

    static long pow(long b, int e, int mod) {
        long ans = 1;
        while (e > 0) {
            if (e % 2 == 1)
                ans = ans * b % mod;
            e >>= 1;
            b = b * b % mod;
        }
        return ans;
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

Measured memory_bytes: 34304
n = int(input())
a = list(map(int, input().split()))

res = 0
i = 0
while i < n:
	# sama
	while (i + 1 < n and a[i] == a[i + 1]):
		i += 1

	if i + 1 < n and a[i] < a[i + 1]:
		while i + 1 < n and a[i] <= a[i + 1]:
			i += 1

	elif i + 1 < n and a[i] > a[i + 1]:
		while i + 1 < n and a[i] >= a[i + 1]:
			i += 1
	res += 1
	i += 1

print(res)


Measured memory_bytes: 62704
#include <iostream>

using namespace std;

int main(){
    int x,a,b;
    cin >> x>> a>> b;
    int ans=100000;
    if(abs(x-a)<abs(x-b)){
        cout <<'A'<<endl;
    }else{
        cout <<'B'<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
#define dd(x) cout << #x << " : " << x << endl
using namespace std;
using ll = int64_t;

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

    loop(i, 1, 10001){
        if(int(double(i)*0.08) == a && int(double(i)*0.1) == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
from itertools import product
N,M,X=map(int,input().split())
C=[]
A = [[] for _ in range(N)]
for i in range(N):
    inp=list(map(int,input().split()))
    C.append(inp[0])
    A[i]=inp[1:]
    
ans=float('inf')

for pattern in product([0,1],repeat=N):
    ms=[0]*M
    tmp_ans=0
    for i,p in enumerate(pattern):
        if p==0:
            continue
        tmp_ans += C[i]
        for j,q in enumerate(A[i]):
            ms[j] += q
    if all(m >= X for m in ms):
        ans = min(ans,tmp_ans)

if ans==float('inf'):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9244
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, x, total = 0;
  cin >> N >> K;

  for (int i = 0; i < N; i++) {
    cin >> x;
    total += x - 0 <= K - x ? 2 * (x - 0): 2 * (K -x);
  }

  cout << total << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n,k; cin >> n >> k;
    ll l,r; cin >> l >> r;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    int mid=n/2;
    vector<ll> beg[n+1];
    vector<ll> ed[n+1];
    rep(i,1ull<<mid){
        ll res=0;
        rep(j,mid){
            if(i&(1<<j))res+=a[j];
        }
        int num=__builtin_popcount(i);
        beg[num].pb(res);
    }
    rep(i,1ull<<(n-mid)){
        ll res=0;
        rep(j,(n-mid)){
            if(i&(1<<j))res+=a[j+mid];
        }
        int num=__builtin_popcount(i);
        ed[num].pb(res);
    }
    rep(i,n+1) sort(ALL(beg[i]));
    rep(i,n+1) sort(ALL(ed[i]));
    ll ans=0;
    rep(i,n+1){
        if(i>k) continue;
        for(ll u:beg[i]){
            //use ed[k-i]
            int p=(int)(lower_bound(ALL(ed[k-i]),l-u)-ed[k-i].begin());
            int q=(int)(upper_bound(ALL(ed[k-i]),r-u)-ed[k-i].begin());
            ans+=(q-p);
        }
    }
    cout << ans <<  endl;
}



Measured memory_bytes: 23356
#ベクトルで考える
x1,y1,x2,y2 =map(int, input().split())
x3=x2+(y1-y2)
y3=y2-(x1-x2)
x4=x1+(y1-y2)
y4=y1-(x1-x2)
print(x3,y3,x4,y4)

Measured memory_bytes: 2940
N,M,X = map(int,input().split())
CA = [list(map(int,input().split())) for i in range(N)]

ans = float('inf')
for b in range(1<<N):
    arr = [0] * (M+1)
    for i in range(N):
        if b&(1<<i)==0: continue
        for j,a in enumerate(CA[i]):
            arr[j] += a
    if all(a >= X for a in arr[1:]):
        ans = min(ans, arr[0])
print(-1 if ans==float('inf') else ans)

Measured memory_bytes: 9216
#include <stdio.h>
int main (void){
    int a,i,n[31]={0};
    for(i=0;i<28;i++){
        scanf("%d",&a);
        n[a]=1;
    }
    for(i=0;i<31;i++){
        if(n[i]==0&&i!=0){
            printf("%d\n",i);
        }
    }
return 0;
}

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

//??????????????§??\??????????????¨??????
const int TOP=0,BOTTOM=1,FRONT=2,BACK=3,LEFT=4,RIGHT=5;

template<class T>
class dice{
public:
    dice(){
        for(int i=0;i<6;i++)id[i]=i;
    }

    T& operator[](int f){return var[id[f]];}
    const T& operator[](int f)const{return var[id[f]];}

    //???????????????????????´????????????
    bool operator==(const dice<T>&b)const{
        const dice<T>&a=*this;
        for(int i=0;i<6;i++)if(a[i]!=b[i])return false;
        return true;
    }

    //????¨??????¢??????
    void roll_x(){roll(TOP,BACK,BOTTOM,FRONT);}
    void roll_y(){roll(TOP,LEFT,BOTTOM,RIGHT);}
    void roll_z(){roll(FRONT,RIGHT,BACK,LEFT);}

    //?????¢??????????????\???24???????????¶????????????
    vector<dice<T> >all_rolls(){
        vector<dice<T> >ret;
        for(int k=0;k<6;(k&1?roll_y():roll_x()),k++){
            for(int i=0;i<4;roll_z(),i++){
                ret.push_back(*this);
            }
        }
        return ret;
    }

    bool equivalent_to(const dice<T>& di){
        vector<dice<T> >vec=all_rolls();
        for(int i=0;i<vec.size();i++){
            if(vec[i]==di)return true;
        }
        return false;
    }
private:
    void roll(int a,int b,int c,int d){
        int tmp=id[a];
        id[a]=id[b];id[b]=id[c];
        id[c]=id[d];id[d]=tmp;
    }

    T var[6];
    int id[6];
};

int main(){
    int N;
    while(cin>>N,N){
        vector<dice<string> >vec;

        int cnt=0;
        while(N--){
            dice<string>d;
            cin>>d[TOP];
            cin>>d[FRONT];
            cin>>d[RIGHT];
            cin>>d[LEFT];
            cin>>d[BACK];
            cin>>d[BOTTOM];

            bool ok=true;
            for(int i=0;i<vec.size();i++)
                if(vec[i].equivalent_to(d))ok=false;
            if(ok)vec.push_back(d);
            else cnt++;
        }

        cout<<cnt<<endl;
    }

    return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	while(cin >> n >> m,n){
		int a,b,c,d;
		int co[m][m];
		int ti[m][m];
		for(int i = 0; i < m; i++)
			for(int j = 0; j < m; j++){
				co[i][j] = 100000000;
				ti[i][j] = 100000000;
			}
		for(int i = 0; i < n; i++){
			cin >> a >> b >> c >> d;
			a--; b--;
			co[a][b] = c;
			co[b][a] = c;
			ti[a][b] = d;
			ti[b][a] = d;
		}
		int asd,p,q,r;
		cin >> asd;
		for(int l = 0; l < m; l++)
			for(int j = 0; j < m; j++)
				for(int k = 0; k < m; k++){
						co[j][k] = min(co[j][k] , co[j][l] + co[l][k]);
						ti[j][k] = min(ti[j][k] , ti[j][l] + ti[l][k]);
				}
		for(int i = 0; i < asd; i++){
			cin >> p >> q >> r;
			p--; q--;
			cout << (r == 0 ? co[p][q] : ti[p][q]) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include<cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
 
int main() {
    ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	int x = 1;
	for (int i = 0 ; i < n ; i++) {
		if (x < k) x *= 2;
		else x += k;
	}
	cout << x;
}


Measured memory_bytes: 3624
//解説あり、他者回答参考
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;
static const long long INF = 2000000000000000007;

ll N, K;
ll a[200005]; 

// 0 1 2 3 4
// i   l r
int main(void) {
    scanf("%lld %lld", &N, &K);
    rep(i, 0, N) {
        scanf("%lld", &a[i]);
    }
    sort(a, a+N);
    ll l = -INF, r = INF; //自分未満がK個未満の最大値がK番目
    while (r-l>1) {
        ll m = (r + l) / 2;
        ll cnt = 0;
        for (int i=0; i<N; i++) { //全てのa[i]についてm未満となる組み合わせの個数を調べる
            ll s = i, t = N;
            if (a[i]<0) {
                while(t-s>1) {
                    ll u = (s + t) / 2;
                    if (a[i]*a[u]<m) t = u;
                    else s = u;
                }
                cnt += N-t;
            } else {
                while (t-s>1) {
                    ll u = (s + t) / 2;
                    if (a[i]*a[u]<m) s = u;
                    else t = u;
                }
                cnt += s-i;
            }

        }
        if (cnt<K) l = m;
        else r = m;
    }
  
    printf("%lld\n", l);

    return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {
	ll kazu = 1;
	while (1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数


template<typename T>
T nCr(ll n, T r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll N, M;cin >> N >> M;
	bool OK = true;
	vector<ll> s(M), c(M);
	ll ans = 0;
	for (int i = 0;i < M;i++) {
		cin >> s[i] >> c[i];
		if (N!=1&&s[i] == 1 && c[i] == 0)OK = false;
	}
	for (int i = 0;i < M - 1;i++) {
		for (int l = i + 1;l < M;l++) {
			if (s[i] == s[l]) {
				if (c[i] == c[l])c[l] = 0;
				else OK = false;
			}
		}
	}
	for (int i = 0;i < M;i++) {
		ans += pow(10, N - s[i]) * c[i];
	}
	if (keta(ans) != N) {
		ans += pow(10, N - 1);
	}
	if (!OK) ans = -1;
	cout << ans << endl;
}


Measured memory_bytes: 512
import java.util.*;
public class Main
{
  	public static void main(String args[])
    {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int t = sc.nextInt();
      int i=0;
      int sum=0;
      for(i=0;i<t;i++)
        sum += sc.nextInt();
      if(sum < n)
        System.out.println("No");
      else
        System.out.println("Yes");
    }
}

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

void solve(long long N, std::vector<long double> p){
    long double dp[N+1][N+1] ={};
    dp[0][0] =1;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){

            dp[i+1][j] += dp[i][j] * (1-p[i]);
            dp[i+1][j+1] += dp[i][j] *p[i];
        }
    }
    long double ans =0;
    int half = N/2 + N%2;
    for(int i=half;i<=N;i++){
        ans += dp[N][i];
    }
    cout << setprecision(10)<<ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long double> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%Lf",&p[i]);
    }
    solve(N, std::move(p));
    return 0;
}


Measured memory_bytes: 140928
#include <bits/stdc++.h>
using namespace std;
long long n, a, b;

int main() {
    cin >> n >> a >> b;
    long long ab = a + b;
    long long st = n / ab;
    long long rest = n - ab*st;
    long long ans = a*st;
    ans += min(rest, a);
    cout << ans << endl;
}

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

#define MAX 20

int main(){
	int count;
	std::cin >> count;
	//dp[計算した回数][計算したとこまでの合計]を宣言する
	std::vector<std::vector<unsigned long long int>> dp(count - 1);
	for(auto &i: dp){
		i.resize(MAX + 1, 0);
	}
	int num;
	std::cin >> num;
	//最初はそのまま入れる
	dp[0][num] = 1;
	for(int i = 1; i < count - 1; ++i){
		std::cin >> num;
		//条件から三つに分ける
		for(int sum = 0; sum < num; ++sum){
			dp[i][sum + num] += dp[i - 1][sum];
		}
		for(int sum = num; sum <= MAX - num; ++sum){
			dp[i][sum + num] += dp[i - 1][sum];
			dp[i][sum - num] += dp[i - 1][sum];
		}
		for(int sum = MAX - num + 1; sum <= MAX; ++sum){
			dp[i][sum - num] += dp[i - 1][sum];
		}
	}
	
	std::cin >> num;
	std::cout << dp[count - 2][num] << std::endl;
	
	return 0;
}
	

Measured memory_bytes: 1212
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------
constexpr int MX = 405;
vector<ll> a(MX);
vector<vector<ll>> dp(MX, vector<ll>(MX, LINF));
vector<ll> cum(MX);

ll dfs(int l, int r) {
    if(dp[l][r]!=LINF) return dp[l][r];
    ll res = LINF;
    for(int i=l; i<r; i++) {
        chmin(res, dfs(l, i)+dfs(i+1,r)+cum[r]-cum[l]+a[l]);
    }
    return dp[l][r] = res;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    int n; cin >> n;
    rep(i,n) cin >> a[i];
    cum[0] = a[0];
    FOR(i,1,n-1) {
        cum[i] = cum[i-1] + a[i];
    }
    rep(i,n) {
        dp[i][i] = 0;
        if(i < n-1) dp[i][i+1] = a[i] + a[i+1];
    }   
    cout << dfs(0, n-1) << endl;
    return 0;
}


Measured memory_bytes: 4964
#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1e5 + 321;
int pole[3][SIZE];
int tab[3][SIZE];

int main(){

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

    int n;
    cin>>n;

    for(int i=0; i<n; i++)
        cin >> pole[0][i] >> pole[1][i] >> pole[2][i];

    tab[0][0]=pole[0][0];
    tab[1][0]=pole[1][0];
    tab[2][0]=pole[2][0];

    for(int i=1;i<=n;i++){
        tab[0][i]+=max(tab[1][i-1],tab[2][i-1])+pole[0][i];
        tab[1][i]+=max(tab[0][i-1],tab[2][i-1])+pole[1][i];
        tab[2][i]+=max(tab[0][i-1],tab[1][i-1])+pole[2][i];
    }
    
    int c=max(tab[0][n-1],tab[1][n-1]);
    c=max(c,tab[2][n-1]);
    cout<<c;
    return 0;
}

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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long H;
	scanf("%lld",&H);
	long long N;
	scanf("%lld",&N);
	std::vector<long long> A(N);
	for(ll i = 0 ; i < N ; i++){
		scanf("%lld",&A[i]);
	}

	ll sum = 0;
	for (ll i = 0; i < N; ++i)
	{
		sum += A[i];
	}
	if (H <= sum)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 1024
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<cstdio>
#include<math.h>
#include<vector>
#include<algorithm>
#include <iomanip>

using namespace std;

//int main()
//{
//    double sum = 0;
//    int n;
//    pair<double, double> cood[8];
//    vector<double> path;
//
//    cin >> n;
//    for (int i = 0; i < n; i++) {
//        cin >> cood[i].first >> cood[i].second;
//    }
//
//    for (int i = 0; i < n-1; i++) {
//        for (int j = i + 1; j < n; j++) {
//            double a= sqrt((cood[i].first - cood[j].first) * (cood[i].first - cood[j].first) + (cood[i].second - cood[j].second) * (cood[i].second - cood[j].second));
//            sum += a;
//            path.push_back(a);
//        }
//    }
//    double ans = 0;
//
//    for (int i = 0; i < path.size(); i++) {
//        ans += sum - path[i];
//    }
//    ans /= path.size();
//    printf("%.10f", ans);
//
//   // cout << sum << endl;
//
//}
//

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

void solve() {
	cin >> N;
	for (int i = 1; i <= N; i++)cin >> x[i] >> y[i];
	double sum = 0.0;
	vector<int> v(N);
	for (int i = 0; i < N; i++)v[i] = i + 1;
	do {
		for (int i = 0; i < N - 1; i++)sum += dist(v[i], v[i + 1]);
	} while (next_permutation(v.begin(), v.end()));
	int Factorial = 1;
	for (int i = 2; i <= N; i++)Factorial *= i;

	cout << fixed << setprecision(10) << sum / Factorial << endl;
	
}
void solve2() {
	cin >> N;
	for (int i = 0; i < N; i++)cin >> x[i] >> y[i];
	double len = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < i; j++) {
			len += dist(i, j);
		}
	}
	int num = 2;
	for (int i = N- 1; i >= 1; --i)num *= i;
	int fact = 1;
	for (int i = N; i >= 1; --i)fact *= i;
	double ans = (len * num) / fact;
	printf("%.10f\n", ans);
	
}

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

Measured memory_bytes: 256