akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	int a, b, c, d, e; cin >> a >> b >> c >> d >> e;
	cout << -min(0, a)*c + (a <= 0 && 0 <= b)*d + (max(0, b) - max(0, a))*e << endl;
	return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    int res = 0;
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        res = __gcd(res, a);
    }
    cout << res << endl;
}

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

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

	n %= 10;

	if (n == 3)
	{
		cout << "bon"s << endl;
	}
	else if ((n == 0) || (n == 1) || (n == 6) || (n == 8))
	{
		cout << "pon"s << endl;
	}
	else
	{
		cout << "hon"s << endl;
	}

	return 0;
}


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

char e[] = { 'A', 'C', 'T', 'G'};

int main() {

    char b;
    cin >> b;
    int retp;
    for(int i = 0; i < 4; i++) {
        if(e[i] == b) {
            retp = (i + 2) % 4;
        }
    }

    cout << e[retp] << endl;
}


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

using namespace std;

int N;
vector<long long int> A(3);
vector<long long int> l;
long long int inf=1e10;

long long int dfs(long long int a, long long int b, long long int c, int cur_ind) {
    if(cur_ind==N) {
        if(a==0 || b==0 || c==0) {
            return inf;
        }
        return abs(a-A[0])+abs(b-A[1])+abs(c-A[2])-30;
    }
    
    long long int nd = dfs(a, b, c, cur_ind+1);
    long long int ad = dfs(a+l[cur_ind], b, c, cur_ind+1)+10;
    long long int bd = dfs(a, b+l[cur_ind], c, cur_ind+1)+10;
    long long int cd = dfs(a, b, c+l[cur_ind], cur_ind+1)+10;
    
    return min(min(nd, ad), min(bd, cd));
}

int main() {
    cin >> N;
    l.resize(N);

    for(int ai=0; ai<3; ai++) {
        cin >> A[ai];
    }
    
    for(int li=0; li<N; li++) {
        cin >> l[li];
    }
    
    cout << dfs(0, 0, 0, 0) << endl;

    return 0;
    
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        System.out.println(problem157a(n));
    }

    private static int problem157a(int n) {
        return (n / 2) + (n % 2);
    }
}

Measured memory_bytes: 23892
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int nums[200009];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,L;
    cin>>N>>L;
    rep(i,N) cin>>nums[i];
    
    int idx=-1;
    rep(i,N-1){
        if(L<=nums[i]+nums[i+1]){
            idx=i;
            break;
        }
    }
    
    if(idx==-1){
        cout1("Impossible");
        return 0;
    }
    
    cout1("Possible")
    for(int i=0;i<idx;i++) cout1(i+1)
    for(int i=N-1;i>idx;i--) cout1(i)
    
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int n;
  cin >> n;
  vii a(n,vi(n));
  rep(i,n)rep(j,n) cin >> a[i][j];
  vii d = a;
  rep(k,n)rep(i,n)rep(j,n) chmin(d[i][j], d[i][k]+d[k][j]);
  ll ans = 0;
  rep(i,n) {
    rep(j,n) {
      if(d[i][j] < a[i][j]) { cout << -1 << endl; return 0; }
      bool ok = true;
      rep(k,n) {
        if(i == k || j == k) continue;
        if(d[i][j] == d[i][k] + d[k][j]) ok = false;
      }
      if(ok) ans += d[i][j];
    }
  }
  ans /= 2;
  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
public static int gcd(int a,int b){
	if(b==0){return a;}
	return gcd(b,a%b);
}
public static void main(String[] args) throws FileNotFoundException, IOException{
       Scanner s=new Scanner(System.in);
       BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
        int a=s.nextInt(),b=s.nextInt();
       long x=(long)a*b;
       x/=gcd(a,b);
       
        out.write(x+"\n");
        out.flush();
  }
}


Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
int main(){
  int f1,f2,f3,sub;
  cin >> f1 >> f2 >> f3;
  sub = f1 * 100 + f2 * 10 + f3;
  if(sub%4 == 0){
    cout << "YES";
  }else{
    cout << "NO";
  }
}

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

int main(){
	int N,M;
	int min,max;
	int i;
	int *L;int *R;
	scanf("%d %d",&N,&M);
	L=(int*)malloc(sizeof(int)*M);
	R=(int*)malloc(sizeof(int)*M);
	scanf("%d %d",&L[0],&R[0]);
	min=L[0],max=R[0];
	for(i=1;i<M;i++){
		scanf("%d %d",&L[i],&R[i]);
		if(L[i]>min)min=L[i];
		if(R[i]<max)max=R[i];
	}
	if(max<min){
		printf("0\n");
	}
	else if(max-min+1>=N){
		printf("%d\n",N);
	}
	else{
		printf("%d\n",max-min+1);
	}
	return 0;
}


Measured memory_bytes: 896
t = input()
while t:
    b = [map(int, raw_input().split()) for i in xrange(9)]
    for i in xrange(9):
        pnt = ""
        for j in xrange(9):
            error = False
            # tate
            for k in xrange(9):
                if k==i:
                    continue
                if b[k][j] == b[i][j]:
                    error = True
                    break
            # yoko
            for k in xrange(9):
                if k==j:
                    continue
                if b[i][k] == b[i][j]:
                    error = True
                    break
            # 3 kake 3
            ix = j//3*3; iy = i//3*3
            for y in xrange(iy, iy+3):
                if error:
                    break
                for x in xrange(ix, ix+3):
                    if x==j and y==i:
                        continue
                    if b[y][x] == b[i][j]:
                        error = True
                        break

            pnt += "*%d"%b[i][j] if error else " %d"%b[i][j]
        print pnt
    if t>1:
        print
    t -= 1

Measured memory_bytes: 4288
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
    }
    int ans = big;
    int left = 0;
    int sum;
    while(left+k-1<n){
        sum=0;
        //右側もa[]<0
        if(a[left+k-1]<0){
            sum = abs(a[left]);
        }
        //右側0以上
        else if(a[left]<0 && a[left+k-1]>=0){
        sum = 2*min(abs(a[left]),abs(a[left+k-1]))+max(abs(a[left]),abs(a[left+k-1]));
        }
        else{
            sum = a[left+k-1];
        }
        //cout<<"sum="<<sum<<endl;
        if(sum<=ans){
            ans = sum;
        }
        left++; 
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep (i, 3) {
    if (s[i] == t[i]) ans++;
  }
  P(ans);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
//#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
#include<set>
//#include<map>
//#include<list>

using namespace std;

class UnionFind {
public:
	vector<int>data;
	UnionFind(int size) :data(size, -1) {};
	bool unionset(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x]) {
				swap(x, y);
			}
			data[x] += data[y];
			data[y] = x;
		}
		return x != y;
	}
	bool findset(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int x, int y) {
	int tmp, r;
	if (x < y) {
		tmp = x;
		x = y;
		y = tmp;
	}
	r = x % y;
	while (r != 0) {
		x = y;
		y = r;
		r = x % y;
	}
	return y;
}

int main(void) {
	int D, N,res;
	cin >> D >> N;
	res = (int)pow(100,D);
	if (N == 100) {
		res = res * (N + 1);
	}
	else {
		res = res * N;
	}
	cout << res << endl;
}

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

using namespace std;

int main(void){
    string s;
    cin>>s;
    int mini=755;
    for(int i=0;i<s.size()-2;i++){
        int num;
        num=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
        num=abs(753-num);
        mini=min(mini,num);
    }
    cout<<mini<<endl;
    return 0;
}



Measured memory_bytes: 256
N, K = map(int, input().split())

c = [1, 1]
t = [c]
for i in range(N):
    c = [c[0] * 2 + 3, c[1] * 2 + 1]
    t.append(c)

def f(cur, n, k):
    u = t[n-1]
    m = u[0] + 2
    if k == t[n][0]:
        return cur + t[n][1]
    elif k == 1:
        return cur
    elif k == m:
        return cur + 1 + u[1]
    elif k > m:
        return f(cur + 1 + u[1], n - 1, k - u[0] - 2)
    elif m > k:
        return f(cur, n - 1, k - 1)
print(f(0, N, K))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7,N=1e5+5;
int mul(int a,int b){return (long long)a*b;}
typedef long long ll;
int n,x[N],y[N],d[N];
const double inf=1e20;
double getans(double mid)
{
    double mnx=inf,mxx=-inf,mny=inf,mxy=-inf;
    for(int i=1;i<=n;i++)
    {
        double xx=x[i],yy=y[i];
        if(d[i]==1) xx-=mid;
        if(d[i]==2) xx+=mid;
        if(d[i]==3) yy+=mid;
        if(d[i]==4) yy-=mid;
        mnx=min(mnx,xx);
        mxx=max(mxx,xx);
        mny=min(mny,yy);
        mxy=max(mxy,yy);
    }
    return (mxx-mnx)*(mxy-mny);
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        char s[5];
        scanf("%d%d%s",&x[i],&y[i],s);
        if(s[0]=='L') d[i]=1;
        else if(s[0]=='R') d[i]=2;
        else if(s[0]=='U') d[i]=3;
        else d[i]=4;
    }
    double l=0,r=1e10;
    for(int i=1;i<=1000;i++)
    {
        double len=(r-l)/3,mid=l+len,midmid=l+2*len;
        if(getans(mid)<getans(midmid)) r=midmid;
        else l=mid;
    }
    printf("%f\n",getans(l));
}


Measured memory_bytes: 1408
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long k = sc.nextLong();
    long a = sc.nextLong();
    long b = sc.nextLong();
    long cnt = 1;
    if(b-a<=2){
      System.out.println(cnt+k);
      return;
    }
    while(k>0&&cnt<a){
      k--;
      cnt++;
    }
    if(k%2==1){
      cnt++;
      k--;
    }
    if(k==0){
      System.out.println(cnt);
      return;
    }
    while(k>0){
      cnt += b-a;
      k-=2;
    }
    System.out.println(cnt);
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll MOD = 1e9+7;
const ll inf = (LLONG_MAX>>2);
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  cin >> n;
  cout << n*(n-1)/2;
  return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int fc[100001], in[100001];

int pwmd(int a, int n = mod - 2)
{
	if (!n)
		return 1;
	int pt = pwmd(a, n / 2);
	pt *= pt, pt %= mod;
	if (n & 1)
		pt *= a, pt %= mod;
	return pt;
}
int nCr(int n, int r)
{
     fc[0] = in[0] = 1;

	for (int i = 1; i <= 100000; ++i)
	{
		fc[i] = (i * fc[i - 1]) % mod;
		in[i] = pwmd(fc[i]);
	}

	int ans = fc[n];
	ans = (ans * in[r]) % mod;
	ans = (ans * in[n - r]) % mod;

	return ans;
}
double pow(double a,int b)
{
	double ans=1;
	while(b>0)
	{
		if(b&1)
			ans*=a;
		a*=a;
		b=b>>1;
	}
	return ans;
}
//vector<pair<int,int>> vec;
bool compare(pair<int,int> v1,pair<int,int> v2)
{
	return v1.ss<v2.ss;
}

vector<int> adj[200005];
int dis[200005];
void dfs1(int par, int u)
{
	for(int x:adj[u])
	{
		if(x==par)
			continue;
		dis[x]=dis[u]+1;
		dfs1(u,x);
	}
}

void dfs(int par, int u,bool *vis)
{
	vis[u]=true;
	for(int x:adj[u])
	{
		if(x==par)
			continue;
		dfs(u,x,vis);
		vis[x]=true;
	}
}

vector<int> vec[100001];
int32_t main()
{       
    FIO;
    int n,m;
    cin>>n>>m;
    int h[n+1];
    for(int i=1;i<=n;i++)
    	cin>>h[i];

    for(int i=0;i<m;i++)
    {
    	int a,b;
    	cin>>a>>b;
    	vec[a].push_back(b);
    	vec[b].push_back(a);
    }

    int ans=0;

    for(int i=1;i<=n;i++)
    {
    	int flag=0;
    	for(int j=0;j<vec[i].size();j++)
    	{
    		int x=vec[i][j];
    		if(h[i]<=h[x])
    			flag=1;
    	}
         
    	if(flag==0)
    		ans++;
    }

    cout<<ans<<endl;



}

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

int main()
{
  uint64_t n;
  cin >> n;
  int ans(0);
  bool nine(true);
  for (int i = 0; i < 16; i++) {
    if (n / 10 == 0) {
      ans += i == 0 ? n : nine ? n % 10 : n % 10 - 1;
      break;
    } else {
      if (nine && n % 10 != 9) nine = false;
      ans += 9;
      n /= 10;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int A,B,C,D;
  cin >> n;
  A =n/1000;
  n = n % 1000;
  B=n/100;
  n = n % 100;
  C =n/10;
  n = n % 10;
  D =n;
  vector<int> ope(3);
  vector<char> op(3);
  vector<int> v = {-1,1};
  for (size_t i = 0; i < 2; i++) {
    for (size_t j = 0; j < 2; j++) {
      for (size_t k = 0; k < 2; k++) {
        if (A+v.at(i)*B+v.at(j)*C+v.at(k)*D == 7) {
          ope[0] = v.at(i);
          ope[1] = v.at(j);
          ope[2] = v.at(k);
        }
      }
    }
  }
  for (size_t i = 0; i < 3; i++) {
    if (ope.at(i) == -1) {
      op[i] = '-';
    }
    else{
      op[i] = '+';
    }
  }
  cout <<A<< op[0] << B << op[1] << C << op[2] << D << '=' <<7<< endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        int i,a,b;
        int[] m,n;
        m = new int[100];
        n = new int[100];
        Scanner scan = new Scanner(System.in);
        for(i=0;i<100;i++){
            m[i] = scan.nextInt();
            n[i] = scan.nextInt();
            if(m[i]==0 && n[i]==0) break;
        }
        for(i=0;i<100;i++){
            if(m[i]==0 && n[i]==0) break;
            for(a=0;a<m[i];a++){
                for(b=0;b<n[i];b++){
                    System.out.print("#");
                }
                System.out.println("");
            }
            System.out.println("");
        }
        
    }
}


Measured memory_bytes: 37540
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 

int char_to_int(char c){
  switch(c){
    case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
  }
}



int main(){
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  
  vector<char> res(3);
  res.at(0) = toupper(s1.at(0));
  res.at(1) = toupper(s2.at(0));
  res.at(2) = toupper(s3.at(0));
  
  rep(i, 3) cout << res.at(i);
         
}

Measured memory_bytes: 256
from math import factorial
from itertools import permutations
 
N = int(input())
x, y = zip(*(map(int, input().split()) for _ in range(N))) if N else ((), ())
 
ans = sum(
    sum(((x[i] - x[j]) ** 2 + (y[i] - y[j]) ** 2) ** 0.5 for i, j in zip(p, p[1:]))
    for p in permutations(range(N))
) / factorial(N)
print(ans)

Measured memory_bytes: 43356
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
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; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    for (ll c = 1; c < n; ++c) {
        ll score = 0;
        set<ll> s; // 同じ座標踏めない
        rep(x, n) {
            if (x * c >= n || n - 1 - x * c < 0) break;
            // b = a - c > 0
            ll A = n - 1 - x * c;
            if (A <= c) break;
            score += a[x * c];
            if (s.find(x * c) != s.end()) break;
            s.insert(x * c);
            score += a[n - 1 - x * c];
            if (s.find(n - 1 - x * c) != s.end()) break;
            s.insert(n - 1 - x * c);
            chmax(ans, score);
        }
    }
    cout << ans << endl;
}


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

int main() {
    int s;
    cin >> s;
    vector<int> v;
    for (int i = 1; i * i <= s; ++i) {
        if (s % i == 0) {
            v.push_back(i);
            if (i != s / i)
                v.push_back(s / i);
        }
    }
    sort(v.begin(), v.end());
    vector<int> cnt(s + 1);
    for (int i : v) {
        int a = i * 2;
        for (int j = 1; j * j <= a; ++j)
            if (a % j == 0 && a / j % 2 != j % 2)
                ++cnt[i];
    }
    int ans = 0;
    for (int i : v) {
        if (i > s / i) break;
        ans += cnt[i] * cnt[s / i] * (i == s / i ? 1 : 2);
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3188
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = sc.nextInt();
		int S = X + Y + Z;
		int[] A = new int[S];
		int[] B = new int[S];
		int[][] lis = new int[S][2];
		long ADD = 0;
		for (int i = 0; i < S; ++i) {
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
			int C = sc.nextInt();
			ADD += C;
			A[i] -= C;
			B[i] -= C;
			lis[i] = new int[] { A[i] - B[i], i, A[i], B[i] };
		}
		Arrays.sort(lis, new Comparator<int[]>() {
			@Override
			public int compare(int[] o1, int[] o2) {
				return -Integer.compare(o1[0], o2[0]);
			}
		});
		for (int i = 0; i < S; ++i) {
			A[i] = lis[i][2];
			B[i] = lis[i][3];
		}
		long[] cum1 = new long[S];
		long[] cum2 = new long[S];
		Arrays.fill(cum1, -Long.MAX_VALUE / 10);
		Arrays.fill(cum2, -Long.MAX_VALUE / 10);
		PriorityQueue<Integer> pq = new PriorityQueue<>();
		long cur = 0;
		for (int i = 0; i < S; ++i) {
			pq.add(A[i]);
			cur += A[i];
			while (pq.size() > X) {
				cur -= pq.peek();
				pq.poll();
			}
			if (pq.size() == X) {
				cum1[i] = Math.max(cum1[i], cur);
			}
		}
		pq.clear();
		cur = 0;
		for (int i = S - 1; i >= 0; --i) {
			pq.add(B[i]);
			cur += B[i];
			while (pq.size() > Y) {
				cur -= pq.peek();
				pq.poll();
			}
			if (pq.size() == Y) {
				cum2[i] = Math.max(cum2[i], cur);
			}
		}
		long ans = -Long.MAX_VALUE / 10;
		for (int i = 0; i + 1 < S; ++i) {
			ans = Math.max(ans, cum1[i] + cum2[i + 1] + ADD);
		}
		System.out.println(ans);
	}

	class F implements Comparable<F> {
		int v;
		int id;

		public F(int v_, int id_) {
			v = v_;
			id = id_;
		}

		@Override
		public int compareTo(F o) {
			return Integer.compare(v, o.v);
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 102592
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c;
    char dust;
    cin >> a >> b >> dust >> c;
    ll ans = a * b;
    ans += a * c / 100;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const double PI = acos(-1.0);

void solve(long long N, std::vector<long long> A, long long Q,
           std::vector<long long> B, std::vector<long long> C) {
    map<long long, int> m;
    rep(i, N) m[A[i]]++;
    long long sum = accumulate(A.begin(), A.end(), 0LL);
    rep(i, Q) {
        sum += m[B[i]] * C[i] - m[B[i]] * B[i];
        m[C[i]] += m[B[i]];
        m[B[i]] = 0;
        cout << sum << endl;
    }
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    long long Q;
    scanf("%lld", &Q);
    std::vector<long long> B(Q);
    std::vector<long long> C(Q);
    for (int i = 0; i < Q; i++) {
        scanf("%lld", &B[i]);
        scanf("%lld", &C[i]);
    }
    solve(N, std::move(A), Q, std::move(B), std::move(C));
    return 0;
}


Measured memory_bytes: 11476
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    public static void process()throws IOException
    {
		int n=ni(),arr[][]=new int[n+1][4];
		long dp[][]=new long[n+1][4];
		for(int i=1;i<=n;i++) for(int j=1;j<=3;j++) arr[i][j]=ni();

		dp[1][1]=arr[1][1];dp[1][2]=arr[1][2];dp[1][3]=arr[1][3];

		for(int i=2;i<=n;i++){
			for(int j=1;j<=3;j++){//I want j to be the ele I choose here, so j can't be in prev case
				for(int k=1;k<=3;k++){

					if(j==k)
						continue;

					dp[i][j]=Math.max(dp[i][j], arr[i][j]+dp[i-1][k]);
				}
			}
		}

		//for(long row[] : dp)System.out.println(Arrays.toString(row));
		pn(Math.max(dp[n][1], Math.max(dp[n][2], dp[n][3])));
    }
 
 
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new FastReader();
 
        long s = System.currentTimeMillis();
        int t=1;
//        t=ni();
        while(t-->0)
            process();
 
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }
    
    
    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static int ni()throws IOException{return Integer.parseInt(sc.next());}
    static long nl()throws IOException{return Long.parseLong(sc.next());}
    static double nd()throws IOException{return Double.parseDouble(sc.next());}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    
    static long mod=(long)1e9+7l;
 
    static<T> void r_sort(T arr[],int n){
        Random r = new Random(); 
        for (int i = n-1; i > 0; i--){ 
            int j = r.nextInt(i+1); 
                  
            T temp = arr[i]; 
            arr[i] = arr[j]; 
            arr[j] = temp; 
        } 
        Arrays.sort(arr); 
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    vector<ll>ara(n+1);
    ara[0]=-1;
    ll sum=0;
    for(ll i=1;i<=n;i++)
    {
        cin>>ara[i];
        sum+=ara[i];
    }
    //sort(ara.begin(),ara.end());
    ll cnt=0;
    if(sum%(4*m)==0)
    {
        for(ll i=1;i<=n;i++)
        {
            if(ara[i]>=(sum/(4*m)))cnt++;
        }
    }
    else
    {
        for(ll i=1;i<=n;i++)
        {
            if(ara[i]>(sum/(4*m)))cnt++;
        }
    }
    if(cnt>=m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll dp[100010][2] = {};
vector<ll> tree[100010];

void dfs(ll cur, ll par){
    ll cnt = 0;
    ll val_all = 1, val_white = 1;
    for(auto &e: tree[cur]){
        if(e == par) continue;
        cnt++;
        dfs(e, cur);
        val_all *= (dp[e][0] + dp[e][1]) % MOD;
        val_all %= MOD;
        val_white *= dp[e][1];
        val_white %= MOD;
    }
    if(cnt == 0){
        dp[cur][0] = 1;
        dp[cur][1] = 1;
    }else{
        (dp[cur][0] += val_white) %= MOD;
        (dp[cur][1] += val_all) %= MOD;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll x[100010], y[100010];
    rep(i,0,N-1){
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
        tree[x[i]].push_back(y[i]);
        tree[y[i]].push_back(x[i]);
    }
    dfs(0, -1);
    ll ans = (dp[0][0] + dp[0][1]) % MOD;
    print(ans);

    

}

Measured memory_bytes: 15872
while True:
    n = int(input())
    if n == 0:
        break
    a = list(range(n + 1))
    a[:4] = [1, 1, 2, 4]
    for i in range(4, n + 1):
        a[i] = a[i-1] + a[i-2] + a[i-3]
    print((a[n] // 3650) + (a[n] % 3650 != 0))

Measured memory_bytes: 7692
// Why am I so dumb? :c
#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

const int MAXN = (int)1e5 + 5;

int L[MAXN], R[MAXN];

ll ans;

int n;

void solve() {
	scanf("%d", &n);

	for (int i = 1; i <= n; ++i) {
		scanf("%d %d", &L[i], &R[i]);
	}

	++n;

	sort(L + 1, L + n + 1);
	reverse(L + 1, L + n + 1);
	sort(R + 1, R + n + 1);

	for (int i = 1; i <= n; ++i) {
		if (L[i] > R[i]) {
			ans += (L[i] - R[i]);
		}
	}

	printf("%lld\n", ans * 2);	
}

int main() {
	int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <queue>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (n); ++i)
#define InitRep(i, begin, n) for (int i = (begin); i < (n); ++i)
#define RepItr(it, begin, end) for (auto it = (begin); it != (end); ++it)
using int64 = long long;
using vint = vector<int>;
using vint64 = vector<int64>;
const static double PI = ::acos(-1);


int main()
{
    int n;
    cin >> n;
    vector<vector<pair<int, int>>> edges(n - 1);
    vint edgeColor(n - 1, -1);
    vector<vector<pair<int, int>>> edgeNumberAndTo(n);
    vector<set<int>> used(n);

    Rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        edges[i].emplace_back(a, b);
        edgeNumberAndTo[a].emplace_back(i, b);
        edgeNumberAndTo[b].emplace_back(i, a);
    }

    int maxColors = 0;
    int maxEdgesVertex = -1;
    Rep(i, n)
    {
        if (edgeNumberAndTo[i].size() > maxColors)
        {
            maxColors = edgeNumberAndTo[i].size();
            maxEdgesVertex = i;
        }
    }
    cout << maxColors << endl;

    queue<int> que;
    que.push(maxEdgesVertex);
    while (!que.empty())
    {
        int from = que.front();
        que.pop();
        int col = -1;
        for (const auto edge : edgeNumberAndTo[from])
        {
            if (edgeColor[edge.first] >= 0) continue;
            int to = edge.second;
            while (true)
            {
                col = (col + 1) % maxColors;
                if (used[from].find(col) == used[from].end() && used[to].find(col) == used[to].end())
                {
                    edgeColor[edge.first] = col;
                    used[from].insert(col);
                    used[to].insert(col);
                    break;
                }
            }
            que.push(to);
        }
    }

    Rep(i, n - 1)
    {
        cout << (edgeColor[i] + 1) << endl;
    }

    return 0;
}


Measured memory_bytes: 26496
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string a,b;
    cin>>a>>b;
    if (a.size()>b.size()) {
        cout<<"GREATER"<<endl;
    } else if (a.size()<b.size()) {
        cout<<"LESS"<<endl;
    } else {
        int flag=0;
        for (int i=0;i<a.size();i++) {
            if (a.at(i)>b.at(i)) {
                cout<<"GREATER"<<endl;
                flag=1;
                break;
            } else if (a.at(i)<b.at(i)) {
                cout<<"LESS"<<endl;
                flag=1;
                break;
            }
        }
        if (flag==0) {
            cout<<"EQUAL"<<endl;
        }
    }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
import copy

sys.setrecursionlimit(1000000)

# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~

R, G, B, N = map(int, input().split())

ans = 0
for r in range(3001):
    for g in range(3001):
        ball = r * R + g * G
        d = N - ball
        if d >= 0 and d % B == 0:
            ans += 1
        # elif d < 0:
        #     break

print(ans)

Measured memory_bytes: 40812
import sys
input = sys.stdin.buffer.readline

MOD = 10 ** 9 + 7

N = int(input())
Cs = sorted(map(int, input().split()), reverse = True)

magic = [pow(2, N-1, MOD)]
for _ in range(N-1):
    magic.append( (magic[-1] + pow(2, N-2, MOD)) % MOD )

ans = 0
for C, m in zip(Cs, magic):
    ans += C * m
    ans %= MOD

ans *= pow(2, N, MOD)
ans %= MOD

print(ans)

Measured memory_bytes: 29184
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define INF INT_MAX
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int a,b,d[10001],n;
int main(){
   cin.tie(0);
   ios::sync_with_stdio(false);
   scanf("%d/%d/%d",&n,&a,&b);
   if(n>2019){
     cout<<"TBD"<<endl;
   }else if(n==2019 && a>=5){
     cout<<"TBD"<<endl;
   }else{
     cout<<"Heisei"<<endl;
   }

   return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    //グローバル変数を定義

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

    void run() {
        Scanner sc = new Scanner(System.in);
        char[] array = sc.next().toCharArray();
        String ans = "WA";

        if(array[0] == 'A'){
            int count = 0;
            for(int i=2; i<array.length-1; i++){
                if(array[i] == 'C'){
                    count++;
                }
            }

            if(count == 1){
                int upperCount = 0;
                for(int i=1; i<array.length; i++){
                    if(Character.isUpperCase(array[i])){
                        upperCount++;
                    }
                }

                if(upperCount == 1){
                    ans = "AC";
                }
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 25044
#d

        
#     import sys
#     input = sys.stdin.readline

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

friends_pair=[]
friend=[[] for _ in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    friends_pair.append((a,b))
    friend[a].append(b)
    friend[b].append(a) 
        
    
block=[]
for i in range(k):
    a,b = map(int,input().split())
    block.append((a-1,b-1))

from collections import deque
clusters=[]
visited=[0]*n
list_cluster=[0]*n
i_c=0

for i in range(n):
    if visited[i]==0:
        start=i
    else:
        continue

    cluster =[start]
    q=deque([(start,togo) for togo in friend[start]]) #スタート地点から行ける場所を列挙
    visited[start]=1
    list_cluster[start]=i_c
    for togo in friend[start]:
        visited[togo]=1
        cluster.append(togo)
        list_cluster[togo]=i_c
    while q:
        parent,x = q.popleft()
        for y in friend[x]:
#             if y == parent:#親ノードを飛ばし
#                 continue
            if visited[y]==0:
                q.append((x,y))#子ノードを追加
                visited[y]=1
                cluster.append(y)
                list_cluster[y]=i_c
#        print(parent,x,q)
    clusters.append(cluster)
    i_c+=1

ans = [len(clusters[list_cluster[i]])-1 for i in range(n)  ]
for f0,f1 in friends_pair:
    if list_cluster[f0] ==  list_cluster[f1]:
        ans[f0]-=1
        ans[f1]-=1
for b0,b1 in block:
    if list_cluster[b0] ==  list_cluster[b1]:
        ans[b0]-=1
        ans[b1]-=1
print(*ans)


Measured memory_bytes: 103328
n,a,b = map(int, input().split())
if a+b > n+1 or a*b < n:
    print(-1)
    exit()

l = []
used = 0
for i in range(a):
    tmp = []
    for j in range(b):
        tmp.append(used+1)
        used += 1
        if n-used == a-i-1:
            break
    l.extend(tmp[::-1])
print(*l)

Measured memory_bytes: 67108
str = gets.split
N,K = str[0].to_i, str[1].to_i
str = gets.split
R,S,P = str[0].to_i, str[1].to_i, str[2].to_i
T = gets.chomp
x = Array.new(N,0)
answer = 0
for i in 0...N do
    if i < K
        if T[i] == "s"
            answer += R
        elsif T[i] == "p"
            answer += S
        else
            answer += P
        end
    else
        if T[i] != T[i-K]
            if T[i] == "s"
                answer += R
            elsif T[i] == "p"
                answer += S
            else
                answer += P
            end
        elsif x[i-K] == 1
            if T[i] == "s"
                answer += R
            elsif T[i] == "p"
                answer += S
            else
                answer += P
            end
        else
            x[i] = 1
        end
    end
end
puts answer

Measured memory_bytes: 2812
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long N = sc.nextLong();
        long min = 100;

        for (long i=1; i<(long) Math.sqrt(N)+1; i++) {
            if (N % i != 0) { 
                continue;
            }
            long m = i > (N / i) ? i : (N / i);
            long a = (long) Math.log10(m) + 1;
            min = min < a ? min : a;
        }

        System.out.println(min);
    }
}



Measured memory_bytes: 21972
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define mp make_pair
ll mod = 10e9+7;
ll mod2 = 998244353;

int main(){
    ld n,k;cin>>n>>k;
    ld ans = 0;
    rep(i,1,n+1){
        ld x = i;
        ld num = 1/n;
        while(x<k){
            num*=0.5;
            x*=2;
        }
        ans+=num;
    }
    cout<<fixed<<setprecision(15)<<ans<<endl;
}

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

//============================================================================
#define PI 3.14159265359
#define succ(x) ((x)+1)
#define pred(x) ((x)-1)
//============================================================================
enum {stS, stH, stC, stD, stEND};
char Suit[]="SHCD";
void enter(FILE *file)
{
    int n,i,j,k; unsigned short card[stEND]; char suit[2];

    memset(card, 0, sizeof(card));
    fscanf(file, "%d", &n);
    for (i=0; i<n; i++){
        fscanf(file, "%s", suit);
        fscanf(file, "%d", &j);
        k=1<<pred(j);
        switch(*suit){
            case 'S': card[stS]|=k; break;
            case 'H': card[stH]|=k; break;
            case 'C': card[stC]|=k; break;
            case 'D': card[stD]|=k; break;
        }
    }
    for (i=0; i<stEND; i++)
    for (j=0, k=1; j<13; j++, k<<=1)
        if (!(card[i] & k))
            printf("%c %d\n", Suit[i], succ(j));
}
//============================================================================
#ifndef DESKTOP
int main(void)
{
    enter(stdin);
    return 0;
}
//============================================================================
#else
int main(void)
{
    FILE *file;

    file=fopen("inlost.txt", "r");
    enter(file);
    fclose(file);
    return 0;
}
#endif
//============================================================================

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#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 (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int par1[300001];
int rank1[300001];
//n要素で初期化
void init(int n){
   for(int i=0;i<n;i++){
       par1[i]=i;
       rank1[i]=0;
   }
}
//木の根を求める
int find(int x){
    if(par1[x] ==x){
         return x;
    }else{
         return par1[x]=find(par1[x]);
    }
}
//xとyの属する集合を併合
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y) return;

    if(rank1[x]<rank1[y]){
         par1[x]=y;
    }else{
         par1[y]=x;
         rank1[x]++;
    }
}
//xとyが同じ集合に属するか否か
bool same(int x,int y){
     return find(x)==find(y);
}

int N,M;
int main(){
        cin>>N>>M;
        init(300001);
        /*REP(i,N){
            cout<<par1[M+i]<<endl;
        }*/
        REP(i,N){
            int num;
            cin>>num;
            REP(j,num){
                int k;
                cin>>k;
                //cout<<k-1<<"a"<<i+M<<endl;
                unite(k-1,i+M);
            }
        }
        bool check=true;
        REP(i,N){
           if(!same(M,M+i)){
              check=false;
              break;
           }
        }
        /*REP(i,N){
            cout<<find(M+i)<<endl;
        }*/
        if(check==true){
           cout<<"YES"<<endl;
        }else{
           cout<<"NO"<<endl;
        }
	return 0;
}

Measured memory_bytes: 2688
import heapq


n, m, s = map(int, input().split())
if s >= 2500:
    s = 2499

edges = [[] for _ in range(n)]
for _ in range(m):
    from_, to, cost, time = map(int, input().split())
    edges[from_-1].append((to-1, cost, time))
    edges[to-1].append((from_-1, cost, time))

banks = []
for i in range(n):
    coin, time = map(int, input().split())
    banks.append((coin, time))

INF = float('INF')
DP = [[INF] * 2500 for _ in range(n)]
ans = [INF] * n


def push_todo(node, coin, time):
    if coin < 0:
        return
    if time >= DP[node][coin]:
        return
    heapq.heappush(todo, (time, node, coin))


def charge(node, current_coin, current_time):
    coin, time = banks[node]
    new_coin = current_coin + coin
    if new_coin >= 2500:
        new_coin = 2499
    push_todo(node, new_coin, current_time+time)


todo = [(0, 0, s)]
while todo:
    current_time, node, current_coin = heapq.heappop(todo)
    if current_time >= DP[node][current_coin]:
        continue

    if current_time < ans[node]:
        ans[node] = current_time

    DP[node][current_coin] = current_time
    charge(node, current_coin, current_time)

    for to, cost, time in edges[node]:
        push_todo(to, current_coin-cost, current_time+time)

for a in ans[1:]:
    print(a)

Measured memory_bytes: 35828
#include <bits/stdc++.h>
#include <boost/format.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/optional.hpp>

#ifdef DEBUG
#include "libs/debug.cpp"
#define DEBUG 1
#else
#define DEBUG 0
#endif

#define rep(i, n) repr((i), 0, (n))
#define repr(i, a, t) reps((i), (a), (t), 1)
#define reps(i, a, t, s) for (long long (i) = (a); (i) < (long long)(t); (i) += (s))
#define rrep(i, n) rrepr((i), (n) - 1, 0)
#define rrepr(i, a, t) rreps((i), (a), (t), 1)
#define rreps(i, a, t, s) for (long long (i) = (a); (i) >= (long long)(t); (i) -= (s))
#define each(v, c) for (auto &&(v) : (c))
#define all(c) (c).begin(), (c).end()

using namespace std;
namespace mp = boost::multiprecision;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ml = mp::cpp_int;
template<typename T>
using optional = boost::optional<T>;
const auto none = boost::none;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;

int main() {
  cout << fixed << setprecision(10);
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ifstream ifs;
  if (DEBUG) {
    ifs.open("src/_in.txt");
    cin.rdbuf(ifs.rdbuf());
  }

  ll N, P;
  cin >> N >> P;
  vector<ll> A;
  rep (i, N) {
    ll v0;
    cin >> v0;
    A.push_back(v0);
  }

  ml ans = (A[0] % 2 == P) + (0 == P);
  repr (i, 1, N) {
    if (A[i] % 2 == 0) {
      ans *= 2;
    } else {
      ans = pow((ml) 2, i);
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 384
import System.IO
import Control.Applicative

main = do
  -- "L M N" ---> [L,M,N]
  n <- fmap (read :: String -> Int) . words <$> getLine
  -- ns <- fmap (fmap (read :: String -> Int) . words) . lines <$> getContents
  print $ digit $ foldl (+) 0 n
  eof <- isEOF
  if eof
    then return ()
    else do main

digit :: Int -> Int
digit n = length $ show n

Measured memory_bytes: 4084
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  for(in z=1;z<=n;++z){
    if(z*(z+1)/2>=n){
      for(in i=z;i>=1;--i){
	if(i<=n){
	  cout<<i<<"\n";
	  n-=i;
	}
      }
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256