akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define IO std::ios::sync_with_stdio(false); cin.tie(0)
#define int long long
#define ull unsigned long long
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define INF 0x3f3f3f3f

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

signed main() {
  IO;
  int x;
  cin >> x;
  cout << (x ^ 1) << '\n';
  return 0;
}

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

using namespace std;

int main(){
    long long int N,P,A,even=1,odd=0,add=0,addodd=0,addeven=1;
    cin >> N >> P;
    for(int i=0;i<N;i++){
        cin >> A;
        if(A%2==0){
            even *= 2;
        }else{
            odd++;
        }
    }

    add = odd;

    addodd += odd;

    for(int i=2;i<=odd;i++){
        add = (odd-i+1)*add/i;
        if(i%2==0){
            addeven += add;
        }else{
            addodd += add;
        }
    }

    if(P==0){
        cout << even*addeven << endl;
    }else{
        cout << even*addodd << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>

using namespace std;

const double EPS=(1e-10);
typedef long long ll;
typedef pair<int,int> pii;
bool EQ(double a,double b){
  return abs((a)-(b))<EPS;
}
void fast_stream(){
  std::ios_base::sync_with_stdio(0);
}

int L,H;
bool sets[101][101];
string nums[101];
int hits[101];
int blows[101];
int resNum[101];
bool used[101];
int cnt;

int ans[101];

void dfs(int pos){
  if(pos==L){
    bool ok=true;
    for(int i=0;i<H;i++)
      if(hits[i]|blows[i])ok=false;
    if(!ok)return;
    cnt++;
    if(cnt==1)
      for(int i=0;i<pos;i++)ans[i]=resNum[i];
    return;
  }
  else{
    for(int i=0;i<10;i++){
      if(used[i])continue;
      resNum[pos]=i;
      used[i]=true;
      bool ok=true;
      // ツ鳴オツ渉つチツェツッツク
      for(int j=0;j<H;j++){
	if(nums[j][pos]-'0'==i)hits[j]--;
	else if(sets[j][i])blows[j]--;
	if(hits[j]<0||blows[j]<0)ok=false;
      }
      if(ok)dfs(pos+1);
      used[i]=false;
      for(int j=0;j<H;j++){
	if(nums[j][pos]-'0'==i)hits[j]++;
	else if(sets[j][i])blows[j]++;
      }
    }
  }
}

int main(){

  while(cin>>L>>H&&(L|H)){
    cnt=0;
    memset(sets,0,sizeof(sets));
    memset(used,0,sizeof(used));
    for(int i=0;i<H;i++){
      cin>>nums[i]>>hits[i]>>blows[i];
      for(int j=0;j<nums[i].size();j++)
	sets[i][nums[i][j]-'0']=true;
    }
    dfs(0);
    if(cnt==1){
      for(int i=0;i<L;i++)cout<<ans[i];
      cout<<endl;
    }
    else cout<<"NO"<<endl;
  }

  return 0;
}

Measured memory_bytes: 940
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    scanf("%d", &N);
    vector<int> A(N);
    for(auto it=A.begin(); it!=A.end(); it++){
        scanf("%d", &(*it));
    }

    auto print=[&A]{
        for(auto it=A.begin(); it!=A.end(); it++){
            if(it!=A.begin()){
                printf(" ");
            }
            printf("%d", *it);
        }
        printf("\n");
    };
    print();

    for(int i=1; i<N; i++){
        int v=A[i];
        int j=i-1;
        while(j>=0 && A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        print();
    }
    return 0;
}

Measured memory_bytes: 2708
def xor_array(n):
    if (n + 1) % 4 == 0:
        return 0
    elif (n + 1) % 2 == 0:
        return 1
    elif n % 4 == 0:
        return n
    else:
        return 1 ^ n


a, b = map(int, input().split())
print(xor_array(a - 1) ^ xor_array(b))


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <string>
#include <utility>
#include <map> 
#include <queue>
#include <stack>
#include <iomanip>
#include <sstream>
#define MP make_pair
#define PB push_back
#define SZ size()
#define B begin()
#define E end()
#define ll long long
#define REP(i,a,n) for(ll i=a; i<n; ++i)
#define RED(i,n,a) for(ll i=n; i>=a; --i)
#define m9 1000000007
#define endl "\n"
#define F first
#define S second
#define ld long double
#define eps 0.00000000001
#define MAX 1000000007
#define vll vector <ll> 
#define pll pair <ll,ll> 

using namespace std;

ll gcd(ll a, ll b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b, a%b);
    }
}
ll powc(ll a, ll b){
    if(b<0){
        return -1;
    }
    ll res=1;
    while(b>0){
        if(b&1){
            res*=a;
        }
        a*=a;
        //res%=m9, a%=m9;
        b>>=1;
    }
    return res;
}



///target expert

int main(){
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s; cin>>s;
    if(s=="RRR"){
        cout<<3<<endl;
    }
    else if(s=="RRS" || s=="SRR"){
        cout<<2;
    }
    else if(s=="SSS"){
        cout<<0;
    }
    else{
        cout<<1;
    }
    
}

Measured memory_bytes: 3652
import math

a, b, x = map(int, input().split())

tan_theta = 0

if x > a * a * b / 2:
    tan_theta = 2 * (a * a * b - x) / (a ** 3)

elif x < a * a * b / 2:
    tan_theta = a * b * b / (2 * x)

else:
    tan_theta = b / a

print(math.degrees(math.atan(tan_theta)))


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int d,t,s,p;
    cin>>d>>t>>s;
    p=d/s;
    if(d%s!=0)
        p++;
    if(p<=t)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 3632
/*我是萌新*/
#include<bits/stdc++.h> 
typedef long long ll;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;
using namespace std;
#define INS(x) x.begin(),x.end()
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    string s;
    cin >> s;

    int z = 0; //0正1反
    string s1, s2;
    int q;
    cin >> q;
    while (q--)
    {
        int t, f;
        string x;
        cin >> t;

        if (t == 1)
        {
            z = !z;
        }
        else
        {
            cin >> f >> x;
            if (f == 1)
            {
                if (z)
                {
                    s2 += x;
                }
                else s1 += x;
            }
            else
            {
                if (z)
                {
                    s1 += x;
                }
                else s2 += x;
            }
        }
    }

    reverse(INS(s1));
    s = s1 + s + s2;
    if (z)
    {
        for (int i = s.size() - 1; i >= 0; i--)
            cout << s[i];
    }
    else
        for (auto i : s)
            cout << i;

    
}



Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5; 
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

ll raise(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


ll x, k, d;

void solve()
{
    cin >> x >> k >> d;
    ll t = abs(x)%d;
    ll temp = abs(x)/d; 
    if (temp>=k) {
        nout(abs((abs(x)-(k*d)))); return;
    }//nout(t);
    k-=temp; 
    if (k%2) {
        nout(d-t);
    }else nout(t);

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define MAXN 100005
using namespace std;
int n,state,a[MAXN];
string S;
int main()
{
	scanf("%d",&n);
	printf("0\n");
	fflush(stdout);
	cin>>S;
	if(S[0]=='V') return 0;
	state=(S[0]=='M'?0:1);
	printf("%d\n",n/2);
	fflush(stdout);
	cin>>S;
	if(S[0]=='V') return 0;
	int lb,rb;
	if(S[0]=='M'&&state==0)
	{
		if((n/2-1)&1)
		{
			lb=n/2;
			rb=n;
		}
		else
		{
			lb=0;
			rb=n/2;
		}
	}
	else if(S[0]=='M'&&state==1)
	{
		if((n/2-1)&1)
		{
			lb=0;
			rb=n/2;
			state=3;
		}
		else
		{
			lb=n/2;
			rb=n;
			state=2;
		}
	}
	else if(S[0]=='F'&&state==0)
	{
		if((n/2-1)&1)
		{
			lb=0;
			rb=n/2;
			state=2;
		}
		else
		{
			lb=n/2;
			rb=n;
			state=3;
		}
	}
	else
	{
		state=1;
		if((n/2-1)&1)
		{
			lb=n/2;
			rb=n;
		}
		else
		{
			lb=0;
			rb=n/2;
		}
	}
	while(true)
	{
		int mid=(lb+rb)/2;
		printf("%d\n",mid);
		fflush(stdout);
		cin>>S;
		if(S[0]=='V') return 0;
		if(state==0)
		{
			if(S[0]=='F')
			{
				int len=mid-lb-1;
				if(len&1)
				{
					rb=mid;
					state=2;
				}
				else
				{
					lb=mid;
					state=3;
				}
			}
			else
			{
				int len=mid-lb-1;
				if(len&1) lb=mid; else rb=mid;
			}
		}
		else if(state==1)
		{
			if(S[0]=='M')
			{
				int len=mid-lb-1;
				if(len&1)
				{
					rb=mid;
					state=3;
				}
				else
				{
					lb=mid;
					state=2;
				}
			}
			else
			{
				int len=mid-lb-1;
				if(len&1) lb=mid; else rb=mid;
			}
		}
		else if(state==2)
		{
			if(S[0]=='F')
			{
				int len=mid-lb-1;
				if(len&1)
				{
					rb=mid;
					state=2;
				}
				else
				{
					lb=mid;
					state=1;
				}
			}
			else
			{
				int len=mid-lb-1;
				if(len&1)
				{
					lb=mid;
					state=2;
				}
				else
				{
					rb=mid;
					state=0;
				}
			}
		}
		else
		{
			if(S[0]=='F')
			{
				int len=mid-lb-1;
				if(len&1)
				{
					lb=mid;
					state=3;
				}
				else
				{
					rb=mid;
					state=1;
				}
			}
			else
			{
				int len=mid-lb-1;
				if(len&1)
				{
					rb=mid;
					state=3;
				}
				else
				{
					lb=mid;
					state=0;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 976
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] str = br.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);
		int l = Integer.parseInt(str[2]);
		long[][] nm = new long[n][m];
		long[][] calc = new long[n][l];

		for (int i = 0; i < n; i++) {
			str = br.readLine().split(" ");
			for (int j = 0; j < m; j++) {
				nm[i][j] = Integer.parseInt(str[j]);
			}
		}
		for (int i = 0; i < m; i++) {
			str = br.readLine().split(" ");
			for (int j = 0; j < l; j++) {
				int ml = Integer.parseInt(str[j]);
				for (int k = 0; k < n; k++) {
					calc[k][j] += nm[k][i] * ml;
				}
			}
		}

		for (int i = 0; i < n; i++) {

			for (int j = 0; j < l; j++) {
				if (j != 0)
					System.out.print(" ");
				System.out.print(calc[i][j]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 33344
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while(s.hasNext()){
		    int l = 0;
		    double d = 0;
		    int a = 0;
		    int out = 0;
		    String[] c = s.next().split(",");
		    int[] in = new int[12];
		    for(int i=0 ; i<12 ; i++)
			in[i] = Integer.parseInt(c[i]);
		    for(int i=0 ; i<10 ; i++)
			l+=in[i];
		    d = (double) l*in[10]/(in[10]+in[11]);
		    while(d>a){
			a+=in[out];
			out++;
		    }
		    System.out.println(out);
		}
	}
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll mod = 998244353;
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; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 


ll gcm(ll a, ll b) {
	ll result = a;
	ll k = 0;
	ll n = b;
	do {
		k = result % n;
		result = n;
		n = k;
	} while(k != 0);
	return result;
}

ll gcd (ll a, ll b){
    if (b == 0) return a;
    return gcd(b, a %b);
}

ll lcm(ll a, ll b) {
	ll g;
	g = gcd(a, b);
	return a*b/g;
}
ll M;
ll lcm_n(vector<ll> &numbers) {
	ll l;
	l = numbers[0];
	for (ll i = 1; i < numbers.size(); i++) {
		l = lcm(l, numbers[i]);
	    if (l > M){
	        //cout << l << " " << M << endl;
	        return l;
	    }
	}
	return l;
}


int main() {
    ll N;
    cin >> N >> M;
    vector<ll> A(N), B(N);
    rep(i, N){
        cin >> A[i];
    }
    int flag;
    do {
        flag = 1;
        rep(i, N){
            if (A[i] % 4 != 0){
                flag = 0;
                goto out;
            }
        }
        if (flag){
            M /= 2;
            rep(i, N){
                //assert(A[i] % 4 == 0);
                A[i] /= 2;
            }
        }
        //fprintf(stderr, "hoge\n");
    }while (flag == 1);
    out:
    
    rep(i, N){
        B[i] = A[i]/2;
    }
    
    if (N == 1){
        if (B[0] > M){
            cout << 0;
        } else {
            cout << 1 + (M - B[0])/A[0];
        }
        return 0;
    }
    
    ll lcmA = lcm_n(A);
    ll lcmB = lcm_n(B);
    //print(lcmA);
    //print(lcmB);
    if (lcmB % 2 == 0 || lcmB > M){
        cout << 0;
        return 0;
    }
    cout << 1 + (M - lcmB)/lcmA;
    return 0;
}


Measured memory_bytes: 1792
S = input().rstrip()
T = input().rstrip()

start = {}
goal = {}

for s, t in zip(S, T):
    if start.get(s) and start[s] != t:
        print('No')
        exit()
    if goal.get(t) and goal[t] != s:
        print('No')
        exit()

    start[s] = t
    goal[t] = s

print('Yes')


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <fstream>
#include <cassert>
using namespace std;

//common
typedef long long i64,ll;

#define BR "\n"
#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,r) for(int i=(l);i<(int)(r);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

//debug
#ifdef NDEBUG
#define DUMP(x)
#define DUMPLN(x)
#define DEBUG(x)
#define DEBUGLN(x)
#define LINE()
#define LINELN()
#define CHECK(exp,act)
#define STOP(e)
#else
#define DUMP(x)  cerr << #x << " = " << (x)
#define DUMPLN(x)  DUMP(x) <<endl
#define DEBUG(x) DUMP(x) << LINE() << " " << __FILE__
#define DEBUGLN(x) DEBUG(x)<<endl
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl
#define CHECK(exp,act)  if(exp!=act){DUMPLN(exp);DEBUGLN(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}

template<class T> inline string toString(const vector<vector<T> >& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

string BITtoString(int bit){
    stringstream ss;
    while(bit!=0){ss<<(bit%2);bit/=2;}
    string res=ss.str();reverse(ALL(res));
    return res;
}

template<typename T,typename V> inline T pmod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}


ll MOD=1000000007;

class Main{
public:
	
	void run(){
		
		while(true){
			int N;cin >> N;if(N==0)break;
			vector<int> ks(N);
			REP(i,N)cin >> ks[i];
			sort(ALL(ks));
			
			int res=0;
			REP(i,N)res+=min(1,ks[i]);
			if(ks[N-1]>=2){
				cout << res+1<<endl;
			}else{
				cout <<"NA"<<endl;
			}
		}

	}
};

 int main(){
	//ios::sync_with_stdio(false);
 	Main().run();
 	return 0;
 }

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

void solveB(){
  int n,t,ci,ti;
  cin >> n >> t;
  int ans = 2000;
  
  for(int i=0;i<n;i++){
    cin >> ci >> ti;
    if (ci<=ans && ti<=t) ans = ci;
  }
  if (ans==2000) cout << "TLE" << endl;
  else cout << ans << endl;  
}

int main(){
  solveB();
}


Measured memory_bytes: 256
//
// Created by 27420 on 2020/8/16.
//

#include<stdio.h>
#include<iostream>
typedef long long ll;
using namespace std;
void solve(ll x,ll k,ll d){
    if(x<0) x=abs(x);//x可以取负数
    if((x/d)>k){
        printf("%lld",x-k*d);}
    else {
        if((k-x/d)%2==1){
            printf("%lld",abs(x%d-d));
        }else{
            printf("%lld",x%d);
        }
    }

}
int main(){
    ll x,k,d;
    scanf("%lld %lld %lld",&x,&k,&d);
    solve(x,k,d);
}

Measured memory_bytes: 3820
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, m;
    while(cin >> n >> m, n|m){
        vector<pair<int, int>> v(n);
        ll ans = 0;
        for (int i = 0; i < n; ++i) {
            scanf("%d%d", &v[i].second, &v[i].first);
            ans += (ll)v[i].second*v[i].first;
        }
        sort(v.begin(), v.end(), greater<>());
        for (int i = 0; i < n; ++i) {
            int y = min(m, v[i].second);
            ans -= y*v[i].first;
            m -= y;
        }
        cout << ans << "\n";
    }
    return 0;
}



Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <algorithm>

template <class T, class... Args>
T& chmin(T& base, Args&&... args)
{
    base = std::min<T>({base, std::forward<Args>(args)...});
    return base;
}

template <class T, class... Args>
T& chmax(T& base, Args&&... args)
{
    base = std::max<T>({base, std::forward<Args>(args)...});
    return base;
}

template <class TVal, size_t Dim>
struct Tensor
{
    template <class T, class... Args>
    explicit Tensor(T s1, Args... size) : vec(s1, Tensor<TVal, Dim - 1>{static_cast<size_t>(size)...})
    {
    }

    Tensor<TVal, Dim - 1>& operator[](size_t i) { return vec.at(i); }
    const Tensor<TVal, Dim - 1>& operator[](size_t i) const { return vec.at(i); }

    template <class F>
    void apply(F&& f)
    {
        for (auto& v : vec)
            v.apply(f);
    }

private:
    std::vector<Tensor<TVal, Dim - 1>> vec;
};

template <class TVal>
struct Tensor<TVal, 1>
{
    explicit Tensor(size_t n) : vec(n) {}

    TVal& operator[](size_t i) { return vec.at(i); }
    const TVal& operator[](size_t i) const { return vec.at(i); }

    template <class F>
    void apply(F&& f)
    {
        for (auto& v : vec)
            f(v);
    }

private:
    std::vector<TVal> vec;
};

#include <iostream>
#include <algorithm>

int main()
{
    int N;
    std::cin >> N;
    Tensor<int, 2> v(N, 3);

    for (int i = 0; i < N; ++i)
        std::cin >> v[i][0] >> v[i][1] >> v[i][2];

    Tensor<int, 2> dp(N + 1, 3);
    dp.apply([](auto& v) { v = 0; });

    for (int i = 0; i < N; ++i) {
        chmax(dp[i + 1][0], dp[i][1] + v[i][0], dp[i][2] + v[i][0]);
        chmax(dp[i + 1][1], dp[i][0] + v[i][1], dp[i][2] + v[i][1]);
        chmax(dp[i + 1][2], dp[i][0] + v[i][2], dp[i][1] + v[i][2]);
    }

    std::cout << std::max({dp[N][0], dp[N][1], dp[N][2]}) << std::endl;
    return 0;
}

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

#define ff first
#define ss second
#define pb push_back

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int N = 200005;

int m;
ll c[N], d[N];

ii f(ll a, ll q){
	ll add = 0;
	while(a > 9){
		a = a % 10 + a / 10;
		add += q;
	}
	if(q == 1){
		return {a, add};
	}
	if(q & 1){
		ii ret = f(a + a, q / 2);
		ret.ss += q / 2;
		ret.ff += a;
		ret.ss++;
		while(ret.ff > 9){
			ret.ff = ret.ff % 10 + ret.ff / 10;
			ret.ss++;
		}
		ret.ss += add;
		return ret;
	}
	else{
		ii ret = f(a + a, q / 2);
		ret.ss += q / 2;
		ret.ss += add;
		return ret;
	}
}

int main() {
	scanf("%d", &m);
	for(int i = 0; i < m; i++){
		scanf("%lld %lld", c+i, d+i);
	}
	ll ans = 0;
	//ii aux = f(2, 2);
	//printf("?? %lld %lld\n",aux.ff, aux.ss);
	vector<ll> v;
	for(int i = 0; i < m; i++){
		ii x = f(c[i], d[i]);
		ans += x.ss;
		v.pb(x.ff);
	}
	while(v.size() > 1){
		ll x = v.back();
		v.pop_back();
		ll y = v.back();
		v.pop_back();
		x += y;
		ans++;
		if(x > 9){
			v.pb(x / 10);
		}
		v.pb(x % 10);
	}
	printf("%lld\n", ans);
}
/*
   229
   49
   13
   4

   229
   211
   31
   5

   229
   211
   22
   4

   1000000007
   100000007
   10000007
   1000007
   100007
   10007
   1007
   107
   17
 */


Measured memory_bytes: 5492
program main
    implicit none
    integer n, lowest, now, i
    character(len=300):: s, first, end_

    read*, n, s
    s = trim(s)
    lowest=0; now=0
    do i = 1,n
        if(s(i:i) == '(')then
            now = now + 1
        else
            now = now - 1
        end if
        lowest = min(lowest, now)
    end do
    ! print*, now, lowest
    first = ''
    end_ = ''

    do i = 1, -lowest
        first = trim(first) // '('
    end do

    do i = 1, now-lowest
        end_ = trim(end_) // ')'
    end do

    print'(a)', trim(first) // trim(s) // trim(end_)

    
end program

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



int main(){
    string S;
    cin >> S;
    if(S.at(S.size()-1) =='s')cout << S+"es" << endl;
    else cout << S+"s" << endl;
    
    
    
}



Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
//struct area

//function area

//main area
int main(){
    string n;
    cin >> n;
    ll sum = 0;
    rep(i,n.size()){
        sum += (n[i]-'0');
    }
    cout << (sum%9==0 ? "Yes" : "No") << endl;
}
/*



*/

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

const ll mx=1e18;

int main(){
    int n;
    cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    if(count(a.begin(),a.end(),0)!=0){
        cout<<0<<endl;
        return 0;
    }
    ll ans=1;
    rep(i,n){
        if(a[i]<=mx/ans){
            ans*=a[i];
        }
        else{cout<<-1<<endl; return 0;}
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4060
// 深さ優先探索
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

#define MAX_N 100
// 値の定義
const int EXIST = 1;
const int NO_EXIST = 0;

const int WHITE = 0;// 未訪問
const int GRAY = 1; // 訪問中
const int BLACK = 2;// 訪問完了

// グラフ情報を保持する配列
int ary_graph[MAX_N + 1][MAX_N + 1];

// 各頂点の訪問状態を保持する配列
int color[MAX_N + 1];

// 発見時刻と完了時刻を保持する構造体
typedef struct
{
    int start_time;
    int end_time;
}SearchTime;

SearchTime st_SearchTime[MAX_N + 1];
int search_T = 0;

void depthFirstSearch(int now_vertex, int vertex_num);

int main(void)
{
    int n, u, num, v_num;

    for(int i = 0; i < MAX_N + 1; i++)
    {
        color[i] = WHITE;

        for(int j = 0; j < MAX_N + 1; j++)
        {
            // 配列の初期化
            ary_graph[i][j] = NO_EXIST;
        }
    }

    cin >> n;

    for(int i = 0; i < n; i++)
    {
        cin >> u;
        cin >> num;

        // 0オリジンにする
        u--;

        for(int j = 0; j < num; j++)
        {
            // 隣接点を記憶する
            cin >> v_num;

            // 0オリジンにする
            v_num--;
            ary_graph[u][v_num] = EXIST;
        }
    }

    // 深さ優先探索を実施
    for(int i = 0; i < n; i++)
    {
        if( color[i] == WHITE )
        {
            depthFirstSearch(i, n);
        }
    }

    // 結果の表示
    for(int i = 0; i < n; i++)
    {
        printf("%d %d %d\n", i + 1, st_SearchTime[i].start_time, st_SearchTime[i].end_time);
    }

    return 0;
}

// 深さ優先探索を実施する関数
// now_vertex : 現在の頂点のNo.
// next_vertex : 次の頂点のNo.
// vertex_num : グラフの頂点数
void depthFirstSearch(int now_vertex, int vertex_num)
{
    // 訪問中
    color[now_vertex] = GRAY;

    // 発見時刻の設定
    search_T++;
    st_SearchTime[now_vertex].start_time = search_T;

    for(int i = 0; i < vertex_num; i++)
    {
        if( color[i] == WHITE
            && ary_graph[now_vertex][i] == EXIST )
        {
            depthFirstSearch(i, vertex_num);
        }
    }

    // 訪問完了
    color[now_vertex] = BLACK;

    // 終了時刻の設定
    search_T++;
    st_SearchTime[now_vertex].end_time = search_T;

    return;
}



Measured memory_bytes: 3244
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
using namespace boost::range;
using boost::irange;
using boost::math::gcd;
using boost::math::lcm;

using ll = int64_t;
constexpr char LN = '\n';
template<class T> bool chmax(T& a, const T& b) {if(a<b){a=b;return true;}else{return false;}}
template<class T> bool chmin(T& a, const T& b) {if(b<a){a=b;return true;}else{return false;}}

#ifdef LOCAL
template<class H> void dump_(const char* s, H h) {cout<<s<<"="<<h<<LN; }
template<class H, class... T> void dump_(const char* s, H h, T... t) {for(;*s!=',';++s){cout<<*s;}cout<<"="<<h<<",";dump_(++s,t...);}
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__)
#else
#define dump(...)
#endif

struct init_ {init_(){cin.tie(nullptr);ios::sync_with_stdio(false);}} init_;

template<class C> C scan(size_t n) {C c(n);for(auto& v:c){cin>>v;}return c;}
template<class C> C scan(size_t n, size_t m) {C vss(n);for(auto& vs:vss){vs.resize(m);for(auto& v:vs){cin>>v;}}return vss;}

template<class R> struct Joined { const R& r; const char* s; };
template<class R> Joined<R> joined(const R& r, const char* s = " ") {return{r,s};}
template<class R> ostream& operator<<(ostream& out, Joined<R> j) {bool f=true;for(const auto& v:j.r){if(f){f=false;}else{out<<j.s;}out<<v;}return out;}

template<class T> using matrix = vector<vector<T>>;
template<class T> matrix<T> make_matrix(size_t n, size_t m, const T& init = T()) {matrix<T> vss(n);for(auto& vs:vss){vs.resize(m,init);}return vss;}
template<class T> ostream& operator<<(ostream& out, Joined<matrix<T>> j) {bool a=true;for(const auto& vs:j.r){if(a){a=false;}else{out<<LN;}bool f=true;for(const auto& v:vs){if(f){f=false;}else{out<<j.s;}out << v;}}return out;}

template<class T> void show_(const T& t) {cout<<t;}
template<class T> void show_(const vector<T>& v) {cout<<joined(v);}
void show_(bool b) {cout<<(b?"Yes":"No");}
void show_(double d) {cout<<fixed<<setprecision(12)<<d;}
template<class T, class... TS> void show_(const T& t, TS... ts) {show_(t);cout<<' ';show_(ts...);}
template<class T> void show(const T& t) {show_(t);cout<<LN;}
template<class T, class... TS> void show(const T& t, TS... ts) {show_(t, ts...);cout<<LN;}

int main() {
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    for (int i : irange(0, N)) {
        cout << S[i] << T[i];
    }
    cout << LN;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
signed main(){
  string a,b;
  cin>>a>>b;
  rep(i,a.size()){
    if(a==b){
      cout<<"Yes";
      return 0;
        }
    a+=a.at(0);
    a.replace(0,1,"");
  }
  cout<<"No";
  }

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

template <typename T> class SegmentTree {
private:
  int n; function<T(T, T)> f; T t;
  vector<T> node;
public:
  SegmentTree() {};
  SegmentTree(function<T(T, T)> f, T t) : f(f), t(t) {}
  void init(int in) {
    n = 1;
    while (n < in) n <<= 1;
    node.assign(n << 1, t);
  }
  void build(const vector<T> &v) {
    int sz = v.size();
    init(sz);
    for (int i = 0; i < sz; i++) node.at(n + i) = v.at(i);
    for (int i = n - 1; i; i--) {
      node.at(i) = f(node.at((i << 1) | 0), node.at((i << 1) | 1));
    }
  }
  void set_val(int k, T a) {
    node.at(k += n) = a;
    while (k >>= 1) {
      node.at(k) = f(node.at((k << 1) | 0), node.at((k << 1) | 1));
    }
  }
  T query(int a, int b) {
    T vl = t, vr = t;
    for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) vl = f(vl, node.at(l++));
      if (r & 1) vr = f(node.at(--r), vr);
    }
    return f(vl, vr);
  }
};

int main() {
  int N;
  string S;
  cin >> N >> S;
  vector<int> V(N);
  for (int i = 0; i < N; i++) {
    int s = S.at(i) - 'a';
    V.at(i) = (1 << s);
  }
  auto f = [&](int x, int y) {return x | y;};
  SegmentTree<int> ST(f, 0);
  ST.build(V);
  int Q;
  cin >> Q;
  while (Q--) {
    int q;
    cin >> q;
    if (q == 1) {
      int a;
      char b;
      cin >> a >> b;
      int s = b - 'a';
      ST.set_val(--a, (1 << s));
    }
    if (q == 2) {
      int a, b;
      cin >> a >> b;
      int ans = ST.query(--a, b);
      cout << __builtin_popcount(ans) << "\n";
    }
  }
}

Measured memory_bytes: 7044
#include <bits/stdc++.h>
#define N 100005
#define oo 1e18

using namespace std;
int n, k, d[N];
long long A[N], F[N];

long long Magic(int i)
{
    if(i>n) return oo;
    if(i==n) return 0;
    if(d[i]) return F[i];
    d[i]=1;
    long long res = oo;
    for(int j=1; j<=k; j++)
    {
        res=min(res, abs(A[i]-A[i+j])+Magic(i+j));
    }
    return F[i]=res;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n>>k;
    for(int i=1; i<=n; i++) cin>>A[i];
    cout<<Magic(1);
    return 0;
}


Measured memory_bytes: 13324
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <list>
#include <cstdint>
#include <bits/stdc++.h>
#include <queue>
#include <set>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for (int i = n - 1; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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;
}

using namespace std;
using uif = uint_fast64_t;
using ll = long long int;

int qp(int a, ll b)
{
  int ans = 1;
  do
  {
    if (b & 1)
      ans = 1ll * ans * a % mod;
    a = 1ll * a * a % mod;
  } while (b >>= 1);
  return ans;
}
int qp(int a, ll b, int mo)
{
  int ans = 1;
  do
  {
    if (b & 1)
      ans = 1ll * ans * a % mo;
    a = 1ll * a * a % mo;
  } while (b >>= 1);
  return ans;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll, ll);
ll mod_add(ll, ll);
ll mod_mul(ll, ll);
ll mod_div(ll, ll);
void make_fact(ll);
void make_invfact(ll);

int main(void)
{

  ll n;
  cin >> n;

  vector<ll> a(n);
  vector<ll> total(n);
  rep(i, n)
  {
    cin >> a[i];
    if (i == 0)
      total[i] = a[i];
    else
      total[i] = a[i] + total[i - 1];
  }
  ll ans = total[n - 1];
  for (ll i = 1; i < n; i++)
  {
    ll diff = abs(total[i - 1] - (total[n - 1] - total[i - 1]));
    chmin(ans, diff);
  }
  cout << ans << endl;
  return 0;
}

ll mod_pow(ll x, ll r)
{
  if (r == 0)
    return 1;
  else if (r == 1)
    return x % mod;
  else if (r % 2 == 0)
  {
    ll t = mod_pow(x, r / 2) % mod;
    return t * t % mod;
  }
  else
  {
    ll t = mod_pow(x, r / 2) % mod;
    ll k = t * t % mod;
    return k * x % mod;
  }
}
ll mod_add(ll a, ll b)
{
  return (a + b) % mod;
}

ll mod_mul(ll a, ll b)
{
  return (a * b) % mod;
}

ll mod_div(ll a, ll b)
{
  return mod_mul(a, mod_pow(b, mod - 2));
}

void make_fact(ll n)
{
  fac[0] = 1;
  rep(i, n)
  {
    fac[i + 1] = mod_mul(fac[i], i + 1);
  }
}

void make_invfact(ll n)
{
  invfac[n] = mod_pow(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--)
  {
    invfac[i] = mod_mul(invfac[i + 1], i + 1);
  }
}

Measured memory_bytes: 3328
#include<stdio.h>

int main(void) {
    int n, i, j;
    int freq[101];
    int count, count_of_trans;
    int flag;
    
    while(1) {
        scanf("%d", &n);
        if(n == 0) break;
        
        int array[n], trans[n];
        
        for(i=0; i<n; i++) {
                scanf("%d", &array[i]);
        }
        
        count_of_trans = 0;
        while(1) {
            for(i=0; i<101; i++) freq[i] = -1;
            
            for(i=0; i<n; i++) {
                if(freq[array[i]] == -1) {
                    count = 0;
                    for(j=0; j<n; j++) {
                        if(array[j] == array[i]) count++;
                    }
                    freq[array[i]] = count;
                }
                trans[i] = freq[array[i]];
            }
            
            flag = 1;
            for(i=0; i<n; i++) {
                if(array[i] != trans[i]) {
                    flag = 0;
                    break;
                }
            }
            if(flag == 1) {
                break;
            }
            count_of_trans++;
            
            for(i=0; i<n; i++) {
                array[i] = trans[i];
            }
        }
        
        printf("%d\n", count_of_trans);
        for(i=0; i<n; i++) {
            if(i!=0) printf(" ");
            printf("%d", array[i]);
        }
        printf("\n");
    }
    
    
    return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    int n; cin >> n;
    vector<lint> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a), greater<lint>());

    bool f = 1; int j = 0;
    lint ans = 0;
    rep(i, n-1){
        ans += a[j];
        if(f) j++;
        f = !f;
    }
    out(ans);
}

Measured memory_bytes: 4840
def main():
    N = int(input())
    A = [None] * N
    B = [None] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())
    A.sort()
    B.sort()
    if N % 2 == 1:
        print(B[N // 2] - A[N // 2] + 1)
    else:
        print(B[N//2]+B[N // 2 - 1] - A[N//2] - A[N // 2 - 1] + 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 25504
/*
Author: Babin Dutta
*/

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define endl "\n"
#define inf 1e18


void solve(int tt){
	int n,k; cin>>n>>k;
	vector<int> v(n,0);
	int d,r;
	for(int i=0;i<k;i++){
		cin>>d;
		for(int j=0;j<d;j++){
			cin>>r;
			r--;
			v[r]++;
		}
	}
	int ans=0;
	for(int i=0;i<n;i++) if(v[i] == 0) ans++;
	cout<<ans<<endl;
}


int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve(i);
	return 0;
}

Measured memory_bytes: 3660
import heapq
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]
        self.rank = [0] * n
    
    def find(self, x):
        if self.parent[x] != x:
            self.parent[x] = self.find(self.parent[x])
        return self.parent[x]

    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y: return
        
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            self.rank[x] += (self.rank[x] == self.rank[y])

def kruskal(n, edge):
    ans = 0
    uf = UnionFind(n)
    while True:
        d, v, u = heapq.heappop(edge)
        
        if uf.find(v) != uf.find(u):
            uf.union(v, u)
            n -= 1
            ans += d
        if n < 2: return ans
    return ans

n = int(input())
x, y = [None]*n, [None]*n

for i in range(n):
    a, b = map(int, input().split())
    x[i] = (a, i)
    y[i] = (b, i)

x.sort(key=lambda x:x[0])
y.sort(key=lambda y:y[0])

edge = []
for i in range(n-1):
    heapq.heappush(edge, (x[i+1][0]-x[i][0], x[i][1], x[i+1][1]))
    heapq.heappush(edge, (y[i+1][0]-y[i][0], y[i][1], y[i+1][1]))

del x, y
print(kruskal(n, edge))

Measured memory_bytes: 51044
R, G, B, N = map(int, input().split())

buyR = int(N/R)
N1 = 0
count = 0


for i in range(buyR+1):
    N1 = N - i*R
    for j in range(int(N1/G)+1):
        if N1 - j*G >= 0:
            if (N1-j*G)%B == 0:
                count += 1

print(count)                

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// const ll INF = 1e18;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()

ll factorial(ll n) {
    ll x = 1;
    reps(i, n) {
        x *= i;
    }
    return x;
}

double distance(double xi, double xj, double yi, double yj) {
    return sqrt(pow(xi-xj,2)+pow(yi-yj,2));
}

ll N;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> N;
    vector<double> x(N);
    vector<double> y(N);

    rep(i, N) {
        cin >> x[i];
        cin >> y[i];
    }

    double d[N][N];

    rep(i, N) {
        rep(j, N) {
            double dist = distance(x[i], x[j], y[i], y[j]);
            d[i][j] = dist;
            d[j][i] = dist;
        }
    }

    vector<ll> p(N);
    rep(i, N) {
        p[i] = i;
    }

    double sum = 0.0;
    do {
        rep(i, N-1) {
            sum += d[p[i]][p[i+1]];
        }
    } while(next_permutation(all(p)));

    double ans = sum/factorial(N);
    cout << setprecision(12) << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string disp(bool x){
    return x ? "Yes" : "No";
}


int main(){
    int n; cin >> n;
    
    int a[n];
    rep(i,n) cin >> a[i];
    rep(i,n) cout << a[i] << ((i == n-1) ? '\n':' ');
    
    for(int i=1;i<=n-1;i++){
        int v = a[i];
        int j = i-1;
        
        while(j>=0 and a[j]>v){
            a[j+1] = a[j];
            j--;
            a[j+1] = v;
        }
        rep(i,n) cout << a[i] << ((i == n-1) ? '\n':' ');
    }
}
    
    







Measured memory_bytes: 3084
// https://atcoder.jp/contests/abc106/tasks/abc106_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

// N以下の約数の個数
vector<int> divisor_all(int n) {
    vector<int> v(n + 1);
    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j += i) {
            v[j]++;
        }
    }
    return v;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    auto d = divisor_all(N);
    int cnt = 0;
    for (int i = 105; i <= N; i += 2) {
        cnt += d[i] == 8;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3528
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  ll n,q; cin >> n >> q;
  str s; cin >> s;
  ll cnt[n];
  cnt[0] = 0;
  REP(i,n-1){
    if(s[i]=='A'&&s[i+1]=='C'){
      cnt[i+1] = cnt[i] + 1;
    }else{
      cnt[i+1] = cnt[i];
    }
  }
  REP(i,q){
    ll l,r; cin >> l >> r;
    l--, r--;
    cout << cnt[r]-cnt[l] << endl;
  }
  return 0;
}


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

int main() {
int A,B;
  cin >> A >> B;
  if (A<B&&A!=1||B==1&&A!=1){
    cout << "Bob" << endl;
  } else if (A>B&&B!=1||A==1&&B!=1){
    cout << "Alice" << endl;
  } else {
    cout << "Draw" << endl;}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using PP = pair<long, long>;
const int INF = 1e9;
template <class T> T Next() { T buf; cin >> buf; return buf; }

int main() {
  vector<int> a;
  for (int i = 0; i < 5; ++i) {
    a.push_back(Next<int>());
  }
  
  int sum = 0;
  for (int i : a) {
    sum += (i + 9) / 10 * 10;
  }
  
  int mx = 0;
  for (int i : a) {
    mx = max(mx, i % 10 == 0 ? 0 : 10 - i % 10);
  }
  cout << sum - mx << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	n := len(s)
	ans := 0
	for i := 0; i < n; i++ {
		for j := i; j < n; j++ {
			if !(s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T') {
				break
			}
			ans = max(ans, j-i+1)
		}
	}
	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


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

#define ll long long
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define fork(i,n) for(ll i=0; i<(n); i++)
#define forn for(ll i=0; i<(n); i++)
#define fori(i,k,n) for(ll i=k; i<(n); i++) 
#define all(x) (x).begin(),(x).end()
#define en '\n'
#define FILL(x,v) memset(x,v,sizeof(x))
#define pb push_back


template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
 
template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
 
template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}
void min_self(int &a, int b){
	a = min(a, b);
}
void max_self(int &a, int b){
	a = min(a,b);
}

const int INF = 1e9 + 5;

void solve(){
	int n;
	cin >> n;
	// dp[i][j] - max happy point on day i if choose act j
	vvi dp(n, vi(3, 0));
	forn{
		int a, b, c;
		cin >> a >> b >>c;
		if(i==0){
			dp[0][0]=a;
			dp[0][1]=b;
			dp[0][2]=c;
			continue;
		}
		dp[i][0]= a+max(dp[i-1][1], dp[i-1][2]);
		dp[i][1]= b+max(dp[i-1][0], dp[i-1][2]);
		dp[i][2]= c+max(dp[i-1][0], dp[i-1][1]);;
	}
	cout << max({dp[n-1][0],dp[n-1][1],dp[n-1][2]}) << en;
}

int main(){
    ios::sync_with_stdio(0);
	cin.tie(0);
    cout.tie(0);
 
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
    return 0;
}

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

int main(){
  int n, sum = 0;
  char s;
  map<char, int> mp;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> s;
    if(!mp[s]) sum++;
    mp[s]++;
  }
  if(sum == 4) cout << "Four" << endl;
  else cout << "Three" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath> 
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
bool vis[13];
int main(){
	int a[4];
	for (int i=0;i<4;i++){
		cin>>a[i];
		vis[a[i]]=1;
	}
	if (vis[7] && vis[1] && vis[9] && vis[4]) cout<<"YES";
	else cout<<"NO";
}

Measured memory_bytes: 384