akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int64_t n; cin >> n;

	int64_t ans = 0;
	FOR_LT(i, 1, n) {
		int64_t c = (n - 1) / i;
		if (c == 1) {
			ans += (n - i);
			break;
		}
		ans += c;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int n,c;
	int a[101];
	cin>>n>>c;
	int sum=0;
	for(int i=0;i<c;i++){
		cin>>a[i];
		sum+=a[i];
	}
	//cout<<sum<<endl;
	if(sum%(n+1)!=0){
		sum=sum/(n+1);
		//cout<<sum<<endl;
		sum++;
	}
	else{
		sum=sum/(n+1);
	}
	
	cout<<sum<<endl;
	return 0;
}


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

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


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
	int n;
	scanf("%d",&n);
	char arr[105];
	scanf("%s", arr);
	int len = strlen(arr);
	
	if (len > n){
		for (int i = 0; i < n;i++){
			printf("%c",arr[i]);
			}
			printf("...");
	}
	else{
		printf("%s",arr);
	}
}

Measured memory_bytes: 1704
#include <iostream>
#include <cstdio>
#include <algorithm>
#define ll long long
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
const int N = 20,M = (1 << 16) + 1000,mod = 1e9 + 7;
int n,m,S,ans,a[N];
ll jc[M],inv[M],jcinv[M];
ll dp[N][M];
void init(int lim)
{
	jc[0] = jc[1] = inv[0] = inv[1] = jcinv[0] = jcinv[1] = 1;
	for(int i = 2;i <= lim;i ++)
	{
		jc[i] = jc[i - 1] * i % mod;
		inv[i] = inv[mod % i] * (mod - mod / i) % mod;
		jcinv[i] = jcinv[i - 1] * inv[i] % mod;
	}
}
ll C(int x,int y){if(y < 0 || y > x) return 0; return jc[x] * jcinv[y] % mod * jcinv[x - y] % mod;}
signed main()
{
	n = read(); m = read(); for(int i = 1;i <= m;i ++) a[i] = read();
	reverse(a + 1,a + 1 + m);
	init(1 << n); S = (1 << n) - 1; dp[0][0] = 1;
	for(int i = 0;i < m;i ++)
	{
		for(int s = 0; s <= S;s ++)
		{
			int les = S + 1 - a[i + 1] - s;
			dp[i + 1][s] = (dp[i + 1][s] + dp[i][s]) % mod;
			for(int j = 0;j < n;j ++) 
				if(!((s >> j) & 1)) 
					dp[i + 1][s | (1 << j)] = (dp[i + 1][s | (1 << j)] + 1ll * dp[i][s] * C(les,(1 << j) - 1) % mod * jc[1 << j] % mod) % mod;
		}
	}
	for(int i = 0,x,cnt;i <= S;i ++)
	{
		x = i; cnt = 0;
		while(x) x -= x & -x,cnt ++;
		if(cnt & 1) ans = (ans + mod - 1ll * dp[m][i] * jc[S - i] % mod) % mod;
		else ans = (ans + 1ll * dp[m][i] * jc[S - i] % mod) % mod;
	}
	ans = 1ll * ans * (S + 1) % mod;
	cout << ans << "\n"; return 0;
}

Measured memory_bytes: 11520
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる


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

  ll k;
  cin>>k;

  cout << 50 << endl;

  vector<ll> p(50,49);
  rep(i,50){
    p[i]+=k/50-k%50;
  }
  rep(i,k%50){
    p[i]+=51;
  }

  rep(i,50){
    if(i!=50) cout << p[i] << " ";
    else cout << p[i] << endl;
  }

}

Measured memory_bytes: 3552
n, m, q = map(int, input().split())
mp = [[0] * 502 for _ in range(502)]
for _ in range(m):
    l, r = map(int, input().split())
    mp[l][r] += 1


for x in range(501):
    mp[0][x + 1] += mp[0][x]

for y in range(1, 502):
    for x in range(501):
        mp[y][x + 1] += mp[y][x]
        mp[y][x] += mp[y - 1][x]

for _ in range(q):
    a, b = map(int, input().split())
    print(mp[b][b] - mp[b][a - 1] - mp[a - 1][b] + mp[a - 1][a - 1])

Measured memory_bytes: 56408
#include<stdio.h>
int main(){
int n,i;
scanf("%d",&n);
int a[n];
for(i=0;i<n;i++){
scanf("%d",&a[n-1-i]);
}
for(i=0;i<n;i++){
printf("%d",a[i]);
if(i==n-1)printf("\n");else printf(" ");
}
return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int num=0;
 	 cin>>num;
  int sum=0;
  int max=0;
  vector<int> goods(num);
  for(int i=0;i<num;i++){
    cin>>goods.at(i);
    sum+=goods.at(i);
    if(goods.at(i)>max)max=goods.at(i);
  }
  cout<<sum-max/2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string A,B,C;
    cin >> A >> B>> C;
    char AB,BB,BC,CC;
    AB = A.at(A.size()-1);
    BB = B.at(0);
    BC = B.at(B.size()-1);
    CC = C.at(0);

    if (AB == BB && BC == CC) cout << "YES" <<endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int n, m, p;
	cin >> n >> m;

	string s;

	vector<vector<bool>> stat(n, vector<bool>());
	for (int i = 0; i < m; i++) {
		cin >> p >> s;
		p--;

		if (stat[p].empty() or stat[p].back() == false) {
			stat[p].emplace_back(s == "AC");
		}
	}

	int n_ac = 0;
	int n_wa = 0;
	for (auto v: stat) {
		if (!v.empty() && v.back()) {
			n_ac++;
			n_wa += v.size() - 1;
		}
	}

	cout << n_ac << " " << n_wa << endl;
	return 0;
}


Measured memory_bytes: 7296
#include <cstdio>
#define MAX 10001

int main( void ){
	int n, i;
	int a[ MAX ] = {0};
	while(1){
		scanf( "%d", &n ); 
		if(!n){break;}
		for( i = 2; i <= n; i++ ){
			if( a[ i ] ){ continue; }
			for( int j = i * 2; j <= n; j += i ){
				a[ j ] = 1;
			}
		}
		for( i = n; a [ i ] || a[ i - 2 ]; i-- ){}
		printf( "%d %d\n", i - 2, i );
	}
	return 0;
}

Measured memory_bytes: 800
#include<stdio.h>

int main(void) {
    int w_num_vertical, n_num_horizontal;
    scanf("%d", &w_num_vertical);
    scanf("%d", &n_num_horizontal);

    int j, results[w_num_vertical];                                                                                
    for(j = 0; j < w_num_vertical; j++) {
        results[j] = j + 1;
    }


    int i, a, b, buf;
    for(i = 0; i < n_num_horizontal; i++) {
        scanf("%d,%d", &a, &b);
        buf = results[a - 1];
        results[a - 1] = results[b - 1];
        results[b - 1] = buf;
    }

    for(j = 0; j < w_num_vertical; j++) {
        printf("%d\n", results[j]);
    }

    return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;

int main(){
    while(1){
        int x,y,s,p_a=0,p_b=0,max=0;
        cin >> x >> y >> s;
        if (x == 0) return 0;
        for (int j = 1; j <= s - 1; j++) {
            p_a = 0;
            p_b = 0;
            for (int a = 1; a<s; a++){
                if (floor(a * (double)(100.0+x)/100) == j) p_a = a;
                if (floor(a * (double)(100.0+x)/100) == s-j) p_b = a;
                if (p_a*p_b !=0) break;
            }
            if (floor(p_a * (double)(100.0+y)/100) + floor(p_b * (double)(100.0+y)/100) > max) max = floor(p_a * (double)(100.0+y)/100) + floor(p_b * (double)(100.0+y)/100);
        }
        cout << max << endl;
    }
}

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

using ll = long long;
const ll INF = 1e18;

using ld = double;
using P = complex<ld>;
using G = vector<P>;
const ld pi = acos(-1);
const ld eps = 1e-10;

ld cross(const P& a, const P& b) { return a.real()*b.imag() - a.imag()*b.real(); }
ld dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }

/*
                    CCW

 -- BEHIND -- [a -- ON -- b] --- FRONT --

                    CW
 */
enum { CCW = +1, CW = -1, BEHIND = +2, FRONT = -2, ON = 0 };
int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if (cross(b, c) > eps)  return CCW;    // counter clockwise
    if (cross(b, c) < -eps) return CW;     // clockwise
    if (dot(b, c) < 0)      return BEHIND; // c--a--b on line
    if (norm(b) < norm(c))  return FRONT;  // a--b--c on line
    return ON;
}


namespace std {
    bool operator < (const P& a, const P& b) {
        return abs(real(a) - real(b)) > eps ? real(a) < real(b) : imag(a) < imag(b);
    }
}

G andrewScan(G ps){
    int N = ps.size(), k = 0;
    sort(ps.begin(), ps.end());
    G res(N*2);
    for(int i=0; i<N; i++) {
        while(k>=2 && ccw(res[k-2], res[k-1], ps[i])!=CCW) k--;
        res[k++] = ps[i];
    }
    int t = k+1;
    for(int i=N-2; i>=0; i--) {
        while(k>=t && ccw(res[k-2], res[k-1], ps[i])!=CCW) k--;
        res[k++] = ps[i];
    }
    res.resize(k-1);
    return res;
}

int n;
int dx[] = {-1,0,1,0};
int dy[] = {0,-1,0,1};
int x[100010], y[100010];

using pii = pair<int,int>;
set<pii> S;

G g;

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

    cin >> n;
    rep(i,n-1){
        int k,d;
        cin >> k >> d;
        x[i+1] = x[k] + dx[d];
        y[i+1] = y[k] + dy[d];
    }
    rep(i,n){
        S.emplace(x[i],   y[i]);
        S.emplace(x[i]+1, y[i]);
        S.emplace(x[i],   y[i]+1);
        S.emplace(x[i]+1, y[i]+1);
    }
    g.clear();
    for(auto &p : S) g.emplace_back(p.first, p.second);
    g = andrewScan(g);

    deque<P> a(g.begin(), g.end());
    int k = a.size();
    ld ans = INF;
    rep(i,k){
        P base = a[1] - a[0];
        base /= abs(base);
        ld min_x = +INF, max_x = -INF;
        ld min_y = +INF, max_y = -INF;
        rep(i,k){
            ld x = real(a[i]/base);
            ld y = imag(a[i]/base);
            min_x = min(min_x, x);
            min_y = min(min_y, y);
            max_x = max(max_x, x);
            max_y = max(max_y, y);
        }
        ld dx = max_x - min_x;
        ld dy = max_y - min_y;
        ans = min(ans, dx*dy);
        a.push_back(a.front());
        a.pop_front();
    }
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 25628
#include<bits/stdc++.h>
#define INF 2*1e18
using namespace std;
long long n,m,a[200100];
int main()
{
	long long ma=0,mi=INF+1;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		mi=min(mi,a[i]);
		ma=max(ma,a[i]);
	}	
	sort(a+1,a+n+1);	
	long long l=-INF,r=INF,w;
	while(r-l!=1)
	{
		w=(l+r)/2;
		long long sum=0;
		for(int i=1;i<=n;i++)
		{
			if(a[i]==0)
			{
				if(w>=0)
					sum+=n-1;	
				continue;	
			}
			long long k=w/a[i];
			if(w%a[i]!=0)
			{	
				if(w<0 && a[i]>0)
					k--;
				else if(w<0 && a[i]<0)
					k++;			
			}
			if(a[i]<0)
			{
				if(k<mi)
					sum+=n-1;
				else if(k>ma)
					sum+=0;	
				else	
				{
					sum+=(a+n+1)-lower_bound(a+1,a+n+1,k);
					if(*lower_bound(a+1,a+n+2,k)<=a[i])
						sum--;
				}
			}	
			else 
			{
				if(k>ma)
					sum+=n-1;
				else if(k<mi)	
					sum+=0;
				else	
				{
					sum+=upper_bound(a+1,a+n+1,k)-(a+1);
					if(*(upper_bound(a+1,a+n+1,k)-1)>=a[i])
						sum--;
				}	
			}	
		}
		sum/=2;
		if(sum>=m)
			r=w;
		else
			l=w;	
	}
	w=l;
	long long sum=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==0)
		{
			if(w>=0)
				sum+=n-1;
			continue;	
		}
		long long k=w/a[i];
		if(w%a[i]!=0)
		{	 
			if(w<0 && a[i]>0)
				k--;
			else if(w<0 && a[i]<0)
				k++;			
		}
		if(a[i]<0)
		{
			if(k<mi)
				sum+=n-1;
			else if(k>ma)
				sum+=0;	
			else	
			{
				sum+=(a+n+1)-lower_bound(a+1,a+n+1,k);
				if(*lower_bound(a+1,a+n+2,k)<=a[i])
					sum--;
			}
		}	
		else 
		{
			if(k>ma)
				sum+=n-1;
			else if(k<mi)	
				sum+=0;
			else	
			{
				sum+=upper_bound(a+1,a+n+1,k)-(a+1);
				if(*(upper_bound(a+1,a+n+1,k)-1)>=a[i])
					sum--;
			}	
		}	
	}
	sum/=2;
	if(sum<m)	
		cout<<r<<endl;
	else
		cout<<l<<endl;	
} 
/*
10 40
-1 -2 -3 -4 -5 -6 -7 -8 -9 0
*/

Measured memory_bytes: 1792
from itertools import accumulate
n,k = map(int, input().split())
p = list(map(int,input().split()))
b = []
for i in p:
    b.append((i+1)/2)
c = list(accumulate([0] + b))
ans = []
for j in range(len(b)-(k - 1)):
    ans.append (c[j + k] - c[j])
print(max(ans))

Measured memory_bytes: 30276
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- getl toInt
  unless (n == 0) $ do
    solve <$> replicateM n (getl $ wrds toInt) >>= mapM_ putStrLn
    main

solve :: [[Int]] -> [String]
solve = map f
  where
    f [m,e,j]
      | m == 100 || e == 100 || j == 100 = "A"
      | (m + e) >= 180 = "A"
      | (m + e + j) >= 240 = "A"
      | (m + e + j) >= 210 = "B"
      | (m + e + j) >= 150 && (m >= 80 || e >= 80) = "B"
      | otherwise = "C"

toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 4044
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    int N, W; cin>>N>>W;
    vector<int> A(N), B(N);
    REP(i, N) cin>>A[i]>>B[i];
    vector<vector<int>> dp(N+1, vector<int>(W+1));
    for(long long i=1; i<=N; i++){
        for(long long j=0; j<=W; j++){
            dp[i][j] = dp[i-1][j];
            if(j>=B[i-1]) dp[i][j] = max(dp[i][j], dp[i-1][j-B[i-1]]+A[i-1]); 
            if(j>=B[i-1]) dp[i][j] = max(dp[i][j], dp[i][j-B[i-1]]+A[i-1]);
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}


Measured memory_bytes: 6844
import std.stdio, std.string, std.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional,std.mathspecial;

void main(){
    auto abc=readln.split.array;
    if(abc[0][$-1]==abc[1][0] && abc[1][$-1]==abc[2][0])writeln("YES");
    else writeln("NO");
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, M, C;
    cin >> N >> M >> C;
    vector<ll> B(M);
    for (ll i = 0; i < M; i++) {
        cin >> B[i];
    }
    vector<vector<ll>> A(N, vector<ll>(M));
    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }

    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        ll s = C;
        for (ll j = 0; j < M; j++) {
            s += A[i][j] * B[j];
        }

        if (s > 0) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <set>
#include <math.h>
#define pai 3.14159265358979323846264338327950288;
#define keta(n) cout << fixed << setprecision((n));
using ll = long long;
int main()
{
  int n;
  cin >> n;
  int ans = 1;

  while (true) {
    if (n / 2 == 0){
      ans--;
    break;
    }
    else
    {
      n /= 2;
      ans++;
    }
  }
  cout << pow(2, ans);
}


Measured memory_bytes: 256
def solve():
    n = int(input())
    F = [input().replace(' ','') for _ in range(n)]
    P = [[int(p) for p in input().split()] for _ in range(n)]
    l = []
    for i in range(1,2**10):
        o = bin(i).replace('0b','').zfill(10)
        profit = 0
        for f,p in zip(F,P):
            count = 0
            for a,b in zip(o,f):
                if a == b == '1':
                    count += 1
            profit += p[count]
        l.append(profit)
    return max(l)

if __name__ == '__main__':
    print(solve())

Measured memory_bytes: 3064
<?php

    // AtCoder Beginner Contest 162
    // A - Lucky 7

    $n = in();

    $num = str_split($n);
    if (in_array('7', $num)) {
        yes();
    } else {
        no();
    }


    // -----------------------------------------------------
    function in() { return trim(fgets(STDIN)); }
    function in_int() { return (int)in(); }
    function in_vals() { return explode(' ', in()); }
    function in_ints() { return array_map('intval', in_vals()); }
    function out($s) { echo $s . PHP_EOL; }
    function yes() { out('Yes'); }
    function no() { out('No'); }


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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = (1 << 21);
const ll inf = 2e18;

const int mod = 924844033;
const int root_pw = 1 << 21;

ll powmod(ll a, ll b)
{
	if (!b)
		return 1;
	ll tmp = powmod(a, b / 2);
	tmp = tmp * tmp % mod;
	if (b & 1)
		tmp = tmp * a % mod;
	return tmp;
}

ll inverse(ll val)
{
	return powmod(val, mod - 2);
}

int root = 44009197, root_1 = inverse(root);

void fft(vector<int> & a, bool invert) {
    int n = a.size();

    for (int i = 1, j = 0; i < n; i++) {
        int bit = n >> 1;
        for (; j & bit; bit >>= 1)
            j ^= bit;
        j ^= bit;

        if (i < j)
            swap(a[i], a[j]);
    }

    for (int len = 2; len <= n; len <<= 1) {
        int wlen = invert ? root_1 : root;
        for (int i = len; i < root_pw; i <<= 1)
            wlen = (int)(1LL * wlen * wlen % mod);

        for (int i = 0; i < n; i += len) {
            int w = 1;
            for (int j = 0; j < len / 2; j++) {
                int u = a[i+j], v = (int)(1LL * a[i+j+len/2] * w % mod);
                a[i+j] = u + v < mod ? u + v : u + v - mod;
                a[i+j+len/2] = u - v >= 0 ? u - v : u - v + mod;
                w = (int)(1LL * w * wlen % mod);
            }
        }
    }

    if (invert) {
        int n_1 = inverse(n);
        for (int & x : a)
            x = (int)(1LL * x * n_1 % mod);
    }
}

int n, sz[maxn], cnt[maxn];
vector<int> A, B, graph[maxn];
ll fact[maxn], invfact[maxn];

ll comb(ll n, ll r)
{
	return (fact[n] * (invfact[r] * invfact[n - r] % mod) % mod);
}

void dfs(int u, int prev)
{
	sz[u] = 1;
	for (int i : graph[u])
		if (i != prev)
			dfs(i, u), sz[u] += sz[i];
}

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

	fact[0] = invfact[0] = 1;
	for (int i = 1; i < maxn; i++)
		fact[i] = fact[i - 1] * i % mod, invfact[i] = inverse(fact[i]);
	for (int i = 0; i < maxn; i++)
		A.pb(0), B.pb(0);

	cin >> n;
	int u, v;
	for (int i = 0; i < n - 1; i++)
	{
		cin >> u >> v;
		graph[--u].pb(--v);
		graph[v].pb(u);
	}

	dfs(0, -1);
	for (int i = 1; i < n; i++)
		cnt[sz[i]]++, cnt[n - sz[i]]++;

	for (int i = 0; i <= n; i++)
		A[i] = (ll)cnt[i] * fact[i] % mod;
	for (int i = 0; i <= n; i++)
		B[(1 << 19) - i] = invfact[i];
	fft(A, false);
	fft(B, false);
	for (int i = 0; i < maxn; i++)
		A[i] = (ll)A[i] * B[i] % mod;
	fft(A, true);

	for (int i = 1; i <= n; i++)
		A[(1 << 19) + i] = (comb(n, i) * n % mod - invfact[i] * A[(1 << 19) + i] % mod + mod) % mod;
	for (int i = 1; i <= n; i++)
		cout << A[(1 << 19) + i] << endl;
}



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

#define ll long long
#define mod 1000000007
#define pb push_back
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector< pi > 
#define ff first
#define ss second
const int N=200010;
ll p[N];
ll a[N],b[N],c[N],d[N],n,mx[N],mn[N];

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) cin>>p[i];
    //for(int i=1;i<=n;i++) p[i]+=p[i-1];
    set<pair<ll,int> >s, ss;
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        sum+=p[i];
        s.insert({sum,i});
        auto it =s.lower_bound({sum/2,0});
        if((abs(sum-2*it->ff)<(sum-it->ff+p[it->ss] -(it->ff-p[it->ss])))&& it->ss != i)
        {
            mx[i]=max(sum-it->ff,it->ff);
            mn[i]=min(sum-it->ff,it->ff);
        }
        else
        {
            mx[i]=max(sum-it->ff+p[it->ss],it->ff-p[it->ss]);
            mn[i]=min(sum-it->ff+p[it->ss],it->ff-p[it->ss]);
        }
    }
    sum=0;
    for(int i=n;i>=1;i--)
    {
        sum+=p[i];
        ss.insert({sum,i});
        auto it =ss.lower_bound({sum/2,0});
        if((abs(sum-2*it->ff)<(sum-it->ff+p[it->ss] -(it->ff-p[it->ss])))&&it->ss != i)
        {
            a[i]=max(sum-it->ff,it->ff);
            b[i]=min(sum-it->ff,it->ff);
        }
        else
        {
            a[i]=max(sum-it->ff+p[it->ss],it->ff-p[it->ss]);
            b[i]=min(sum-it->ff+p[it->ss],it->ff-p[it->ss]);
        }
        
    }
    ll res =mod*1000000ll;
    for(int i=2;i<=n-2;i++)
    {
        //cout<<a[i]<<" "<<b[i]<<" ";
        //cout<<max(mx[i],a[i+1])-min(mn[i],b[i+1])<<"\n";
        res=min(res,max(mx[i],a[i+1])-min(mn[i],b[i+1]));
    }
    cout<<res;
    return 0;
}

Measured memory_bytes: 34176
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    String k=gs();
	    char c=k.charAt(0);
	    c++;

	    System.out.print(String.valueOf(c));
//
//        if (k*500>=x) {
//        	System.out.print("Yes");
//        }else {
//        	System.out.print("No");
//        }


	}
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35568
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (win, osx, linux)
 * Author: step_by_step
 * Time: 2020-03-19 17:35:03
**/

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 3000 + 13;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
//const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD = 998244353;
const ld eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

inline void add(int &x, int y) {
    x += y;
    if (x >= MOD) {
        x -= MOD;
    }
}

int dp[N][N];

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n, S;
    cin >> n >> S;
    rep(i, 1, n + 1) {
        int x;
        cin >> x;
        add(dp[i][x], i);
        rep(j, 0, S + 1) {
            add(dp[i][j], dp[i - 1][j]);
            if (j - x >= 0) {
                add(dp[i][j], dp[i - 1][j - x]);
            }
        }
    }
    int ans = 0;
    rep(i, 1, n + 1) {
        add(ans, 1LL * dp[i][S]);
    }
    cout << ans << "\n";
    return 0;
}

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

class UnionFind:
    __slots__ = ["data"]
    
    def __init__(self, n=0):
        self.data = [-1]*(n+1)
    
    def root(self, x):
        if self.data[x] < 0:
            return x
        self.data[x] = self.root(self.data[x])
        return self.data[x]
    
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            if self.data[x] < self.data[y]:
                self.data[x] += self.data[y]
                self.data[y] = x
            else:
                self.data[y] += self.data[x]
                self.data[x] = y
    
    def same(self, x, y):
        return self.root(x) == self.root(y)
    
    def size(self, x):
        return -self.data[self.root(x)]
                


def main():
    n, m, k = map(int, input().split())
    friends = [0]*(n+1)
    blocks = [0]*(n+1)
    uf = UnionFind(n)
    ans = []
    for _ in range(m):
        a, b = map(int, input().split())
        friends[a] += 1
        friends[b] += 1
        uf.unite(a, b)
    for _ in range(k):
        c, d = map(int, input().split())
        if uf.same(c, d):
            blocks[c] += 1
            blocks[d] += 1
    for i, (nf, nb) in enumerate(zip(friends[1:], blocks[1:]), 1):
        ans.append(uf.size(i)-1-nf-nb)
    print(" ".join(list(map(str, ans))))


if __name__ == "__main__":
    main()

Measured memory_bytes: 16232
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int i = 1;
		int swi;

		while (i <= n) {
			int x = i;
			swi = 0;
			if (x % 3 == 0) {
				System.out.printf(" %d", i);
				swi = 1;
			}
			while (x != 0) {
				if (swi == 0) {
					if (x % 10 == 3) {
						System.out.printf(" %d", i);
						swi = 1;
					}
				}
				x = x / 10;
			}
			i++;

		}
		System.out.println();
		sc.close();
	}
}

Measured memory_bytes: 40748
#include <bits/stdc++.h>
using namespace std;
struct unionFind {
	vector<int> ps;
	unionFind(int n) : ps(n, -1) {}
	int root(int x) {
		if (ps[x] < 0)
			return x;
		else
			return ps[x] = root(ps[x]);
	}
	bool same(int x, int y) { return root(x) == root(y); }
	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return;
		if (-ps[x] < -ps[y]) swap(x, y);
		ps[x] += ps[y];
		ps[y] = x;
		return;
	}
	int size(int x) { return -ps[root(x)]; }
};
int main() {
	int n, m;
	cin >> n >> m;
	unionFind t(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		t.unite(a, b);
	}
	set<int> s;
	for (int i = 0; i < n; i++) {
		s.insert(t.root(i));
	}
	cout << (int)s.size() - 1 << endl;
	return 0;
}

Measured memory_bytes: 7564
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    W = []
    fail = False
    seen = set()
    for i in range(N):
        w = S()
        if i == 0:
            pass
        else:
            if w[0] != prev[-1]:
                fail = True
            if w in seen:
                fail = True
        seen.add(w)
        prev = w

    if fail:
        print("No")
    else:
        print("Yes")


main()



Measured memory_bytes: 78200
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
#define int long long
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

string S;
int K;

signed main() {
    //cin.tie(0); ios::sync_with_stdio(false);
    cin >> S >> K;
    int one = 0;
    rep(i, S.size()) {
        if (S[i]=='1') one++;
        else break;
    }
    if (K<=one) cout << 1 << endl;
    else cout << S[one] << endl;
}

Measured memory_bytes: 256
#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 998244353
#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_alter
const int N=1e7+5;
int pw2[N],pw3[N],fac[N],inv[N],n;
//
inline void add(int &x,int y){
	x+=y;if(x>=MOD)x-=MOD;
}	
inline void sub(int &x,int y){
	x-=y;if(x<0)x+=MOD;
}
inline int mul(int x,int y){
	ll ans=1ll*x*y;
	return ans%MOD;
}
inline int c(int x,int y){
	return mul(fac[x],mul(inv[y],inv[x-y]));
}
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(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=getint();
	fac[0]=1;
	for(int i=1;i<=n;i++)fac[i]=mul(fac[i-1],i);
	inv[n]=modinv(fac[n]);
	for(int i=n-1;i>=0;i--)inv[i]=mul(inv[i+1],i+1);
	pw3[0]=1;
	for(int i=1;i<=n;i++)pw3[i]=mul(pw3[i-1],3);
	pw2[0]=1;
	for(int i=1;i<=n;i++)pw2[i]=mul(pw2[i-1],2);
	int res=pw3[n];
	for(int i=n/2+1;i<=n;i++)sub(res,mul(c(n,i),pw2[n-i+1]));
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 156544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
int w, h;

void dfs(int x, int y, vector<vector<int>> &c) {
  if (x < 0 || y < 0 || x >= h || y >= w) {
    return;
  }
  if (c[x][y] == 0) {
    return;  // umi or seeen
  }
  c[x][y] = 0;

  for (int i = 0; i < 8; i++) {
    dfs(x + dx[i], y + dy[i], c);
  }
}
int main() {
  vector<int> ans;
  while (1) {
    cin >> w >> h;
    if (w == 0 && h == 0) {
      break;
    }
    vector<vector<int>> c(h, vector<int>(w));

    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> c[i][j];
      }
    }
    int count = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (c[i][j] == 1) {
          dfs(i, j, c);
          count++;
        }
      }
    }
    ans.push_back(count);
  }
  for (auto it = ans.begin(); it != ans.end(); it++) {
    cout << *it << endl;
  }
}


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

using namespace std;

#define len(x) int(x.size())
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef pair <int, int> pii;

int main(){
#ifdef HOME
    freopen("input.txt", "rt", stdin);
#endif //HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int n = len(s);
    vector <int> ans(n, 0);
    int idd = 0;
    while(s[idd] == 'L'){
        idd++;
    }
    if (idd != 0){
        ans[0] = idd;
    }
    int l = 0, r = 0, id = -1;
    for (int i = idd; i < n; i++){
     //   cout << l << ' ' << r << endl;
        if (l == 0 && r == 0){
            if (s[i] == 'L')
                l++;
            else
                r++;
        }
        else
        if (l == 0 && s[i] == 'R')
            r++;
        else
        if (s[i] == 'L'){
            l++;
            if (id == -1)
                id = i;
        }
        else
        if (r != 0 && l != 0 && s[i] == 'R'){
            int x = (l + r) / 2;
            if ((l + r) % 2 == 0){
                ans[id - 1] = x;
                ans[id] = x;
            }
            else{
                int k = max(l - 1, r - 1);
                int a = (l + r) / 2;
                int b = (l + r + 1) / 2;
                if (l > r) swap(a, b);
                if (k % 2 == 0)
                    swap(a, b);
                ans[id - 1] = a;
                ans[id] = b;
            }
            l = 0;
            r = 1;
            id = -1;
        }
    }
    if (id != -1){
        int x = (l + r) / 2;
        if ((l + r) % 2 == 0){
            ans[id - 1] = x;
            ans[id] = x;
        }
        else{
            int k = max(l - 1, r - 1);
            int a = (l + r) / 2;
            int b = (l + r + 1) / 2;
            if (l > r) swap(a, b);
            if (k % 2 == 0)
                swap(a, b);
            ans[id - 1] = a;
            ans[id] = b;
        }
        l = 0;
        r = 1;
        id = -1;
    }
    else{
        ans[n - 1] = r;
    }
    for (int i : ans)
        cout << i << ' ';
    return 0;
}

Measured memory_bytes: 1104
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let n = input::<usize>();
    let w = (0..n).map(|_| input()).collect::<Vec<String>>();

    let mut ok = true;
    let mut done = std::collections::HashSet::new();
    done.insert(w[0].clone());
    for i in 1..n {
        if done.contains(&w[i]) {
            ok = false;
            break;
        }
        if w[i].chars().nth(0).unwrap() != w[i - 1].chars().last().unwrap() {
            ok = false;
            break;
        }
        done.insert(w[i].clone());
    }

    let ans = if ok { "Yes" } else { "No" };
    println!("{}", ans);
}


Measured memory_bytes: 4352
import * as fs from 'fs';

function bigMax(...a: bigint[]): bigint {
  return a.reduce((prev, current) => prev > current ? prev : current);
}
function main(input) {
  input = input.split('\n');
  const [a, b, c, d]: bigint[] = input[0].split(' ').map(i => BigInt(parseInt(i)));
  console.log('%s', bigMax(a * c, a * d, b * c, b * d).toString());
}

main(fs.readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29544
import io.StdIn._

object Main extends App {
  val n = readInt

  require(2 <= n && n <= 100000)

  def isPrime(n: Int): Boolean = (2 until n).toList.forall(n % _ != 0)

  def minPrime(n: Int): Option[Int] = (n to 200000).find(isPrime)

  minPrime(n).map(println)
}


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

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

total = 0
remain = M
for x in A:
    yen, num = x
    purchase = min(num, remain)
    total += (yen * purchase)
    remain -= purchase
    if remain == 0:
        print(total)
        exit()

Measured memory_bytes: 29032
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF  2000000000
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<int, int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d); BR;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
#define SUM(a, n) accumulate(a, a+n, 0)
#define VSUM(v) accumulate(ALL(v), 0);
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))

signed main(){ INIT;
    VAR(string, a, b);
    sort(ALL(a));
    sort(ALL(b));
    reverse(ALL(b));

    if(a < b){
        Yes;
    }else{
        No;
    }
RET;}

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

int main() {
    int h, m, s;
    while (cin >> h >> m >> s && (0 <= h)) {
        int second = 7200 - (h * 3600 + m * 60 + s);
        int hh, mm, ss;
        hh = second / 3600;
        mm = (second % 3600) / 60;
        ss = second % 60;
        cout << (10 <= hh ? "" : "0") << hh << ":";
        cout << (10 <= mm ? "" : "0") << mm << ":";
        cout << (10 <= ss ? "" : "0") << ss << endl;
        second *= 3;
        hh = second / 3600;
        mm = (second % 3600) / 60;
        ss = second % 60;
        cout << (10 <= hh ? "" : "0") << hh << ":";
        cout << (10 <= mm ? "" : "0") << mm << ":";
        cout << (10 <= ss ? "" : "0") << ss << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
using System;
class Program
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int a = int.Parse(s[0]);
        int b = int.Parse(s[1]);

        Console.WriteLine("{0} {1} {2}",a/b,a%b,(decimal)a/b);
    }
}

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

const ll MAXN = 200000;

ll N, ans=0, tmp=0;

void double_factorial(ll num) {
    if(num==0||num%2==1) return;
    vector<ll> v;
    ll j = 10;
    v.push_back(0);
    while(j<=num) {
        //cout << j << endl;
        ans += num/j;
        j*=5;
    }
}

signed main(){
    cin >> N;
    double_factorial(N);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string a;
int main()
{
    cin>>a;
    int i=0;
    while(a[i]!=0){
        i++;
    }
    for(int j=0;j<i-8;j++){
        cout<<a[j];
    }
    return 0;
}


Measured memory_bytes: 256
class _Node {
  constructor(key, left = null, right = null) {
    this.key = key;
    this.left = left;
    this.right = right;
  }
}

class BinaryTree {
  constructor() {
    this.root = null;
  }

  static get Node() { return _Node; }

  insert(key) {
    this.root = new BinaryTree.Node(key);
    this.insert = (key) => {
      let x = this.root, y;
      let newNode = new BinaryTree.Node(key);
      while (x !== null) {
        y = x;
        x = x[key < x.key ? 'left' : 'right'];
      }
      y[key < y.key ? 'left' : 'right'] = newNode;
    }
  }

  find(key, n = this.root) {
    if (n === null) return false;
    if (n.key === key) return true;
    return this.find(key, n[key < n.key ? 'left' : 'right']);
  }

  printByIneorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      innerFunc(n.left);
      str += ` ${n.key}`;
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  printByPreorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      str += ` ${n.key}`;
      innerFunc(n.left);
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  print() {
    this.printByIneorder();
    this.printByPreorder();
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  const tree = new BinaryTree();
  lines.forEach(function(cmd) {
    switch(cmd.charAt(0)) {
    case 'i': tree.insert(Number(cmd.split(' ')[1])); break;
    case 'f': console.log(tree.find(Number(cmd.split(' ')[1])) ? 'yes' : 'no'); break;
    default: tree.print();
    }
  });
})();



Measured memory_bytes: 196112
// compile in C++11. use -std=c++11.
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>

// these require C++11
#include <unordered_set>
#include <unordered_map>
#include <random>

using namespace std;

#define int long long

#define all(c) c.begin(), c.end()
#define repeat(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x) 
#endif

typedef complex<double> point;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
	int n; cin>>n;
	int a[n];
	repeat(i,n){
		cin>>a[i];
	}
	unsigned long dp[110][25]={};
	dp[0][a[0]]=1;
	for(int i=1;i<n-1;i++){
		repeat(j,21){
			if(j+a[i]<=20){dp[i][j+a[i]]+=dp[i-1][j];}
			if(j-a[i]>=0) {dp[i][j-a[i]]+=dp[i-1][j];}
		}
	}
	cout<<dp[n-2][a[n-1]]<<endl;
    return 0;
}

Measured memory_bytes: 1216
n = int(input())
const = 10**5+100

a = [i for i in range(2,const+1)]
prime = []

for i in a:
    prime.append(i)

    if i > int(n**0.5):
        break

    a = [j for j in a if j % i != 0]

prime += a

ans = [i for i in a if i >= n][0]

print(ans)

Measured memory_bytes: 8600
n,m = map(int,input().split())
data = [[0,0,0] for i in range(m)]
ans = ['']*m
city = [0]*n
for i in range(m):
    data[i] = list(map(int,input().split()))+[i]
    data[i][0] -= 1
for d in sorted(data,key=lambda x:x[1]):
    city[d[0]] += 1
    ans[d[2]] = str(d[0]+1).zfill(6)+str(city[d[0]]).zfill(6)
for i in ans:
    print(i)

Measured memory_bytes: 32204
N = int(input())
A = [int(_) - 1 for _ in input().split()]
B = [int(_) for _ in input().split()]
C = [int(_) for _ in input().split()]
ans = sum(B)
for i in range(N - 1):
    if A[i] + 1 == A[i + 1]:
        ans += C[A[i]]
print(ans)

Measured memory_bytes: 3064
n,x = gets.split.map(&:to_i)
patti = [1]
sum = [1]
mid = [1]
n.times do |i|
  patti << patti[-1]*2 +1
  sum << sum[-1] * 2 + 3
  mid << sum[i] + 2
end
lv = n
ans = 0
while lv > 0
  if x == (mid[lv]-1)
    ans += patti[lv-1]
    x -= mid[lv]-1
  elsif x >= mid[lv]
    ans += patti[lv-1] + 1
    x -= mid[lv]
  else
    x -= 1
  end
  lv -= 1
  #p [lv,ans,x]
end
ans += 1 if x > 0
p ans

Measured memory_bytes: 3836
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int N = Integer.parseInt(br.readLine());
		int K = Integer.parseInt(br.readLine());
		int num = 1;
		for(int i = 0; i < N; i++){
			num = Math.min(num+K,num*2);
		}
		System.out.println(num);
	}
}

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

#define pb push_back
#define MP make_pair
#define MOD 1000000000
#define FOR(i,a,b) for(int i=(a);(i)<(b);(i)++)

typedef unsigned int UI;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<char, int> PCI;
const int mod = 1000000000 + 7;
int n , m;
map<int , int> cnt;
vector<int> dpT[4];
vector<int> parse(string s)
{
	vector<int> ans;
	int cnt = 0;
	for(int i = 0; i < s.size(); i++)
	{
		//cout << cnt << endl;
		if(s[i] == '0')
		{
			ans.pb(cnt);
			cnt = 0;
		}
		else
			cnt++;
	}
	if(cnt)
		ans.pb(cnt);

	return ans;
}
int dp(vector<int> vals)
{
	if(vals.size() == 1)
		return 0;
	dpT[0].assign(vals.size() , 0);
	dpT[1].assign(vals.size() , 0);
	dpT[2].assign(vals.size() , 0);
	dpT[3].assign(vals.size() , 0);
	//1 - Left
	//0 - Right
	//2 - Right - 1

	dpT[0][0] = vals[1];
	dpT[1][0] = vals[0];
	dpT[2][0] = vals[1] - 1;
	dpT[3][0] = 0;
	for(int i = 1; i < vals.size() - 1; i++)
	{
		dpT[0][i] = max(dpT[0][i] , dpT[2][i - 1] + vals[i + 1]);
		if(vals[i] > 1)
			dpT[0][i] = max(dpT[0][i] , dpT[1][i - 1] + vals[i + 1]);
		dpT[0][i] = max(dpT[0][i] , dpT[3][i - 1] + vals[i + 1]);

		dpT[2][i] = max(dpT[2][i] , dpT[2][i - 1] + vals[i + 1] - 1);
		if(vals[i] > 1)
			dpT[2][i] = max(dpT[2][i] , dpT[1][i - 1] + vals[i + 1] - 1);
		dpT[2][i] = max(dpT[2][i] , dpT[3][i - 1] + vals[i + 1] - 1);

		dpT[1][i] = max(dpT[1][i] , dpT[2][i - 1] + 1);
		dpT[1][i] = max(dpT[1][i] , dpT[1][i - 1] + vals[i] - 1);
		dpT[1][i] = max(dpT[1][i] , dpT[3][i - 1] + vals[i]);

		dpT[3][i] = max(max(dpT[0][i - 1] , dpT[1][i - 1]) , dpT[2][i - 1]);
		dpT[3][i] = max(dpT[3][i] , dpT[3][i - 1]);
		//cout << dpT[0][i] << " " << dpT[1][i] << " " << dpT[2][i] << endl;
	}
	return max(dpT[0][vals.size() - 2] , dpT[1][vals.size() - 2]);
}
int main()
{
	//freopen("input.txt" , "r" , stdin);
	int n;
	cin >> n;
	string s;
	cin >> s;
	string t;
	int ans = 0;
	for(int i = 0; i < s.size(); i++)
	{
		t += s[i];

		if(t.size() >= 2 && t.back() == '0' && t[t.size() - 2] == '0')
		{
			t.pop_back();
			//cout << t << endl;
			vector<int> blocks = parse(t);
			//cout << dp(blocks) << endl;
			ans += dp(blocks);
			t.clear();
		}
		if(t.size() == 1 && t[0] == '0')
			t.pop_back();
	}
	if(t.size())
	{
		//cout << t << endl;
		vector<int> blocks = parse(t);
		//cout << dp(blocks) << endl;
		ans += dp(blocks);
	}
	cout << ans;
}






Measured memory_bytes: 1800
import java.util.Scanner;

public class Main
{
    public  static  void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int sum = 0;
        int arr[] = new int[M];
        for(int i=0;i<M;i++)
        {
            arr[i] = sc.nextInt();
            sum = sum+arr[i];
        }

        if(N-sum>=0)
        {System.out.print((N-sum));}
        else
        {System.out.print(-1);}


    }
}


Measured memory_bytes: 45948