akhauriyash/Code-Regression huggingface dataset:
//BISMILLAHIR RAHMANIR RAHIM
//RHYTHM_086_NS_01
//ALAN_IS_ON....

#include <bits/stdc++.h>

#define     boost_              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define     iter_(i,n)          for (int i = 0; i < int(n); i++)
#define     for_n(i, n)         for (int i = 1; i <= int(n); i++)
#define     pb                  push_back
#define     mp                  make_pair
#define     itr                 ::iterator
#define     s_sort(s)           sort(s.begin(),s.end())
#define     n_sort(a)           sort(a,a+n)
#define     thank_you           return 0
#define     precise_impact      cout<<setprecision(10)<<fixed;

using namespace std;

typedef long long int ll;
typedef double db;
#define MOD 1000000007

ll bigmod(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll tm=bigmod(a,b/2);
    tm=(tm*tm)%MOD;
    if(b%2==1)
        tm=(tm*a)%MOD;
    return tm;

}
void solve();


int main()
{
    boost_;
    precise_impact;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Here we go...
    solve();

    thank_you;
}


void solve()
{
    ll n;
    cin>>n;
	ll a[n];
	ll b=0;
	iter_(i,n){
		cin>>a[i];
		b+=a[i];
	}
	b/=n;
	ll res=MOD;
	for (ll i=-1;i<=1;i++) {
		ll car=0;
		iter_(j,n){
			car+=(a[j]-(b+i))*(a[j]-(b + i));
		}
		res=min(res,car);
	}
	cout<<res<<endl;

}



Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<set>
#include<cstring>
#include<algorithm>
#include<cmath>
#define max_n
using namespace std;
typedef long long ll;
int a[100000+20],b[100000+20]={0};

int main ()
{
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(i>0&&a[i]==a[i-1])
		{
			n--;
			i--;
		}
	}
	int ans=1;
	for(i=1;i<n-1;i++)
	{
	//	printf("%d\n",i);
		if(a[i-1]>a[i]&&a[i+1]>a[i])
			ans++,i++;
		else if(a[i-1]<=a[i]&&a[i+1]<a[i])
			ans++,i++;
		else
			continue;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

vector<int> v;
ll memo[123456][66];
bool done[123456][66];

ll comb(int n, int k){
	if(done[n][k]){
		return memo[n][k];
	}
	done[n][k] = true;
	if(k == 0 || k == n){
		memo[n][k] = 1ll;
		return memo[n][k];
	}
	memo[n][k] = (comb(n-1,k)+comb(n-1,k-1))%MOD;
	return memo[n][k];
}

int main(void){
	int n,i,c;
	ll m,x,p=2ll,ans=1ll;
	fill(done[0],done[123456],false);
	cin >> n >> m; x = m;
	while(p*p <= m){
		c = 0ll;
		while(!(x%p)){
			++c;
			x /= p;
		}
		if(c){
			v.push_back(c);
		}
		++p;
	}
	if(x > 1ll){
		v.push_back(1ll);
	}
	for(i=(v.l_ength()-1); i>=0; --i){
		mul_mod(ans,comb(n+v[i]-1,v[i]));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 66304
#include <iostream>
int flag[26];
int main(void){
	std::string S;
	std::cin >> S;
	int Slen = S.size();
	int i;
	for(i=0;i<Slen;i++){
		flag[S[i]-'a']++;
	}
	for(i=0;i<Slen;i++){
		if(flag[i]>1){
			std::cout << "no";
			return 0;
		}
	}
	std::cout << "yes";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
using itn = int;
template<class T>
using vec = vector<T>;

#define FOR(i,a,b) for(int i=((int)(a));i<((int)(b));i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define all(x) (x).begin(),(x).end()

int main(){
  itn n,k;
  cin >>n >>k;
  vec<int> a(n);
  REP(i,n) cin >>a[i];

  vec<int> num(n+1,0);
  REP(i,n) ++num[a[i]];
  sort(all(num));
  itn ans=0;
  REP(i,n+1){
    if(n-i < k) break;
    ans += num[i];
  }

  cout <<ans <<endl;
}


Measured memory_bytes: 1792
unittest
{
	assert( [ "5 7 9" ].parse.expand.solve == "win" );
	assert( [ "13 7 2" ].parse.expand.solve == "bust" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	return ( as.sum <= 21 ) ? "win" : "bust";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,x,y,w,k,p,now;
long long fi[1000001],ne[1000001],la[1000001],q[2000001],a[1000001],b[1000001],dis[100001];
int bo[100001];
char s[110][110];
void add(int x,int y,int z)
{
	a[++k]=y; b[k]=z;
	if (!fi[x]) fi[x]=k; else ne[la[x]]=k;
	la[x]=k;
}
void spfa(int x)
{
	for (int i=0;i<=n*m;i++) dis[i]=1e9;
	dis[x]=0;
	int h=0,t=1;
	q[1]=x;
	while (h<t)
	{
		now=q[++h];
		bo[now]=0;
		p=fi[now];
		while (p)
		{
			if (dis[now]+b[p]<dis[a[p]])
			{
				dis[a[p]]=dis[now]+b[p];
				if (!bo[a[p]]) q[++t]=a[p],bo[a[p]]=1;
			}
			p=ne[p];
		}
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%s",s[i]+1);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
		{
			x=(i-1)*m+j;
			if (j<m)
			{
				if (s[i][j]=='.'&&s[i][j+1]=='#') add(x,x+1,1);
		        	else add(x,x+1,0);
			}
			if (i<n)
			{
				if (s[i][j]=='.'&&s[i+1][j]=='#') add(x,x+m,1);
		        	else add(x,x+m,0);
			}
		}
	if (s[1][1]=='#') add(0,1,1); else add(0,1,0);
	spfa(0);
	printf("%d",dis[n*m]);
} 

Measured memory_bytes: 10752
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    string s;
    cin >> s;

    ll cnt = 0;
    ll ans = 0;
    rep(i, s.size()) {
        if(s[i] == 'B') {
            cnt++;
        }
        else {
            ans += cnt;
        }
    }

    out(ans);
    re0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main()
{
	int A, B;
	char op;
	cin >> A >> op >> B;
	if (op == '+') cout << A + B << endl;
	else cout << A - B << endl;	
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    A = list(map(int, input().split()))
    lim = 10**18

    ret = 1
    if A.count(0)>0:
        ret = 0
    else:
        for a in A:
            ret *= a
            if ret > lim:
                ret = -1
                break
    print(ret)

if __name__ == '__main__':
    main()

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

int main()
{
string s;
cin>>s;

long long sum =0;

for(int i=0;i<s.length();i++)
{
sum += (s[i] -'0');
sum = (sum%9);
}

if(sum%9==0)
cout<<"Yes";
else
cout<<"No";

return 0;
}

Measured memory_bytes: 3732
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int N;
vector<int>A, B, C;

int main(void)
{
	cin >> N;
	for (int i = 0; i < N; ++i) {
		int tmp; cin >> tmp;
		A.push_back(tmp);
	}
	for (int i = 0; i < N; ++i) {
		int tmp; cin >> tmp;
		B.push_back(tmp);
	}
	for (int i = 0; i < N; ++i) {
		int tmp; cin >> tmp;
		C.push_back(tmp);
	}
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());
	vector<LL>imos(N + 1);
	for (int i = 0; i < N; ++i) {
		imos[i + 1] = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
	}
	for (int i = 0; i < N; ++i) {
		imos[i + 1] += imos[i];
	}
	LL ans = 0;
	for (int i = 0; i < N; ++i) {
		int itr = lower_bound(B.begin(), B.end(), C[i]) - B.begin();
		ans += (LL)imos[itr];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2424
#include <iostream>
#include <numeric>
#include <algorithm>
#include <vector>

bool solve() {
    int n, m, h, k;
    std::cin >> n >> m >> h >> k;
    if (n == 0) return false;

    std::vector<int> ss(n, 0);
    for (auto& s : ss) std::cin >> s;

    std::vector<std::vector<int>> lines(h - 1);
    while (m--) {
        int a, b;
        std::cin >> a >> b;
        lines[--b].push_back(--a);
    }

    std::vector<int> ps(n);
    std::iota(ps.begin(), ps.end(), 0);

    for (const auto& vs : lines) {
        for (auto v : vs) {
            std::swap(ps[v], ps[v + 1]);
        }
    }

    auto calc = [&]() {
        int sum = 0;
        for (int i = 0; i < n; ++i) {
            if (ps[i] < k) sum += ss[i];
        }
        return sum;
    };

    int ans = calc();

    std::reverse(lines.begin(), lines.end());
    for (const auto& vs : lines) {
        for (auto v : vs) {
            std::swap(ps[v], ps[v + 1]);
            ans = std::min(ans, calc());
            std::swap(ps[v], ps[v + 1]);
        }

        for (auto v : vs) {
            std::swap(ps[v], ps[v + 1]);
            std::swap(ss[v], ss[v + 1]);
        }
    }

    std::cout << ans << "\n";
    return true;
}

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

    while (solve()) {}

    return 0;
}



Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define ll long long

#define TASKNAME ""

using namespace std;

const int INF = 1e9 + 7;
const int MAXN = 1e6 + 7;
const double EPS = 1e-8;

int main() {
    #ifdef MY
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #else
        //freopen(TASKNAME".in", "r", stdin);
        //freopen(TASKNAME".out", "w", stdout);
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // MY
    ll n, a, b;
    cin >> n >> a >> b;
    if (a + b - 1 > n) {
        cout << -1;
        return 0;
    }
    if (n > a * b) {
        cout << -1;
        return 0;
    }
    vector <queue <int> > q;
    for (int i = 0; i < n; i += a) {
        queue <int> nq;
        q.push_back(nq);
        for (int j = 0; j < min(n - i, a); j++) {
              q.back().push(n - i - j);
        }
    }
    //cout << ost << "\n";
    int ost = b - q.size();
    //cout << ost << "\n";
    vector <vector <int> > last(1);
    bool fl = false;
    while (ost) {
        if (!fl) {
            ost++;
        }
        fl = true;
        int v = q.back().front();
        q.back().pop();
        //cout << v << " ";
        last.back().push_back(v);
        ost--;
        if (!q.back().size()) {
            q.pop_back();
            last.push_back({});
            fl = false;
        }
    }
    for (int i = 0; i < q.size(); i++) {
        vector <int> mas;
        while (!q[i].empty()) {
            mas.push_back(q[i].front());
            q[i].pop();
        }
        reverse(mas.begin(), mas.end());
        for (int x : mas) {
            cout << x << " ";
        }
    }
    for (int i = (int) last.size() - 1; i >= 0; i--) {
        for (int x : last[i]) {
            cout << x << " ";
        }
    }
    cout << "\n";
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> a >> b >> h;
    MSG((a + b) * h / 2)
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

template<typename T> bool chmax( T &a, const T &b ) { if ( a <= b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, const T &b ) { if ( a >= b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


int main()
{
	string S;
	cin >> S;

	map<char, int> m;

	rep( i, 4 )
	{
		m[S[i]]++;
	}

	arep( it, m )
	{
		if ( it.second != 2 )
		{
			cout << "No" << endl;
			return ( 0 );
		}
	}

	cout << "Yes" << endl;

	return ( 0 );
}


Measured memory_bytes: 888
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << "[" << pa.first << ", " << pa.second << "]";
}

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  os << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "}";
  return os;
}

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

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

  ll n,m;
  std::cin>>n>>m;

  std::vector<ll> a(m),c(m,0);

  rep(i,0,m){
    ll b;
    std::cin>>a[i]>>b;
    rep(j,0,b){
      ll temp;
      std::cin>>temp;
      c[i]+=1ll<<(temp-1);
    }
  }

  std::vector<std::vector<ll>> dp(m+1,std::vector<ll>(1ll<<n,1e11));

  dp[0][0]=0;

  rep(i,1,m+1){
    rep(j,0,1<<n){
      if((c[i-1]|j)!=j){
        dp[i][j]=dp[i-1][j];
      }else{
        ll min=dp[i-1][j];
        for(ll bit=j;bit>0;bit=(bit-1)&j){
          if((bit|c[i-1])==j)min=std::min(min,dp[i-1][bit]+a[i-1]);
        }
        if(c[i-1]==j)min=std::min(min,a[i-1]);
        dp[i][j]=min;
      }
    }
  }

  if(dp[m][(1ll<<n)-1]!=1e11)std::cout<<dp[m][(1ll<<n)-1];
  else std::cout<<-1;

  return 0;
}

Measured memory_bytes: 32384
// Contest.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include"iostream"
#include"string"
#include"vector"
#include"algorithm"

using namespace std;

int main()
{
	/*int n,k;
	cin >> n;
	vector<char>s(n);
	for (int j = 0; j < n; j++)  cin >> s[j];
	cin >> k;
	for (int i = 0; i < n; i++)
	{
		if (s[i] != s[k-1]) {
			s[i] = '*';
		}
	}

	for (int l = 0; l < n; l++)
	{
		cout << s[l] ;
	}*/

	int n;
	cin >> n;
	vector<int>d(n);
	vector<int>e(n);
	vector<int>f(n-1);
	for (int i = 0; i < n; i++) cin >> d[i];
	for (int i = 0; i < n; i++) cin >> e[i];
	for (int i = 0; i < n-1; i++) cin >> f[i];
	
	int sum = 0;

	for (int i = 0; i < n;i++) {

		sum = sum + e[i];

	}

	for (int i = 0; i < n-1; i++) {
		if (d[i] + 1 == d[i + 1]) {
			sum = sum + f[d[i]-1];
		}
	}

	cout << sum<<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1e6 + 10;
#define fi first
#define se second
#define pb push_back
int p[N],a[N],cnt;
void P(){
  for(int i=2;i<N;i++){
    if(!p[i])a[++cnt]=i;
    for(int j=1;j<=cnt&&1ll*i*a[j]<N;j++){
      p[i*a[j]]=1;
      if(i%a[j]==0)break;
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  P();
  LL x;
  cin>>x;
  if(x==1)return cout<<0,0;
  int ans=0;
  for(int j=1;1ll*a[j]*a[j]<=x;j++){
    if(x%a[j]==0){
      int tmp=0;
      while(x%a[j]==0){
        x/=a[j];
        tmp++;
      }
      for(int i=1;;i++){
        if(i+1<=tmp-i){
          tmp-=i;
          ans++;
        }else{
          ans++;
          break;
        }
      }
    }
  }
  if(x>1)ans++;
  cout<<ans<<'\n';
  return 0;
}

Measured memory_bytes: 7908
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
int main() {
    ll t=1;
    //cin>>t;
    while(t--)
    {
      ll n,d,i;
      cin>>n>>d;
      ll ans=0;
      for(i=0;i<n;i++)
      {
          ll x,y;
          cin>>x>>y;
          if(x*x+y*y<=d*d)
            ans++;
      }
       cout<<ans<<endl;
    }
}


Measured memory_bytes: 3632
MAX_SUM = 1000
MAX_I = 100
MAX_N = 9

### global variables

$sn_cache = (0..MAX_I).map{(0..MAX_N).map{[]}}

### subroutines

def check_sum(k, n, s)
  #puts "check_sum(#{k}, #{n}, #{s})"
  ret = $sn_cache[k][n][s]
  if ret.nil?
    count = 0
    max_i = [MAX_I, s].min

    for i in (k...max_i)
      break if i >= s - i
      count += check_sum(i + 1, n - 1, s - i)
    end

    ret = $sn_cache[k][n][s] = count
  end

  #puts "(#{k}, #{n}, #{s}) = #{ret}"
  return ret
end

### main

for i in (0..MAX_I)
  $sn_cache[i][1] =
    (0...i).map{0} + (i..MAX_I).map{1} + ((MAX_I + 1)..MAX_SUM).map{0}
end
#p $sn_cache[1]

while true
  n, s = gets.chomp.split(" ").map{|s| s.to_i}
  break if n == 0 && s == 0

  puts check_sum(0, n, s)
end

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


int main() {
  string s;
  cin >> s;

  bool judge = true;

  for(int i=0; i<s.size(); i++){
    if((i+1)%2 != 0){
      if(s.at(i) == 'L'){
        judge = false;
        break;
      }
    }else{
      if(s.at(i) == 'R'){
        judge = false;
        break;
      }
    }
  }

  if(judge){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define MAX 128
#define fst first
#define sec second
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define bit(n) (1LL << (n))
#define int long long
const double PI = 3.141593;
const ll MOD = 1e9 + 7;
const int INF = 100100100;
const double EPS = 1e-9;
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 a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }     //最小公倍数
ll combination(ll n, ll r){if (r * 2 > n)r = n - r;ll dividend = 1;ll divisor = 1;for (ll i = 1; i <= r; ++i){dividend *= (n - i + 1);divisor *= i;}return dividend / divisor;}


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

    ll n;
    cin >> n;
    ll ans = 0;
    ll a = 0;
    ll tmp=10;

    if(n%2!=0){
        cout << 0 << endl;
    }
    else{
        while(tmp<=n){
            ans += n / tmp;
            tmp *= 5;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,m,cnt=0,o,aa[220000],cntl=0,ab[220000];
pair<int,int> p[220000];
string s,ss[220000];
char c,cc[5000][5000]={};
queue<int> que;
signed main(){
    cin>>n;
    rep(i,n-1){
        cin>>aa[i];
        ab[aa[i]]++;
    }
    rep(i,n){
        cout<<ab[i+1]<<endl;
    }
}

Measured memory_bytes: 13648
#!/usr/bin/env python
# coding: utf-8

import sys


def railway_lines(arg):
    b = arg.pop()
    a = arg.pop()
    base = a + b
    rail = []
    for area_number, length in enumerate(arg):
        area_number += 1
        rail += [area_number] * (length * base)
    a_last = 0
    while rail:
        for i in xrange(a):
            a_last = rail.pop(0)
        for i in xrange(b):
            rail.pop()
    return a_last


def main():
    params = [map(int, line.split(",")) for line in sys.stdin.readlines()]
    for param in params:
        print railway_lines(param)

if __name__ == '__main__':
    main()

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

int main(){
  int n;
  cin >>n;
  vector<string> blue(n);
  rep(i,n) cin >>blue[i];
  int m;
  cin >>m;
  vector<string> red(m);
  rep(i,m) cin >>red[i];
  int ans = 0;
  auto calc = [&](string s){
    int buf = 0;
    for (string t: blue){
      if(t==s) buf++;
    }
    for (string t: red){
      if(t==s) buf--;
    }
    return buf;
  };
  
  for (string t: blue){
    ans = max(ans, calc(t));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[][] ab = new int[n][2];
		for(int i = 0; i < n; i++){
		    ab[i][0] = sc.nextInt();
		    ab[i][1] = sc.nextInt();
		}
		
		// 計算
		int result = 0;
		int from = 0;
		int to = 0;
		if(n%2 == 1){
		    Arrays.sort(ab, (s, t) -> Integer.compare(s[0], t[0]));
		    from = ab[n/2][0];
		    Arrays.sort(ab, (s, t) -> Integer.compare(s[1], t[1]));
		    to = ab[n/2][1];
		}else{
		    Arrays.sort(ab, (s, t) -> Integer.compare(s[0], t[0]));
		    from = ab[n/2-1][0] + ab[n/2][0];
		    Arrays.sort(ab, (s, t) -> Integer.compare(s[1], t[1]));
		    to = ab[n/2-1][1] + ab[n/2][1] ;
		}
		result = to-from+1;
		
		// 出力
		System.out.println(result);
	}

	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


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

int main(){
  long long int w, h, x, y;
  cin >> w >> h >> x >> y;
  
  cout << w * h / 2.0;
  
  if(w % 2 == 0 && h % 2 == 0 && w / 2 == x && h / 2 == y){
    cout << ' ' << 1 << endl;
  }else{
    cout << ' ' << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
    int i,j,n,t[100005],a[1000]={0},b[1000]={0},c[1000]={0};
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&t[i]);
    sort(t,t+n);
    int s1=1,s=0,maxs=0;
    for(i=n-2;i>=0;i--)
    {
        if(t[i]==t[i+1])
        {
            for(j=i-2;j>=0;j--)
            if(t[j]==t[j+1])
            {
                //printf("** %d %d \n",t[i],t[j]);
                int x=0,y=0;
                while(t[i]>0)
                {
                    a[++x]=t[i]%10;
                    t[i]=t[i]/10;
                }
                while(t[j]>0)
                {
                    b[++y]=t[j]%10;
                    t[j]=t[j]/10;
                }
                maxs=max(x,y);
                for(int k=1;k<=maxs;k++)
                {
                    int temp=k;
                    for(int kk=1;kk<=maxs;kk++,temp++)
                    {
                        c[temp]+=b[k]*a[kk]%10;
                        c[temp+1]+=b[k]*a[kk]/10+c[temp]/10;
                        c[temp]%=10;
                    }
                }
                break;
            }
            break;
        }
    }
    if(!maxs)printf("0");
    else
    {
        for(i=25;i>=1;i--)
        {
            if(c[i]==0)continue;
            else
            {
                for(j=i;j>=1;j--)
                printf("%d",c[j]);
                break;
            }
        }
    }
    printf("\n");
}
//1000000000 1000000000 1000000000 1000000000


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const int INF = 0x3f3f3f3f;
ll max(ll a, ll b){return a > b ? a : b;}
ll min(ll a, ll b){return a < b ? a : b;}

ll dp[3001][3001];
ll a[3001];

ll R(int i, int j, int x)
{
    if(dp[i][j]) return dp[i][j];
    if(i==j) return a[i];
    ll c = a[i] - R(i+1, j, x*-1);
    ll d = a[j] - R(i, j-1, x*-1);
    dp[i][j] = max(c, d);
    return dp[i][j];
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("C.txt", "r", stdin);
    #endif
    int n;
    cin >> n;
    for(int i=1; i<=n; i++) cin >> a[i];
    ll ans = R(1, n, 1);
    cout << ans;
}



Measured memory_bytes: 70272
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;




    double aa,bb;

    cin>>aa>>bb;

    double cc=aa/bb;

    cout<<setprecision(12)<<fixed<<cc<<endl;








}



Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int n, f[MAXN], dis[MAXN];
inline int getfa(int x)
{
	if(f[x] == x)
		return x;
	int root(getfa(f[x]));
	dis[x] ^= dis[f[x]];
	return f[x] = root;
}
inline void merge(int u, int v)
{
	int x = getfa(u), y = getfa(v);
	if(x == y)
		return;
	dis[y] = (dis[v] ^ dis[u] ^ 1), f[y] = x;
}
struct T
{
	int root, head[MAXN], cnt, to[MAXN], nxt[MAXN], son[MAXN];
	inline void ae(int u, int v)
	{
		++cnt, to[cnt] = v, nxt[cnt] = head[u], head[u] = cnt;
	}
	void init()
	{
		for(int i = 1, fa; i <= n; ++i)
		{
			scanf("%d", &fa);
			if(fa == -1)
				root = i;
			else
				ae(fa, i), ++son[fa];
		}
	}
	int work(int u)
	{
		vector<int> tp;
		for(int i = head[u]; i; i = nxt[i])
			tp.push_back(work(to[i]));
		if((son[u] & 1) == 0)
			tp.push_back(u);
		sort(tp.begin(), tp.end());
		for(int i = 1; i < tp.size(); i += 2)
			merge(tp[i], tp[i + 1]);
		return tp[0];
	}
};
T A, B;
template <class T>
inline void _read(T &x)
{
	x = 0;
	char t = getchar();
	while(!isdigit(t) && t != '-') t = getchar();
	if(t == '-')
	{
		_read(x);
		x *= -1;
		return ;
	}
	while(isdigit(t))
	{
		x = x * 10 + t - '0';
		t = getchar();
	}
}
int main()
{
	_read(n);
	A.init(), B.init();
	for(int i = 1; i <= n; ++i)
	{
		f[i] = i, dis[i] = 0;
		if((A.son[i] & 1) != (B.son[i] & 1))
		{
			puts("IMPOSSIBLE");
			return 0;
		}
	}
	puts("POSSIBLE");
	A.work(A.root), B.work(B.root);
	for(int i = 1; i <= n; ++i)
		if((A.son[i] & 1) == 0)
			printf("%d ", (getfa(i), dis[i]) ? +1 : -1);
		else
			printf("%d ", 0);
	return 0;
}

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

int N, h[100005], dp[100005];

int main() {
    cin >> N;

    for (int i = 0; i < N; ++i) {
        scanf("%d", &h[i]);
    }

    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);

    for (int i = 2; i < N; ++i) {
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }

    printf("%d\n", dp[N-1]);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+10;
#define int long long
int n,m;
map<int,pair<int,int>>map1;
typedef long long ll;
int num[N];
signed main()
{
	for(int i=0;i<=1000;i++)
	{
		int y=pow(i,5);
		num[i]=y;
	}
	for(int i=0;i<=1000;i++)
		for(int j=0;j<=1000;j++)
		{
			map1[num[i]-num[j]]={i,j};
			map1[num[i]+num[j]]={i,-j};
		}
	int x;
	cin>>x;
	cout<<map1[x].first<<" "<<map1[x].second<<endl;
	return 0;
}


Measured memory_bytes: 97932
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
  ll d;cin >> d;
  vl c(26);rep(i,26)cin >> c[i];
  vvl s(d,vl(26));rep(i,d)rep(j,26)cin >> s[i][j];
  vector<set<ll>> ch(26);rep(i,26)ch[i].ins(-1),ch[i].ins(d);
  vl days(d);
  ll pre=0;
  vl last(26,-1);
  rep(i,d){
    ll t=0;
    ll maxi=-INF;
    rep(j,26){
        ll p=s[i][j];
        rep(k,26){
            if(k==j)continue;
            p-=c[k]*(i-last[k]);
        }
        if(chmax(maxi,p))t=j;
      }
      days[i]=t;
      last[t]=i;
  }
  rep(i,d){
    ll t=days[i];
    pre+=s[i][t];
    ch[t].ins(i);
    days[i]=t;
  }
  ll score=pre; 
  rep(i,26){
      ll mini=0;
      ll pp=-1;
      for(auto a:ch[i]){
        mini+=(a-pp)*(a-pp-1)/2;
        pp=a;
      }
      score-=c[i]*mini;
  }
  //rep(i,d)cout << days[i] <<endl;

  ll q=950000;
  while(q--){
    ll x=rand()%d,y=rand()%26;
    if(days[x]==y)y+=1,y%=26;
    //cout << x <<" " << y <<endl;
    ll old=days[x];
    pre-=s[x][days[x]];
    ch[days[x]].erase(x);
    days[x]=y;
    pre+=s[x][y];
    ch[y].ins(x);
    ll p=0;
    rep(i,26){
      ll mini=0;
      ll pp=-1;
      for(auto a:ch[i]){
        mini+=(a-pp)*(a-pp-1)/2;
        pp=a;
      }
      p+=c[i]*mini;
    }
    //if(q>299990)cout << score <<endl;
    if(pre-p>=score){
      score=pre-p;
    }
    else{
      ch[y].erase(x);
      pre-=s[x][y];
      days[x]=old;
      ch[days[x]].ins(x);
      pre+=s[x][old];
    }
  }
  rep(i,d)cout << days[i]+1 <<endl;
}   



Measured memory_bytes: 3716
s = int(input())

def collatz(n):
    if n % 2 == 0:
        return n/2
    else:
        return 3*n+1

a = []
a.append(s)
for i in range(1000001):
    tmp = collatz(a[i])
    if tmp in a:
        print(len(a)+1)
        exit()
    a.append(tmp)

Measured memory_bytes: 3060
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int solve(int n, int a, int b, int c, int x) {
    // bool flag = true;
    int y[n];
    int ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> y[i];
    }
    int index = 0;
    int count = 0;
    while (1) {
        if (y[index] == x) {
            index++;
        }
        if (index == n) {
            break;
        }

        ans++;
        count++;
        if (count > 10000) {
            ans = -1;
            break;
        }
        x = (a * x + b) % c;
    }
    return ans;
}

int main(int argc, char const *argv[]) {
    int n, a, b, c, x;
    vector<int> ans;
    while (1) {
        cin >> n >> a >> b >> c >> x;
        if (n == 0 && a == 0 && b == 0 && c == 0 && x == 0) break;
        ans.push_back(solve(n, a, b, c, x));
    }
    for (int a : ans) {
        cout << a << endl;
    }
    return 0;
}
/*
入力
solve呼びだし
入力
（A*X+B)modCを計算
指定された数字か判断
不可能判断？？？？
回答
*/


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

typedef vector<int> veci;
typedef pair<int,int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9+7)
#define fi first
#define se second
#define endl '\n'

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL_TEST    
    int tcs;
    cin >> tcs;
    while (tcs-->0)
#endif        
{
    int n;
    cin >> n;

    ll res = 0;
    int l, r;
    for (int i=0; i<n; ++i) {
        cin >> l >> r;
        res += r-l+1;
    }

    cout << res << endl;
}}

Measured memory_bytes: 256
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,j;
            cin>>n;
            int ar[n+1],sum[n+1];
            for(i=1;i<=n;++i)
                cin>>ar[i];
            sum[0]=0;
            int ans=1e9;
            for(i=1;i<=n;++i)
            {
                sum[i]=sum[i-1]+ar[i];
            }

            for(i=1;i<=n;++i)
            {

                ans=min(ans,abs(sum[n]-sum[i-1]-sum[i-1]));
            }
            ans=min(ans,sum[n]);
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false


signed main(void){
    int N,a;
    vector<int> A;
    cin >> N;
    REP(i,N){
        cin >> a;
        A.push_back(a);
    }
    
    int Ans=INF;
    int num=0;
    int sum=0;
    REP(i,N){
        sum+=A[i];
        if(i%2==0 && sum<=0){
            num+=1-sum;
            sum=1;
        }else if(i%2==1 && sum>=0){
            num+=sum+1;
            sum=-1;
        }
    }
    Ans=num;
    
    num=0;
    sum=0;
    REP(i,N){
        sum+=A[i];
        if(i%2==1 && sum<=0){
            num+=1-sum;
            sum=1;
        }else if(i%2==0 && sum>=0){
            num+=sum+1;
            sum=-1;
        }
    }
    Ans=min(Ans,num);
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint N;
    cin >> N;
    vector<lint> A(N);
    REP(i, N) cin >> A[i];
    double ans1 = 1;
    REP(i, N) {
        ans1 *= (double)A[i];
    }
    if(ans1 > 2*1000000000000000000) {
        cout << -1 << endl;
        return 0;
    }
    lint ans2 = 1;
    REP(i, N) {
        ans2 *= A[i];
    }
    if(ans2 > 1000000000000000000) {
        cout << -1 << endl;
    } else {
        cout << ans2 << endl;
    }
}

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


vector<int> A = { 0 , 1 , 2 , 3 , 4, 5 , 6 , 7 , 8 , 9 } ;
vector<int> ans ;
void dfs( int i , int j ){
    if( i >= j ){
        ans.push_back(i) ;
        return ;
    } 
    for(auto p : A){
        dfs( 10*i + p , j ) ;
    }
} 

int main(){
    int n , k ;
    cin >> n >> k ;
    rep(i,k){
        int a ;cin >> a ;
        A.erase(remove(A.begin(), A.end(), a), A.end());
    }
    /*
    if(A[0] == 0 ) dfs(A[1],n) ;
    else dfs(A[0],n) ;
    */
    for(auto p : A){
        if( p == 0 ) continue ;
        dfs(  p , n ) ;
    }
    sort(ans.begin(),ans.end()) ;
    cout << ans[0] << endl;
}

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

using namespace std;

// #define int long long

signed main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int K;
	cin >> K;

	int k1 = b > a ? 0 : ceil(log(double(a) / double(b)) / log(2.0f));
	b *= int(pow(2, k1));
	if (b == a) b *= 2, k1++;
	int k2 = c > b ? 0 : ceil(log(double(b) / double(c)) / log(2.0f));
	c *= int(pow(2, k2));
	if (c == b) k2++;
	if (k1 + k2 <= K)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 4096
// ABC162A.cpp
//#include "pch.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	string ans = "No";
	for (int i = 0; i < s.size(); i++) {
		if (s.at(i) == '7') ans = "Yes";
	}
	cout << ans << endl;
}


Measured memory_bytes: 3100
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a,b,c = map(int, input().split())
    print(max(a,b,c)-min(a,b,c))


if __name__ == '__main__':
    main()

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

using namespace std;

using ll = int_fast64_t;
constexpr ll llmax = INT_FAST64_MAX; // std::numeric_limits<int_fast64_t>::max()
constexpr ll llmin = INT_FAST64_MIN; // std::numeric_limits<int_fast64_t>::min()
using ull = uint_fast64_t;
constexpr ull ullmax = UINT_FAST64_MAX; // std::numeric_limits<uint_fast64_t>::max()

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanInt(Q);
    string S;
    cin >> S;
    vector<pair<char, char>> TD;
    REP(q, Q){
        char tq;
        char dq;
        cin >> tq >> dq;
        TD.emplace_back(tq, dq);
    }
    int result = N;
    {
        int n = 0;
        RREP(q, Q){
            auto& tq = TD[q].first;
            auto& dq = TD[q].second;
            if (tq == S[n] && dq == 'L'){
                n++;
            }
            if (1 <= n && tq == S[n - 1] && dq == 'R'){
                n--;
            }
        }
        result -= n;
    }
    {
        int n = N - 1;
        RREP(q, Q){
            auto& tq = TD[q].first;
            auto& dq = TD[q].second;
            if (tq == S[n] && dq == 'R'){
                n--;
            }
            if (n <= N - 2 && tq == S[n + 1] && dq == 'L'){
                n++;
            }
        }
        result -= (N - 1 - n);
    }
    cout << max(0, result) << endl;
}


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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);

struct debug {
#ifdef LOCAL

~debug() { cerr << "\n---------------\n"; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")"; }
sim dor(rge<c> d) {
	*this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
	ris << "]"; }

#else
sim dor(const c&) { ris; }
#endif
};
#define deb(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define found(m,x) ((m).find(x)!=(m).end())
#define uset unordered_set
#define umap unordered_map
#define db(x) cerr << #x << " == " << x << ";\n";
#define a(x) x.begin(),x.end()
#define input(v,n) for(int i=0;i<n;i++)cin>>v[i]
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pi;

const int nax = 1e5+7;
const int mod = 1e9+7; //1e9+2667
const int inf = numeric_limits<int> :: max();
// ===================== MANASH =================== //

int n,m;

void test() {

	cin >> n >> m;
	cout << n*m;
}

signed main() {

	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);

	#ifdef LOCAL
	freopen("input.txt","r",stdin);
	cout<<"Time Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec.\n";
	#endif

	int T = 1;
	//cin >> T;
	while(T--) {
		test();
		cout << "\n";
	}
	return 0;

}

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int X, Y, Z, K;
    std::cin >> X >> Y >> Z >> K;

    vector<ll> X_v(X), Y_v(Y), Z_v(Z);
    REP(i, X) {
        std::cin >> X_v[i];
    }
    REP(i, Y) {
        std::cin >> Y_v[i];
    }
    REP(i, Z) {
        std::cin >> Z_v[i];
    }

    RSORT(X_v);
    RSORT(Y_v);
    RSORT(Z_v);

    priority_queue<tuple<ll, int, int, int>> Q;
    Q.emplace(X_v[0] + Y_v[0] + Z_v[0], 0, 0, 0);

    set<tuple<int, int, int>> pushed;
    REP(i, K) {
        auto d = Q.top();
        Q.pop();

        auto v = get<0>(d);
        auto x = get<1>(d);
        auto y = get<2>(d);
        auto z = get<3>(d);

        std::cout << v << std::endl;

        if(x + 1 < X && pushed.find(make_tuple(x + 1, y, z)) == pushed.end()) {
            Q.emplace(X_v[x + 1] + Y_v[y] + Z_v[z], x + 1, y, z);
            pushed.emplace(x + 1, y, z);
        }
        if(y + 1 < Y && pushed.find(make_tuple(x, y + 1, z)) == pushed.end()) {
            Q.emplace(X_v[x] + Y_v[y + 1] + Z_v[z], x, y + 1, z);
            pushed.emplace(x, y + 1, z);
        }
        if(z + 1 < Z && pushed.find(make_tuple(x, y, z + 1)) == pushed.end()) {
            Q.emplace(X_v[x] + Y_v[y] + Z_v[z + 1], x, y, z + 1);
            pushed.emplace(x, y, z + 1);
        }
    }

    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;
constexpr ll MOD = 1000000007;

int main()
{
  ll n,m;
  cin>>n>>m;
  vecint s(n),t(m);
  REP(i,n)cin>>s[i];
  REP(i,m)cin>>t[i];
  vector<vector<ll>> dp(n+1, vector<ll>(m+1));
  vector<vector<ll>> sum(n+1, vector<ll>(m+1));
  dp[0][0] = 1;
  REP(i,n+1)sum[i][0] = 1;
  REP(i,m+1)sum[0][i] = 1;
  REP(i,n)REP(j,m) {
    if (s[i] == t[j]) {
      dp[i+1][j+1] += sum[i][j];
      dp[i+1][j+1] %= MOD;
    }
    sum[i+1][j+1] = sum[i+1][j] + sum[i][j+1] + (MOD - sum[i][j]) + dp[i+1][j+1];
    sum[i+1][j+1] %= MOD;
  }
  cout<<sum[n][m]<<endl;
  return 0;
}


Measured memory_bytes: 62976