akhauriyash/Code-Regression huggingface dataset:
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;
#define SORTVL(v) sort(v.begin(), v.end());
#define SORTVL_GR(v) sort(v.begin(), v.end(), greater<LL>());

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a % b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }
// 桁和
LL Ketawa_s(string s) { LL a = 0; FOR(i, 0, s.length())a += s[i] - '0'; return a; }
// 末尾数字で切り上げ
LL CeilLastNumber(LL n) { return ((n + (10 - 1)) / 10) * 10; }
//二項係数 nCk mod pを求める
const LL MAX = 510000, p = 998244353; LL fac[MAX], finv[MAX], inv[MAX];
/* 前処理 */void COM_init() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; FOR(i, 2, MAX) { fac[i] = fac[i - 1] * i % p; inv[i] = p - inv[p % i] * (p / i) % p; finv[i] = finv[i - 1] * inv[i] % p; } }
/* 主処理 */LL COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % p) % p; }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

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

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL N, M;
	cin >> N >> M;

	if (N == M) {
		O("Yes");
	}
	else {
		O("No");
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
  int n; cin >> n;
  vector<ll> a(n+1);

  a[0] = a[1] = 1;

  for (int i = 2; i <= n; i++) a[i] = a[i-1] + a[i-2];

  cout << a[n] << endl;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    char s;cin >> s;
    s += 1;

    cout << s <<"\n";

    return 0;
}

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

const std::int64_t INF = 1e18;

int main() {
    std::int32_t N; std::cin >> N;
    std::vector<std::int64_t> A(N + 1), B(N + 1);
    for (std::int32_t i = 0; i <= N; ++i) {
        std::cin >> A[i];
    }
    // if (N == 0) {
    //     if (A[0] == 1) std::cout << 1 << std::endl;
    //     else std::cout << -1 << std::endl;
    //     return 0;
    // }
    // if(A[0] != 0) {
    //     std::cout << -1 << std::endl;
    //     return 0;
    // }
    B[N] = A[N];
    for (std::int32_t i = N - 1; i >= 0; --i) {
        B[i] = B[i + 1] + A[i];
    }
    B[0] = 1;
    for (std::int32_t i = 1; i <= N; ++i) {
        B[i] = std::min(B[i], 2 * (B[i - 1] - A[i - 1]));
    }
    std::int64_t ans = 0;
    for (std::int32_t i = 0; i <= N; ++i) {
        if (B[i] < A[i]) {
            std::cout << -1 << std::endl;
            return 0;
        }
        ans += B[i];
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 4844
def pos(x, n, m):
    if n == 0:
        return 1
    res = pos(x*x%m, n//2, m)
    if n%2 == 1:
        res = res*x%m
    return res

N=int(input().strip())
A = list(map(int, input().strip().split()))

MOD=10**9+7

ans=0
for i in range(60):
    count1=0
    count0=0
    for j in range(N):
        if A[j]>>i & 1:
            count1+=1
        else:
            count0+=1
    ans+=count0*count1%MOD*pos(2,i,MOD)
    ans%=MOD
print(ans)

Measured memory_bytes: 122808
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=1e6+7;
ll dp[maxn];
ll pre[maxn];
int main()
{
	int n;
    cin>>n;
    dp[1]=n;
    pre[1]=n;
    for(int i=2;i<=n;i++)
    {
        dp[i]=(dp[i-1]+1LL*(n-1)*(n-1)%mod)%mod;
        if(i>=3) dp[i]=(dp[i]+pre[i-3])%mod;
        if(i==2) dp[i]=(dp[i]+n-1)%mod;
        else dp[i]=(dp[i]+n-i+2);
        pre[i]=(pre[i-1]+dp[i])%mod;
        //dbg(i,dp[i]);
    }
    cout<<dp[n]<<'\n';
}

Measured memory_bytes: 15872
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

ll factrial(ll n){
    if(n == 0) return 1;
    ll p = factrial(n-1)*n%MOD;
    return p;
}

//MOD逆元
ll farmat(ll n,ll p){    
    if(p == 0) return 1;
    else if(p == 1) return n%MOD;
    ll d = farmat(n,p/2);
    if(p%2 == 0){
        return (d*d)%MOD;
    }else{
        return ((n*d)%MOD*d)%MOD;
    }
}

ll conbination(ll n,ll k){
    ll a = factrial(n);
    ll b = factrial(k);
    ll c = factrial(n-k);
    return (a*farmat(b,MOD-2)%MOD*farmat(c,MOD-2))%MOD;
}

int memo[10000000];

int fib(int i){
    if(i <= 1) return i;
    if(memo[i] != 0) return memo[i];
    return memo[i] = fib(i-1)+fib(i-2);
}

ll dig(ll n){
    ll d = 0;
    while(n != 0){
        n/=10;
        d++;
    }
    return d;
}

void solve() {
    //差分の最大公約数
    ll n,x;
    cin >> n >> x;
    
    ll xp[n+1];
    for(ll i = 0;i < n;i++){
        cin >> xp[i];
    }
    xp[n] = x;
    sort(xp,xp+n);

    ll sub[n];
    for(int i = 0;i < n;i++){
        sub[i] = xp[i+1] - xp[i];
    }
    ll ans;
    if(n != 1)  ans = gcd(sub[0],sub[1]);
    else ans = sub[0];
    for(int i = 2;i < n;i++){
        ans = gcd(ans,sub[i]);
    }
    cout << abs(ans) << endl;
}


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}



Measured memory_bytes: 1792
using System;
using System.Linq;

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            int cnt = 0;
            for (int i = 0; i < n; i+=2)
            {
                if (a[i]%2 == 1)
                {
                    cnt++;
                }
            }
            Console.WriteLine(cnt);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28244
# 2019/05/12
# diverta 2019 Programming Contest - B

# Input
r, g, b, n = map(int, input().split())

# Init
cnt = 0

# Calc
for i in range(n+1):
    rcnt = r * i
    if rcnt > n:
        break
    
    for j in range(n+1):
        rgcnt = rcnt + g * j
        if rgcnt > n:
            break
        bcnt = n - rgcnt
        if bcnt % b == 0:
            cnt += 1
# Output
print(cnt)


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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N,M;
const int INF = 1e9;

int main()
{
	scanf("%d%d",&N,&M);

	int ans = M * 1900 + (N - M) * 100;
	FOR(i,0,M) ans *= 2;
	printf("%d\n",ans);
	
	return 0;
}


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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int Left = A + B;
    int Right = C + D;
    if (Left > Right) cout << "Left";
    else if (Left == Right) cout << "Balanced";
    else cout << "Right";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _for(i,a,b) for(int i=(a);i<=(b);++i)
#define _rep(i,a,b) for(int i=(a);i>=(b);--i)

using namespace std;
typedef long long ll;

const int maxn=(1<<21)+3;
const double pi=acos(-1);

int _n;
int r[maxn<<1];
ll cnt[maxn];
struct cp{
	double x,y;
	cp(double _x=0.,double _y=0.):x(_x),y(_y){}
	cp operator+(const cp&R)const{return cp(x+R.x,y+R.y);}
	cp operator-(const cp&R)const{return cp(x-R.x,y-R.y);}
	cp operator*(const cp&R)const{return cp(x*R.x-y*R.y,y*R.x+x*R.y);}
}b[maxn<<1],c[maxn<<1];

void FFT(cp*f,int op){
	_for(i,0,_n-1)if(i<r[i])swap(f[i],f[r[i]]);
	for(int i=2;i<=_n;i<<=1){
		int len=i>>1;
		cp tmp(cos(pi/len),op*sin(pi/len));
		for(int j=0;j<_n;j+=i){
			cp t(1,0);
			_for(k,j,j+len-1){
				cp tt=t*f[len+k];
				f[len+k]=f[k]-tt,f[k]=f[k]+tt;
				t=t*tmp;
			}
		}
	}
	if(op==-1)_for(i,0,_n-1)f[i].x/=_n;
}

int main(){
//	freopen("in","r",stdin);
	ios::sync_with_stdio(0),cin.tie(0);
	int n,sum=0,_m;cin>>n;
	const int P=(n-1)*(n<<1|1);
	_for(i,0,n-1){
		_for(j,0,n-1){
			int x;cin>>x;
			sum+=x;
			cnt[0]+=(x)*(x-1)>>1;
			int id=i*(n<<1)+j;
			b[P-id].x=x;
			c[id].x=x;
		}
	}
	
	for(_m=P<<1,_n=1;_n<=_m;_n<<=1);
	_for(i,0,_n-1)r[i]=r[i>>1]>>1|(i&1?_n>>1:0);
	FFT(b,1),FFT(c,1);
	_for(i,0,_n-1)b[i]=b[i]*c[i];
	FFT(b,-1);
	
	double ans=0.;
	_for(i,1,P){
		ll t=(ll)(b[P+i].x+.5);
		if(!t)continue;
		int x=(i/n+1)>>1,y=abs(i-(x*n<<1));
		ans+=sqrt((double)x*x+(double)y*y)*t;
		cnt[x*x+y*y]+=t;
	}
	ans/=(double)sum*(sum-1)/2;
	cout<<fixed<<setprecision(10)<<ans<<'\n';
	
	const int lim=(n-1)*(n-1)<<1;
	int tot=0;
	_for(i,0,lim)if(cnt[i]){
		if(++tot>10000)break;
		cout<<i<<' '<<cnt[i]<<'\n';
	}
return 0; }


Measured memory_bytes: 166980
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;


int main(void){
  int h,w,i,j;
  bool ipos;
  string a[10];
  
  cin >> h >> w;
  for (i=0;i<h;i++) cin >> a[i];
  
  i=j=0;
  while (1){
    ipos=false;
    ipos|=(i>0 && j>0 && a[i-1][j]==a[i][j-1]);
    ipos|=(i<h-1 && j<w-1 && a[i+1][j]==a[i][j+1]);
    ipos|=(i==h-1 && a[i][j+1]=='.');
    ipos|=(j==w-1 && a[i+1][j]=='.');
    if (ipos){
      cout << "Impossible" << endl;
      return 0;
    }
    if (i==h-1 && j==w-1) break;
    if (i<h-1 && a[i+1][j]=='#') i++;
    else j++;
  }
  
  cout << "Possible" << endl;
  
  return 0;
}

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

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

  if (N == 500) { 
    cout << "Yes" << endl;
  } else if ( N < 500 ) {
    if ( A >= N ) {
      cout << "Yes" << endl;
    } else {
       cout << "No" << endl;
    }
  } else {
       int S = N%500;
       if ( A >= S ) {
      cout << "Yes" << endl;
      } else {
      cout << "No" << endl;
      }
  }
}


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

map<int, int> pf(int n) {
  map<int, int> ma;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) ma[i]++, n /= i;
  }
  if (n != 1) ma[n]++;
  return ma;
}

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  vector<int> cnt(1e6+1);
  for (auto a : A) {
    for (auto [b, c] : pf(a)) {
      if (cnt.at(b)) goto NG;
      cnt.at(b)++;
    }
  }
  return cout << "pairwise coprime" << "\n", 0;
  NG:;
  int G = 0;
  for (int i = 0; i < N; i++) G = gcd(G, A.at(i));
  if (G == 1) cout << "setwise coprime" << "\n";
  else cout << "not coprime" << "\n";
}


Measured memory_bytes: 11052
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

class DisjointSet{
public:
  int N;
  vector<int> rank,p;
  vector<int> sz;
 
  DisjointSet(){}
  DisjointSet(int n):N(n),rank(n),p(n),sz(n){
    for(int i=0;i<N;i++) makeSet(i);
  }
 
  void makeSet(int x){
    p[x]=x;
    rank[x]=0;
    sz[x]=1;
  }
 
  bool same(int x,int y){
    return leader(x)==leader(y);
  }
 
  void unite(int x,int y){
    if(same(x,y)) return;
    link(leader(x),leader(y));
  }
 
  void link(int x,int y){
    if(rank[x]>rank[y]){
      p[y]=x;
      sz[x]+=sz[y];
    }else{
      p[x]=y;
      sz[y]+=sz[x];
      if(rank[x]==rank[y]){
        ++rank[y];
      }
    }
  }
 
  int leader(int x){
    if(x!=p[x]) p[x]=leader(p[x]);
    return p[x];
  }
 
  int size(int x){
    return sz[leader(x)];
  }
};

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

  int N,M;
  cin>>N>>M;

  DisjointSet us(N);
  rep(i,M){
    int a,b;
    cin>>a>>b;
    a--;b--;
    us.unite(a,b);
  }

  int ans=0;
  rep(i,N) if(us.leader(i)==i) ans++;
  cout<<ans-1<<endl;

  return 0;
}


Measured memory_bytes: 4516
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//　敵の体力
		long h = sc.nextLong();
      
      	for(int i=0;h>=Math.pow(2,i);i++){
          if(h<Math.pow(2,i+1)){
		    System.out.println((long)Math.pow(2,i+1)-1);
          }
		}
     }
}


Measured memory_bytes: 22868
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>

using namespace std;
void sayYes() { cout << "Yes" << endl; };
void sayNo() { cout << "No" << endl; };
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int digitSum(int n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

void Main()
{
    // int n;
    // cin >> n;
    // vector<int> a(n);
    // rep(i, n)
    // {
    //     cin >> a[i];
    // }

    int l;
    cin >> l;
    cout << pow(l / 3.0, 3.0) << endl;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 384
def to_i(e):
  return int(e)

n = int(raw_input().rstrip())

for i in range(n):
  a = sorted(map(to_i, raw_input().rstrip().split(" ")))
  if a[0]*a[0]+a[1]*a[1] == a[2]*a[2]:
    print "YES"
  else:
    print "NO"

Measured memory_bytes: 6348
import Control.Monad

main = do
  n <- readLn :: IO Int
  f <- (replicateM n getLine) >>= return . map ((map read) . words) :: IO [[Int]]
  p <- (replicateM n getLine) >>= return . map ((map read) . words) :: IO [[Int]]

  let
--    func :: [Int] -> Int
    func xs = sum [p!!(i-1)!!(c!!(i-1)) | i<-[1..n]]
      where
        c = [sum [(xs!!t) * (f!!(i-1)!!t) | j<-[1..5], k<-[1,2], let t = 2*j-3+k] | i<-[1..n]]

  print $ maximum $ map func (tail (patt 10))

  where
    patt :: Int -> [[Int]]
    patt 0 = [[]]
    patt n = concat [map (i:) (patt (n-1)) | i<-[0,1]]


Measured memory_bytes: 1916
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#define inf 1e9+7
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl;
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

typedef pair<ll,ll> Pair;
typedef set<ll> Set;

typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
typedef pair<ll,ll> Pair;

int main(){
    ll x,y,a,b,c;
    cin >> x >> y >> a >> b >>c;
    vector<Pair> ap;
    rep(i,a){
        ll p;
        cin >> p;
        ap.pb(make(p,1));
    }
    rep(i,b){
        ll p;
        cin >> p;
        ap.pb(make(p,2));
    }
    rep(i,c){
        ll p;
        cin >> p;
        ap.pb(make(p,0));
    }
    sort(ap.begin(),ap.end(),greater<Pair>());
    ll red=0;
    ll blue=0;
    ll count=0;
    ll ans=0;
    for(ll i=0;count<x+y;i++){
        if(red>=x && ap[i].second==1) continue;
        else if(blue>=y && ap[i].second==2) continue;
        else{
            ans+=ap[i].first;
            if(ap[i].second==1) red++;
            if(ap[i].second==2) blue++;
            count++;
        }
    }
    kaku(ans);
}



Measured memory_bytes: 10476
#[allow(unused_imports)]
use std::io::{self, BufRead};
#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(dead_code)]
fn readln_to_vec<T>(buf: &mut BufRead) -> Vec<T> 
where T: std::str::FromStr,
      <T as std::str::FromStr>::Err: std::fmt::Debug
{
    let mut s = String::new();
    buf.read_line(&mut s).unwrap();
    s.split(" ")
        .map(|x| x.trim())
        .filter(|x| !x.is_empty())
        .filter_map(|x| x.parse().ok())
        .collect()
}

#[allow(dead_code)]
fn readln_to<T>(buf: &mut BufRead) -> T
where T: std::str::FromStr + std::clone::Clone,
      <T as std::str::FromStr>::Err: std::fmt::Debug
{
    readln_to_vec::<T>(buf)[0].clone()
}

#[allow(unused_macros)]
macro_rules! readln_to_tuple {
    (
        $bufRead: expr, ( $( $t: ty ),* )
    ) => (
        {
            let buf: &mut BufRead = $bufRead;
            let ln = readln_to_vec::<String>(buf);
            let mut i = ln.into_iter();
            ( $( i.next().unwrap().parse::<$t>().unwrap() ),* )
        }
        )
}


fn main() {
    let stdin = io::stdin();
    let mut stdin = stdin.lock();
    let stdin = &mut stdin;

    let (n, y) = readln_to_tuple!(stdin, (i64, i64));
    for i in 0..min(y/10000, n)+1 {
        let y = y - 10000 * i;
        let n = n - i;
        for j in 0..min(y/5000, n)+1 {
            let y = y - 5000 * j;
            let n = n - j;
            if y == n * 1000 {
                println!("{} {} {}", i, j, n);
                return;
            }
        }
    }
    println!("-1 -1 -1");
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

const int maxn = 2e5+5;

int n;

int arr[maxn];

ll sum[maxn];
ll qs[maxn];

int main()
{
	scanf("%d", &n);
	ll best = 0;
	for(int i = 1; i<= n; i++)
	{
		char tmp = '+';
		if(i != 1) scanf(" %c", &tmp);
		int x; scanf("%d", &x);
		if(tmp == '-') x = -x;
		arr[i] = x;
		best += arr[i];
	}
	sum[n] = abs(arr[n]);
	for(int i = n-1; i>= 1; i--)
	{
		sum[i] = sum[i+1]+abs(arr[i]);
	}
	for(int i = 1; i<= n; i++)
	{
		qs[i] = qs[i-1]+arr[i];
	}
	vector<int> neg;
	for(int i = 1; i<= n; i++) if(arr[i]< 0) neg.pb(i);
	for(int i = 0; i+1< (int) neg.size(); i++)
	{
		ll loc = 0;
		loc += arr[neg[i]];
		for(int j = neg[i]+1; j< neg[i+1]; j++)
		{
			loc -= arr[j];
		}
		// printf("[%d, %d) loc = %d\n", neg[i], neg[i+1], loc);
		best = max(best, qs[neg[i]-1]+loc+sum[neg[i+1]]);
	}
	printf("%lld\n", best);
}

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

int main() {
  vector<int> num(3);

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

  sort(num.begin(),num.end());


  for (int i = 0; i < 3;i++){
    if (i == 2){
      cout << num[i] << endl;
    } else {
     cout << num[i] << " ";
    }
  }

}



Measured memory_bytes: 3160
import Data.List

f s n = 
    let s1 = take n s
        s2 = drop n s
        r1 = reverse s1
        r2 = reverse s2
    in
        [s1++s2, s1++r2, r1++s2, r1++r2, s2++s1, s2++r1, r2++s1, r2++r1]


ans s =
    let l = length s
        p = nub $ sort $ concat $ map (f s) [1..(l-1)]
    in
        length p


main = do
    _ <- getLine
    c <- getContents
    let i = lines c
        o = map ans i
    mapM_ print o



Measured memory_bytes: 6468
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    int n,m,i,j,x,y;
    queue<int> q;
    vector< vector <int> > graph;
    vector<int> dist,lol;
    cin>>n>>m;
    graph.resize(n+1);
    for(i=1;i<=m;i++)
    {
        int x,y;
        cin>>x>>y;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    dist.resize(n+1,-1);
    dist[1] = 0;
    q.push(1);
    while(!q.empty())
    {
        int x = q.front();
        q.pop();
        for(auto v : graph[x])
        {
            if(dist[v] != -1)
                continue;
            dist[v] = x;
            q.push(v);
        }
    }
    lol = dist;
    sort(lol.begin(),lol.end());
    if(lol[1] == -1)
        cout<<"No"<<endl;
    else
    {
        cout<<"Yes"<<endl;
        for(i=2;i<=n;i++)
        {
            cout<<dist[i]<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 10744
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <map>
using namespace std;
#define ms(a, x) memset(a, x, sizeof(a))
#define fore(i, a, n) for (long long i = a; i < n; i++)
#define ford(i, a, n) for (long long i = n - 1; i >= a; i--)
#define si(a) scanf("%d", &a)
#define sl(a) scanf("%lld", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define debug(a) cout << a << endl
#define pr(a) printf("%d ", a)
#define endl '\n'
#define pi acos(-1.0)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define ull unsigned long long
#define py puts("Yes")
#define pn puts("No")
#define pY puts("YES")
#define pN puts("NO")
#define re(i, a, b) for (int i = a; i <= b; ++i)
#define de(i, a, b) for (int i = b; i >= a; i--)
const double eps = 1e-8;
inline int sgn(const double &x) { return x < -eps ? -1 : x > eps; }
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int MAXN = 2e6 + 5;
template <class T>
inline void cmin(T &a, T b) { ((a > b) && (a = b)); }
template <class T>
inline void cmax(T &a, T b) { ((a < b) && (a = b)); }
ll a[MAXN];
vector<ll> v;
void solve()
{
  ll n;
  sl(n);
  v.clear();
  re(i, 1, n) sl(a[i]);
  if (a[n] > 0)
    a[n + 1] = -1;
  else
    a[n + 1] = 1;
  ll ma = -1e9 - 5;
  re(i, 1, n) if (a[i] > 0 && a[i + 1] > 0)
  {
    ma = max(a[i], ma);
  }
  else if (a[i] < 0 && a[i + 1] < 0)
  {
    ma = max(ma, a[i]);
  }
  else if (a[i] > 0 && a[i + 1] < 0)
  {
    ma = max(a[i], ma);
    v.push_back(ma);
    ma = -1e9 - 5;
  }
  else if ((a[i] < 0 && a[i + 1] > 0))
  {
    ma = max(a[i], ma);
    v.push_back(ma);
    ma = -1e9 - 5;
  }
  ll sum = 0;
  for (auto it : v)
  {
    sum += it;
  }
  cout << sum << endl;
}
int main()
{
  string s;
  cin>>s;
  for(auto it:s)
  {
    if(it=='7'){py;return 0;}
  }
  pn;
}

Measured memory_bytes: 3552
package main

import "fmt"

func main() {
	var a [3][3]int
	var n int

	for i := 0; i < 3; i++ {
		fmt.Scan(&a[i][0], &a[i][1], &a[i][2])
	}
	fmt.Scan(&n)

	b := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&b[i])
	}

	var c [3][3]bool
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			c[i][j] = false
			for k := 0; k < n; k++ {
				if a[i][j] == b[k] {
					c[i][j] = true
					break
				}
			}
		}
	}

	for i := 0; i < 3; i++ {
		if c[i][0] && c[i][1] && c[i][2] {
			fmt.Println("Yes")
			return
		}
	}

	for i := 0; i < 3; i++ {
		if c[0][i] && c[1][i] && c[2][i] {
			fmt.Println("Yes")
			return
		}
	}

	if c[0][0] && c[1][1] && c[2][2] {
		fmt.Println("Yes")
		return
	}

	if c[2][0] && c[1][1] && c[0][2] {
		fmt.Println("Yes")
		return
	}

	fmt.Println("No")
}


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

using namespace std;

#ifndef ONLINE_JUDGE
  #define pr_debug(...) do { printf("DEBUG: line %d: %s: ", __LINE__, __PRETTY_FUNCTION__); printf(__VA_ARGS__); } while(0)
  #define pr_vars(...) do { pr_debug(" "); pr_var(split(#__VA_ARGS__, ',').begin(), __VA_ARGS__); } while(0)
#else
  __attribute__ ((constructor)) static void fast_cin() { ios_base::sync_with_stdio(false); cin.tie(0); }
  #define pr_debug(...) do { } while(0)
  #define pr_vars(...) do { } while(0)
#endif /* ONLINE_JUDGE */

using ll = int64_t;
using ull = uint64_t;

template<typename T> ostream &operator<< (ostream &fout, const vector<T> &vec)
{ for (const auto &el : vec) fout << el << ' '; return fout; }

template<typename T> istream &operator>> (istream &fin, vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fin >> vec[i]; return fin; }

vector<string> split(const string &s, char c) { vector<string> v; ull st = 0, fn = 0, lvl = 0;
for ( ; fn < s.size(); fn++ ) { if (s[fn] == c && lvl == 0) { v.push_back(s.substr(st, fn - st)); st = fn + 1; }
if (s[fn] == '(') { lvl++; } if (s[fn] == ')') { lvl--; } } v.push_back(s.substr(st, fn - st)); return v; }

void pr_var(vector<string>::iterator it) { (void) it; cout << endl; }
template<typename T, typename... Args> void pr_var(vector<string>::iterator it, T a, Args... args)
{ cout << *it << "=" << a << "  "; pr_var(++it, args...); }

ll div_ceil(ll n, ll d) { ll res = n / d; if (res >= 0) res += n % d ? 1 : 0; return res; }
ll gcd(ll a, ll b) { a = llabs(a); b = llabs(b); while (a && b) a > b ? a %= b : b %= a; return a + b; }
ll lcm(ll a, ll b) { ll c = gcd(a, b); return c == 0 ? 0 : llabs(a / c * b); }

#define setp(a) fixed << setprecision(a)
const double PI = acos(-1.0);
constexpr double EPS = 1e-9;
constexpr double INF = 2e18;

using mp = pair<ll, ll>;
using mt = tuple<ll, ll, ll>;    // unpack: tie(ll, ll, ll) = mt;

constexpr ll MAX = 1e5 + 5;

int main()
{
    string s; cin >> s;
    string pref = "YAKI";
    if (s.substr(0, pref.size()) == pref)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int p = 1000000007;
long long modsub(long long a, long long b){
	if (a >= b){
		return (a - b) % p;
	} else {
		return p - (b - a) % p;
	}
}
long long modpow(long long a, long long b){
	long long res = 1; 
	while (b > 0){
		if (b % 2 == 1) res = res * a % p;
		a = a * a % p;
		b = b / 2;
	}
	return res;
}
long long modinv(long long a){
	return modpow(a,p - 2);
}
vector<long long> mf;
long long modfact(long long n){
	if (n < mf.size()){
		return mf[n];
	} else {
		if (mf.empty()) mf.push_back(1);
		long long res = mf.back();
		for (int i = mf.size(); i <= n; i++){
			res = res * i % p;
			mf.push_back(res);
		}
		return res;
	}
}
long long modbinom(long long n, long long r){
	long long res;
	res = modfact(n);
	res = res * modinv(modfact(r)) % p;
	res = res * modinv(modfact(n - r)) % p;
	return res;
}
long long modf(long long r, long long c){
  return modbinom(r + c, r);
}
int main(){
  int r1,c1,r2,c2;
  cin >> r1 >> c1 >> r2 >> c2;
  long long A = modf(r2 + 1, c2 + 1);
  long long B = modf(r1, c2 + 1);
  long long C = modf(r2 + 1, c1);
  long long D = modf(r1, c1);
  long long ans = modsub(A + D, B + C);
  cout << ans;
}

Measured memory_bytes: 18664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    public static void main(String[] args) {
//        Scanner sc = new Scanner(System.in);
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n=sc.nextInt();
        int a[]=new int[(int)1e6+1];
        Arrays.fill(a,0);
        for (int i=1;i<=n;i++){
            for (int j=i;j<=n;j+=i){
                a[j]++;
            }
        }
        long ans=0;
        int x=0;
        for (int i=1;i<n;i++){
//            x=n-i;
//            ans+=a[x];
            ans+=a[i];
        }
        System.out.println(ans);








        out.flush();

    }









    static void sort(int[] a) {
        ArrayList<Integer> l=new ArrayList<>();
        for (int i:a) l.add(i);
        Collections.sort(l);
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }
    static void sortReverse(long[] a) {
        ArrayList<Long> l=new ArrayList<>();
        for (long i:a) l.add(i);
//        Collections.sort.(l);
        Collections.sort(l,Collections.reverseOrder());
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }

    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long[] readArrayLong(long n) {
            long[] a=new long[(int)n];
            for (int i=0; i<n; i++) a[i]=nextLong();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }


}

Measured memory_bytes: 37780
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	vector<vector<int>> h(3,vector<int>(n + 1));
	rep(i, 1, n)cin >> h[0][i] >> h[1][i] >> h[2][i];

	vector<vector<int>> dp(3, vector<int>(n + 1));
	dp[0][1] = h[0][1];
	dp[1][1] = h[1][1];
	dp[2][1] = h[2][1];
	rep(i, 1, n - 1)rep(j, 0, 2)rep(k, 0, 2)
	{
		if (j != k)
		{
			dp[j][i + 1] = max(dp[k][i] + h[j][i + 1], dp[j][i + 1]);
		}
	}
	cout << max({ dp[0][n],dp[1][n],dp[2][n] }) << endl;
}

Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku

int main(void){
	int a=in(),b=in(),c=in();
	puts(a+b>=c?"Yes":"No");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define maxn 400005

using namespace std;
const int E=400;
char s[maxn];
int a[maxn],b[maxn],n,m,r,rr,d[maxn][2];
bool vis[maxn];
vector<int> h[maxn];

int main(){
    cin >> n >> m;
    scanf("%s",s);
    for (int i=1;i<=n;i++) a[i]=(s[i-1]=='A');
    for (int i=0;i<m;i++){
        int u,v; scanf("%d%d",&u,&v);
        h[u].push_back(v);
        h[v].push_back(u);
        d[u][a[v]]++; d[v][a[u]]++;
    }
    queue <int> q;
    for (int i=1;i<=n;i++) if (!d[i][0]||!d[i][1]) q.push(i);
    while (!q.empty()){
        int u=q.front(); q.pop();
        if (vis[u]) continue;
        vis[u]=true; rr++;
        for (int i=0;i<h[u].size();i++){
            int v=h[u][i];
            d[v][a[u]]--;
            if (!d[v][a[u]]) q.push(v);
        }
    }
    if (rr<n) puts("Yes"); else puts("No");
    return 0;
}


Measured memory_bytes: 22400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5 + 5, LG = 28, A = 1 << LG;

int n, a[N], b[N];
vector<int> bit0, bit1;

int count(int l, int r, vector<int> &v) {
  if (l > r) return 0;
  return upper_bound(v.begin(), v.end(), r) - lower_bound(v.begin(), v.end(), l);
}

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i) cin >> b[i];
  int ans = 0;
  for (int mod = 1, bit = 0; mod <= A; mod <<= 1, ++bit) {
    bit0.clear(); bit1.clear();
    for (int i = 1; i <= n; ++i) {
      if ((b[i] / mod) & 1)
        bit1.emplace_back(b[i] % mod);
      else
        bit0.emplace_back(b[i] % mod);
    }
    sort(bit0.begin(), bit0.end());
    sort(bit1.begin(), bit1.end());

    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
      int rem = a[i] % mod;
      if ((a[i] / mod) & 1) {
        (cnt += count(0, mod - 1 - rem, bit0)) %= 2;
        (cnt += count(mod - rem, mod - 1, bit1)) %= 2;
      } else {
        (cnt += count(0, mod - 1 - rem, bit1)) %= 2;
        (cnt += count(mod - rem, mod - 1, bit0)) %= 2;
      }
    }
    if (cnt & 1) ans += 1 << bit;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3444
#include<iostream>
#include<vector>
int main(){
	int n,m,sum=0,count1=0,count2=0;
	while(1){
		char a;
		std::cin>>n>>a>>m;
		if(std::cin.eof())break;
		//if(n==0)break;
		sum+=n*m;
		count1+=m;
		count2++;
	}
	int average=(int)((double)count1/(double)count2+0.5);
	std::cout<<sum<<std::endl;
	std::cout<<average<<std::endl;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

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

    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double pi = 4 * atan(1);
    double aa = (h / 12.0 + m / 720.0) * 2 * pi;
    double ab = (m / 60.0) * 2 * pi;

    double ans = sqrt(a * a + b * b - 2 * a * b * cos(aa - ab));
    cout << setprecision(10) << fixed << ans << endl;

    return 0;
}


Measured memory_bytes: 4240
#include<bits/stdc++.h>
#include<stdio.h>
#include<stdlib.h>

using namespace std;
#define endl "\n"
#define FILEIO freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define LL long long 
#define mod 1000000007LL
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back
//#define p push
#define I insert
#define bg begin()
#define ed end()
#define sz size()
#define all(v) v.begin(),v.end()
typedef vector<LL> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef map<LL ,LL > mii;
//typedef priority_queue<int> pq;
typedef queue<int>que;
typedef stack<int>stk;
#define Inf 100000005LL
#define f first
#define s second






int main(){

  
	LL n,k;
	cin>>n>>k;
	LL sum=0;
	for(int i=0;i<k;i++)
	   {
		   LL a;
		   cin>>a;
		   sum+=a;
	   }
	   if(sum>n)
	       cout<<-1;
		else
		{
			cout<<n-sum;
		}
		   

return 0;
   
}

Measured memory_bytes: 3624
object Main {
  def main(args: Array[String]): Unit = {
    val n = io.StdIn.readInt()
    val r = Iterator.continually(io.StdIn.readInt()).take(n).toList
    println(maximumProfit(r))
  }

  def maximumProfit(r: List[Int]): Int = {
    @annotation.tailrec
    def maximum(min: Int, max: Int, r: List[Int]): Int = r match {
      case Nil => max
      case h :: t => maximum(Math.min(min, h), Math.max(max, h - min), t)
    }

    maximum(r.head, Int.MinValue, r.tail)
  }
}

Measured memory_bytes: 70008
#include<bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint(){
    int x=0,p=1;char c=getchar();
    while (c<=32)c=getchar();
    if(c==45)p=-p,c=getchar();
    while (c>32)x=x*10+c-48,c=getchar();
    return x*p;
}
using namespace std;
//ruogu
const int N=3500;
int n,mod,a[N],inv[N],inv2[N],res[N];
int dp[N][N];
//
inline int add(int x,int y){x+=y;if(x>=mod)x-=mod;return x;}
inline int sub(int x,int y){x-=y;return (x<0)?x+mod:x;}
inline int mul(int x,int y){int ans=x*y;return ans%mod;}
inline int modpow(int x,int y){
	int ans=1;
	while(y){
		if(y&1)ans=mul(ans,x);
		x=mul(x,x);
		y>>=1;
	}
	return ans;
}
inline int modinv(int x){
	return modpow(x,mod-2);
}
int main(){
	n=getint();mod=n;
	rep(i,n)a[i]=getint();
	rep(i,N)inv[i]=modinv(i);
	rep(i,N)inv2[i]=modinv(sub(0,i));
	dp[n][0]=1;
	for(int i=n-1;i>=0;i--)for(int j=0;j<=n-i;j++){
		dp[i][j]=mul(dp[i+1][j],sub(0,i));
		if(j)dp[i][j]=add(dp[i][j],dp[i+1][j-1]);
		//cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
	}
	rep(i,n)if(a[i]){
		int ans=1;
		rep(j,i)ans=mul(ans,inv[i-j]);
		for(int j=i+1;j<n;j++)ans=mul(ans,inv2[j-i]);
		int tmp=0;
		if(!i)tmp=dp[1][0];
		res[0]=add(res[0],mul(tmp,ans));
		for(int j=1;j<n;j++){
			tmp=mul(sub(dp[0][j],tmp),inv2[i]);
			if(!i)tmp=dp[1][j];
			res[j]=add(res[j],mul(tmp,ans));
		}
	}
	rep(i,n)printf("%d ",res[i]);
	return 0;
}


Measured memory_bytes: 43392
#include<stdio.h>

int main(void) {
	int a, b, c;
	int cnt = 0;
	int i;
	
	scanf("%d %d %d", &a, &b, &c);
	
	for(i = a; i <= b; i++) {
		if(c%i == 0) {
			cnt++;
		}
	}
	printf("%d\n", cnt);
	
	return 0;
}

Measured memory_bytes: 596
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); int w = sc.nextInt();
        long [] dp = new long[100003];
        int [] a = new int [n+1]; int [] v = new int [n+1];
        for (int i = 1; i <= n; i++) {
            a[i] = sc.nextInt(); v[i] = sc.nextInt();
        }
        Arrays.fill(dp, Long.MAX_VALUE / 2);
        dp[0] = 0; long ans = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 100000; j >= 0; j--) {
                if (j - v[i] < 0) continue;
                dp[j] = Math.min(dp[j], dp[j - v[i]] + a[i]);
                if (dp[j] <= w) ans = Math.max(ans, j);
            }
        }
        System.out.println(ans);
    }


}

Measured memory_bytes: 37204
#include<bits/stdc++.h>
using namespace std;
int main()
{
int long answer=0;
int N;
cin>>N;
vector<long> A(N+1);
A[0]=0;
for(int i=1;i<=N;i++)
{cin>>A[i];}
//入力完了
vector<long>L(N+1);
L[0]=0;
for(int i=1;i<=N;i++)
{L[i]=i+A[i];}
vector<long>R(N+1);
R[0]=0;
for(int i=1;i<=N;i++)
{R[i]=i-A[i];}
map<long,int>Lmap;
for(int i=1;i<=N;i++)
{Lmap[L[i]]++;}

for(int i=1;i<=N;i++)
{
if(Lmap.count(R[i]))
{answer+=Lmap[R[i]];}
}

cout<<answer<<endl;


}



Measured memory_bytes: 20264
#include<bits/stdc++.h>
	#define ll long long
	#define f   first
	#define s   second
	#define pb          push_back
	#define mod         1000000007
	#define hell        998244353
	#define inf         1000000000000000000LL
	using namespace std;
	ll n,k,m,l,mx,sum,q;
	void solve()
	{   ll a,b;
		cin>>k;
		cin>>a>>b;
		for(int i=a;i<=b;i++)
		{
			if(i%k==0)
				{cout<<"OK";return;}
		}
		cout<<"NG";
		
				

	}    
	int main()
	{   
	    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	    //cout<<primes.size();
	    

	    ll t=1;
	   //cin>>t;
	    for(int i=1; i<=t; i++) {
        solve();
    }

	}

Measured memory_bytes: 3604
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 11 11:26:39 2019
D - 連結 / Connectivity
実行時間制限: 2 sec / メモリ制限: 256 MB

配点 : 
400 点
@author: justwah
"""
from collections import Counter

class UnionFind:
    def __init__(self, N):
        self.rank = [0]*N
        self.parent = [i for i in range(N)]
        self.n = N
        
    def root(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.parent[x]
        
    def merge(self, a, b):
        a = self.root(a)
        b = self.root(b)
        if a == b:
            return
        if self.rank[a] < self.rank[b]:
            self.parent[a] = b
        else:
            self.parent[b] = a
            if self.rank[a] == self.rank[b]:
                self.rank[a] +=1
                
    def same(self, a, b):
        return self.root(a) == self.roob(b)


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

uf_road = UnionFind(n)
for _ in range(k):
    p, q = map(int, input().split())
    uf_road.merge(p-1, q-1)

uf_rail = UnionFind(n)
for _ in range(l):
    r, s = map(int, input().split())
    uf_rail.merge(r-1, s-1)
    
ctr = Counter()
for i in range(n):  # make a list to count number of cities that both road and rail-wise are in the same group
    r1 = uf_road.root(i)
    r2 = uf_rail.root(i)
    ctr[(r1,r2)] += 1

ans = []
for i in range(n): # print the group size of that city when looped
    r1 = uf_road.root(i)
    r2 = uf_rail.root(i)
    ans.append(ctr[(r1,r2)])

print(*ans)   # * is for unpack the list

Measured memory_bytes: 56312
#!/usr/bin/env python3
N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]
INF = 10**9


def dfs(now):
    global color
    if now == N:
        gosei = 0
        cnt = [0] * 4
        for i in range(N):
            if color[i] > 0 and cnt[color[i]] > 0:
                gosei += 1
            cnt[color[i]] += l[i]
        if min(cnt[1:]) == 0:
            return INF
        diff = abs(A - cnt[1]) + abs(B - cnt[2]) + abs(C - cnt[3])
        return gosei * 10 + diff

    res = INF
    for c in range(4):
        color[now] = c
        res = min(res, dfs(now + 1))
    return res


color = [None] * N
print(dfs(0))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;


int main() {
    ll K;
    cin>>K;
    vel s={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout<<s[K-1]<<endl;
}


Measured memory_bytes: 256