akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N, M;
	cin >> N >> M;
	LL sum = 0;
	for (LL m = 0; m < M; m++) {
		LL a;
		cin >> a;
		sum += a;
	}
	if (sum > N)cout << "-1\n";
	else cout << N - sum << "\n";
	return 0;
}


Measured memory_bytes: 3196
N, K, Q = map(int, input().split())
A = []
for _ in range(Q): A.append(int(input()))

points = [K] * N
points = list(map(lambda x: x - Q, points))
for a in A:
    points[a - 1] += 1

# output: 0 opint => No, else => Yes
for p in points:
    if p > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 11844
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>
#include <algorithm>
#include<iomanip>
#define INF 1000000000
#define LM 55555
#define LL long long
using namespace::std;


long long  b, c,now, N, K, M, ans, A[100000], AA[100000];
string S, s[100];
bool h,w[10], k[100];
char cc;

int main() {
	cin >> S;
	h = false;
	if (S[0] == 'A') {
		w[0] = true;
		for (int i = 2; i < S.size()-1; i++) {
			if (S[i] == 'C') {
				if (h == false) {
					h = true;
					w[i] = true;
				}
				else {
					cout << "WA" << endl;
					return 0;
				}
			}
		}

		if (h == false) {
			cout << "WA" << endl;
			return 0;
		}

		for (int i = 'A'; i < 'Z'; i++) {
			for (int j = 0; j < S.size(); j++) {
				if (S[j] == i&&w[j] == false) {
					cout << "WA" << endl;
					return 0;
				}
			}
		}
	}
	else {
		cout << "WA" << endl;
		return 0;
	}
	cout << "AC" << endl;
	return 0;

}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define m_p make_pair
#define sz(x) (int)x.size()
#define out(x) cerr<<#x<<" = "<<x<<" "
#define outln(x) cerr<<#x<<" = "<<x<<endl
#define outarr(x,l,r) cerr<<#x"["<<l<<"-"<<r<<"] = "; for (int _i=l;_i<=r;++_i) cerr<<x[_i]<<" ";cerr<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define gc() getchar()
//char buf[1<<23],*p1=buf,*p2=buf;
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <class T> void read(T &x)
{
    x=0; char c=gc(); int flag=0;
    while (c<'0'||c>'9') flag|=(c=='-'),c=gc();
    while (c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=gc();
    if (flag) x=-x;
}
template <class T> T _max(T a,T b){return a>b ? a : b;}
template <class T> T _min(T a,T b){return a<b ? a : b;}
template <class T> bool checkmax(T &a,T b){return b>a ? a=b,1 : 0;}
template<class T> bool checkmin(T &a,T b){return b<a ? a=b,1 : 0;}
const int mod=998244353;
int Add(int a,int b){a+=b; return a>=mod ? a-mod : a;}
int Sub(int a,int b){a-=b; return a<0 ? a+mod :	a;}
int Mul(int a,int b){return (ll)a*b%mod;}
void add(int &a,int b){a=Add(a,b);}
void sub(int &a,int b){a=Sub(a,b);}
void mul(int &a,int b){a=Mul(a,b);}
int qpow(int a,int b)
{
	int ans=1;
	while (b)
	{
		if (b&1) mul(ans,a);
		mul(a,a);
		b>>=1;
	}
	return ans;
}
const int N=400005;
char a[N],A[N];
int n,b[N];
int flag[N],prime[N],cnt=0,mu[N];
int f[N],g[N];
int calc(int x)
{
	int tot=n/x;
	if (tot%2==0) return 0;
	int ans=b[x];
	for (int i=1;i<=x;++i)
	{
		A[i]=a[i];
	}
	for (int i=x+1;i<=n;++i)
	{
		A[i]='0'+'1'-A[i-x];
	}
	int flag=0;
	for (int i=1;i<=n;++i)
	{
		if (a[i]<A[i]) 
		{
			flag=-1;
			break;
		}
		else if (a[i]>A[i])
		{
			flag=1;
			break;
		}
	}
	if (flag>=0) ++ans;
	return ans%mod;
}

void init()
{
	read(n);
	scanf("%s",a+1);
	for (int i=1;i<=n;++i)
	{
		b[i]=Mul(b[i-1],2);
		add(b[i],a[i]-'0');
	}
	mu[1]=1;
	for (int i=2;i<=n;++i)
	{
		if (!flag[i])
		{
			prime[++cnt]=i;
			mu[i]=mod-1;
		}
		for (int j=1;j<=cnt&&i*prime[j]<=n;++j)
		{
			flag[i*prime[j]]=1;
			if (i%prime[j]==0)
			{
				mu[i*prime[j]]=0;
				break;
			}
			mu[i*prime[j]]=mod-mu[i];
		}
	}
	for (int i=1;i<=n;++i)
	{
		if (n%i) continue;
		f[i]=calc(i);
	}
}

void solve()
{
	for (int i=1;i<=n;++i)
	{
		for (int j=i;j<=n;j+=i)
		{
			add(g[j],Mul(f[i],mu[j/i]));
		}
	}
	int ans=Mul(b[n]+1,n+n);
	for (int i=1;i<=n;++i)
	{
		if (!f[i]) continue;
		int tmp=Mul(n+n-i-i,g[i]);
		sub(ans,tmp);
	}
	printf("%d\n",ans);
}

#undef int
int main()
{
    init();
	solve();
	return 0;
}


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

bool solve();

int main(){
	int n;cin>>n;
	while(n--){
		if(solve()){
			cout<<"YES";
		}else{
			cout<<"NO";
		}
		cout<<endl;
	}	
	return 0;
}

bool solve(){
	float x1,x2,y1,y2;
	float vx1,vx2,vy1,vy2;
	
	cin>>x1>>y1>>x2>>y2;
	vx1=x2-x1;vy1=y2-y1;
	cin>>x1>>y1>>x2>>y2;
	vx2=x2-x1;vy2=y2-y1;
	
	//vx1:vy1=vx2:vy2
	return (vx1*vy2==vy1*vx2);
}

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

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

    double a[N];
    string S[N];

    for(int i = 0; i < N; i++){
        cin >> a[i] >> S[i];
    }

    int ans_j = 0;
    double ans_b = 0.0;

    for(int i = 0; i < N; i++){
        if(S[i] == "JPY"){
            ans_j += a[i];
        }else{
            ans_b += a[i];
        }
    }

    double ans = 0;
    ans = ans_j + (ans_b * 380000);

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#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;

using namespace std;


int  main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,x;
  cin>>n>>x;
  ll a,b;
  cin>>a;
  ll res=0;
  rep(i,n-1)
  {
    cin>>b;
    //cout<<a<<b<<endl;
    if(x<a+b)
    {
      res+=a+b-x;
      if(x<a)
      {
        a=x;
        b=0;
      }
      else
      {
        b=x-a;
      }
    }
    a=b;

  }
  cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 256
now=1000
kabu=0
n=int(input())
a=list(map(int,input().split()))
for i in range(n-1):
	if a[i]<a[i+1]:
		kabu+=now//a[i]
		now%=a[i]
	else:
		now+=kabu*a[i]
		kabu=0
print(now+kabu*a[-1])

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

int main() {
    int h, w;
    cin >> h >> w;

    vector<vector<char>> data(h, vector<char>(w));

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> data.at(i).at(j);
        }
    }

    
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if(j==w-1) cout << data.at(i).at(j) << endl;
            else cout << data.at(i).at(j);
        }
        for (int j = 0; j < w; j++)
        {
            if(j==w-1) cout << data.at(i).at(j) << endl;
            else cout << data.at(i).at(j);
        }
        
    }
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define N 50
#define INF 99999999
typedef pair<int,int>P;
int digit;
string u;
int n;
int maxx=0;
void dfs(string,int);
int main(){
    int k;
    cin>>n>>k;
    int a[k+1];for(int i=0;i<k;i++)cin>>a[i];
    string s="";
    for(int i=0;i<k;i++)s+=to_string(a[i]);
    //s+="\0";
    //cout<<s<<endl;
    digit=(int)to_string(n).size();
    //printf("digit=%d\n",digit);
    for(int i=0;i<10;i++){
        //cout<<s[i];
        if(s.find(to_string(i))==string::npos)u+=to_string(i);
    }

    for(int i=0;i<digit;i++){             
        maxx+=(u[u.size()-1]-'0')*pow(10,digit-i-1);
    }
    //printf("max=%d\n",maxx);
    //cout<<u<<endl;
    string ans="";
    dfs(ans,0);
}
int flag=0;


void dfs(string s,int d){
    if(flag==1)return;
    //printf("d=%d\n",d);
    //cout<<"s="<<s<<endl;
    if(d==digit){
        int sum=0;
        for(int i=0;i<d;i++){
            if(s[0]!='0'){          
                sum+=(s[i]-'0')*pow(10,d-i-1);
            }
        }
        //cout<<"sum="<<sum<<endl;
        if(sum>=n){
            cout<<s<<endl;
            flag=1;
            return;
        }else if(sum==maxx){
            //cout<<"ketaagari"<<endl;
            int i=0;
            while(u[i]-'0'==0&&i<(int)u.size()){i++;}
            //printf("i=%d\n",i);
            cout<<u[i];
            for(int j=0;j<digit;j++){
                //printf("j=%d\n",j);
                cout<<u[0];}
            cout<<endl;return;
        }else return;
    }
    //else return;
    
    for(int i=0;i<(int)u.size();i++){
        char c2=u[i];
        dfs(s+c2,d+1);
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    string k;
    ll D;
    cin >> k >> D;
    ll n = k.length();

    ll dp[10100][110][2];
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;
    rep(dgt, 0, n) rep(d, 0, D) rep(flg, 0, 2) {
        ll c = k[dgt] - '0';
        rep(nxt, 0, 10) {
            if (nxt < c) (dp[dgt+1][(d+nxt)%D][1] += dp[dgt][d][flg]) %= MOD;
            else if (nxt == c) (dp[dgt+1][(d+nxt)%D][flg] += dp[dgt][d][flg]) %= MOD;
            else {
                if (flg) (dp[dgt+1][(d+nxt)%D][flg] += dp[dgt][d][flg]) %= MOD;
            }
        }
    }
    ll ans = (dp[n][0][0] + dp[n][0][1]) % MOD;
    ans = (ans + MOD - 1) % MOD;
    cout << ans << endl;
}

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

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

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


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

using namespace std;

const int mxn = 1e7;

long long f[mxn + 11];

void init(){
	for (int i = 1; i <= mxn; i++){
		for (int j = i; j <= mxn; j += i){
			f[j]++;
		}
	}
}

int main(){
	//~ freopen("input.txt", "r", stdin);
	//~ freopen("output.txt", "w", stdout);
	init();
	int n;
	scanf("%d", &n);
	long long ans = 0;
	for (int i = 1; i <= n; i++){
		long long cur = (i * 1LL * f[i]);
		ans += cur;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 81948
N = int(input())
dic = {}
nmax = 1
for i in range(N):
  s = str(input())
  if s in dic:
    dic[s] += 1
    #毎回dic更新する度に最大値も更新
    nmax = max(dic[s], nmax)
  else:
    dic[s] = 1
slist = []
for k in dic:
  if dic[k] == nmax:
    slist.append(k)
for s in sorted(slist):
  print(s)

Measured memory_bytes: 32988
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

const inf = 1 << 60
const mod int = 1e9 + 7

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func maxAndSec(a []int) (int, int) {
	max, sec := -1, -1
	for _, i := range a {
		if max <= i {
			max, sec = i, max
		} else if sec < i {
			sec = i
		}
	}
	return max, sec
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()

	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = ri()
	}

	// fmt.Println(a)

	mx, sec := maxAndSec(a)

	ctMx := 0
	for _, aa := range a {
		if aa == mx {
			ctMx++
		}
	}

	// fmt.Println(mx, ctMx)

	if ctMx > 1 {
		for i := 0; i < n; i++ {
			fmt.Println(mx)
		}
		return
	} else { // ctMx == 1
		for _, aa := range a {
			if aa == mx {
				fmt.Println(sec)
			} else {
				fmt.Println(mx)
			}
		}
	}
}


Measured memory_bytes: 6144
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}

long long gcd (long long a, long long b)
{
	if (b > a)
		swap(a, b);
	return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
	ios::sync_with_stdio(false);
	#ifdef ONLINE_JUDGE
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.setstate(ios::failbit);
	#endif

	int n, m;
	cin >> n >> m;
	vvi M(n);
	rep(i,0,m)
	{
		int x, y;
		cin >> x >> y;
		x--, y--;
		M[x].push_back(y);
		M[y].push_back(x);
	}
	vi par(n, -1);
	par[0] = 0;
	queue<int> q;
	q.push(0);
	while(!q.empty())
	{
		int x = q.front();
		q.pop();
		for(int y : M[x])
		{
			if(par[y] == -1)
			{
				par[y] = x;
				q.push(y);
			}
		}
	}
	cerr << par << '\n';
	if(count(all(par), -1))
		ret("No");
	cout << "Yes\n";
	rep(i,1,n)
		cout << par[i] + 1 << '\n';
}


Measured memory_bytes: 10264
public class Main {

  private static void solve() {
    int n = ni();
    int s = ni();
    int[] a = na(n);

    int mod = 998244353;

    long[][] dp = new long[n + 1][s + 1];
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j <= s; j++) {
        if (j + a[i] <= s) {
          dp[i + 1][j + a[i]] += dp[i][j];
          dp[i + 1][j + a[i]] %= mod;
        }
        dp[i + 1][j] += dp[i][j] * 2 % mod;
        dp[i + 1][j] %= mod;
      }
    }

    System.out.println(dp[n][s]);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 107548
#include <iostream>

using namespace std;

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

  if(a==5&&b==5&&c==7
    ||a==5&&b==7&&c==5
    ||a==7&&b==5&&c==5)
    cout<<"YES";
    else
    cout<<"NO";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define sum(x) accumulate(all(x),0)
#define gll greater<ll>()


void solve(){
 ll n;
  cin >> n;
  ll ans=0;
  
  for(int i=1;i<=n;i++){
    ans+=i*(n/i)*(n/i+1)/2;  
  }
  cout << ans << endl;

}

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

Measured memory_bytes: 3648
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

#define ull unsigned long long

const ull mod = 998244353;

ull dp[310][310];

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


	string S;
	int K;
	int k = 0;
	int A[301] = {};

	cin >> S >> K;
	rep(i, S.size()) {
		if (S[i] == '0') k++;
		else A[k]++;
	}

	int kosuu = 0;
	dp[0][0] = 1;
	for (int i = k; i >= 0; i--) {
		if (i % 4 == 0) {
			for (int j = kosuu; j >= 0; j--) {
				ull tmp = 0;
				for (int k = kosuu; k >= 0; k--) {
					dp[j][k] %= mod;
					tmp += dp[j][k];
					rep1(p, A[i]) dp[j + p][k + p] += dp[j][k];
					dp[j][k] = tmp;
				}
			}
		}
		else {
			for (int j = kosuu; j >= 0; j--) {
				ull tmp = 0;
				for (int k = kosuu; k >= 0; k--) {
					tmp += dp[j][k];
					rep1(p, A[i]) dp[j + p][k + p] += dp[j][k];
					dp[j][k] = tmp;
				}
			}
		}
		kosuu += A[i];
	}

	ull kotae = 0;
	rep(i, min(K, kosuu) + 1) {
		kotae += dp[i][0] % mod;
	}
	co(kotae % mod);



	Would you please return 0;
}

Measured memory_bytes: 4300
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 200010, LOG=20;

struct Fenwick{
	ll fen[MAXN];
	Fenwick(){
		reset();
	}
	void reset(){ memset(fen, 0, sizeof(fen));}
	void add(int pos, ll val){
		for (; pos<MAXN; pos+=pos&-pos) fen[pos]=(fen[pos] + val)%mod;
	}
	ll get(int pos){
		ll res=0;
		for (; pos; pos-=pos&-pos) res=(res + fen[pos])%mod;
		return res;
	}
} fen;

ll n, m, k, u, v, x, y, t, a, b, ans;
ll A[MAXN], B[MAXN], C[MAXN];
int prv[MAXN];

ll powmod(ll a, ll b){
	ll res=1;
	for (; b; b>>=1, a=a*a%mod) if (b&1) res=res*a%mod;
	return res;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n;
	for (int i=1; i<=n; i++) cin>>A[i], B[A[i]]++;
	for (int i=n-1; i; i--) B[i]+=B[i+1]-1;
	for (int i=1; i<=n; i++) if (B[i]<=0) kill(0)
	//debug("shit")
	C[0]=1;
	for (int i=1; i<=n; i++){
		prv[i]=prv[i-1];
		C[i]=C[i-1];
		if (B[i]==1) prv[i]=i;
		else C[i]=C[i]*(B[i]-1)%mod*powmod(B[i], mod-2)%mod;
	}
	
	for (int i=1; i<=n; i++){
		ans+=(fen.get(A[i])-fen.get(prv[A[i]]-1))*C[A[i]]%mod;
		fen.add(A[i], powmod(C[A[i]], mod-2));
	}
	fen.reset();
	
	for (int i=n; i; i--){
		ans-=(fen.get(A[i]-1)-fen.get(prv[A[i]]-1))*C[A[i]]%mod;
		fen.add(A[i], powmod(C[A[i]], mod-2));
	}
	
	ans%=mod;
	ans=ans*(mod+1)/2%mod;
	
	fen.reset();
	for (int i=n; i; i--){
		ans+=fen.get(A[i]-1);
		fen.add(A[i], +1);
	}
	
	for (int i=1; i<=n; i++) ans=ans*B[i]%mod;
	if (ans<0) ans+=mod;
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int N,M; cin>>N>>M;
  vi A(N);
  rep(_,0,M){
    int X,Y; cin>>X>>Y;
    A[X-1]++;
    A[Y-1]++;
    }
  rep(i,0,N) cout<<A[i]<<endl;
  }


Measured memory_bytes: 256
/*input
10
1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1
*/
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define input(str) freopen(str,"r",stdin);
#define output(str) freopen(str,"w",stdout);
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define INF  3e16+1
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld\n",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define modd 1000000007
#define len(x) x.size()
#define all(v) (v.begin(),v.end())
#define ll int
#define pi 3.1415926535897932384626
#define ld double
const int N =6e5+5;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
int powmod(int base,int exp,int mod)
{
	int res=1LL;
	while(exp>0)
	{
		if(exp&1LL)
			res=(res*base)%mod;
		exp/=2LL;
		base=(base*base)%mod;
	}
	return res%mod;
}
int dp[3005][3005];
signed main()
{
	int n;
	cin>>n;
	int a[n+1];
	Rep(i,n)
	{
		cin>>a[i];
		if((n&1))
		{
			dp[i][i]=a[i];
		}
		else
		{
			dp[i][i]=-a[i];
		}
	}
	for(int i=1;i<n;i++)
	{
		for(int j=1;j+i<=n;j++)
		{
			if(n&1)
			{
				if(!(i&1))
				{
					dp[j][j+i]=max(dp[j+1][j+i]+a[j],dp[j][j+i-1]+a[j+i]);
				}
				else
				{
					dp[j][j+i]=min(dp[j+1][j+i]-a[j],dp[j][j+i-1]-a[j+i]);
				}
			}
			else
			{
				if(!(i&1))
				{
					dp[j][j+i]=min(dp[j+1][j+i]-a[j],dp[j][j+i-1]-a[j+i]);
				}
				else
				{
					dp[j][j+i]=max(dp[j+1][j+i]+a[j],dp[j][j+i-1]+a[j+i]);
				}
			}
		}
	}
	cout<<dp[1][n]<<endl;
}

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

int main() {
    string s;
    cin >> s;
    std::string::size_type pos = 0;
    while ((pos = s.find(',', pos)) != std::string::npos) {
        s.replace(pos, 1, " ");
        pos += 1;
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    int n; cin >> n;
    cout << n*800 - (n/15)*200 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (110)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
T1 mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  T1 tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

bool isPrime(int n){
  if(n == 1) return false;
  rep(i, 2, min((int)(pow(n, 0.5) + 1), n)){
    if(n % i == 0) return false;
  }
  return true;
}

/////////////////////////////////////////////////////////

void Main() {
  ll N; cin >> N;
  vector<ll> A(N);
  rep(i, 0, N) cin >> A[i];
  ll res = 0;
  rep(i, 1, N){
    if(A[i] == A[i - 1]){
      A[i] = -1;
      res++;
    }
  }
  cout << res << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 256
import fractions
n,x = map(int,input().split())
a = list(map(int,input().split()))
res,ans = [],0
for i in range(n):
	res.append(abs(a[i]-x))
if len(res) > 3:
	D = fractions.gcd(res[0],res[1])
	for j in range(2,len(res)-2):
		D = fractions.gcd(D,res[j])
	ans = D
else:
	ans = min(res)
print(ans)

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

using namespace std;
#define ll long long
const int N = 105;
vector<int> g[N];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
//#ifndef ONLINE_JUDGE
//  cout << "\x1B[34m";
//#endif
  int n, k;
  cin >> n >> k;
  if (k > (n - 1) * (n - 2) / 2) return cout << "-1", 0;
  int m = 0;
  for (int i = 2; i <= n; i++) g[1].push_back(i), m++;
  int rem = abs((n - 1) * (n - 2) / 2 - k);
  for (int i = 2; i < n && rem > 0; i++) {
    for (int j = i + 1; j <= n && rem > 0; j++) g[i].push_back(j), rem--, m++;
  }
  if (rem != 0)
    cout << "-1";
  else {
    cout << m << '\n';
    for (int i = 1; i <= n; i++)
      for (auto a : g[i]) cout << i << " " << a << '\n';
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define INF 1000000000000
typedef long long ll;

ll iMAX = 1000000000000;
set<ll> amari;

int main()
{
  ll k, seven = 0, comp, size, result = 0;
  cin >> k;

  for (ll i = 0; i < iMAX; i++)
  {
    seven *= 10;
    seven += 7;
    size = amari.size();
    comp = seven % k;
    amari.insert(comp);
    seven = comp;
    if (comp == 0)
    {
      result = i + 1;
      break;
    }
    else if (size == amari.size())
    {
      result = -1;
      break;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 50492
import sys
sys.setrecursionlimit(10**9)

def dfs(x): #グラフでの再帰DFS
    if dp[x] != -1:
        return dp[x] #すでに値が決まっていたらそれをかえす
    ans = 0
    for e in graph[x]: #すべての枝について
        ans = max(ans,1 + dfs(e))
    dp[x] = ans
    return ans # 最も長い距離を返す　

n,m = list(map(int, input().split()))

graph = [[] for i in range(n+1)]
dp = [-1]
for i in range(1,n+1):
    dp.append(-1) # dpは初期値-1

for _ in range(m): # グラフの作成
    a,b = map(int, input().split())
    graph[a].append(b)
    #graph[b].append(a) #無向グラフの時
    
ans=0

for i in range(1,n+1):
    ans=max(ans,dfs(i))
print(ans)

Measured memory_bytes: 163528
from sys import setrecursionlimit
setrecursionlimit(10 ** 9)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.d = [-1] * n

    def find(self, x):
        if self.d[x] < 0:
            return x
        else:
            self.d[x] = self.find(self.d[x])
            return self.d[x]
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return False
        else:
            if self.d[x] > self.d[y]:
                x, y = y, x
            self.d[x] += self.d[y]
            self.d[y] = x
            return True

    def same(self, x, y):
        return self.find(x) == self.find(y)


    def size(self, x):
        return -self.d[self.find(x)]

n, m = map(int, input().split())
a = [0] * m
b = [0] * m
for i in range(m):
    val1, val2 = map(int, input().split())
    val1 -= 1
    val2 -= 1
    a[i],b[i] = val1, val2
uf = UnionFind(n)
a.reverse()
b.reverse()
ans = [0] * m
for i in range(m):
    if uf.same(a[i], b[i]) == True:
        continue
    else:
        ans[i] = uf.size(a[i]) * uf.size(b[i])
        uf.unite(a[i], b[i])
ans.reverse()
cnt = 0
for i in range(m):
    print(ans[i] + cnt)
    cnt += ans[i]

Measured memory_bytes: 16888
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int N;
vector<int> memo;
int dfs(int N){
    if(N == 0) return 0;
    if(N < 6) return memo[N] = dfs(N - 1) + 1;
    if(memo[N] != 1e9) return memo[N];
    int i = 9;
    int res = 1e9;
    while(N >= i){
        res = min(res, dfs(N - i) + 1);
        i *= 9;
    }
    int j = 6;
    while(N >= j){
        res = min(res, dfs(N - j) + 1);
        j *= 6;
    }
    return memo[N] = res;
}
int main(){
    cin >> N;
    int cnt = 0;
    memo.resize(N + 1, 1e9);
    cout << dfs(N) << endl;
}

Measured memory_bytes: 1152
N,M,K=map(int,input().split())
P=10**9+7
import math
print(M*N*(M+N)*(M*N-1)//6*math.factorial(N*M-2)*pow(math.factorial(K-2),P-2,P)*pow(math.factorial(N*M-K),P-2,P)%P)


Measured memory_bytes: 101308
a,b,ab,x,y = map(int,input().split())
total = 0
if (a+b)/2 > ab :
	m = max(x,y)
	n = min(x,y)
	total += n*ab*2
	z = 0
	s = 0
	t = 0
	if x > y :
		z = x-y
		s = z*a
	elif y>x :
		z = y-x
		s = z*b
	t = z*ab*2
	total += s if s<t else t

else :
	total += a*x+b*y
print(total) 

Measured memory_bytes: 3316
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#define MAXN 300005
using namespace std;

char s[MAXN];
char l[MAXN], r[MAXN];
int lpos, rpos;

int main(void)
{
    scanf("%s",s);
    int q; scanf("%d",&q);
    int cnt = 0;
    while(q--){
        int t; scanf("%d",&t);
        if(t==1) ++cnt;
        else{
            int f; char c[3];
            scanf("%d%s",&f,c);
            if(f==1){
                if(cnt&1) r[rpos++] = c[0];
                else l[lpos++] = c[0];
            }
            else{
                if(cnt&1) l[lpos++] = c[0];
                else r[rpos++] = c[0];
            }
        }
    }
    if(cnt&1) {
        for(int i=rpos-1;i>=0;--i) printf("%c",r[i]);
        int len = strlen(s);
        for(int i=len-1;i>=0;--i) printf("%c",s[i]);
        printf("%s",l);
    }
    else {
        for(int i=lpos-1;i>=0;--i) printf("%c",l[i]);
        printf("%s%s",s,r);
    }
    return 0;
}

Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  int n;
  cin >> n;

  int sum = 0;

  REP(i, n){
    if((i+1) % 3 != 0 && (i+1) % 5 != 0){
      sum += i + 1;
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[17];
vector<ll> s;
const ll INF = 1e18;


int main(){
    ll N, K; cin >> N >> K;
    for(ll i = 1; i <= N; i++){
        cin >> a[i];
    }
    s.assign(N, 0);
    for(ll i = 0; i < K; i++){
        s[i] = 1;
    }
    ll ans = INF;
    for(ll i = 1; i <= pow(2, N); i++){
        ll lastnum = a[1]-1;
        ll sum = 0;
        random_shuffle(s.begin(), s.end());
        /*for(ll j = 0; j < N; j++){
            cout << s[j] << " ";
        }
        cout << endl;*/
        for(ll j = 1; j <= N; j++){
            if(s[j-1] == 1){
                if(a[j] <= lastnum){
                    sum += lastnum - a[j] + 1;
                    lastnum += 1;
                }
                else lastnum = max(lastnum, a[j]);
            }
            else lastnum = max(lastnum, a[j]);
            //cout << lastnum << " " << sum << endl;
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

bool check(char a, char b) {
	return a > b;
}

int kuraiwa(int n) {
	int ans = 0;
	while (n > 0) {
		ans += n % 10;
		n /= 10;
	}
	return ans;
}

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

Measured memory_bytes: 256
//in the name of god
//if you read this code please search about imam hussain
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pb push_back
#define endl "\n"
#define X first
#define Y second
#define pii pair<int,int>
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout)

const int maxn=1e5+5;
const int mod=1e9+7;
const int inf=1e9;
const int del=728729;

ll poww(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));}
string s;
string t;
string st;
int main(){
	migmig;
	int n;
	cin>>n;
	cin >> s >>t;
	for(int i = 0 ; i < s.size();i++){
		st+=s[i];
		st+=t[i];
	}
	cout<<st;
	return 0;
}



Measured memory_bytes: 256
n = int(input())
l = sorted(list(map(int, input().split())))
ans = 0
now = l[0]
count = 1
if len(l) == 1:
  if now == 1:
    print(0)
  else:
    print(1)
else:
  for i in range(1, n):
    if l[i] == now:
      count += 1
    else:
      if count < now:
        ans += count
      elif count > now:
        ans += count-now
      
      now = l[i]
      count = 1
    
    if i == n-1:
      if count < now:
        ans += count
      elif count > now:
        ans += count-now

  print(ans)

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

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

    string S;
    cin >> S;

    char alpha[26];
    char c = 'A';
    for (int i = 0; i < 26; i++) {
        alpha[i] = c + i;
    }

    map<char, char> mp;
    int index;
    for (int i = 0; i < 26; i++) {
        index = i + N;
        if (index > 25) index = index - 26;
        mp[c + i] = alpha[index];
    }

    string ans = "";
    for (int i = 0; i < S.length(); i++) {
        ans += mp[S[i]];
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<pair<int,int>> coordinate(n);
  for(int i=0;i<n;i++){
    int x,y;
    cin>>x>>y;
    coordinate[i].first=x;
    coordinate[i].second=y;
  }
  sort(coordinate.begin(),coordinate.end());
  long double ans=0;
  long long cnt=1;
  for(int i=n;i>=1;i--)cnt*=i;
  do{
    for(int i=0;i<n-1;i++){
      long long a=coordinate[i+1].first-coordinate[i].first;
      long long b=coordinate[i+1].second-coordinate[i].second;
      ans+=sqrt(a*a+b*b);
    }
  }while(next_permutation(coordinate.begin(),coordinate.end()));
  cout<<fixed<<setprecision(10)<<ans/cnt<<endl;
  return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

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

void solve() {
    string sw = "SW";
    int n;
    string s;
    cin >> n >> s;
    REP(i,0,2) REP(j,0,2) {
        VI v(n);
        v[0] += i;
        v[1] += j;
        REP(k,2,n) {
            if (v[k-1] == 0) v[k] = s[k-1] == 'o' ? v[k-2] : 1 - v[k-2];
            else v[k] = s[k-1] == 'x' ? v[k-2] : 1 - v[k-2];
        }
        if (v[0] == 0) {
            if (s[0] == 'o') {
                if (v[1] != v[n-1]) continue;
            } else {
                if (v[1] == v[n-1]) continue;
            }
        } else {
            if (s[0] == 'x') {
                if (v[1] != v[n-1]) continue;
            } else {
                if (v[1] == v[n-1]) continue;
            }            
        }
        if (v[n-1] == 0) {
            if (s[n-1] == 'o') {
                if (v[0] != v[n-2]) continue;
            } else {
                if (v[0] == v[n-2]) continue;
            }
        } else {
            if (s[n-1] == 'x') {
                if (v[0] != v[n-2]) continue;
            } else {
                if (v[0] == v[n-2]) continue;
            }            
        }
        REP(i,0,n) cout << (v[i] == 0 ? 'S' : 'W');
        cout << endl;
        return;
    }
    cout << -1 << endl;
}

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

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

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

const int MAXN = 300;
ld dp[MAXN + 5][MAXN + 5][MAXN + 5];
int n;

ld get(int i, int j, int k) {
  if (dp[i][j][k] != -1) return dp[i][j][k];
  int total = i + j + k;
  if (total == 0) return 0;
  int z = n - total;
  ld evturns = (ld) n / (n - z);
  auto p1 = (ld) i / total;
  auto p2 = (ld) j / total;
  auto p3 = (ld) k / total;
  dp[i][j][k] = evturns;
  if (i)
    dp[i][j][k] += p1 * get(i - 1, j, k);
  if (j)
    dp[i][j][k] += p2 * get(i + 1, j - 1, k);
  if (k)
    dp[i][j][k] += p3 * get(i, j + 1, k - 1);
  return dp[i][j][k];
}

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

  cin >> n;
  vi a(4);
  rep(i, 0, n) {
    int v;
    cin >> v;
    a[v]++;
  }
  rep(i, 0, MAXN + 1) rep(j, 0, MAXN + 1) rep(k, 0, MAXN + 1)
    dp[i][j][k] = -1;
  cout << fixed << setprecision(11) << get(a[1], a[2], a[3]) << '\n';
}


Measured memory_bytes: 438656
#include <bits/stdc++.h>
#define pb push_back
#define sf(n) scanf("%lld", &n);
#define sff(n,m) scanf("%lld %lld", &n, &m)
#define pf(n) printf("%lld\n", n)
#define pff(n,m) printf("%lld %lld\n", n, m)
#define mem(a) memset(a, 0, sizeof(a))
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type))
#define pi 2*acos(0.0)
#define F first
#define S second
#define EPS 1e-9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    ll sum=a+b+c;
    if(sum>=22)
        cout<<"bust"<<endl;
    else
        cout<<"win"<<endl;
}


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

int n, k;
int a[100000];
int ra[100001];	//ra[i] = a[0] + ??? + a[i-1]

int main() {
	while (cin >> n >> k) {
		for(int ii = 0; ii < n; ii++) cin >> a[ii];
		if (!n) { break; }
		ra[0] = 0;
		for (int i = 0; i < n; i++) {
			ra[i+1] = ra[i] + a[i];
		}

		int ans = -1000000001;
		for (int i = k; i <= n; i++) {
			ans = max(ans, ra[i] - ra[i-k]);
		}

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

Measured memory_bytes: 1940
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)

	n := 0
	d := float64(0)

	count := 0
	x := float64(0)
	y := float64(0)

	fmt.Scanf("%d %f", &n, &d)

	for i := 0; i < n; i++ {
		fmt.Fscan(r, &x, &y)
		// x = rand.Float64() * 200000
		// y = rand.Float64() * 200000
		dist := math.Sqrt(math.Pow(x, 2) + math.Pow(y, 2))
		if dist <= float64(d) {

			count++
		}
	}

	fmt.Println(count)

}


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	char c; cin>>c;
	if     (c=='A') cout<<'T'<<endl;
	else if(c=='T') cout<<'A'<<endl;
	else if(c=='C') cout<<'G'<<endl;
	else            cout<<'C'<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
const int MOD = 1000000007;

int main() { 
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++)cin >> A[i];
    while (true) {
      ll cnt0 = 0;
      ll mini = INF;
      ll idx = -1;
      sort(A.begin(), A.end());
      for(int i = 0; i < N; i++){
        if (A[i] != 0) {
            mini = A[i];
            idx = i;
            break;
        }
        else cnt0++;
      }
      if (cnt0 == N-1) break;
      for (int i = cnt0; i < N; i++) {
        if (i == idx) continue;
        A[i] = A[i] % mini;
      }
    }

    cout << A[N-1] << endl;
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    bool flag = true;
    if (s[0] != 'A'){
        flag = false;
    }
    int sum = 0;
    for (int i = 2; i < s.size() - 1; i++){
        if (s[i] == 'C'){
            sum++;
        }
    }
    if (sum != 1){
        flag = false;
    }

    sum = 0;
    for (int i = 0; i < s.size(); i++){
        if (isupper(s[i])){
            sum++;
        }
    }
    if (sum > 2){
        flag = false;
    }
    
    if (flag){
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
A = [list(map(int, input().split())) for i in range(N)]

# N = 3
# A = [[1, 3], [2, 5], [1, 7]]

if N % 2 == 1:
    minA = sorted([row[0] for row in A])
    maxA = sorted([row[1] for row in A])
    medA = minA[int(N/2)]
    medB = maxA[int(N/2)]
    print(medB-medA+1)
else:
    minA = sorted([row[0] for row in A])
    maxA = sorted([row[1] for row in A])
    medA = (minA[int(N/2-1)]+minA[int(N/2)])/2
    medB = (maxA[int(N/2-1)]+maxA[int(N/2)])/2
    print(int((medB-medA)*2+1))

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005;
vector<int> S[MAX];
int state[MAX],N;
stack<int> st,st2;

void DFS2(int u){
    for(int i=0;i<N;i++){
        state[i]=0;
    }
    vector<int> T={u+1};
    state[u]=1;
    st.push(u);
    bool flag=true;
    while(flag){
        int a=st.top();
        st.pop();
        for(int i=0;i<S[a].size();i++){
            int b=S[a][i];
            if(!state[b]){
                state[b]=1;
                st.push(b);
                T.push_back(b+1);
                break;
            }
            if(i==S[a].size()-1) flag=false;
        }
    }
    
    vector<int> T2;
    st2.push(u);
    flag=true;
    while(flag){
        int a=st2.top();
        st2.pop();
        for(int i=0;i<S[a].size();i++){
            int b=S[a][i];
            if(!state[b]){
                state[b]=1;
                st2.push(b);
                T2.push_back(b+1);
                break;
            }
            if(i==S[a].size()-1) flag=false;
        }
    }
    
    
    cout<<T.size()+T2.size()<<endl;
    
    reverse(all(T));
    
    for(int i=0;i<T.size();i++){
        if(i) cout<<" ";
        cout<<T[i];
    }
    
    for(int i=0;i<T2.size();i++){
        cout<<" "<<T2[i];
    }
    
    cout<<endl;
    
}

int main(){
    
    int M;cin>>N>>M;
    
    for(int i=0;i<M;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        S[a].push_back(b);
        S[b].push_back(a);
    }
    
    for(int i=0;i<N;i++){
        if(S[i].size()>=2){
            DFS2(i);
            break;
        }
    }
    
    if(N==2) cout<<2<<endl<<1<<" "<<2<<endl;
    
}


Measured memory_bytes: 7160