akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
int main(void){
	int N;
	scanf("%d",&N);
	int a,b;
	int A[N];
	int max=0;
	for(a=0;a<N;a++){
		scanf("%d",&A[a]);
		for(b=0;b<a;b++){
			if((abs(A[a]-A[b]))>max){
				max=abs(A[a]-A[b]);
			}
		}
	}
	printf("%d",max);
return 0;
}

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

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

    int a[110];

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

    int ans = INT_MIN;
    for(int i = 0;i <= min(n, k);i++){
        for(int j = 0;j <= min(n-i, k-i);j++){
            priority_queue<int, vector<int>, greater<int> > que;

            int kk = k;

            for(int x = 0;x < i;x++){
                que.push(a[x]);
                kk--;
            }

            for(int x = 0;x < j;x++){
                que.push(a[n-x-1]);
                kk--;
            }

            while(kk > 0 && !que.empty()){
                if(que.top() < 0){
                    kk--;
                    que.pop();
                }else{
                    break;
                }
            }

            int atmp = 0;
            while(!que.empty()){
                atmp += que.top();
                que.pop();
            }
            ans = max(ans, atmp);
        }
    }

    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
    string s; cin >> s;
    int a[] = {1,1,0,2,0,0,1,0,1,0};
    int t = a[s[s.size()-1]-'0'];
    if(t == 0){
        cout << "hon" << endl;
    }
    else if(t == 1){
        cout << "pon" << endl;
    }
    else cout << "bon" << endl;

    system("pause");
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  ll x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<ll> a(x), b(y), c(z);
  vector<ll> ab;
  vector<ll> result;
  for(i = 0; i < x; i++)
    cin >> a[i];
  for(i = 0; i < y; i++)
    cin >> b[i];
  for(i = 0; i < z; i++)
    cin >> c[i];
  for(i = 0; i < x; i++){
    for(j = 0; j < y; j++){
      ab.push_back(a[i] + b[j]);
    }
  }
  sort(ALL(ab));
  reverse(ALL(ab));
  //cout << ab[0] << endl;
  for(i = 0; i < k && i < ab.size(); i++){
    for(j = 0; j < z; j++){
      result.push_back(ab[i] + c[j]);
      //cout << i spa j spa ab[i] spa c[j] << endl;
    }
  }
  sort(ALL(result));
  reverse(ALL(result));
  for(i = 0; i < k; i++){
    cout << result[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 43368
//#include "stdc++.h"
#include<bits/stdc++.h>
#include<iostream>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))
#define sz(x) (int)(x.size())
#define ff first
#define ss second
#define endl "\n"
#define int long long int
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p;}
const ll MOD = 1000000007;
const ll MOD1=1000000009;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
/*
 shuffle(x,x+n,rng) // shuffling elements of x in random order
 */

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int a[n+1],b[n+1],c[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
        cin>>b[i];
    for(int i=1;i<=n-1;i++)
        cin>>c[i];
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(i>=2&&a[i-1]+1==a[i])
        {
            ans+=c[a[i]-1];
        }
        ans=ans+b[a[i]];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()

ll power(ll b,ll e,ll m)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
} 

void solve()
{
  ll x;
  cin>>x;
  if(x>=400 and x<=599)
    cout<<"8";
  else if(x>=600 and x<=799)
    cout<<"7";
  else if(x>=800 and x<=999)
    cout<<"6";
  else if(x>=1000 and x<=1199)
    cout<<"5";
  else if(x>=1200 and x<=1399)
    cout<<"4";
  else if(x>=1400 and x<=1599)
    cout<<"3";
  else if(x>=1600 and x<=1799)
    cout<<"2";
  else
    cout<<"1";
}

int main()       
{
  fastio
  ll tt=1;
  while(tt--)
  {
    solve();
    cout<<"\n";
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1000000000000000000;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)

int main(){
    int n;
    cin>>n;
    vector<ll> numbers(n);
    rep(i,n)cin>>numbers[i];
    ll prod=1;
    rep(i,n){
        if(numbers[i]==0){
            cout<<0<<endl;
            return 0;
        }
    }
    rep(i,n){
        if(numbers[i]<=LongINF/prod){
            prod*=numbers[i];
        }else{
            cout<<"-1\n";
            return 0;
        }
    }
    cout<<prod<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N, M;
    cin >> N >> M;
    //vector<vector<ll>> G(N);
    vector<ll> a(M), b(M), c(N);
    rep(i,M){
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
        c[a[i]]++;
        c[b[i]]++;
    }
    rep(i,N){
        if(c[i]%2 == 1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 5616
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    A,B,K = map(int, lines.pop(0).split(' '))
    NLIST = set()
    for i in range(K):
        if A+i <= B:
            NLIST.add(A+i)
        if A <= B-i:
            NLIST.add(B-i)

    NLIST = list(NLIST)
    NLIST.sort()
    for i in NLIST:
        print(i)

#
# main
#
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,d,e,f,g;
    vector<long long>vc;
    vector<long long>dc;
    cin>>a>>b;
    c=a;
    while(c--)
    {
        cin>>d;
        vc.push_back(d);


    }
    sort(vc.begin(),vc.end());

 for(long long i=0;i<=a-b;i++)
 {
    e=vc[i+b-1]-vc[i];
    dc.push_back(e);
 }
sort(dc.begin(),dc.end());
cout<<dc[0];


}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FL          freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const double E = 1e-9;
int dx[] = {1, 0}, dy[] = {0, 1};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0 ,1, 1, 1, 0, -1, -1, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int sumMod(int a, int b){return 0LL + a + b > mod ? a + b - mod : a + b;}
int H, W;
char v[1005][1005];
int dp[1005][1005];
int f(int i, int j){
    if(i == H - 1 && j == W - 1)
        return 1;
    int &ans = dp[i][j];
    if(ans == -1){
        ans = 0;
        for(int k = 0; k < 2; k++){
            int x = i + dx[k];
            int y = j + dy[k];
            if(x >= 0 && x < H && y >= 0 && y < W && v[x][y] == '.')
                //ans = (ans % mod + f(x, y)% mod) % mod;
                ans = sumMod(ans, f(x, y));
        }
    }
    return ans;
}
int main(){
    //FL;
    FIN;
    cin >> H >> W;
    for(int i = 0; i < H; i++)
        for(int j = 0; j < W; j++)
            cin >> v[i][j];
    for(int i = H - 1; i >= 0; i--){
        for(int j = W - 1; j >= 0; j--){
            int &ans = dp[i][j];    
            if(i == H - 1 && j == W - 1){
                ans = 1;
                continue;
            } 
            ans = 0;
            for(int k = 0; k < 2; k++){
                int x = i + dx[k];
                int y = j + dy[k];
                if(x < H && y < W && v[x][y] == '.'){
                    ans = sumMod(ans, dp[x][y]);
                }

            }
        }
    }
    cout << dp[0][0] << '\n';
    EjecuteTime;
    return 0;
}       

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

// #define DEBUG

const int MAX_N = 300;
int main()
{
    ios::sync_with_stdio(false);

    int N;
    while (cin >> N, N) {
        vector<int> W(N);
        rep(i, N) cin >> W[i];

        bool dp[MAX_N][MAX_N] = {};
        rep(i, MAX_N) {
            dp[i][i] = true;
        }

        for (int len=2; len<=N; len+=2) {
            for (int l=0; l<=N-len; l++) {
                {
                    int inner_len = len - 2;
                    if (!(inner_len > 0 && !dp[l + 1][l + inner_len]) && abs(W[l] - W[l+ (len - 1)]) <= 1) {
                        dp[l][l + (len - 1)] = true;
                    }
                }
                for (int len2 = 2; len2 <= len - 2; len2+=2) {
                    int part_l = len2, part_r = len - len2;

                    if ((dp[l][l + part_l - 1] && dp[l + part_l][l + len - 1]) ||
                        (dp[l][l + part_r - 1] && dp[l + part_r][l + len - 1])) {
                        dp[l][l+len-1] = true;
                    }
                }
            }
        }

        int dp2[MAX_N + 1] = {};
        rep(r, N) {
            if (r > 0) dp2[r] = dp2[r-1];
            for (int len=2; len<=r+1; len+=2) {
                int l = r - len + 1;
#ifdef DEBUG
                // DUMP(len);
                // DUMP2(l, r);
#endif
                if (dp[l][r]) {
                    if (l-1 >= 0) {
                        dp2[r] = max(dp2[r], dp2[l-1] + len);
                    } else {
                        dp2[r] = max(dp2[r], len);
                    }
                }
            } 
        }

#ifdef DEBUG
        rep(l, N) {
            rep(r, N) cerr << dp[l][r] << " ";
            cerr << endl;
        }
        cerr << "-----------------------------" << endl;
        rep(i, N) cerr << dp2[i] << " ";
        cerr << endl;
#endif

        cout << dp2[N-1] << endl;
    }
}

Measured memory_bytes: 3276
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, a);
  	Cin(string, s);
  string r = "red";
    Cout((a >= 3200) ? s : r);
}


Measured memory_bytes: 256
n = int(input())
a = sorted(map(int,input().split()))

ans = 0

baisu = [0]*(a[n-1]+1)
an = a[n-1]

for i in range(n):
    a0 = a[i]
    a1 = a0
    while a1 <= an:
        baisu[a1] += 1
        a1 += a0


for i in range(n):
    if baisu[a[i]] == 1:
        ans += 1
print(ans)


Measured memory_bytes: 106228
#include<stdio.h>
#define MAX 1000
#define INF 1000000000

void bfs(int id, int dis);

int n;
int G[MAX][MAX], d[MAX];
int size[MAX];//それぞれの頂点から出ている辺の本数を記録しておく配列

int main(){
    int i, j;
    int u, k, v;

    scanf("%d", &n);
    for(i = 1 ; i <= n ; i++){
        d[i] = INF;//距離を「無限の値」に初期化する
        scanf("%d%d", &u, &k);
        size[u] = k;
        for(j = 1 ; j <= size[u] ; j++){
            scanf("%d", &v);
            G[u][j] = v;
        }
    }

    bfs(1, 0);

    for(i = 1 ; i <= n ; i++){
        printf("%d %d\n", i, (d[i] == INF) ? -1 : d[i]);
    }

    return 0;
}

void bfs(int id, int dis){
    int i;

    d[id] = dis;

    for(i = 1 ; i <= size[id] ; i++){
        if(dis + 1 < d[G[id][i]]) bfs(G[id][i], dis + 1);
    }
}



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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;


ll pow_mod(ll n, ll k, ll m) {
	ll r = 1;
	for (; k > 0; k >>= 1) {
		if (k & 1)r = (r*n) % m;
		n = (n*n) % m;
	}
	return r;
}//nのk乗をmで割った時のあまり



int main() {

	int n;
	cin >> n;
	n--;
	VI d(n);
	int a;
	cin >> a;
	if (a != 0) {
		cout << 0 << endl;
		return 0;
	}
	REP(i, n)cin >> d[i];

	ll ans = 1;
	sort(ALL(d));
	if (d[0] != 1) {
		cout << 0 << endl;
		return 0;
	}

	REP(i, n-1) {
		if (d[i + 1] - d[i] > 1) {
			cout << 0 << endl;
			return 0;
		}
	}
	int b = d[0];
	ll cnt = 1;

	VLL v;

	REP(i, n - 1) {
		if (d[i + 1] == b)cnt++;
		else {
			v.push_back(cnt);
			b = d[i + 1];
			cnt = 1;
		}
	}
	v.push_back(cnt);
	REP(i, v.size() - 1) {
		ans *= pow_mod(v[i], v[i + 1], mod);
		ans %= mod;
	}

	cout << ans << endl;


}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep_r(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define resize(x, n) x.resize(n)
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ll MAX = 100000;
struct edge {
    ll from, to, weight;
    edge(ll f, ll t, ll w) : from(f), to(t), weight(w) { }
};
vector<vector<edge>> edges;
vector<vector<ll>> graph;
vector<bool> visited;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll n, k;

// ll dp[2001][2001];

// ll c(ll n, ll r) {
//     if (n < r) return 0;
//     if (dp[n][r] != -1) return dp[n][r];
//     if (n == r || r == 0) return 1;
//     if (r == 1) return dp[n][r] = n;
//     return dp[n][r] = (c(n-1, r-1) + c(n-1, r)) % mod;
// }

ll dp[2001][2001];
ll ncr(ll n, ll r) { // nCrの組み合わせ
    if (n < r) return 0;
    if (dp[n][r] != -1) return dp[n][r];
    // memset(dp, -1, sizeof(dp));
    for (ll i = 0; i <= n; i++) {
        for (ll j = 0; j <= i; j++) {
            if (j == 0 || i == j) dp[i][j] = 1;
            else dp[i][j] = dp[i-1][j-1] % mod + dp[i-1][j] % mod;
        }
    }
    return dp[n][r] % mod;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    memset(dp, -1, sizeof(dp));
    cin >> n;
    cin >> k;
    ll blue = k, red = n-k;
    for (ll i = 1; i <= k; i++) {
        ll answer = ncr(red+1, i) * ncr(blue-1, i-1) % mod;
        // printf("%lld回の場合 %lld\n", i, answer);
        cout << answer << "\n";
    }
}

Measured memory_bytes: 34924
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int n, m, K;
    scanf("%d%d%d", &n, &m, &K);
    int dark[n], v[n][K], idx[m], rev[n];
    memset(dark, 0, sizeof(dark));
    rep(i, m){
        scanf("%d", &idx[i]);
        --idx[i];
        dark[idx[i]] = 1;
        rev[idx[i]] = i;
    }
    rep(i, n)rep(j, K){
        scanf("%d", &v[i][j]);
        --v[i][j];
    }

    int dist[1<<m];
    fill(dist, dist+(1<<m), mod);
    queue<pii> que;
    que.emplace((1<<m)-1, 0);
    dist[(1<<m)-1] = 0;
    while(!que.empty()){
        int S, d;
        tie(S, d) = que.front();
        que.pop();
        rep(j, K){
            int T = 0;
            rep(i, m)if(S>>i & 1){
                int to = v[idx[i]][j];
                if(dark[to]) T |= 1 << rev[to];
            }
            if(chmin(dist[T], d + 1)){
                if(T == 0){
                    printf("%d\n", d + 1);
                    return 0;
                }
                que.emplace(T, d + 1);
            }
        }
    }
}


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

int main(){
  int k,r;
  cin >> k >> r;
  if (k >= 10) cout << r << endl;
  else cout << r+(100*(10-k)) << endl; 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> ans(N+1);
  FOR(i, 1, N+1){
    for(int j = 1; i*j <= N; j++){
      ans[i*j]++;
    }
  }

  int ret = 0;
  FOR(i, 1, N+1){
    ret += ans[i]*i;
  }

  cout << ret << "\n";

  return 0;
}


Measured memory_bytes: 81324
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		for(int i=1;i<=k;i++) {
			long ans = ((long)nCk(n-k+1,i,1000000007)*(long)nCk(k-1,i-1,1000000007))%1000000007;
			if(i>n-k+1) ans = 0;
			System.out.println(ans);
		}
		
		in.close();

	}
	
	//return a^b mod M O(logB)
	public static long pow(long a,long b,int M) {
		long ret = 1;
		long tmp = a;
		while(b>0) {
			if((b&1)==1) ret = (ret * tmp) % M;
			tmp = (tmp * tmp) % M;
			b = b>>1;
		}
		return ret;
	}
	
	//return nCk mod M (M must be prime number) O(min(k,n-k)*logM)
	public static int nCk(int n,int k,int M) {
		long ret = 1;
		int min = Math.min(k, n-k);
		for(int i=1;i<=min;i++) {
			ret = (ret * pow(i,M-2,M)) % M;
		}
		for(int i=n-min+1;i<=n;i++) {
			ret = (ret * i) % M;
		}
		return (int)ret;
	}

}


Measured memory_bytes: 22228
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ConsoleApp5
{

    class Program
    {
        static void Main(string[] args)
        {

            String S = Console.ReadLine();
            String[] L = S.Split(' ');
            int X = int.Parse(L[0]);
            int A = int.Parse(L[1]);

            if (X < A)
            {
                Console.WriteLine("0");
            }
            else
            {
                Console.WriteLine("10");
            }
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  long long N, M;
  cin >> N >> M;
  long long ans;
  if (N == 1 && M == 1)
    ans = 1;
  else if (N == 1 && M != 1)
    ans = M - 2;
  else if (N != 1 && M == 1)
    ans = N - 2;
  else if (N != 1 && M != 1)
    ans = (N - 2) * (M - 2);

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

Measured memory_bytes: 256
#include <stdio.h>
 
char s[11];
typedef long long ll;
ll res = 0;
int p[11], sz=0;
 
void solve(int a, ll b, ll c) {
  //printf("%d %lld %lld\n", a, b, c);
  if (!s[a]) {
    res += b+c;
    return;
  }
 
  solve(a+1, b+c, s[a]-'0');
  solve(a+1, b, (s[a]-'0')+c*10);
}
 
int main(void) {
  scanf("%s", s);
 
  solve(0, 0, 0);
 
  printf("%lld\n", res/2);
 
  return 0;
}

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i(0);i<N;i++) cin>>A[i];
  int cnt(0);
  for(int i(0);i<N;i++){
    if(A[i]%2==1 && (i+1)%2==1){
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}



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

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

    if (s <= w)
        cout << "unsafe";
    else
        cout << "safe";

    cout << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int a[N];
  for(int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int x[N];
  for(int i = 0; i < N; i++) {
    x[i] = 0;
  }
  
  int now = 0;
  int i = 0;
  while(x[now] == 0) {
    i++;
    x[now] = 1;
    now = a[now] - 1;
    if(now == 1) {
      cout << i << endl;
      break;
    }
  }
  if(now != 1) {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 3940
from typing import List, NamedTuple


class Card(NamedTuple):
    suit: str
    value: int


def bubble_sort(cards: List[Card]):
    for i in range(len(cards)):
        for j in range(len(cards) - 1, i, -1):
            if cards[j].value < cards[j - 1].value:
                cards[j], cards[j - 1] = cards[j - 1], cards[j]


def selection_sort(cards: List[Card]):
    for i in range(len(cards)):
        minj = i
        for j in range(i, len(cards)):
            if cards[j].value < cards[minj].value:
                minj = j
        cards[i], cards[minj] = cards[minj], cards[i]


def gen_numbet_card_pair(cards: List[Card]):
    return {n: [c for c in cards if c.value == n] for n in range(1, 10)}


def is_stable(in_cards: List[Card], out_cards: List[Card]):
    in_lists = gen_numbet_card_pair(in_cards)
    out_lists = gen_numbet_card_pair(out_cards)
    for n in range(10):
        if in_lists.get(n, []) != out_lists.get(n, []):
            return False
    return True


def printing(arr, f):
    b_arr = arr.copy()
    f(b_arr)
    print(" ".join([c.suit+str(c.value) for c in b_arr]))
    print("Stable" if is_stable(arr, b_arr) else "Not stable")


n = int(input())
cards: List[Card] = [Card(suit=x[0], value=int(x[1])) for x in input().split(" ")]
printing(cards, bubble_sort)
printing(cards, selection_sort)



Measured memory_bytes: 7236
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define EPS 0.000000001 //1e-9
using ll = long long;
using pii = pair<int, int>;
const long long INF = 2e18;

template <class A, class B> ostream& operator<<(ostream &os, const pair<A, B> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;} 
template <class A> ostream& operator<<(ostream &os, const vector<A> &v) {os << "{"; for(int i = 0; i < (int)v.size(); i++) if(i == 0) os << v[i]; else os << ", " << v[i]; os << "}"; return os;}

void dprint(string s) {cout << endl;}
template <class T, class... U> void dprint(string s, T t, U... u) 
{int w = s.find(','); cout << "[" << s.substr(0, w) << ": " << t << "] "; dprint(s.substr(w+2, (int)s.size()-w-1), u...);} 

#define DEBUG 
#ifdef DEBUG
#define dbg(X...) dprint(#X, X)
#else
#define dbg(X...) "KEEP CALM" 
#endif

const int N=1e3+5; // CHANGE this value ACC. TO Q.

vector<int> dx={0, 1, -1, 0};
vector<int> dy={1, 0, 0, -1};

char arr[N][N];
bool vis[N][N]={};
int cost[N][N];
int n, m, inix, iniy, tarx, tary;

queue<pii> q;

bool valid(int x, int y)
{return x>=0 and y>=0 and x<n and y<m and arr[x][y]!='#';}

void dfs(int x, int y, int cur)
{
    if(cost[x][y]==-1)
        cost[x][y]=cur;
    else
        cost[x][y]=min(cost[x][y], cur);
 
    vis[x][y]=1;
    for(int i=0;i<4;i++)
    {
        int X=x+dx[i], Y=y+dy[i];
        if(valid(X, Y) and !vis[X][Y])
        {
            // if(x==inix and y==iniy)
            //     dbg(cur, cost[x][y]);
            dfs(X, Y, cost[x][y]);
        }
    }
    for(int dxx=-2;dxx<=2;dxx++)
        for(int dyy=-2;dyy<=2;dyy++)
        {
            if(valid(x+dxx, y+dyy)==0) continue;
            int &val=cost[x+dxx][y+dyy];
            if(val==-1)
                val=cost[x][y]+1, q.push({x+dxx, y+dyy});
            else
                val=min(val, cost[x][y]+1);
        }
}

int32_t main()
{
    IOS;
    memset(cost, -1, sizeof(cost));
    cin>>n>>m;
    cin>>inix>>iniy;
    cin>>tarx>>tary;
    inix--, iniy--, tarx--, tary--;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
            cin>>arr[i][j];
    }
    // dbg(vis[0][1]);
    q.push({inix, iniy});
    cost[inix][iniy]=0;
    while(!q.empty())
    {
        pii k=q.front();
        // dbg(cost[k.ff][k.ss]);
        // dbg(vis[0][1]);
        if(vis[k.ff][k.ss]==0)
        {
            dfs(k.ff, k.ss, cost[k.ff][k.ss]);
        }
        q.pop();
    }
    // for(int i=0;i<n;i++)
    // {
    //     for(int j=0;j<m;j++)
    //         cout<<cost[i][j]<<" ";
    //     cout<<endl;
    // }

    cout<<cost[tarx][tary];

    return 0;
}

Measured memory_bytes: 13592
n = int(input()) 
p =  [int(i) for i in input().split()] 

c = 0
for i in range(1, n-1):
    if p[i-1] < p[i] and p[i] < p[i+1]:
        c += 1
    
    if p[i-1] > p[i] and p[i] > p[i+1]:
        c += 1

print(c)


Measured memory_bytes: 3060
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		int count = 0;

		for(int i=1; i<= N; i++) {
			if(K <= Integer.parseInt(sc.next())) count++;
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 44040
s = input()
j = 0
a = [0]
for i in s:
    if (i == 'A') or (i == 'C') or (i == 'G') or (i == 'T'):
        a[j] += 1
    else:
        a.append(0)
        j += 1
a = sorted(a,reverse = True)
print(a[0])    
    

Measured memory_bytes: 2940
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    
    //cout << (int)(a/b) << " " << a % b << " " << (double)a / b << endl;
    printf("%d %d %.5f\n", a/b, a%b, (double)a/b);
    
    return 0;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a;
    for(int i=0;i<n;i++){
        int in;cin >> in;
        a.push_back(in);
    }
    a.push_back(1000000);
    sort(a.begin(),a.end());
    vector<int> b(100001,0);
    int tmp=1;
    for(int i=0;i<n;i++){
        if(a[i]!=a[i+1]){
            b[a[i]]+=tmp;
            tmp = 1;
        }
        else{
            tmp ++ ;
        }
    }
    int ans=0;
        for(int i=1;i<b.size()-1;i++){
            int t;
            t = b[i-1]+b[i] + b[i+1];
            if(t>ans){
                ans = t;
            }
        }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int N,n,sum=0,d;
  cin>>N;
  n=N;
  while(n){
    d=n%10;
    sum+=d;
    n/=10;
  }
  if(N%sum==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define testP	 cout << "------------------ test ------------------" << endl;	// 動作確認テスト
#define testX(x) cout << "testout : " << x << endl;	// テストアウト
typedef long long ll;
using namespace std;
const int MOD{ int(1e9 + 7) };	// int 1000000007
const int inf{ int(1e9) };	// inf = 1000000000

// ------------------ ベクター表示 ------------------ //
void printVec(vector<int> & vec) {
	cout << "";
	for (auto it = vec.begin(); it != vec.end(); it++) cout << *it << " ";
	cout << endl;
}

// ------------------ ベクター合計 ------------------ //
ll sumVec(vector<ll> v) {
	int sum = 0;
	for (size_t i = 0; i < v.size(); i++) sum += v[i];
	return sum;
}

// ------------------ int -> Vector 変換 ------------------ //
vector<int> ItoVec(int x) {

	vector<int> xVec;

	while (x > 0) {
		int tmp = x % 10;
		xVec.insert(xVec.begin(), tmp);
		x /= 10;
	}

	return xVec;
}

// ------------------ 最大公約数関数 ------------------ //
int GCD(int x, int y) {
	if (x == 0) return y;
	else GCD(y % x, x);
}


// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	string S;

	cin >> S;

	cout << (S == "ABC" ? "ARC" : "ABC");



	return 0;
}

Measured memory_bytes: 3628
M=10**6+1
f=lambda p: exit(print(['pairwise','setwise','not'][p]+' coprime'))
n,*l=map(int,open(0).read().split())
from math import *
g,C=0,[0]*M
for x in l:
  g=gcd(g,x)
  C[x]=1
if g>1: f(2)
if any(sum(C[i::i])>1 for i in range(2,M)): f(1)
f(0)

Measured memory_bytes: 121456
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <vector>
#include <cstring>
#include <ctime>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cassert>
#define fr first
#define sc second
#define MP make_pair
#define PB push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define lli long long int
#define y1 arayikhalatyan
#define j1 jiglypuff
#define ld long double
using namespace std;

lli gcd(lli a, lli b) { return (b == 0 ? a : gcd(b, a % b)); }

char vow[] = { 'a', 'e', 'i', 'o', 'u' };
int dx[] = { 1, -1, 0, 0 };
int dy[] = { 0, 0, 1, -1 };



const int N = 1e5;
const lli mod = 1e9 + 7;

int n;
char ask(int l, int r)
{
	cout << "? ";
	for (int i = l; i <= r; i++)
	{
		cout << i << " ";
	}
	cout << endl;
	string s;
	cin >> s;
	return s[0];
}
char ask1(int l, int r, int i1)
{
	cout << "? ";
	cout << i1 << " ";
	for (int i = l; i <= r; i++)
	{
		cout << i << " ";
	}
	cout << endl;
	string s;
	cin >> s;
	return s[0];
}
char nax = '*', hima;
string pat;
vector <int> b, R;
char ask2(int i1)
{
	cout << "? ";
	cout << i1 << " ";
	for (int i = 0; i < n / 2; i++)
	{
		cout << b[i] << " ";
		cout << R[i] << " ";
	}
	cout << endl;
	string s;
	cin >> s;
	return s[0];
}
int nxl, nxr;
int main()
{
	fastio;
	cin >> n;
	for (int i = 0; i <= 2 * n; i++) pat += '0';
	int l, r, l1 = 2, r1 = n + 1;
	nax = ask(1, n);
	while (l1 <= r1)
	{
		int mid = (l1 + r1) / 2;
		hima = ask(mid, mid + n - 1);
		if (nax != hima)
		{
			l = mid;
			r = mid + n - 1;
			r1 = mid - 1;
		}
		else l1 = mid + 1;
	}
	//cout << l << " " << r << endl;
	pat[l - 1] = nax;
	if (nax == 'R') pat[r] = 'B';
	else pat[r] = 'R';
	for (int i = 1; i < l - 1; i++)
	{
		hima = ask1(l, r - 1, i);
		pat[i] = hima;
	}
	for (int i = r + 1; i <= 2 * n; i++)
	{
		hima = ask1(l, r - 1, i);
		pat[i] = hima;
	}
	for (int i = 0; i <= 2 * n; i++)
	{
		if (pat[i] == 'B') b.PB(i);
		else if (pat[i] == 'R') R.PB(i);
	}
	for (int i = l; i < r; i++)
	{
		hima = ask2(i);
		pat[i] = hima;
	}
	pat.erase(0, 1);
	cout << "! ";
	cout << pat << endl;
	return 0;
}

Measured memory_bytes: 724
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n,x,y = nm()
d = y-x
p = [0]*n
cnt = 0
for i in range(1,n):
    for j in range(i+1, n+1):
        p[min(abs(x-i) + 1 + abs(y-j), j-i)] += 1
print(*p[1:], sep = '\n')


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;

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

	long double L;
	cin >> L;
	L /= 3;
	cout << fixed << setprecision(9);
	cout << L * L * L << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int  //comment for large arrays
#define pll pair<int,int>
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define eps 0.00000001
#define INF 10000000000000001
#define all(x) (x).begin(),(x).end()
#define LB(v,x) (lower_bound(all(v),x) - v.begin()) 
#define UB(v,x) (upper_bound(all(v),x) - v.begin())
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define popb() pop_back()
#define popf() pop_front()
#define mp(x,y) make_pair((x),(y))
#define vec(dt) vector<dt>
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define init(v,s) memset(v,s,sizeof(v)) 
#define bug(x) cerr<<"LINE: "<<__LINE__<<" || click to see test details "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(int i=s;i<n;i++)
#define bugprint(v) for(auto it:v) cout<<it<<" "; cout<<endl 
using namespace std;


signed main()
{
	fastio(0);
	int n;
	cin>>n;
	dbl p[n+1],dp[n+1];
	loop(i,1,n+1) cin>>p[i];
	dp[0] = 1;
	loop(i,1,n+1) dp[i] = 0;
	loop(i,1,n+1)
	{
		for(int j=n;j>0;j--)
		{
			dp[j] = p[i]*dp[j-1] + (1-p[i])*dp[j];
		}
		dp[0] = dp[0]*(1-p[i]);
	}
	dbl ans = 0;
	loop(i,n/2 + 1,n+1) ans += dp[i];
	cout<<fixed<<setprecision(15)<<ans<<endl;
	return 0;		
}

Measured memory_bytes: 384
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <set>
//#inlcude<stringstream>
#define ll long long
#define MODD 1000000007
using namespace std;
ll arr[1000000]={0};
ll brr[1000000]={0};
int main() {
    //
    ll a , b;cin >>a>>b;
    int flag=1;
    a--,b--;
    cout<<100<<" "<<100<<endl;
    for(int i=1;i<=50;i++){
        for(int j=1;j<=100;j++){
           if(i%2==0&&j%2==0&&a){
                a--;
                cout<<".";
           }
           else cout<<"#";
        }
       cout<<endl;
    }
    for(int i=1;i<=50;i++){
        for(int j=1;j<=100;j++){
            if(i%2==0&&j%2==0&&b){
                b--;
                cout<<"#";
           }
           else cout<<".";
        }
        cout<<endl;

    }
    return 0;
}


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

using namespace std;

int main() {
  string s, o, p;
  int n, a, b;
  cin >> s >> n;
  for (int i = 0; i < n; i++) {
    cin >> o >> a >> b;
    p = s.substr(a, b - a + 1);
    if (o == "print") {
      cout << p << '\n';
      continue;
    } else if (o == "reverse") {
      reverse(p.begin(), p.end());
    } else {
      cin >> p;
    }
    s = s.substr(0, a) + p + s.substr(b + 1);
  }
  return 0;
}



Measured memory_bytes: 3204
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200000


long long gcd(long long x,long long y){
if(x>y)swap(x,y);
if(x<=0)return y;
else if(y%x==0)return x;
else return gcd(y%x,x);
}



int main(){
	vector<long long>a;
	long long n, g,s;
	long long x, y, z;
	scanf("%lld", &n);
	f(i,n){
		scanf("%lld", &x);
		a.push_back(x);
	}
if(n==1){
printf("Second\n");
return 0;
}
x=0;
while(true){
y=0;
z=0;
s=0;
f(i,n){
if(a[i]%2==1){
y++;
z=i;
}
s+=a[i];
s=s%2;
}

if(y>1||a[z]==1||(s+n)%2==1){
if((s+n+x)%2==0){
printf("Second\n");
return 0;
}
else{
printf("First\n");
return 0;
}
}


a[z]--;
g=0;
f(i,n)g=gcd(g,a[i]);
f(i,n)a[i]=a[i]/g;

x=(x+1)%2;
}


	return 0;
}


Measured memory_bytes: 1400
n, k = [int(x) for x in input().split()]
a_list = [int(x) for x in input().split()]

if k == 0:
    print(sum([0 ^ a for a in a_list]))
    exit()

l = len(bin(k)) - 2
b = n / 2
x = 0
for i in range(l, -1, -1):
    count = sum([(a >> i) & 1 for a in a_list])
    if count < b:
        temp = 1 << i
        if x + temp <= k:
            x += temp
print(sum([x ^ a for a in a_list]))

Measured memory_bytes: 14708
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int h, n;
int a[100010];


signed main(){
    cin >> h >> n;
    rep(i, 0, n) cin >> a[i];

    sort(a, a+n, greater<int>());
    rep(i, 0, n) h -= a[i];

    if(h <= 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int n, m;
	double ans = 0;
	vector<int> a, p, dp;
	vector<double> pro;
	
	cin>>n>>m;
	
	a.resize(n);
	p.resize(n);
	pro.resize(1<<n, 1);
	dp.resize(1<<n);
	
	for(int i = 0; i < n; i++){
		cin>>a[i];
	}
	
	for(int i = 0; i < n; i++){
		cin>>p[i];
	}
	
	for(int i = 0; i < (1<<n); i++){
		for(int j = 0; j < n; j++){
			if((i>>j)&1) pro[i] *= (p[j]/100.0); 
			else         pro[i] *= (1.0 - (p[j]/100.0)); 
		}
	}
	
	for(int i = 1; i < (1<<n); i++){
		__int128 lcm = 1;
		int sum = 0, num = 0;
		
		for(int j = 0; j < n; j++){
			if((i>>j)&1){
				lcm = lcm/__gcd((int)lcm, a[j])*a[j];
				if(lcm > m){
					lcm = m+1;
					break;
				}
				num++;
			}
		}
		if(num%2 == 0) dp[i] = - m/lcm;
		else dp[i] =  m/lcm;
	}
	
	for(int j = 0; j < n; j++){
		for(int i = 1; i < (1<<n); i++){
			if(i & (1<<j)) dp[i] += dp[i&~(1<<j)];
		}
	}
	
	for(int i = 1; i < (1<<n); i++){
		ans += dp[i]*pro[i];
	}
	
	cout<<ans<<endl;
	return 0;
}


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

#define INF 50001

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> coins;

    int c;
    for (int i = 0; i < m; i++) {
        cin >> c;
        coins.push_back(c);
    }

    vector<int> T(INF, INF);
    T[0] = 0;
    for (int i = 0; i < m; i++) {
        for (int j = coins[i]; j <= n; j++) {
            T[j] = min(T[j], T[j - coins[i]] + 1);
        }
    }

    cout << T[n] << endl;

    return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
// until dimension reduction.

using namespace std;
typedef long long LL;

const int N = 300005, MOD = 1000000007; 
int n;
LL a[N], use[2];
LL ans =0 ;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  LL ans =0 ; 
  for (LL bit = 0; bit < 60; bit++) {
    LL d = (1ll << bit), cnt = 0;
    use[0] = use[1] = 0;
    for (int i = 1; i <= n; i++) {
      cnt += use[!(bool)(a[i] & d)];
      cnt %= MOD; 
      ++use[(bool)(a[i] & d)];
    }

    ans += 1ll * (d % MOD) * (cnt % MOD) % MOD;
    ans %= MOD;
  }
  cout << ans << endl; 
  return 0;
}


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

int main() {
  std::string s;
  std::cin >> s;
  
  int r_cnt = 0;
  for (int i = 0; i < 3; ++i)
    if (s[i] == 'R') r_cnt++;
  
  if (r_cnt == 3) std::cout << r_cnt << std::endl;
  else if (r_cnt == 2 and s[1] == 'R') std::cout << r_cnt << std::endl;
  else if (r_cnt > 0) std::cout << 1 << std::endl;
  else std::cout << 0 << std::endl;
  
  return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>

int main (void){
    int S,h,m,s;
	scanf("%d",&S);
	h=S/3600;
	m=(S-h*3600)/60;
	s=S-h*3600-m*60;
	printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2144