akhauriyash/Code-Regression huggingface dataset:
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
#define DD 1
#else
#define DD 0
#endif
#define Debug if(DD) printf("line %d\n",__LINE__)
#define deb(x) if(DD) cerr<<#x<<'='<<x<<endl
#define debug if(DD) printf
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void gg1(){write2(-1);exit(0);}
	void gg2(){puts("NO");exit(0);}
	
	const double eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int N=2e5+10;
	
	int dp[N+N];
	void main()
	{
		ll H=qread(),cnt=1,ans=0;
		while(H)
		{
			ans+=cnt,cnt*=2,H/=2;
		}write(ans);
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	#endif
	srand(time(0));
	mine::main();
	if(DD) cerr<<"Time: " <<1.0*clock()/CLOCKS_PER_SEC<<"s";
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <numeric>
#include <ctype.h>
#include <cstdlib>
#include <string.h>
#include <cmath>
#include <cstdio>


#define N 1000000


using namespace std;

int main()
{
	int n, input;
	vector<int> vec;

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> input;
		vec.push_back(input);
	}

	int minv = vec[0];
	int maxv = -10e09;

	for (int i = 1; i < vec.size(); i++)
	{
		maxv = max(maxv, vec[i] - minv);
		minv = min(minv, vec[i]);
	}

	cout << maxv << endl;
	

}

Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> dat(n);
    rep(i,n){
        int a,b;
        cin>>a>>b;
        dat[i]=make_pair(a,b);
    }
    sort(dat.begin(),dat.end());
    ll ans=0,now=0;
    rep(i,n){
        while(now!=m&&dat[i].second!=0){
            dat[i].second--;
            ans+=dat[i].first;
            now++;
        }
    }
    cout<<ans<<endl;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int testcase=1;
    //cin>>testcase;
    for(int p=0;p<testcase;p++){
      float x1=0,x2=0;
      double n=0;
      cin>>n;
      x1=ceil(n*100/108);
      x2=floor(n*100/108);
      if(floor(x1*1.08)==n )
      cout<<x1<<"\n";
      else if(floor(x2*1.08)==n)
      cout<<x2<<"\n";
      else
      cout<<":("<<"\n";
        
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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



int main() {
  int a, b;
  cin >> a >> b;
  if((a * b) % 2 == 1) cout << "Odd" << endl;
  else cout << "Even" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main()
{
  int s, w;
 
  cin >> s >> w;
 
if(w >= s){
  cout << "unsafe" << endl;
}
else{
  cout << "safe" << endl;
}
 
  return 0; 
}

Measured memory_bytes: 3652
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <cmath>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
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; }
const long long mod = 1e9 + 7;
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
ll dx[] = { 1, 0 , -1,  0 }, dy[] = { 0, 1, 0, -1 };
ll cb(ll a, ll b);

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

	ll cnt = 0;

	repl(i, 1, n) {
		cnt += (n - 1) / i;
	}
	
	cout << cnt;
}


ll cb(ll a, ll b) {
	ll ans = 1;
	rep(i, b) ans *= (a - i);
	rep(i, b) ans /= (b - i);

	return ans;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b;
 
  if ((a * b) % 2 == 0) {
    cout << "Even" << endl;
  } 
  else {
    cout << "Odd" << endl;
  }
}

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

for i in range(N-1):
    tm = 0 #時刻を表す
    for j in range(i, N-1):
        if tm < M[j][1]: #開通していない
            tm = M[j][1]
        elif tm % M[j][2] != 0: #発車していない
            tm += M[j][2] - (tm % M[j][2])
 
        tm += M[j][0]
 
    print(tm)
print(0)

Measured memory_bytes: 3188
let () = Scanf.scanf "%d" @@ fun n ->
  let rec aux n d p k =
    if n < p
    then k n d
    else aux (n - p) (d + 1) (26 * p) k in
  let rec solve acc n = function
    | 0 -> acc
    | d -> solve (Char.chr (Char.code 'a' + n mod 26) :: acc) (n / 26) (d - 1) in
  List.iter print_char @@ aux n 0 1 @@ solve ['\n']



Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
//setprecision(15)
#define MAX 1000000
int minf[MAX + 1];
// エラトステネスの篩
void sieve() {
	memset(minf, -1, sizeof(minf));
	for (int i = 2; i <= MAX; i++) {
		if (minf[i] != -1) continue;
		minf[i] = i;
		for (int j = i * 2; j <= MAX; j += i) {
			minf[j] = i;
		}
	}
}
int main() {
	int X; cin >> X;
	sieve();
	while (1) {
		if (minf[X] == X) {
			cout << X << endl;
			return 0;
		}
		X++;
	}
}

Measured memory_bytes: 7544
import java.util.*;
import java.io.*;

public class Main {
    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        public long[] readLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = nextLong();
            return a;
        }
    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        String s = sc.next();
        String s2 = sc.next();
        int aa = Integer.parseInt(s.concat(s2));
        int a = (int) Math.sqrt(aa);
        if(a * a == aa){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }


    }
}


Measured memory_bytes: 32672
#include <iostream>
#include <string>

void funcA() {
  std::string s;
  std::cin >> s;
  if (s[s.size() - 1] == 's') {
    std::cout << s << "es" << std::endl;
  }
  else {
    std::cout << s << "s" << std::endl;
  }
}


int main(void) {
  funcA();
  return 0;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
  
int main()
{
  ll Q,H,S,D,N;
  cin >> Q >> H >> S >> D >> N;

  S = min(min(Q*4,H*2),S);

  if(S*2<D){
    cout << S*N << endl;
  }else{
    if(N%2==0){
      cout << D*(N/2) << endl;
    }else{
      cout << D*(N/2)+S << endl;
    }
  }
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>

#define nl '\n';

using namespace std;

long long n;

int main(){

    cin >> n;

    if(n%2==0){
        cout << n;
    } else{
        cout << n*2;
    }





}

//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out

// char** arr = new char*[r];
// for(long long i = 0; i < r; i++) arr[i] = new char[c];

Measured memory_bytes: 256
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)

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

    llong X, Y;
    cin >> X >> Y;

    llong now = X;
    llong count = 1;
    while(now * 2 <= Y) {
        now *= 2;
        count += 1;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int dp[3010][3010] = {0};
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;
}
int main()
{
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++)
    {
        for (int j = 0; j < t.size(); j++)
        {
            if (s[i] == t[j])
            {
                chmax(dp[i + 1][j + 1], dp[i][j] + 1);
            }
            chmax(dp[i + 1][j + 1], dp[i + 1][j]);
            chmax(dp[i + 1][j + 1], dp[i][j + 1]);
        }
    }
    string k = "";
    int i = (int)s.size(), j = (int)t.size();
    while (i && j)
    {
        if (dp[i][j] == dp[i - 1][j])
        {
            i--;
        }
        else if (dp[i][j] == dp[i][j - 1])
        {
            j--;
        }
        else
        {
            k = s[i - 1] + k;
            i--;
            j--;
        }
    }
    cout << k << endl;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef complex<double> pnt;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, pii> pp;
typedef double ld;
typedef long double lld;
#define INF 0x3f3f3f3f // for int
#define LL_INF 0x3f3f3f3f3f3f3f3f // for ll
#define ms(x, y) memset(x, y, sizeof(x))
//coordinate compression:sort(val.begin(), val.end());
//		val.resize(unique(val.begin(), val.end()) - val.begin());
#define nl '\n'
typedef unsigned long long ull;
const lld pi = 3.14159265358979323846;
const int MOD = 1e9 + 7;

//remember to remove ios stuff if i use scanf

//printf("%05lld\n", x); --> print last 5 digits including 0's
//printf("%02d:%02d", h, m); --> time
ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll pwmd(ll b, ll exp) {
    ll ret = 1;
    while (exp > 0) {
        if (exp % 2 == 1) ret = (ret * b) % MOD;
        exp /= 2;
        b = (b * b) % MOD;
    }
    return ret;
}
//void RotateArr(int X) {
//    for (int n=0; n<X; n++) {
//        for (int i=0; i<N/2; i++) {
//            for (int j=0; j<N; j++) {
//                swap(a[i][j], a[N-i-1][j]);
//            }
//        }
//        for (int i=0; i<N; i++) {
//            for (int j=i+1; j<N; j++) {
//                swap(a[i][j], a[j][i]);
//            }
//        }
//    }
//}

/*
 * string input;
 *
 * stringstream ss(input);
 *- if the input contains '\n', separate lines with: string line; while (getline(ss, line))
 * - clear() to clear the stream
 * - >> : read smth from stringstream object ie. while (s >> word)
 */

struct pair_hash { //--> for unordered_set<pair<ll, ll>>
    //initialize the set with unordered_set<pair<ll, ll>, pair_hash>st
    inline std::size_t operator()(const std::pair<ll,ll> & v) const {
        return v.first*31+v.second;
    }
};
/* for dijkstra:
 * bool operator < (const E &other) const {
        return this->w > other.w;
    }
 */

int N; ll ans;

void solve(int tc) {

    cin >> N;
    ans = (pwmd(10, N) - pwmd(8, N) + MOD) % MOD;
    ll sub = 0;
    for (int i = 1; i <= N; i++) {
        sub = (sub + (1LL * pwmd(9, N-i) * pwmd(8, i-1))) % MOD;
    }
    sub = (2 * sub) % MOD;
    ans = (ans - sub + MOD) % MOD;
    cout << ans << nl;

}

//you should really read the stuff at the bottom

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int tc = 1; //cin >> tc;
    for (int t = 1; t <= tc; t++) solve(t);

    return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* DON'T GET STUCK ON ONE APPROACH
// Did you read the bounds?
// Did you make typos?
// Are there edge cases (N=1?)
// Are array sizes proper (scaled by proper constant, for example 2* for koosaga tree)
// Integer overflow?
// DS reset properly between test cases?
// Is using long longs causing TLE?
// Are you using floating points?
*/

Measured memory_bytes: 3632
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <iostream>
#include <cmath>
using namespace std;
int gcb(int a,int b){
    if(b==0){
        return a;
    }
    return gcb(b,a%b);
}

int main(){
    long long ans=0;
    int K;
    cin>>K;
    for(int i=1;i<=K;i++){
        for(int j=1;j<=K;j++){
            int gb=gcb(i,j);
            for(int l=1;l<=K;l++){
                ans+=gcb(gb,l);
            }
            

        }
    }
    cout<<ans;

}

Measured memory_bytes: 3192
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

map<long long int, vector<pair<long long int, long long int> >* > m;

void solv()
{
	long long int N, X, D; scanf("%lld%lld%lld", &N, &X, &D);

	if (0 == D){
		if (0 == X){
			printf("1");
		}
		else{
			printf("%lld", N + 1);
		}

		return;
	}
	if (D < 0){
		D = -D;
		X = -X;
	}

	long long int left = 0, right = 0;
	for (int i = 0; i <= N; i++){
		if (m.end() == m.find((((X*i) % D) + D) % D)){
			vector<pair<long long int, long long int> > *v = new vector<pair<long long int, long long int> >();
			m.insert(make_pair((((X*i) % D) + D) % D , v));
		}
		vector<pair<long long int, long long int> > *v = m.find((((X*i) % D) + D) % D)->second;
		v->push_back(make_pair(D*left + X*i, D*right + X*i));

		left += i;
		right += N - 1 - i;
	}
	
	long long int cnt = 0;
	for (map<long long int, vector<pair<long long int, long long int> >* >::iterator itr = m.begin(); itr != m.end(); itr++){
		sort(itr->second->begin(), itr->second->end());
		cnt += ((*itr->second)[0].second - (*itr->second)[0].first) / D + 1;
		long long int head = (*itr->second)[0].first, tail = (*itr->second)[0].second;
		for (int i = 1; i < itr->second->size(); i++){
			if (head <= (*itr->second)[i].first && (*itr->second)[i].first <= tail){
				if ((*itr->second)[i].second > tail){
					cnt += ((*itr->second)[i].second - tail) / D;
					tail = (*itr->second)[i].second;
				}
			}
			else{
				cnt += ((*itr->second)[i].second - (*itr->second)[i].first) / D + 1;
				head = (*itr->second)[i].first;
				tail = (*itr->second)[i].second;
			}
		}
	}

	printf("%lld", cnt);

	//for (map<int, vector<pair<int, int> >* >::iterator itr = m.begin(); itr != m.end(); itr++){
	//	delete itr->second;
	//	itr++;
	//}

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);
 
int main() {
int a,b,c,k;
cin >> a >> b >> c >> k;
rep(i,k){
  if(a>=b)b*=2;
  else if(b>=c)c*=2;
}
cout << ((a<b&&b<c)?"Yes":"No") << endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
const int N=100010;
int n;
char s[N];
set<int>L,R;
int ans[N];
int main(){
//	freopen("1.in","r",stdin);
    cin>>s+1;
    n=strlen(s+1);
    for(int i=1;i<=n;++i){
        if(s[i]=='L'){
            L.insert(i);
		}else{
		    R.insert(i);
		}
	}
	for(int i=1;i<=n;++i){
	    if(s[i]=='R'){
	        while(i>*L.begin())L.erase(L.begin());
	        int l=*L.begin();
	        if((l-i)&1)ans[l-1]++;
	        else ans[l]++;
		}
	}
	for(int i=n;i;--i){
	    if(s[i]=='L'){
	        while(i<*(--R.end()))R.erase(--R.end());
	        int l=*(--R.end());
	        if((i-l)&1)ans[l+1]++;
	        else ans[l]++;
		}
	}
	for(int i=1;i<=n;++i)printf("%d ",ans[i]);
	puts("");
	return 0;
}

Measured memory_bytes: 5632
#include <stdio.h>

int main(){
  char input_data, output_data[128];
  output_data['A'] = 'T';
  output_data['G'] = 'C';
  output_data['C'] = 'G';
  output_data['T'] = 'A';

  scanf("%c", &input_data);

  printf("%c\n", output_data[input_data]);

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 2e+5+10;

struct edge{
	int x,nxt,v;
}e[N*3];
int h[N],tot;
int n;
int sona[N],sonb[N];
int val[N];
multiset<int>s[N];

void inse(int x,int y){s[x].insert(y);}

void addedge(int x,int y){inse(x,y);inse(y,x);}

void euler(int x){
	for(;s[x].begin()!=s[x].end();){
		int y=(*s[x].begin());
		if (x<=n&&y>n&&y<=n*2)val[x]=1;
		if (x>n&&x<=2*n&&y<=n)val[x-n]=-1;
		s[y].erase(s[y].find(x));
		s[x].erase(s[x].find(y));
		euler(y);
	}
}

int main(){
	n=get();
	tot=1;
	int rta,rtb;
	fo(i,1,n){
		int x=get();
		if (x!=-1){
			sona[x]++;
			addedge(x,i);
		}
		else rta=i;
	}
	fo(i,1,n){
		int x=get();
		if (x!=-1){
			sonb[x]++;
			addedge(i+n,x+n);
		}
		else rtb=i;
	}
	bool ans=1;
	fo(i,1,n)
	if (sona[i]%2!=sonb[i]%2){ans=0;break;}
	if (!ans){
		printf("IMPOSSIBLE\n");
		return 0;
	}
	fo(i,1,n)if (sona[i]%2==0)addedge(i,n+i);
	addedge(n*2+1,rta),addedge(n*2+1,rtb+n);
	euler(1);
	printf("POSSIBLE\n");
	fo(i,1,n)printf("%d ",val[i]);
	putchar('\n');
	return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

struct Height {
  int x, y, z;
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int w, d, n; cin >> w >> d >> n;
  vector<vector<int>> grid(w, vector<int>(d, -INF));

  vector<Height> v(n);
  for(int i=0;i<n;++i) {
    cin >> v[i].x >> v[i].y >> v[i].z;
    v[i].x--;
    v[i].y--;
  }

  bool ok = true;
  for(int i=0;i<n;++i) {
    for(int j=i+1;j<n;++j) {
      ok &= abs(v[i].z - v[j].z) <= abs(v[i].x - v[j].x) + abs(v[i].y - v[j].y);
    }
  }
  if(!ok) {
    cout << "No" << endl;
    return 0;
  }

  for(int i=0;i<n;++i) {
    for(int j=0;j<w;++j) {
      for(int k=0;k<d;++k) {
        grid[j][k] = max(grid[j][k], v[i].z - abs(v[i].x - j) - abs(v[i].y - k));
      }
    }
  }

  ll su = 0;
  for(int i=0;i<w;++i) {
    for(int j=0;j<d;++j) {
      su += grid[i][j];
    }
  }
  cout << su << endl;
}


Measured memory_bytes: 3248
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cout << v << " ";                                                          \
  }                                                                            \
  cout << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

vec< vec< int > > sum;
bool isOK(int index, int from) {
  bool check = true;
  REP(j, 20) { check = check && (sum[index + 1][j] - sum[from][j] <= 1); }
  return check;
}

signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vec< int > a(N);
  REP(i, N) cin >> a[i];

  sum.assign(N + 2, vec< int >(20, 0));
  REP(i, N) {
    REP(j, 20) {
      if (a[i] & BIT(j)) {
        sum[i + 1][j] = sum[i][j] + 1;
      } else {
        sum[i + 1][j] = sum[i][j];
      }
    }
  }
  REP(j, 20) { sum[N + 1][j] = INF; }

  int ans = 0;
  int prevl;
  REP(i, N) {

    //初期値は異なる。
    int left = i;
    int right = N;
    while (right - left > 1) {
      int mid = (left + right) / 2;
      // left trueの場合
      if (isOK(mid, i))
        left = mid;
      else
        right = mid;
    }

    prevl = left;
    ans += left + 1 - i;
  }
  print(ans);
}

Measured memory_bytes: 40832
#include<bits/stdc++.h>
typedef long long int LL;
using namespace std;
int n, a, b, c, d, up, down;
int main(){
	bool ans = false;
	cin>>n>>a>>b>>c>>d;
	if(c == 0){
		if(abs(a - b) <= d * LL(n - 1))
	 		ans=1;
	 	else 
	 		ans=0;
	}
	else{
		for(up = 0; up < n; ++ up){
			down = n - 1 - up;
			if(a + LL(up - down) * c - down * LL(d - c) <= b) 
				if(b <= a + LL(up - down) * c + up * LL(d - c))
					ans = true;
		}
	} 
	if(ans==1)	cout<<"YES";
	else cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

int main() {
    ll n,l,p=1,m,c=0,i; m=pow(10,18); cin>>n; ll a[n];
    for(i=0;i<n;i++) {cin>>a[i]; if (a[i]==0) {c++;}}
    if (c>0) {cout<<0; return 0;}
    for(i=0;i<n;i++)
    {
        if (a[i]<=m/p) {p*=a[i];}
        else {cout<<-1; return 0;}
    }
    cout<<p;
    return 0;
}

Measured memory_bytes: 4380
X=chomp(readline())[1]
#println("X=$X")
#println(typeof(X))
L="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#println("L=$L")
#println(typeof(L))
#s="abcdefghijklmnopqrstuvwxyz"

if X in L
  println('A')
else
  println('a')
end


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

#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
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;
}

const long long INF = 1LL << 60;

const double PI = acos(-1.0);

// long long積のオーバーフロー検出
bool detect_mul_overflow(ll a, ll b)
{
    return a >= LONG_MAX / b;
}

int lcm(int a, int b)
{
    //最小公倍数
    return a / __gcd(a, b) * b;
}

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

// int型の2次元配列(3×4要素の)の宣言
// vector<vector<int>> data(3, vector<int>(4));


string S,T;

int main()
{
    cin>>S>>T;
    ll ans=0;
    ll len=S.length();
    rep(i,len){
        if(S[i]!=T[i]){
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3892
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q,K,R,W,H,P,L;
string S,T;
ll ans[101010];
ll x[101010];
ll y[101010];
ll a[101010];
ll b[101010];
ll c[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(int to, int cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;
ll outnum[101010];
ll innum[101010];


int main() {
	rep(i,0,3){
		cin>>a[i]>>b[i];
		x[a[i]]++;
		x[b[i]]++;
	}
	ll count1=0;
	ll count2=0;
	rep(i,1,5){
		if(x[i]==1)count1++;
		if(x[i]==2)count2++;
	}
	if(count1==2 && count2==2){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};


int A,B,C;


int main() {
	cin>>A>>B>>C;
	if(A+B>=C) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)


int f(const char c, const string s, int i) {
    int n = s.size();
    if (count(s.begin(), s.end(), c) == n)
        return i;
    
    string t = "";
    rep(i, n - 1) {
        if (s[i] == c || s[i + 1] == c) t += c;
        else t += s[i];
    }
    return f(c, t, i + 1);
}

int main() {
    string s;
    cin >> s;
    int ans = 114514;
    for (char c = 'a'; c <= 'z'; c++) if (count(s.begin(), s.end(), c) != 0) {
        ans = min(ans, f(c, s, 0));
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;

int main(){
	double tot = 0,alfa = 90,x=0,y=0;
	int m,t;
	while(scanf("%d,%d",&m,&t),m || t){
		//alfa += t;
		x += m*cos(alfa*3.1416/180.0);
		y += m*sin(alfa*3.1416/180.0);
		alfa -= t;
	}
	x = (int)x;
	y = (int)y;
	cout<<x<<endl;
	cout<<y<<endl;
	return 0;
}

Measured memory_bytes: 1272
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count etc.
#include <cstdlib>	// require abs
#include <cstdio>	// require printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require sqrt ceil floor
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <stdint.h>	// require uint64_t
#include <fstream>	// require freopen

using namespace std;

typedef pair <pair<int, int>, string > ITEM;	// ACeÌd³AACeÌãÉu¯éd³ÌãÀAACe¼

//int memo[10][10];		// s: ACe¼ ñ:½iÚ© -1: Ü¾ãÉÏßé©Ç¤©¢èA0:ÏßÈ¢ 1: Ïßé
vector <ITEM> list;
int N;
int minG;
vector <int> minorder;
int total;

int getG (vector <int> order )
{
	int res = 0;

	for (int i = 0; i < order.size(); ++i ){
		res += (i+1)*(list[order[i]].first.first);
	} // end for

	return res;
}

void bt (vector <int> & order, int curr )
{
	if (curr == N ){
		int currG = getG (order );
		if (currG < minG ){
			minorder = order;
			minG = currG;
		} // end if
		return;
	} // end if

//	if (order[curr] != -1 && memo[order[curr]][curr] == 0 ){
//		return;
//	} // end if

//	if (order[curr] == -1 ){
	vector <bool> used (N, false );
	for (int i = 0; i < curr; ++i ){
		used[order[i]] = true;
	} // end if

	for (int i = 0; i < N; ++i ){
		if (!used[i] ) {
			order[curr] = i;
			int curr_w = total;
			for (int j = 0; j <= curr; ++j ){
				curr_w -= list[order[j]].first.first;
			} // end for
			if (curr_w <= list[order[curr]].first.second ){
	//			memo[order[curr]][curr] = 1;
				bt (order, curr + 1 );
	//		}else{
	//			memo[order[curr]][curr] = 0;
			}// end if
			order[curr] = -1;
		} // end if
	} // end for
}

void init (int n )
{
	N = n;
	list.clear();
	list.resize(n);
	minorder.clear();
	minorder.resize(n);
	total = 0;
	minG = INT_MAX;
//	memset (memo, -1, sizeof(memo) );
}	

int main()
{
//	cut here before submit 
//	freopen ("testcase.lunch", "r", stdin );
	int n;

	while (cin >> n && n ){
		init (n );
		for (int i = 0; i < n; ++i){
			cin >> list[i].second;
			cin >> list[i].first.first;	// w
			cin >> list[i].first.second;	// s
			total += list[i].first.first; 
		} // end for
		vector <int> order(n, -1 );

		bt (order, 0 );

		for (int i = 0; i < n; ++i ){
			cout << list[minorder[i]].second << endl;
		} // end for

	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
N,M = map(int,input().split())
demand = [list(map(int,input().split())) for _ in range(M)]
demand = sorted(demand,key=lambda x:(x[0],x[1]))
ans = M
for i in range(M):
    a = demand[i][0]; b = demand[i][1]
    if i == 0:
        l = a; r = b
        continue
    if a < r:
        l = a
        if b < r:
            r = b
        ans -= 1
    else:
        l = a; r = b
print(ans)

Measured memory_bytes: 36200
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,n;
  cin >> k >> n;
  int a[n];
  int d=0,e;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(d<a[i]){
      d=a[i];
      e=i;
    }
  }
  cout << max(a[e]- 1 -(k-a[e]),0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int const nax = 2e6 + 10;
const int mod=1000000007;//
void plusle (int &a, int b) {
    if (( a += b) >= mod ) a -= mod ;
}
void minun (int &a, int b) {
    if ((a -= b) < 0) a += mod ;
}
int add (int a, int b) {
    return (( a += b ) >= mod ) ? a - mod  : a;
}
int sub (int a, int b) {
    return (( a -= b) < 0) ? a + mod : a;
}
int mul (int a, int b) {
    return 1LL * a * b % mod;
}
int power (int a, int b) {
    int res = 1;
    for (; b > 0 ; b >>= 1 , a = mul(a, a))
        if (b & 1) res = mul(res, a);
    return res ;
}

const int Mx = 2e6 + 10;
int fac[Mx], invf[Mx] ;
void prefact () {
    fac[0] = 1 ;
    for (int i = 1 ; i < Mx ; i ++) {
        fac[i] = mul(fac[i - 1], i);
    }
    invf[Mx - 1] = power (fac[Mx - 1] ,  mod - 2 );
    for (int i = Mx - 2 ; i >= 0 ; i --) {
        invf[i] = mul(invf[i + 1], i + 1);
    }
}

int ncr (int N, int R) {
    if (R > N) return 0;
    if (R == 0 || R == N) return 1;
    return mul (fac[N], mul(invf[N - R], invf[R]));
}


int k;
char s[nax];

int main () {
    prefact();
    scanf("%d", &k);

    scanf("%s", s + 1);

    int n = strlen(s + 1);


    int ans = 0;
  	int x = 1;
    for (int i = 0 ; i <= k ; ++ i) {
        plusle(ans, mul(ncr(n + k, i), x));
      	x = 1LL * x * 25 % mod;
    }

    printf("%d\n", ans);
}


Measured memory_bytes: 20328
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x=0; char ch=gc(); bool positive=1;
	for (;!isdigit(ch);ch=gc())if(ch=='-')positive=0;
	for (;isdigit(ch);ch=gc())x=x*10+ch-'0';
	return positive?x:-x;
}
inline void write(int a){
    if(a>=10)write(a/10);
	putchar('0'+a%10);
}
inline void writeln(int a){
	if(a<0){
		a=-a; putchar('-');
	}
	write(a); puts("");
}
const int N=3,mod=1000000007;
struct matrix{
	int a[N][N];
	inline int* operator [] (int x){
        return a[x];
    }
	void clear(){
    	memset(a,0,sizeof(a));
	}
}zs,ans,md;
matrix operator *(matrix a,matrix b){
	matrix tmp; tmp.clear();
	for(int i=0;i<3;i++){for(int k=0;k<3;k++){
		
			for(int j=0;j<3;j++){
				tmp[i][j]=(tmp[i][j]+(ll)a[i][k]*b[k][j])%mod;
			}
		}
	}
	return tmp;
}
matrix ksm(matrix zs,int k){
	matrix ans; ans.clear(); for(int i=0;i<3;i++)ans[i][i]=1;
	for(;k;k>>=1){
		if(k&1)ans=ans*zs;
		zs=zs*zs;
	}
	return ans;
}
int n,m,a[100005];
int main(){
	n=read(); m=read();
	for(int i=1;i<=m;i++)a[i]=read()+1;
	zs[0][0]=1; zs[0][1]=2;
	zs[0][2]=1; zs[1][1]=1; zs[1][2]=1;
	zs[2][0]=1; zs[2][1]=2; zs[2][2]=2;
	md=zs; md[2][0]=md[2][1]=0; md[2][2]=1;
	for(int i=0;i<3;i++)ans[i][i]=1;
	for(int i=1;i<=m;i++){
		ans=ans*ksm(zs,a[i]-a[i-1]-1);
		ans=ans*md;
	}
	//cout<<ans[0][0]<<" "<<ans[0][1]<<" "<<ans[0][2]<<endl;
	ans=ans*ksm(zs,n-a[m]);
	cout<<ans[0][2]<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll K;
    cin >> K;
    //全体がN-1=49以下となるのを目標とする
    //50回ごとに全体-1となるとしてよい
    ll x, y;
    x = K / 50;
    y = K - 50 * x;
    putout(50);
    vec ans(50);
    loop(i, y) ans[i] = x + (100 - y);
    loop(i, 50 - y) ans[y + i] = x + (49 - y);
    loop(i, 50)
    {
        cout << ans[i];
        if (i != 49)
            cout << " ";
        else
            putout("");
    }
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
	int n;string s;
	cin>>n>>s;
	int ans = 0;
	for(int i=0;i<n;i++){
		set<char> s1,s2;
		int cur=0;
		for(int j=0;j<=i;j++){
			s1.insert(s[j]);
		}
		for(int j=i+1;j<n;j++){
			s2.insert(s[j]);
		}
		for(auto x:s1){
			cur+=s2.count(x);
		}
		ans = max(ans,cur);
	}
	cout<<ans;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;cin>>s;
  ll ans=0,ans_=0; 
  vector<ll> v(s.length(),0);
  rep(i,s.length()) 
    if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T') v[i]+=1;
  rep(i,s.length()) {
    if(v[i]==1) ans_+=1;
    else {
      if(ans_>ans) ans=ans_;
      ans_=0;
    }
  }
  if(ans_>ans) ans=ans_;
  print(ans);
  return 0;
}

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

int main(void) {
	int N, M;
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	N = atoi(ch);
	ch = strtok(NULL, " ");
	M = atoi(ch);

	if(M + N >= 10) {
		printf("error\n");
	} else {
		printf("%d\n", M + N);
	}

	return 0;
}


Measured memory_bytes: 2108
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	for (string s; cin >> s&&s != "0";) {
		int a = 0, b = 0;
		rep(i, 1, s.size()) {
			if (s[i] == 'A')a++;
			else b++;
		}
		if (a > b)a++; else b++;
		cout << a << " " << b << endl;
	}
	return 0;
}

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

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, w;
    cin >> n >> w;
    vector<int> weight(n+1), value(n+1);
    vector<vector<int>> memo(n+1, vector<int>(w+1, 0));
    for(int i = 1; i <= n; ++i) {
        cin >> weight[i] >> value[i];
        for(int j = 0; j <= w; ++j) {
            memo[i][j] = max(memo[i][j], memo[i-1][j]);
            if(j-weight[i] >= 0)
                memo[i][j] = max(memo[i][j], value[i]+memo[i-1][j-weight[i]]);
        }
    }
    cout << memo[n][w] << '\n';
    return 0;
}


























Measured memory_bytes: 80256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;
using ll = long long;

int main() {
	string s;
	cin >> s;
	int c = 0;
	if (s[0] == s[1])c++;
	if (s[0] == s[2])c++;
	if (s[0] == s[3])c++;
	if (s[1] == s[2])c++;
	if (s[1] == s[3])c++;
	if (s[2] == s[3])c++;

	if (c == 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)

//#include <bits/stdc++.h>
//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
#define MOD 1000000007

#define pb push_back
#define fir first
#define scn second

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
bool ans[1000];
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}

int main() { 
  int N;cin>>N;
  string S;cin>>S;
  for(int i = 0; 1000 > i; i++){
    int nw = 100;
    for(int j = 0; N > j; j++){
      if((i/nw)%10 == S[j]-'0'){
        nw /= 10;
        if(nw == 0){
          ans[i] = true;
          break;
        }
      }
    }
  }
  int anss = 0;
  for(int i = 0; 1000 > i; i++){
    if(ans[i])anss++;
  }
  cout << anss << endl;

}




Measured memory_bytes: 384
import sys
(n, m) = list(map(int, input().split()))

ab = []
bn = {}
for i in range(m):
    tmp = list(map(int, input().split()))
    if tmp[0] == 1:
        ab.append(tmp[1])
    elif tmp[1] == n:
        bn[tmp[0]] = 1
for i in ab:
    if i == n:
        print('POSSIBLE')
        sys.exit(0)
    elif i in bn:
        print('POSSIBLE')
        sys.exit(0)

print('IMPOSSIBLE')

Measured memory_bytes: 18552
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double PI = 3.14159265358979323846;
template <class T, class U>
void chmin(T& t, const U& u) {
  if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
  if (t < u) t = u;
}

int main(void) {
  int n;
  string s;
  cin >> n >> s;
  bool find[1009] = {false};
  rep(i, 1000) {
    int pos = 0;
    int d[] = {i / 100, (i % 100) / 10, i % 10};
    int dpos = 0;
    while (pos < n) {
      if (d[dpos] + '0' == s[pos]) dpos++;
      pos++;
    }
    if (dpos > 2) find[i] = true;
  }
  int res = 0;
  rep(i, 1000) if (find[i]) res++;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3604
/* https://codeforces.com/contest/1360/problem/H */
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;
using ld = double;

#define f first
#define s second 
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define pb push_back
#define	lb lower_bound
#define	ub upper_bound
#define	sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert

const int MAX = INT_MAX;

int main() {
	int x, y;
	cin>>x>>y;

	for (int i = 0;i <= x;i++) {
		int j =  x - i;
		if ((i*2 + j*4) == y) {
			cout<<"Yes"<<endl;
			return 0;
		}

		if ((i*4 + j*2) == y) {
			cout<<"Yes"<<endl;
			return 0;
		}
	}

	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3628
N = input()
K = int(input())

memo = [[[0 for _ in range(4)] for _ in range(2)] for _ in range(len(N))]

N_size = len(N)

def dfs(i=0,small=0,k = K):
    if k == 0: return 1
    if i > N_size - 1: return 0
    if memo[i][small][k] > 0: return memo[i][small][k]

    ret = 0
    dgt = int(N[i])

    if small == 1:
        ret += dfs(i+1,1,k-1) * 9
        ret += dfs(i+1,1,k)
    else:
        if dgt == 0:
            ret += dfs(i+1,0,k)
        else:
            ret += dfs(i+1,1,k)
            ret += dfs(i+1,1,k-1) * (dgt-1)
            ret += dfs(i+1,0,k-1)

    memo[i][small][k] = ret
    return ret

print(dfs())


Measured memory_bytes: 3064