akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
    template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
    template<typename T> void chadd(T& a, T b) { a = a + b; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t sz;
        inp(std::size_t _sz = 1) : sz(_sz) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
    };

    // 2次元用の標準入出力
    template<typename T>
    struct inpn {
        std::size_t szi, szj;
        inpn(std::size_t _szi, std::size_t _szj) : szi(_szi), szj(_szj) {}
        operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i)
                for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j];
            return a;
        }
    };

    inp inp1; // input one
}

int main() {

    int n = inp1;
    vector<string> s = inp(n);

    map<string, int> mp;
    rep(i, n) ++mp[s[i]];

    Cout(mp.size());

    return 0;
}

Measured memory_bytes: 25008
N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

count = 0

for i,b in enumerate(Bs):
    if As[i] - b >= 0:
        count += b
    else:
        if As[i+1] + As[i] - b >= 0:
            count += b
            As[i+1] -= b-As[i]
        else:
            count += As[i+1] + As[i]
            As[i+1] = 0

print(count)

Measured memory_bytes: 18624
#include<stdio.h>
int main(void)
{
	int a,b,c,d,x,y;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	x=(a+b+c+d)/60;
	y=(a+b+c+d)%60;
	printf("%d\n",x);
	printf("%d\n",y);
	return 0;
}


Measured memory_bytes: 2140
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


#A
def A():
    a,b = LI()
    if not (a*b)%2:
        print("Even")
    else:
        print("Odd")
    return

#B
def B():
    s = S()
    print(s.count("1"))
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 38512
n = int(input())
hlist = list(map(int, input().split()))

# The minimum cost to reach step i (1->n)
dp = [0]*(n+1)
dp[1] = 0 # 1->1

for i in range(2, n+1):
    dp[i] = min(dp[i-1] + abs(hlist[i-2] - hlist[i-1]), (dp[i-2] + abs(hlist[i-3] - hlist[i-1]) if i>2 else 10**9))

print(dp[n])

Measured memory_bytes: 13924
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	int m = max({ abs(a[0] - a[1]),abs(a[1] - a[2]),abs(a[2] - a[0]) });
	cout << abs(a[0] - a[1]) + abs(a[1] - a[2]) + abs(a[2] - a[0]) - m << endl;
}

Measured memory_bytes: 256
# ２つの整数を受け取る
n, d = gets.chomp.split.map(&:to_i)
ans = 0

n.times do
  # スペース区切りの整数の入力
x, y = gets.chomp.split.map(&:to_i)
  # 原点からの距離がD以下なら
  if x * x + y * y <= d * d
    # カウンターを１増やす
    ans += 1
  end
end

# 出力
puts ans


Measured memory_bytes: 14292
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(long long N, std::vector<long long> a){
  sort(all(a));
  int n=0,m=0;
  for (int i = 0; i < N; i++) {
    if(i%2 == 0)n += a[i];
    else m += a[i];
  }  
  cout << abs(n-m) << 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 long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main()
{
    unsigned char A, B, C;
    scanf("%u %u %u", &A, &B, &C);
    
    if(((A^B) && (A^C) && (B^C)) || (!(A^B) && !(A^C) && !(B^C)))
    {
        printf("No");
    }
    else
    {
        printf("Yes");
    }

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_N (300)
#define SIZE_BUF (30)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  int N;
  char css[MAX_N][MAX_N], buf[SIZE_BUF];
  scanf("%d", &N);
  fgets(buf, N, stdin);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      scanf("%c", &css[i][j]);
    }
    fgets(buf, N, stdin);
  }

  // move to larger grid
  char dss[2 * MAX_N][2 * MAX_N];
  for (int i = 0; i < 2 * N; i++) {
    for (int j = 0; j < 2 * N; j++) {
      dss[i][j] = css[i % N][j % N];
    }
  }

  // count maximum number nss[i][j] <= min(i, j) where,
  //   for all n <= nss[i][j], dss[i - n][j] == dss[i][j - n]
  int nss[2 * MAX_N][2 * MAX_N] = {};
  for (int i = 0; i < 2 * N; i++) {
    for (int j = 0; j < 2 * N; j++) {
      nss[i][j] = min(i, j);
      for (int k = 0; k <= min(i, j); k++) {
        if (dss[i][j - k] != dss[i - k][j]) {
          nss[i][j] = k - 1;
          break;
        }
      }
    }
  }
  // for (int i = 0; i < 2 * N; i++) {
  //   for (int j = 0; j < 2 * N; j++) {
  //     printf("%c ", dss[i][j]);
  //   }
  //   printf("\n");
  // }
  // for (int i = 0; i < 2 * N; i++) {
  //   for (int j = 0; j < 2 * N; j++) {
  //     printf("%d ", nss[i][j]);
  //   }
  //   printf("\n");
  // }

  // solve
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      int is_symmetric = 1;
      for (int k = 0; k < N; k++) {
        if (nss[i + k][j + k] < k) {
          is_symmetric = 0;
          break;
        }
      }
      if (is_symmetric) {
        ans++;
      }
    }
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


using ll=long long;

class mod_ll
{
public:
	ll m_v;
	static const ll m_m=1000000007; // prime value ex. 1000000009
	mod_ll(ll v=0) : m_v(v%m_m) {}
	mod_ll& operator = (ll rhs)
	{
		m_v=rhs%m_m;
		return *this;
	}
	ll operator ()(){return (m_v+m_m)%m_m;}
	mod_ll& operator += (const mod_ll rhs)
	{
		m_v=(m_v+rhs.m_v)%m_m;
		return *this;
	}
	const mod_ll operator + (const mod_ll rhs)
	{
		auto ret=*this;
		return ret+=rhs;
	}
	mod_ll& operator -= (const mod_ll rhs)
	{
		m_v=(m_v-rhs.m_v+m_m)%m_m;
		return *this;
	}
	const mod_ll operator - (const mod_ll rhs)
	{
		auto ret=*this;
		return ret-=rhs;
	}
	mod_ll& operator *= (const mod_ll rhs)
	{
		m_v=(m_v*rhs.m_v)%m_m;
		return *this;
	}
	const mod_ll operator * (const mod_ll rhs)
	{
		mod_ll ret=*this;
		return ret*=rhs;
	}
	const mod_ll operator ^ (ll rhs)
	{
		mod_ll t=*this;
		mod_ll ret(1LL);

		for(;rhs>0;rhs>>=1)
		{
			if(rhs&1) ret*=t;
			t*=t;
		}
		return ret;
	}
	mod_ll& operator /= (mod_ll rhs)
	{
		mod_ll t=rhs^(m_m-2);
		return *this*=t;
	}
	const mod_ll operator / (const mod_ll rhs)
	{
		mod_ll ret=*this;
		return ret/=rhs;
	}
};


mod_ll mod_fact(int n)
{
	static vector<mod_ll> memo(1);

	if((int)memo.size()<=n)
	{
		if(memo.size()==1)
		{
			memo[0]=1;
		}
		for(int i=memo.size();i<=n;i++)
		{
			memo.push_back(memo.back()*i);
		}
	}
	return memo[n];
}


mod_ll mod_nCr(int n, int r)
{
	if(n<=0) return 1;
	return mod_fact(n)/(mod_fact(n-r)*mod_fact(r));
}


mod_ll mod_nCr2(int n, int r)
{
	mod_ll bunsi(1);
	mod_ll bunbo(1);
	if(r*2>n) r=n-r;

	for(int i=0;i<r;i++)
	{
		bunsi*=(n-i);
		bunbo*=(i+1);
	}
	return bunsi/bunbo;
}


mod_ll mod_nPr(int n, int r)
{
	return mod_fact(n)/mod_fact(n-r);
}


struct solve
{
	solve(){}
	ll operator()() {
		return 0;
	}
};

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

	for(;;)
	{
		int n;
		cin >> n;
		if(cin.fail()) break;

		vll a(n);
		for(auto&m:a) cin >> m;

		mod_ll w(0), s(0);
		for(auto m:a)
		{
			w+=m;
			s+=m*m;
		}

		mod_ll ans=w*w;
		ans-=s;
		ans/=2;

		cout << ans() << "\n";
	}
	return 0;
}


Measured memory_bytes: 4780
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int n, m;
vector<string> A, B;

bool match_temp(int w, int h) {
  for(int i = 0; i < m; i++) {
    for(int j = 0; j < m; j++) {
      if(A[h+i][w+j] != B[i][j]) {
        return false;
      }
    }
  }
  return true;
}

int main(){
  cin >> n >> m;
  
  for(int i = 0; i < n; i++){
    string tmp;
    cin >> tmp;
    A.push_back(tmp);
  }
  for(int i = 0; i < m; i++){
    string tmp;
    cin >> tmp;
    B.push_back(tmp);
  }

  bool flg = false;
  for(int h = 0; h < n-m+1; h++){ // vertical search
/*
    size_t Pos = A[h].find(B[h]);
    if(Pos == string::npos){
      cout << "npos: " << h << endl;
      continue;
    }
    */
    for(int w = 0; w < n-m+1; w++) { // horizontal search
      if(match_temp(w, h)) {
        flg = true;
      }
      if(flg) {
        break;
      }
    }
  }
  if(flg) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3592
#include<cstdio>
#include<vector>
#include<map>
#include<set>

using namespace std;
using ll=long long;
using vll=vector<ll>;


int main(void)
{
	vector<ll> s={0, 0, 1, -2}, t={0, 0, 1, -2};

	ll x=4;
	for(int i=4;i<40;i++)
	{
		s.push_back(x);
		t.push_back(t[i-2]+x);
		x*=-2;
	}

	ll n;
	while(scanf("%lld", &n)==1)
	{
		int is_print=0;
		for(int i=s.size()-1;i>1;i--)
		{
			int b=0;
			if(n>0)
			{
				if(t[i-2]<n && n<=t[i]) b=1;
			}
			else
			{
				if(t[i]<=n && n<t[i-2]) b=1;
			}
			if(b)
			{
				n-=s[i];
				is_print=1;
			}

			if(is_print) printf("%d", b);
		}
		if(!is_print) printf("0");
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<numeric>
#include<climits>
#include<tuple>
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
template<class T> void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }
using namespace std;

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

	cout << 180 * (N - 2) << endl;
}

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

ll N;

vector<ll> divisor(ll n) {
    vector<ll> ret;
    for (ll i = 1; i*i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) {
                ret.push_back(n/i);
            }
        }
    }
    sort(begin(ret), end(ret));
    return ret;
}

int main() {
    cin >> N;
    
    vector<ll> div_N = divisor(N);

    if (div_N.size() % 2 == 0) {
        ll ans = 1.0e9;
        for (int i = div_N.size()-1; i >= div_N.size()/2; i--) {
            ll B = div_N[i];
            ll cnt = 0;
            while (B > 0) {
                B /= 10;
                cnt++;
            }
            ans = min(ans, cnt);
        }

        cout << ans << endl;
    }
    else {
        ll ans = 1.0e9;
        for (int i = div_N.size()-1; i >= (div_N.size()+1)/2; i--) {
            ll B = div_N[i];
            ll cnt = 0;
            while (B > 0) {
                B /= 10;
                cnt++;
            }
            ans = min(ans, cnt);
        }

        ll B = div_N[div_N.size()/2];
        ll cnt = 0;
        while (B > 0) {
            B /= 10;
            cnt++;
        }
        ans = min(ans, cnt);

        cout << ans << endl;

    } 

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

const ll M=5005;
ll n,a,b,c,F[M],C[M][M];

int main(){
	cin>>n>>a>>b>>c;
	F[0]=C[0][0]=1;
	if(b%2==1){
		cout<<0<<endl;
		return 0;
	}
	b/=2;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
	for(int i=0;i<M-1;i++) for(int j=0;j<=i;j++){
		(C[i+1][j]+=C[i][j])%=mod;
		(C[i+1][j+1]+=C[i][j])%=mod;
	}
	ll res=0;
	for(int i=0;i<=a;i++) for(int j=0;j<=c;j++){
		int t=c-a+i-3*j;
		if(t>=0&&(b>0||!t)) (res+=Div(F[j+b+a],F[i]*F[a-i]%mod*F[b]%mod*F[j]%mod)*(b==0?1:C[b+t-1][t]))%=mod;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 194176
#include<bits/stdc++.h>
using namespace std;
vector <pair<long long,long long> > v,v1;
map <pair <long long, long long>, long long > aa;
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    long long i,j,k,a,b,c,x,y,z,n,ans,mn;
	pair <long long, long long> p,p1;
	cin>>n;
	for (i=0;i<n;i++)
	{
		cin>>p.first>>p.second;
		v.push_back(p);
		aa[p]=1;
	}
	for (i=0;i<n;i++)
	{
		for (j=0;j<n;j++)
		{
			if (j==i)
			{
				continue;
			}
			p.first=v[i].first-v[j].first;
			p.second=v[i].second-v[j].second;
			v1.push_back(p);
		}
	}
	ans=n;
	for (i=0;i<v1.size();i++)
	{
		mn=n;
		for (j=0;j<n;j++)
		{
			p.first=v[j].first-v1[i].first;
			p.second=v[j].second-v1[i].second;
			if (aa[p]==1)
			{
				mn--;
			}
		}
		ans=min(ans,mn);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4096
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	n := nextInt()
	m := nextInt()
	xs := make([]int, n)
	for i := 0; i < n; i++ {
		xs[i] = nextInt()
	}
	ys := make([]int, m)
	for i := 0; i < m; i++ {
		ys[i] = nextInt()
	}
	p := int(math.Pow10(9)) + 7

	var X, Y int
	for i, x := range xs {
		X += i*x - (n-(i+1))*x
		X %= p
	}
	for i, y := range ys {
		Y += i*y - (m-(i+1))*y
		Y %= p
	}

	fmt.Println(X * Y % p)
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

func diff(x, y int) int {
	return abs(-(x) + y)
}

// ---------- Util.


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

class dice{
    public :
    int d[6] ;
    void in(vector<int> &a){
        for(int i=0;i<6;i++) d[i] = a.at(i) ;
    }
    void roll(char c){
        if(c=='N'){
            int sub = d[0] ;
            d[0] = d[1] ;
            d[1] = d[5] ;
            d[5] = d[4] ;
            d[4] = sub ;
        }
        if(c=='S'){
            int sub = d[0] ;
            d[0] = d[4] ;
            d[4] = d[5] ;
            d[5] = d[1] ;
            d[1] = sub ;
        }
        if(c=='E'){
            int sub = d[0] ;
            d[0] = d[3] ;
            d[3] = d[5] ;
            d[5] = d[2] ;
            d[2] = sub ;
        }
        if(c=='W'){
            int sub = d[0] ;
            d[0] = d[2] ;
            d[2] = d[5] ;
            d[5] = d[3] ;
            d[3] = sub ;
        }
    }
    int serch(int n){
        for(int i=0;i<6;i++){
            if(d[i]==n) return i ;
        }
    }
} ;

int main(){
    vector<vector<int>> ans = 
    {
        {-1,2,4,1,3,-1},
        {3,-1,0,5,-1,2},
        {1,5,-1,-1,0,4},
        {4,0,-1,-1,5,1},
        {2,-1,5,0,-1,3},
        {-1,3,1,4,2,-1},
    } ;
    vector<int> a(6) ;
    for(int i=0;i<6;i++) cin >> a.at(i) ;
    dice d ;
    d.in(a) ;
    int q ; cin >> q ;
    for(int i=0;i<q;i++){
        int u,f ; cin >> u >> f ;
        cout << d.d[ans.at(d.serch(u)).at(d.serch(f))] << endl ;
    }
}


Measured memory_bytes: 3168
#include <stdio.h>

int main(void) {

  char S[128];

  do {
    scanf("%s", S);
  } while (S[0] < 'A' || S[0] > 'Z' || S[1] < 'A' || S[1] > 'Z' || S[2] < 'A' || S[2] > 'Z' || S[3] < 'A' || S[3] > 'Z');

  int n = 0;
  for (int i = 0; i < 3; i++) {
    for (int j = i + 1; j < 4; j++) {
      if (S[i] == S[j]) {
	n++;
      }
    }
  }

  if (n == 2) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::pair<ll,ll> P;

using namespace std;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

struct interval {
  ll s, f;
};

bool compare_f(const interval &x, const interval &y) {
  return x.f < y.f;
}

vector<interval> interval_scheduling(vector<interval> J) {
  vector<interval> A;
  sort(J.begin(), J.end(), compare_f);
  ll f = -2e12;
  for (int i = 0; i < sz(J); ++i) {
    if (J[i].s >= f) {
      A.push_back(J[i]);
      f = J[i].f;
    }
  }
  return A;
}

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<interval> L(N);
  rep(i,N) {
    ll x, l; std::cin >> x >> l;
    L[i].s = x-l;
    L[i].f = x+l;
  }
  
  auto a = interval_scheduling(L);
  std::cout << sz(a) << std::endl;
  return 0;
}


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

using namespace std;

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

int main(void){
    long long A, B, C, D;
    long long c, d, cd;
    cin >> A >> B >> C >> D;
    c = B / C - (A - 1) / C;
    d = B / D - (A - 1) / D;
    long long CD = C * D / gcd(C, D);
    cd = B / CD - (A - 1) / CD;
    cout << B - A + 1 - (c + d - cd) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n),b(n),c(n);
    rep(i,0,n-1) cin>>a[i];
    rep(i,0,n-1) cin>>b[i];
    rep(i,0,n-1) cin>>c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());

    ll ans = 0;

    rep(i,0,n-1){
        auto ite1 = lower_bound(a.begin(),a.end(),b[i]);
        auto ite2 = upper_bound(c.begin(),c.end(),b[i]);
        ll anum = ite1 - a.begin();
        ll cnum = c.end() - ite2;
        ans += anum * cnum;
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2688
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n;
  scanf("%d", &n);
  if (n%10 == 9 || n/10 == 9)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


Measured memory_bytes: 128
fun main(args : Array<String>) {
    val (N, M) = readLine()!!.split(" ").map { it.toInt() }
    val timePerTry = 100 * (N-M) + 1900 * M


    var anser = 0.0
    val X = 1.0 / Math.pow(2.0, M.toDouble())
    (1..10000).forEach {
        anser += it * timePerTry * Math.pow((1.0-X), (it - 1).toDouble()) * X
    }
    println(Math.round(anser).toInt())
}

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

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  int n, k, s;cin>>n>>k>>s;
  rep(i, k)cout<<s<<" ";
  if(s!=int(1e9)){
    rep(i, n-k)cout<<int(1e9)<<" ";
  }else{
  	rep(i, n-k)cout<<1<<" ";
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 1280
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    boolean P = false;
    if (A==B && B!=C){ P = true; }
    if (A==C && B!=C){ P = true; }
    if (B==C && B!=A){ P = true; }
    if (P) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21972
package main

import (
	"fmt"
	"sort"
)

func main(){
	var n,k,ans int
	fmt.Scan(&n,&k)
	p := make([]int,n)
	for i:=0 ; i<n ; i++ {
		fmt.Scan(&p[i])
	}
	sort.Ints(p)
	for i:=0 ; i<k ; i++ {
		ans += p[i]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1888
#include<stdio.h>
int main()
{
    char ch;
    while((ch=getchar())!=EOF)
    {
        if(ch>=97&&ch<=122)
            printf("%c",ch-32);
        else if(ch>=65&&ch<=90)
            printf("%c",ch+32);
        else
            printf("%c",ch);
    }
}



Measured memory_bytes: 2612
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long int ll;
typedef long double ld;


int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if (a+b==c || a+c==b || b+c==a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
        
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int a, b, c;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b >> c;
	cout << c - min(a - b, c) << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    int N;cin>>N;
    int A[N];
    REP(i,N)cin>>A[i];
    set<int> st;
    for(int i=0;i<N;i+=2)st.insert(A[i]);
    sort(A,A+N);
    for(int i=0;i<N;i+=2)st.erase(A[i]);

    cout<<st.size()<<endl;

    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

 
void solve(){
    int n;
    cin >> n;
    int sum = 0;
    int mx = 0;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        mx = max(mx, x);
        sum += x;
    }
    sum -= mx;
    //cout << mx << ' ' << sum << endl;
    cout << ((mx < sum) ? "Yes" : "No");
}

 
int main() {
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}


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

int main() {
  int H,W;
  string a;
  cin >> H >> W;
  
  //一行目の#出力
  for (int i=0;i<W+2;i++) {
    cout << "#";
  }
  cout << endl;
  for (int i=0;i<H;i++) {
    cin >> a;
    cout << "#" << a << "#" << endl;
  }
  for (int i=0;i<W+2;i++) {
    cout << "#";
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < pii, int > a, pair < pii, int > b)//true for a before b
{
	if(a.F.F/300 < b.F.F/300)
		return 1;
	if(a.F.F/300 > b.F.F/300)
		return 0;
	if(a.F.S < b.F.S)
		return 1;
	if(a.F.S > b.F.S)
		return 0;
	if(a.F <= b.F)
		return 1;
	return 0;
}

const int N = (1e2) + 9;
const int M = (1e4) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 100;
const int SQRT = BUCK+9;

const int MAX = 10000;
int a[N];

void solve()
{
	int n, i, cnt, ans = 0;
	cin >> n;
	fo(i,1,n+1)
		cin >> a[i];
	cnt = 1;
	fo(i,2,n+1)
	{
		if(a[i] != a[i-1])
		{
			ans += (cnt/2);
			cnt = 1;
		}
		else
			cnt++;
	}
	ans += (cnt/2);
	cout << ans << '\n';
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(9);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

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

int main() {
  ll count=0,x,y;
  cin >> x >> y;
  if(x==1&&y==1)count+=400000;
  if(x<=3)count+=400000-x*100000;
  if(y<=3)count+=400000-y*100000;
  cout<<count<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        int N  = sc.nextInt();
        String[] list = new String[N];
        String ans = "No";
       
        for(int i = 0; i < N; i++){
           list[i] = sc.next();
        }
      
        for(int i = 1; i < N; i++){
          char[] first = list[i-1].toCharArray();
          char[] second = list[i].toCharArray();
          if(first[first.length-1] != second[0]){
            System.out.println("No");
            return;  
          }else{
            continue;
          }
        }
      
        for(int i = 0; i < N; i++){
          String a = list[i];
          for(int j = i+1; j < N; j++){
            String b = list[j];
            if(a.equals(b)){
              System.out.println("No");
              return;
            }else{
              continue;
            }
          }
        }
      
       System.out.println("Yes");
	}

}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    int d;
    cin>>d;
    cout<<"Christmas";
    
    for(int i = 0; i < 25-d ; i++)
    {
        cout<<" Eve";
    }
    

    cout<<endl;
    return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){

	int n;
	cin>>n;
	int i = 1;
	while(1){
		int x = i;
		if(x % 3 == 0){
		cout<<" "<<i;
		}
	else {
		while(1){
			if(x % 10 == 3){
			cout<<" "<<i;
			break;
			}
			x /= 10;
			if(x == 0) break;
		}
	}
	if(++i > n) break;
	}
	cout<<endl;

	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int dp[3001][3001];

int solve(vector<int>& a, int st, int end, int chance, int diff) {
    if(st > end) return 0;
    if(dp[st][end] != -1) return dp[st][end];
    else if(chance & 1) {
        int opt1 = -a[st] + solve(a, st+1, end, chance+1, diff - a[st]);
        int opt2 = -a[end] + solve(a, st, end-1, chance+1, diff - a[end]);
        return dp[st][end] = min(opt1, opt2);
    }
    else {
        int opt1 = a[st] + solve(a, st+1, end, chance+1, diff + a[st]);
        int opt2 = a[end] + solve(a, st, end-1, chance+1, diff + a[end]);
        return dp[st][end] = max(opt1, opt2);
    }
}

int32_t main() {
    int N; cin>>N;
    vector<int> a(N+1);
    for(int i=0; i<N; i++) cin>>a[i];
    memset(dp, -1, sizeof dp);
    int X, Y;
    X = Y = 0;
    cout<<solve(a, 0, N-1, 0, 0)<<endl;
    return 0;
}


Measured memory_bytes: 74216
// D - Dice in Line
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N,K; cin>>N>>K;
	vector<int> P(N+K); rp(i,0,N) cin>>P[i+K];
	int ans = 0, sum = 0;
	rp(i,0,N) ans = max(ans, sum += P[i+K] - P[i]);
	printf("%.12f\n",(ans+K)/2.0);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
  unsigned long long k,sum=0;
  cin>>k;
  for(int i = 1;i<=k;i++)
   for(int j = 1;j<=k;j++)
    for(int r = 1;r<=k;r++)
      sum+=(__gcd(__gcd(i,j),r));
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 3648
import java.util.*;

public class Main {

    int N = 2 * 100000;

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] xs = new int[n];
        int[] ys = new int[n];

        UnionFind uf = new UnionFind(N);

        for (int i = 0; i < n; i++) {
            xs[i] = sc.nextInt() - 1;
            ys[i] = sc.nextInt() - 1 + N / 2;
            uf.union(xs[i], ys[i]);
        }

        HashMap<Integer, Integer> xc = new HashMap<>();
        HashMap<Integer, Integer> yc = new HashMap<>();

        for (int i = 0; i < N / 2; i++) {
            xc.put(uf.find(i), xc.getOrDefault(uf.find(i), 0) + 1);
            yc.put(uf.find(i + N / 2), yc.getOrDefault(uf.find(i + N / 2), 0) + 1);
        }

        long ans = 0;
        for (int i = 0; i < N; i++) {
            ans += 1L * xc.getOrDefault(i, 0) * yc.getOrDefault(i, 0);
        }
        System.out.println(ans - n);
    }

    class UnionFind {
        private int n, t;
        private int[] parent, rank;

        public UnionFind(int n) {
            this.n = n;
            this.parent = new int[n];
            this.rank = new int[n];
            Arrays.fill(rank, 1);
            for (int i = 0; i < n; i++) parent[i] = i;
        }

        public void union(int x, int y) {
            t++;
            int xr = find(x);
            int yr = find(y);

            if (xr > yr) {
                parent[yr] = xr;
            } else if (xr < yr) {
                parent[xr] = yr;
            } else {
                parent[yr] = xr;
                rank[yr]++;
            }

        }

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

        public boolean same(int x, int y) {
            return find(x) == find(y);
        }

    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

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


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,n,k;
	char ch;
	t = 1;
	while(t--) {
	 cin >> ch;
	 if(ch == 'A')
	  cout << 'T' << endl;
	 else if(ch == 'T')
	  cout << 'A' << endl;
	 else if(ch == 'C')
	  cout << 'G' << endl;
	 else
	  cout << 'C' << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define MOD 1000000007
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LLI long long int
#define LI long int 
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//               When something is important enough, you do it even if the odds are not in your favor.

int main(){   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // code goes here
    int t=1;//cin>>t;
    while(t--){
      int k,i;
      string s;cin>>k>>s;
      if(s.length()<=k) cout<<s;
      else {
        fo(i,0,k) cout<<s[i];cout<<"...";
      }
    }
    return 0;
}

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

using namespace std;

int dgcd(int a,int b){
	int tmp;
	if(a < b){
		tmp = a;
		a = b;
		b = tmp;
	}
	while(a%b != 0){
		tmp = a % b;
		a = b;
		b = tmp;
	}
	return b;
}
int gcd(int a,int b,int c){
	int ab = dgcd(a,b);
	int re = dgcd(ab,c);
	return re;
}
int main(void)
{
	int k;
	cin>>k;
	long long ans = 0;
	for(int a = 1; a <= k; a++){
		for(int b = 1; b <= k; b++){
			for(int c = 1; c <= k; c++){
				ans+=gcd(a,b,c);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3636
n, m = map(int, input().split())
a = [[0] * m for i in range(n)]
b = [0] * m
c = [0] * n
# read matrix A
for i in range(n):
    w = list(map(int, input().split()))
    for j in range(m):
        a[i][j] = w[j]
# read vevtor b
for j in range(m):
    b[j] = int(input())
# Ab -> c
for i in range(n):
    for j in range(m):
        c[i] += a[i][j] * b[j]
# output c
for i in range(n):
    print(c[i])

Measured memory_bytes: 7852
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
    int n,t;
    double a;
    cin >> n >> t >> a;
    double h[n];
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    double tmp=1e8;
    int ans;
    for(int i=0;i<n;i++){
        h[i]=t-h[i]*0.006;
        h[i]=fabs(h[i]-a);
        //cout << h[i] << endl;
        if(h[i]<tmp){
            tmp=h[i];
            ans=i+1;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main(){
    int n,x[8],y[8];
    int64_t count = 0;
    double dist = 0;
    cin >> n;
    vector<int> order(n);
    for(int i = 0;i < n;i++){
        order[i] = i;
    }
    for(int i = 0;i < n;i++){
        cin >> x[i] >> y[i];
    }
    do{
        for(int i = 1;i < n;i++){
            dist += sqrt((x[order[i-1]]-x[order[i]])*(x[order[i-1]]-x[order[i]]) +(y[order[i-1]]-y[order[i]])*(y[order[i-1]]-y[order[i]]));
        }
        count++;
    }while(next_permutation(order.begin(),order.end()));
    cout << setprecision(13);
    cout << dist/count;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

int ima[1005];

int main(){
    ios_base::sync_with_stdio(false);
	cout.precision(10);
	cout << fixed;

    int n, k;
    cin >> n >> k;
    for(int i=1; i<=k; i++){
        int x;
        cin >> x;
        while(x--){
            int g;
            cin >> g;
            ima[g] = 1;
        }
    }
    int res = n;
    for(int i=1; i<=n; i++) res -= ima[i];
    cout << res;
    return 0;
}


Measured memory_bytes: 3640
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    long Q = lread();
    auto cnt = new long[](10 ^^ 5 + 1);
    foreach (a; A)
    {
        cnt[a]++;
    }
    long S = A.sum();
    foreach (_; 0 .. Q)
    {
        long B, C;
        scan(B, C);
        S -= B * cnt[B];
        S += C * cnt[B];
        writeln(S);
        cnt[C] += cnt[B];
        cnt[B] = 0;
    }
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

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

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) ++res[i], n /= i;
  }
  if (n != 1) res[n] = 1;
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b,k; cin>>a>>b>>k;
  auto v=divisor(a);
  auto w=divisor(b);
  set<ll> s;
  for(auto e:v){
    s.insert(e);
  }
  vll x;
  for(auto e:w){
    if(s.count(e)) x.push_back(e);
  }
  sort(x.rbegin(),x.rend());
  cout<<x[k-1]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

//八方向を見るのに使うと便利(楽)
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
 
signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  int ans = INF, sum;
  for(int i = 0;i < s.size() - t.size() + 1;i ++){
    sum = 0;
    rep(j, t.size()){
      if(s[i + j] != t[j]){
	sum ++;
      }
    }
    ans = min(ans, sum);
  }
  cout << ans << '\n';
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;
    vector<int> s(n);
    int sum = 0;
    rep(i, n) {
        int x; cin >> x;
        s[i] = x;
        sum += x;
    }

    sort(all(s));
    if(sum % 10 != 0){
        cout << sum << endl;
        return 0;
    }
    rep(i, n){
        if((sum - s[i]) % 10 != 0) {
            cout << sum - s[i] << endl;
            return 0;
        }
    }

    cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif


bool solve()
{
    const int mod = 1000000007;
    int n, m;
    cin >> n >> m;

    unordered_set<int> us;
    for (int i = 0; i < m; ++i)
    {
        int num;
        cin >> num;
        us.insert(num);
    }

    vector<int> stairs(n + 1, 0);
    stairs[0] = 1;

    for (int i = 1; i <= n; ++i)
    {
        if (us.count(i) == 0)
        {
            if (us.count(i-1) == 0)
                stairs[i] = stairs[i-1];
            
            if (i - 2 >= 0 && us.count(i - 2) == 0)
                stairs[i] = (stairs[i] + stairs[i - 2]) % mod;
        }
    }

    cout << stairs[n] << endl;

    return false;
}

int main()
{
    solve();

    return 0;
}

Measured memory_bytes: 4772