akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ALL(c) (c).begin(), (c).end()
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6+6;


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n, m, P;
	
	cin>>n>>m>>P;
	
	vector<vector<int>> e(m);
	for(auto &p : e){
		p.resize(3);
		cin>>p[0]>>p[1]>>p[2];
		--p[0];
		--p[1];
		p[2]-=P;
	}
	
	ll inf = 1e18;
	vector<ll> d(n, -inf);
	d[0] = 0;
	
	auto gg = [&](int cnt){
		for(int k=0;k<cnt;++k){
			vector<ll> t = d;
			for(auto &v : e){
				int i = v[0], j = v[1], c = v[2];
				if(t[i]==inf) d[j] = inf;
				else if(t[i]!=-inf) d[j] = min(inf, max(d[j], t[i]+c));
			}
		}
	};
	
	gg(n-1);
	auto dd = d;
	gg(1);
	for(int i=0;i<n;++i) if(d[i] > dd[i]) d[i] = inf;
	gg(n);
	
	if(d[n-1]==inf) cout<<-1<<endl;
	else cout<<max(0LL,d[n-1])<<endl;
	
	
	
	
	return 0;
}


Measured memory_bytes: 640
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,t,dp[110][10010],all=1,ans=0;

int main()
{
	cin>>n>>t;
	rep(i,n-1) all=all*(t+1)%MOD;
	all=all*(t+1)*t/2*n%MOD;
	if(n==t)
	{
		dp[n-1][1]=1;
		dp[n-1][0]=t;
	}
	else dp[n-1][0]=t+1;
	for(int i=n-1;i>0;i--)
	{
		rep(j,10005)
		{
			if(dp[i][j]==0) continue;
			rep(k,t+1)
			{
				if(k<=i) dp[i-1][j+(j+k)/i]=(dp[i-1][j+(j+k)/i]+dp[i][j])%MOD;
				else dp[i-1][j]=(dp[i-1][j]+dp[i][j])%MOD;
			}
		}
	}
	repn(i,10003) ans=(ans+i*dp[0][i])%MOD;
	cout<<(all-ans+MOD)%MOD<<endl;
	rt0;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    ll n;
    
    cin >> n;
  
  	cout << (n+1)/2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
using namespace std;
#define ff(i,n,m) for(int i=n;i<m;i++)
#define i64 int64_t

int main() {
	int x, y, n;
	cin >> x >> y >> n;
	int x1 = 0, x2 = x, y1 = 0, y2 = y;
	ff(i, 0, n) {
		int a, b, c;
		cin >> a >> b >> c;
		if (c == 1) {
			x1 = max(a, x1);
		}
		if (c == 2) {
			x2 = min(a, x2);
		}
		if (c == 3) {
			y1 = max(b, y1);
		}
		if (c == 4) {
			y2 = min(b, y2);
		}
	}
	if ((x2 - x1) < 0 || (y2 - y1) < 0) {
		cout << 0 << endl;
		return 0;
	}

	cout << (x2 - x1) * (y2 - y1) << endl;

	return 0;
}

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

const int Max=1e5+1;
int a[Max];

struct stu
{
    int id,tal;
    bool operator <(const stu& st)  const
	{
        return tal<st.tal;
    }
}s[Max];

int main()
{
	int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        s[i].id=i;
        s[i].tal=a[i];
    } 
    sort(s+1,s+n+1);
    for(int i=1;i<=n;i++)
        cout<<s[i].id<<" ";
    return 0;
}   

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

ll modpow(ll x, ll n, ll mod = MOD){
  ll res = 1;
  while(n > 0){
    if(n & 1)
      res = res * x % mod;
    x = x * x & mod;
    n >>= 1;
  }
  return res;
}

int main(){
  cin.tie(0);
  ios:: sync_with_stdio(false);
  string s;
  cin >> s;
  int n = s.size();
  vector<ll> dp(13, 0);
  dp[0] = 1;
  for(int i = 0; i < n; i++){
    vector<ll> ndp(13, 0);
    int val = (s[i] == '?' ? -1 : s[i] - '0');
    for(int j = 0; j < 13; j++){
      if(val == -1){
        for(int k = 0; k < 10; k++){
          int nex = (j * 10 + k) % 13;
          (ndp[nex] += dp[j]) %= MOD;
        }
      }
      else{
        int nex = (j * 10 + val) % 13;
        (ndp[nex] += dp[j]) %= MOD;
      }
    }
    dp = move(ndp);
  }
  cout << dp[5] << endl;
  return 0;
}

Measured memory_bytes: 512
s = input()
alpha = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
l = []
for i in alpha:
    if i not in s:
        l.append(i)

if len(l) == 0:
    print('None')
else:
    print(l[0])

Measured memory_bytes: 62080
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


const int mod=1000000007;
//const int mod=998244353;




long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}


vector<long long int> fact,fact_inverse;
template<typename type>
void tabulate(type n){
    fact.resize(n+1);
    fact_inverse.resize(n+1);
    fact[0]=1;
    fact_inverse[0]=binpow(1, mod-2, mod);
    for (int i=1; i<n+1; i++) {
        fact[i]=fact[i-1]*i;
        fact[i]%=mod;
        fact_inverse[i]=binpow(fact[i], mod-2, mod);
    }
}
template<typename type>
long long int nCk(type n,type k){
    return fact[n]*fact_inverse[n-k]%mod*fact_inverse[k]%mod;
}
template<typename type>
long long int nPk(type n,type k){
    return fact[n]*fact_inverse[n-k]%mod;
}


int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r;
    tabulate(3e5);
    cin >> a >> b >> m;
    vpll p(m);
    for(int i=0; i<m; i++){
        cin >> p[i].fi >> p[i].se;
        p[i].fi--;
        p[i].se--;
    }
    a--;b--;
    p.eb(a,b);
    sort(all(p),[&](pll a, pll b){return a.fi+a.se<b.fi+b.se;});
    vll dp(m+1,0);
    for(int i=0; i<=m; i++){
        ll ans=0;
        for(int j=0; j<=m; j++){
            if(p[i].fi>=p[j].fi&&p[i].se>=p[j].se){
                ans+=dp[j]*nCk(p[i].fi+p[i].se-p[j].fi-p[j].se,p[i].fi-p[j].fi);
                ans%=mod;
            }
        }
        ans=(nCk(p[i].fi+p[i].se,p[i].fi)-ans+mod)%mod;
        dp[i]=ans;
    }
    cout << dp[m] << el;
    return 0;
}


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

main(){
  
  double a,b,c,d,e,f;
  double x, y;
  

  while(cin >> a >> b >> c >> d >> e >> f){
  

    y = (c*d - f*a)/(b*d-e*a);
    x = (c - b*y)/a;
    
    
    x*=10000;
    y*=10000;
    
    x+=0.5;
    y+=0.5;
    
    x/=10000;
    y/=10000;
    
    //cout << x << y << endl;
    printf("%.3f %.3f\n", x, y);
  }

  return 0;
}

Measured memory_bytes: 0
n = int(raw_input())
m = map(int, raw_input().split())
max_m = [0 for i in range(n)]
max_m[0] = m[0]
ans = 1
for i in range(1, n):
  if m[i] >= max_m[i - 1]:
    ans = ans + 1
    max_m[i] = m[i]
  else:
    max_m[i] = max_m[i - 1]
print ans

Measured memory_bytes: 2568
#include<cstdio>
#include<cstring>
using namespace std;
const int MAXN=3000;
typedef unsigned long long ull;
const int maxn=1e5+5;
typedef long long ll;
int ans[200][200];
int main(){
    memset(ans,0,sizeof(ans));
    int a,b;
    scanf("%d%d",&a,&b);
    printf("100 100\n");
    int i,j;
    for (i=0;i<100;i++){
    for (j=0;j<100;j++){
        if (i%2)
            ans[i][j]=0;
        else {
            if (a==1)
                ans[i][j]=0;
            else {
                if (j%2==0)
                {
                    ans[i][j]=1;
                    a--;
                }
                else
                    ans[i][j]=0;
            }
        }
        }
            if (a==1)
            break;
    }
    i++;
    if (i%2){
        for (j=0;j<100;j++)
            ans[i][j]=0;
        i++;
    }
        for (j=0;j<100;j++)
            ans[i][j]=1;
        i++;
    b--;
    for (;i<100;i++)
        for (j=0;j<100;j++){
            if (i%2==0)
                ans[i][j]=1;
            else {
                if (b==0)
                    ans[i][j]=1;
                else {
                    if (j%2==0)
                    {
                        ans[i][j]=0;
                        b--;
                    }
                    else
                        ans[i][j]=1;
                }
            }
        }
    for (i=0;i<100;i++){
        for (j=0;j<100;j++)
            if (ans[i][j])
                printf(".");
            else
                printf("#");
        printf("\n");
    }
}


Measured memory_bytes: 384
# coding: utf-8
import sys
stdin = sys.stdin

sr = lambda: stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
AB = [lr() for _ in range(M)]
V = [x for x in range(N+1)]
total = N * (N-1) // 2

def find(A, x):
    parent = A[x]
    if parent == x: return x
    root = find(A, parent)
    A[x] = root
    return root

def union(A, x, y):
    root, second = find(A, x), find(A, y)
    if root > second:
        second, root = root, second
    A[second] = root

def merge(A, x, y):
    root_A = find(A, a); root_B = find(A, b)
    if root_A == root_B:
        return 0
    ret = group[root_A] * group[root_B]
    new_group = group[root_A] + group[root_B]
    group[root_A] = group[root_B] = new_group
    union(A, a, b)
    return ret

conv = 0
answer = []
group = [1] * (N+1)
for a, b in AB[::-1]:
    answer.append(total - conv)
    conv += merge(V, a, b)

for x in answer[::-1]:
    print(x)


Measured memory_bytes: 38104
#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;

int main() {

    int n,m;
    cin >> n >> m ;
    vector<int>p(m, 0);
    vector<int>y(m, 0);
    vector<vector<int>>s(n+1);

    for (int i = 0; i < m; i++) {
        cin >> p[i] >> y[i];
        s[p[i]].push_back(y[i]);
    }
    for (int i = 1; i <= n; i++) {
        sort(s[i].begin(), s[i].end());
    }
    for (int i = 0; i < m; i++) {
        auto itr = lower_bound(s[p[i]].begin(), s[p[i]].end(), y[i]);
        printf("%06d%06d\n", p[i],distance(s[p[i]].begin(),itr)+1);
    }

    return 0;
}


Measured memory_bytes: 7808
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  string s;

  cin >> s;

  if(s.back() != 's') cout << s << 's';
  else {
    cout << s << "es";
  }

  return 0;
}
/*

*/


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

int main()
{
	int n, b[105],ans=0;
	cin >> n;
	for (int i = 1; i <=n-1; i++) {
		cin >> b[i];
	}
	b[0] = b[n] =10000000;
	for (int i = 1; i <=n; i++) {
			ans += min(b[i], b[i - 1]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll modpow(ll a, ll n, ll mod_) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod_;
        a = a * a % mod_;
        n >>= 1;
    }
    return res;
}

const ll MAX_SIZE = 2005;
array<ll, MAX_SIZE> fac, inv, finv;
void finit() {
    // combination init
    fac[0] = 1;
    for (ll i = 1; i < MAX_SIZE; i++) fac[i] = fac[i - 1] * i % MOD;
    finv[MAX_SIZE - 1] = modpow(fac[MAX_SIZE - 1], MOD - 2, MOD);
    for(ll i = MAX_SIZE - 1; i > 0; i--) finv[i - 1] = finv[i] * i % MOD;
    
    //inv init
    repe(i, 1, MAX_SIZE) inv[i] = modpow(i, MOD - 2, MOD);
}

ll perm(ll a, ll b) { return fac[a] * finv[a - b] % MOD; }

ll comb(ll a, ll b) { return fac[a] * finv[b] % MOD * finv[a - b] % MOD; }

// N個の区別できるものをK個のグループに分類する通り数 O(KlogN)
ll stirling_number(ll N, ll K){
    ll ret = 0;
    for (ll i = 0; i <= K; i++) ret += comb(K, i) * modpow(i, N, MOD) % MOD * ((K - i) & 1 ? -1 : 1);

    return (MOD + ret % MOD) * finv[K] % MOD;
}

int main() {
    init();
    finit();
    ll N, K;
    cin >> N >> K;

    cout << stirling_number(N, K) << endl;
}


Measured memory_bytes: 3280
#include <iostream>
#include <stdio.h>
#include <string>
#include <memory.h>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <time.h>
#include <assert.h>
#include <cmath>
#include <stack>
#include <string.h>
#include <sstream>
#include <algorithm>
using namespace std;
typedef long long ll;
int f(int x) {
	int res = 0;
	while (x) {
		res += x % 10;
		x /= 10;
	}
	return res;
}
int main()
{
	int n;
	cin >> n;
	int res = 1e9;
	for (int a = 1; a < n; ++a) {
		int b = n - a;
		res = min(res, f(a) + f(b));
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }


int main()
{
    int n;
    while (cin >> n) {
        int t1,x1,y1; t1 = x1 = y1 = 0;
        bool good = true;
        FOR(i,0,n) {
            int t2,x2,y2; cin >> t2 >> x2 >> y2;
            const int d = abs(x1-x2) + abs(y1-y2);
            const int t = t2 - t1;
            if (t >= d && (t-d)%2 == 0)
                ;
            else
                good = false;
            t1 = t2; x1 = x2; y1 = y2;
        }
        if (good)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9+7;

int N, C;
int D[35][35];
int c[516][516];
int cost[3][35];
int ans;
int main(){
    cin>>N>>C;
    REP(i,0,C){
        REP(j,0,C){
            cin>>D[i][j];
        }
    }
    REP(i,0,N){
        REP(j,0,N){
            cin>>c[i][j];
            c[i][j]--;
        }
    }
    REP(i,0,3){
        REP(k,0,C){
            cost[i][k] = inf;
        }

    }
    REP(k,0,C){
        int tmp[3];
        REP(i,0,3){
            tmp[i] = 0;
        }
        REP(i,0,N){
            REP(j,0,N){
                tmp[(i+j+2)%3]+=D[c[i][j]][k];
            }
        }
        REP(i,0,3){
            cost[i][k] = min(cost[i][k], tmp[i]);
        }

    }
    ans = inf;
    REP(i,0,C){
        REP(j,0,C){
            if(i==j) continue;
            REP(k,0,C){
                if(i==k||j==k) continue;
                ans = min(ans, cost[0][i] + cost[1][j] +cost[2][k]);
            }
        }
    }
    p(ans);
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include<string>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;


int main() {
	int A, B, C, total;//A:500jpy,B:100jpy,C:50jpy
	int counter = 0;
	cin >> A >> B >> C>>total;

	 int tmp;
	for (int i = 0; i <= A; ++i) 
	{
		int A_500 = 500 *i;
		
		for (int j = 0; j <= B; ++j)
		{
			int B_100 = 100 *j;
			
			//cout << "j=" << j << endl;
			for (int k = 0; k <= C; ++k)
			{
				int C_50 = 50 *k;
				
				//cout << "k=" << k << endl;
				
				tmp = A_500 + B_100  + C_50;
				if (tmp == total) {
					++counter;
				}
				
			}
		}
	}

	cout << counter << endl;
}


Measured memory_bytes: 256
using System;

class Program
{
  /// <summary>
  /// ABC095 A - Something on It
  /// </summary>
  static void Main(string[] args)
  {
    var s = Console.ReadLine();
    int x = 700;
    int y = 0;
    if (s[0] == 'o') y += 100;
    if (s[1] == 'o') y += 100;
    if (s[2] == 'o') y += 100;
    Console.WriteLine(x + y);
  }
}


Measured memory_bytes: 17372
//2017-10-9
//miaomiao
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

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

#define N (500000+5)

char s[N];
int f[N];

int main(){
	int n;
	scanf("%d%s", &n, s+1);
	
	int lst = 0;

	For(i, 2, n){
		f[i] = f[i-1];

		if(s[i] == '1' && s[i-1] == '0' && s[i-2] == '1'){
			lst = i;
			Forr(j, i-2, 1){
				if(s[j] == '0') break;
				f[i] = max(f[i], f[j-1] + ((i-2)-j+1));
			}
		}

		if(s[i] == '0') lst = 0;	
		if(lst) f[i] = max(f[i], f[lst-3] + (i-lst+1));
		
	//	printf("f[%d] = %d\n", i, f[i]);
	}
	
	printf("%d\n", f[n]);

	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << ": " << x << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
//#define int long long
#define print(x) cout << (x) << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = (1LL << 30);
const ll MOD = 1000000007;


//=============================================================
string S,T;

void solve()
{
    bool isOK = true;

    set<pair<char,char>> s2t;
    rep(i,S.size()){
        if (S[i] != T[i]){
            s2t.insert(make_pair(S[i],T[i]));
            //s2t.insert(make_pair(T[i],S[i]));
        }
        else s2t.insert(make_pair(S[i],T[i]));
    }
    
    bool exs1[40] = {false};
    bool exs2[40] = {false};
    
    for (auto x: s2t) {
      if (exs1[x.second - 'a' ]){
        isOK = false;
        break;
      }
      else exs1[x.second - 'a'] = true;

      if (exs2[x.first - 'a']){
        isOK = false;
        break;
      }
      else exs2[x.first - 'a'] = true;
    }




    // for (auto x: s2t){
    //     cout<<x.first<<" " << x.second<< endl;
    // }

    cout << (isOK ?  "Yes" : "No") << endl;

}
signed main()
{
    cin>>S;
    cin>>T;
    if (S.size() != T.size()) return -1;

    solve();
    return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

typedef long long ll;

int main () {
	int N;
	ll ans = 0;
	cin >> N;
	for (int i=1; i<N; i++) {
		ll tmp = N/i;
		if (N%i==0)
			tmp --;
		ans += tmp;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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(int argc, char const *argv[]) {
  string s;
  string t="CODEFESTIVAL2016";
  cin >> s;
  
  int cnt=0;
  rep(i,sz(s)){
    if(s[i]!=t[i]) cnt++;
  }
   cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




/*10億7。　　　100000007
2*2行列 H*W
vector<vector<int>> vec(H,vector<int>(W));
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>vec[i][j];
  }
}

文字列→数列
string S;int A=atoi(S.c_str());
数列→文字列
int A;string S=to_string(A);
数字判定　isdigit(a)
pair宣言　pair<int,int> p(5,7);
ソート　sort(vec.begin(),vec.end());
キュー　queue<int> q;
   q.push(7);　//７が入る
   cout << q.front() << endl;  // 先頭の値を出力
   q.pop();  // 先頭の値を削除
   q.empty();
*/
//座標　corrdinateト深さヲ保持スルタメノ構造体
struct Coor{
  ll y;
  ll x;
  ll depth;
};
 ll N,M;  
 ll sy,sx,gy,gx;
 ll y,x,depth;//キューから取り出した座標
vector<string> vec;
queue<Coor> q;
vector<ll> y_vec={0,0,-1,+1};//technique
vector<ll> x_vec={-1,+1,0,0};

int BFS(){
  while(!q.empty()){
    Coor now=q.front();q.pop();//キューの先頭を取り出す
    y=now.y,x=now.x,depth=now.depth;
    
    //停止条件
    if(y==gy&&x==gx){return depth;}
    
    //上下左右４方向を探索、進むことができればキューに格納
    for(int i=0;i<4;i++){
      Coor next={y+y_vec[i],x+x_vec[i],depth+1};
      if(0<=next.y&&next.y<=N-1&&0<=next.x&&next.x<=M-1&&vec[next.y][next.x]=='.'){
        vec[next.y][next.x]='x';//同じ場所を探索しないようにする
        q.push(next);
      }
    }
  }
  return 0;
}
                   
  


int main(void){
cout<<fixed<<setprecision(14);
//cin.tie(0); ios::sync_with_stdio(false);
ll N;cin>>N;
  cout<<48-N<<endl;
  
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
int main(){
    ll n; cin>>n;
    for(int i=0;;i++){
        string temp, hoge;
        ll ans=0;
        temp=to_string(n+i);
        hoge=to_string(n-i);
        bool check=true;
        for(int j=0; j<(int)(temp.length()/2);j++){
            if(temp[j]!=temp[(int)temp.length()-1-j]){check=false; break;}
        }
        if(check){ans=stoi(temp);}
        check=true;
        for(int j=0; j<(int)hoge.length()/2;j++)
            if(hoge[j]!=hoge[hoge.length()-1-j]){check=false;break;}
        if(check&&ans!=0){ll poge=stoi(hoge); cout<<min(ans,poge)<<endl; return 0;}
        else if(ans!=0){cout<<stoi(temp)<<endl;return 0;}
        else if(check){cout<<stoi(hoge)<<endl;return 0;}
    }
}

Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(){
  int k,n,t;
  cin >> k >> n;
  vi a(n,0);
  vi d(n,0);
  rep(i,0,n+1){
    cin >> a[i];
  }
  rep(i,1,n){
    d[i]= a[i]-a[i-1];
  }
  d[0]= a[0]+(k-a[n-1]);
  int max= *max_element(all(d));
  
  cout << (k-max);
  
  return 0;
}


Measured memory_bytes: 1792
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <queue>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define sort_key(struct_name,key_name) [](const struct_name &x, const struct_name &y){return x.key_name < y.key_name;}
#define pb(x) push_back(x)
typedef long long ll;
const long long MOD = 1e9 + 7;
using namespace std;

//main
int main(){
  int N; cin >> N;
  int c = 0;
  for(int i=1; i<10; i++){
    if (N/i<10 && N%i==0){
      c++;
    }
  }
  if (c > 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
while True:
    vals = list(map(int,input().split()))
    if vals[0]==0 and vals[1]==0:
        break
    count = 0
    for i in range(1, vals[0]+1):
        for j in range(i+1, vals[0]+1):
            for k in range(j+1, vals[0]+1):
                if i+j+k==vals[1]:
                    count += 1
    print (count)
                    


Measured memory_bytes: 5596
def solve():
  N = int(raw_input())
  hist = []
  for i in range(N):
    s = raw_input()
    tmphist = [0 for i1 in range(26)]
    for c in s:
      tmphist[ord(c) - ord('a')] = tmphist[ord(c) - ord('a')] + 1

    #print 'i=',i,'hist=',hist,'tmphist=',tmphist
    if(i == 0):
      hist = tmphist
    else:
      for i2 in range(26):
        hist[i2] = min(hist[i2], tmphist[i2])
  ret = ''
  for i3 in range(26):
    ret += chr(ord('a') + i3) * hist[i3]
  return ret

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

Measured memory_bytes: 2692
import java.util.*;
public class Main {
  public static void main(String[] args){
    int counter=0;
    Scanner sc=new Scanner(System.in);
    String str=sc.next();
    char[] s=str.toCharArray();
    if(s[0]=='1') counter++;
    if(s[1]=='1') counter++;
    if(s[2]=='1') counter++;
    System.out.println(counter);
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>

int main( void )
{
 char str_s[101] = {};
 char str_p[101] = {};
 int i, j;
 int len_s, len_p;
 int rp;
 int result = 0;

 scanf( "%s", str_s );
 scanf( "%s", str_p );

 len_s = strlen( str_s );
 len_p = strlen( str_p );
 for ( i = 0; i < len_s + 1; ++i ) {
  rp = i;
  for ( j = 0; j < len_p + 1; ++j ) {
   if ( str_s[rp] != str_p[j] ) {
    break;
   }
   if ( ++rp == len_s ) {
    rp = 0;
   }
  }

  if ( j == len_p ) {
   result = 1;
   break;
  }
 }

 if ( result == 1 ) {
  printf( "Yes\n" );
 }
 else {
  printf( "No\n" );
 }

 return 0;
}


Measured memory_bytes: 2696
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    rep (c, N) {
        int field[5][5];
        rep(j, 5){
            rep(i, 5){
                int input;
                cin >> input;
                field[j][i] = input;
            }
        }
        int maxa = 0;
        rep(y, 5){ // posy
            rep(x, 5){ // posx
                for (int j = 1; j+y<=5; j++) { // height
                    for (int i = 1; i+x<=5; i++) { // width
                        int allone = 1;
                        rep(m, j){
                            rep(l, i){
                                allone &= field[y+m][x+l];
                            }
                        }
                        if (allone) maxa = max(i*j, maxa);
                    }
                }
            }
        }
        cout << maxa << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

int main()
{
    ll x, k, d; cin >> x >> k >> d;
    ll ans;
    x = abs(x);

    if (x/d >= k) {
        ans = x - k*d;
    } else {
        ll tmp1 = x % d;
        ll tmp2 = abs(tmp1 - d);
        k -= x/d;
        if (k % 2 == 0)
            ans = tmp1;
        else
            ans = tmp2;
    }
    cout << abs(ans) << endl; 
    return 0;
}


Measured memory_bytes: 3640
#include "bits/stdc++.h"
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 REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

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

	string s, t;
	cin >> s >> t;

	int cnt = 0;
	rep(i, 3) {
		if (s[i] == t[i]) cnt++;
	}

	out(cnt);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    int n,m;
    cin >> n >> m;
    vector<int> h(n);
    vector<int> a(m);
    vector<int> b(m);
    vector<int> check(n);
    rep(i,0,n){
        cin >> h.at(i);
    }
    rep(i,0,m){
        cin >> a.at(i) >> b.at(i);
    }
    rep(i,0,m){
        if(h[a.at(i)-1]<=h[b.at(i)-1]){
            check.at(a.at(i)-1)++;
        }
        if(h[b.at(i)-1]<=h[a.at(i)-1]){
            check.at(b.at(i)-1)++;
        }
    }
    int cnt = 0;
    rep(i,0,n){
        if(check.at(i)==0){
            cnt++;
            //cout<< i;
        }
    }
    

    cout << cnt << endl;


  return 0;
}

Measured memory_bytes: 4840
from bisect import bisect_right
import sys
input = sys.stdin.buffer.readline

class SegmentTree:
    """
    0-indexed
    query : [L, R)
    """
    def __init__(self, size, initValue, cmpFunc):
        self.size = 1 << (size.bit_length())  # 完全二分木にする
        self.data = [initValue] * (2 * self.size - 1)
        self.initValue = initValue
        self.cmpFunc = cmpFunc

    def build(self, rawData):
        self.data[self.size - 1: self.size - 1 + len(rawData)] = rawData
        for i in range(self.size - 1)[:: -1]:
            self.data[i] = self.cmpFunc(self.data[2 * i + 1], self.data[2 * i + 2])

    def update(self, index, value):
        index += self.size - 1
        self.data[index] = value
        while index >= 0:
            index = (index - 1) // 2
            self.data[index] = self.cmpFunc(self.data[2 * index + 1], self.data[2 * index + 2])

    def query(self, left, right):
        L = left + self.size
        R = right + self.size
        ret = self.initValue
        while L < R:
            if R & 1:
                R -= 1
                ret = self.cmpFunc(ret, self.data[R - 1])
            if L & 1:
                ret = self.cmpFunc(ret, self.data[L - 1])
                L += 1
            L >>= 1
            R >>= 1
        return ret

N, D, A = map(int, input().split())
XH = [tuple(map(int, input().split())) for _ in range(N)]
XH.sort()
X = [x for x, _ in XH]

tree = SegmentTree(N + 1, 0, lambda a, b: a + b)

ans = 0
for i, (x, h) in enumerate(XH):
    cnt = tree.query(0, i + 1)
    h -= cnt * A

    if h <= 0:
        continue

    ness = -(-h // A)
    ans += ness
    tree.update(i, tree.query(i, i + 1) + ness)
    j = bisect_right(X, x + 2 * D)
    tree.update(j, tree.query(j, j + 1) - ness)

print(ans)

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

#define pb push_back
#define F first
#define S second
#define y1 dasdasfasfas
#define x1 wqdadfasfasfas
#define All(c) c.begin(), c.end()
#define SZ(A) (int((A).size()))
#define umap unordered_map
#define __ fflush(stdout)
#define FILENAME ""

typedef long long ll;
typedef long double ld;    

using namespace std;

void FREOPEN() {
	#ifdef LOCAL
		freopen(".in", "r", stdin);
		freopen("1.out", "w", stdout);
	#else
		//freopen(FILENAME".in", "r", stdin);
		//freopen(FILENAME".out", "w", stdout);
	#endif
}

inline double Time() {return (clock() * 1.0) / CLOCKS_PER_SEC; }             

const int N = 200500, inf = 1e9 * 2;

const ll MOD = 1e9 + 7ll, INF = 1e18;

const int dx[] = {1, -1, 0, 0, -1, 1, -1, 1};
const int dy[] = {0, 0, 1, -1, -1, 1, 1, -1};

int main() {
	FREOPEN();
	int n;
	cin >> n;
	string s;
	cin >> s;
	int cnt = 0;
	for (int i = 0; i < n; i++) if (s[i] == 'R') cnt++;
	if (cnt > n - cnt) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
def on_segment(u0,v0,u1,v1,u2,v2):
     return u1<=max(u0,u2) and u1>=min(u0,u2) and v1<=max(v0,v2) and v1>=min(v0,v2)

def signed_area(x0,y0,x1,y1):
    return (x0*y1-x1*y0)

q=int(input())

for _ in [0]*q:
    x0,y0,x1,y1,x2,y2,x3,y3=map(int,input().split())
    ta=signed_area(x1-x0,y1-y0,x2-x0,y2-y0)
    tb=signed_area(x1-x0,y1-y0,x3-x0,y3-y0)
    tc=signed_area(x3-x2,y3-y2,x0-x2,y0-y2)
    td=signed_area(x3-x2,y3-y2,x1-x2,y1-y2)

    """
    print(ta/2)
    print(tb/2)
    print(tc/2)
    print(td/2)
    
    print(on_segment(x0,y0,x2,y2,x1,y1))
    print(on_segment(x0,y0,x3,y3,x1,y1))
    print(on_segment(x2,y2,x0,y0,x3,y3))
    print(on_segment(x2,y2,x1,y1,x3,y3))
    """

    if ta*tb<0 and tc*td<0:
        print("1")
    elif ta==0 and on_segment(x0,y0,x2,y2,x1,y1):
        print("1")
    elif tb==0 and on_segment(x0,y0,x3,y3,x1,y1):
        print("1")
    elif tc==0 and on_segment(x2,y2,x0,y0,x3,y3):
        print("1")
    elif td==0 and on_segment(x2,y2,x1,y1,x3,y3):
        print("1")
    else:
        print("0")


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


int main() {
    int A, B, K;
    std::cin >> A >> B >> K;
    int n = 0;
    for (int i = std::min(A, B); i >= 1; i--) {
        if (A % i == 0 && B % i == 0) {
            n++;
            if (n == K) {
                std::cout << i  << "\n";
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;

bool graph[10][10];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	VE a(m), b(m);
	rep(i, m) {
		cin >> a[i] >> b[i]; a[i]--; b[i]--;
		graph[a[i]][b[i]] = true; graph[b[i]][a[i]] = true;
	}
	VE tmp(n-1);
	int ans = 0;
	rep(i, n - 1)tmp[i] = i + 1;
	do {
		bool ok = true;
		rep(i, n - 1) {
			if (i == 0) {
				if (!graph[0][tmp[i]]) {
					ok = false;
				}
			}
			else {
				if (!graph[tmp[i - 1]][tmp[i]]) {
					ok = false;
				}

			}
		}
		if (ok)ans++;
	} while (next_permutation(ALL(tmp)));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//Position this line where user code will be pasted.

int M = 1e9 + 7;

int main() {
    
	int n, m;

    cin>>n>>m;

    vector<int > adj[n];
    int ui, vi;
    for(int i=0;i<m;i++){
        cin>>ui>>vi;
        adj[ui-1].push_back(vi-1);
    }

    int s, t;
    cin>>s>>t;
    s--;
    t--;

    queue<int > q;
    queue<int > q2;

    
    q.push(s);

    q2.push(0);

    set<int > prevc[n];

    int ans = -1;
    while(!q.empty()){

        int ver = q.front();
        int c = q2.front();
        
        q.pop();
        q2.pop();
        
        int sz = adj[ver].size();

        if(prevc[ver].find(c%3) == prevc[ver].end()){
            prevc[ver].insert(c%3);
        }
        else{
            continue;
        }          

        if(ver == t && c%3 == 0) {
            ans = c/3;
            break;
        }

        for(int i=0;i<sz;i++){
            int l = adj[ver][i];
                q.push(l);
                q2.push(c+1);
        }
    }

    cout<<ans<<endl;


}

Measured memory_bytes: 24448
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner vd = new Scanner(System.in);
		int a = vd.nextInt();
		int b = vd.nextInt();
		int x = vd.nextInt();
		int y = vd.nextInt();
		vd.close();
		System.out.println(Math.min(a, b)+Math.min(x, y));

	}

}


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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k,s;
    cin >> n >> k >> s;
    for(i=0;i<n;i++){
        if(i<k){
            cout << s << " ";
        }else {
            if(s==1000000000)cout << 1 << " ";
            else cout << 1000000000 << " ";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>

int main(void){

  int n,q;
  int m,d;
  int i,j;

  for(;;){

    scanf("%d %d",&n,&q);
    if(n==0&&q==0)break;

    int date[100]={0};

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

      scanf("%d",&m);
        for(j=0;j<m;j++){
          scanf("%d",&d);
          date[d-1]++;
        }
    }

    int day = 0;
    int t = q-1;

    for(i=0;i<100;i++){
      if(date[i]>t){
        t = date[i];
        day = i + 1;
      }
    }

    printf("%d\n",day);

  }
    
  return 0;

}

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

using ll = long long;

vector<int> compress(vector<int> v) {
    sort(begin(v), end(v));
    v.erase(unique(begin(v), end(v)), end(v));
    return v;
}

int read_time() {
    int h, m; cin >> h >> m;
    return h * 60 + m;
}

int main() {
    int n; cin >> n;
    vector<vector<int>> s(n, vector<int>(3)), t(n, vector<int>(3));
    vector<vector<int>> xs(3);
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < 3; ++j) {
            s[i][j] = read_time(), t[i][j] = read_time();
            t[i][j] += 1;
            xs[j].push_back(s[i][j]);
            xs[j].push_back(t[i][j]);
        }
    }
    vector<vector<ll>> sum(3);
    for(int i = 0; i < 3; ++i) {
        xs[i] = compress(move(xs[i]));
        sum[i].resize(xs[i].size());
    }
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < 3; ++j) {
            s[i][j] = lower_bound(begin(xs[j]), end(xs[j]), s[i][j]) - begin(xs[j]);
            t[i][j] = lower_bound(begin(xs[j]), end(xs[j]), t[i][j]) - begin(xs[j]);
            sum[j][s[i][j]] |= (1LL << i);
            sum[j][t[i][j]] |= (1LL << i);
        }
    }
    const vector<int> sz = { (int)sum[0].size(), (int)sum[1].size(), (int)sum[2].size() };
    for(int i = 0; i < 3; ++i) {
        for(int j = 0; j + 1 < sz[i]; ++j) {
            sum[i][j + 1] ^= sum[i][j];
        }
    }

    int ans = 0;
    for(int i = 0; i < sz[0]; ++i) {
        for(int j = 0; j < sz[1]; ++j) {
            for(int k = 0; k < sz[2]; ++k) {
                ans = max(ans, __builtin_popcountll(sum[0][i] & sum[1][j] & sum[2][k]));
            }
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 3164
#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()
{
	string s;
	cin >> s;
	int len = s.size();
	int i = len - 1;
	string b;
	while (i > 0)
	{
		if (s[i] == 'm' && i >= 4)
		{
			b.insert(0, "dream");
			i -= 4;
		}
		else if (s[i] == 'e' && i >= 4)
		{
			b.insert(0, "erase");
			i -= 4;
		}
		else if (s[i] == 'r')
		{
			if (s[i - 2] == 's' && i >= 5)
			{
				b.insert(0, "eraser");
				i -= 5;
			}
			else if (s[i - 2] == 'm' && i >= 6)
			{
				b.insert(0, "dreamer");
				i -= 6;
			}
		}
		i--;
	}
	// cout << b << endl;
	if (b == s)
		cout << "YES\n";
	else
		cout << "NO\n";
	return (0);
}


Measured memory_bytes: 640