akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef pair<int,int>P;
typedef long long ll;

class Dinic {
private:
	struct Edge {
		int to, cap, rev;
		Edge(int t, int c, int r) :to(t), cap(c), rev(r) {}
	};
	int V;
	std::vector<std::vector<Edge>> graph;
	std::vector<int> level, iter;

public:
	Dinic(int v) : V(v) {
		graph.resize(v);
		level.resize(v, -1);
		iter.resize(v, 0);
	}

	void add_edge(int from, int to, int cap) {
		graph[from].emplace_back(to, cap, graph[to].size());
		graph[to].emplace_back(from, 0, graph[from].size() - 1);
	}

	void bfs(int s) {
		std::fill(level.begin(), level.end(), -1);
		std::queue<int> queue;
		level[s] = 0;
		queue.push(s);
		while (!queue.empty()) {
			int v = queue.front(); queue.pop();
			for (int i = 0; i < (int)graph[v].size(); ++i) {
				Edge& e = graph[v][i];
				if (e.cap > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					queue.push(e.to);
				}
			}
		}
	}

	int dfs(int v, int t, int f) {
		if (v == t) return f;
		for (int& i = iter[v]; i < (int)graph[v].size(); ++i) {
			Edge& e = graph[v][i];
			if (e.cap > 0 && level[v] < level[e.to]) {
				int d = dfs(e.to, t, std::min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					graph[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

	ll max_flow(int s, int t) {
		ll res = 0;
		while (true) {
			bfs(s);
			if (level[t] < 0) return res;
			std::fill(iter.begin(), iter.end(), 0);
			int f;
			while ((f = dfs(s, t, (1LL << 31) - 1)) > 0) {
				res += f;
			}
		}
	}
};

int a[200];
int main(){
	int n;scanf("%d",&n);
	rep(i,n)scanf("%d",&a[i]);
	Dinic dinic(n+2);
	int s=n,t=n+1;
	ll sum=0;
	rep(i,n){
		if(a[i]<0){
			dinic.add_edge(s,i,-a[i]);
			dinic.add_edge(i,t,0);
		}
		else{
			sum+=a[i];
			dinic.add_edge(s,i,0);
			dinic.add_edge(i,t,a[i]);
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=i*2;j<=n;j+=i){
			dinic.add_edge(i-1,j-1,INT_MAX);
		}
	}
	cout<<sum-dinic.max_flow(s,t)<<endl;
}

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

#define mod 1000000007
#define int long long

int power(int a,int b)
{
    int ans=1;

    while(b>0)
    {
        if(b&1)
        {
            ans*=a;
            ans%=mod;
        }
        a*=a;
        a%=mod;
        b/=2;
    }

    return ans;
}
 
int32_t main()
{
    int n;
    cin>>n;

    long long ans=power(10,n);
    ans-=power(9,n);
    ans+=mod;
    ans%=mod;
    ans-=power(9,n);
    ans+=mod;
    ans%=mod;
    ans+=power(8,n);
    ans%=mod;
    cout<<ans;

}

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

using namespace std;

long long int joon[100][5];

int main()
{
    long long int n;
    cin >> n;
    joon[61][0] = 1;
    for(int i = 60; i >= 0; i--){
        long long int jj = (n >> i) & 1;
        joon[i][2] += joon[i + 1][2] * 3;
        if(jj){
            joon[i][2] += joon[i + 1][1] * 2;
            joon[i][1] += joon[i + 1][1];
            joon[i][1] += joon[i + 1][0];
            joon[i][0] += joon[i + 1][0];
        }
        else{
            joon[i][2] += joon[i + 1][1];
            joon[i][1] += joon[i + 1][1];
            joon[i][0] += joon[i + 1][1];
            joon[i][0] += joon[i + 1][0];
        }
        joon[i][0] %= 1000000007;
        joon[i][1] %= 1000000007;
        joon[i][2] %= 1000000007;
    }
    cout << (joon[0][0] + joon[0][1] + joon[0][2]) % 1000000007;
    return 0;
}


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

using namespace std;

int main() {
	string s;
	int K;
	cin >> s >> K;
	vector<string> v;
	for (int i = 1; i <= K; i++) {
		if (i > s.size()) break;
		for (int j = 0; j < s.size(); j++) {
			v.push_back(s.substr(j, i));
		}
	}
	sort(v.begin(), v.end());
	auto result = unique(v.begin(), v.end());
	v.erase(result, v.end());
	/*for (auto itr = v.begin(); itr != result; itr++) {
		cout << *itr << endl;
	}*/
	cout << v[K - 1] << endl;
}


Measured memory_bytes: 1160
N=parse(Int,readline())
A=map(x->parse(Int,x),split(readline()))
B=map(x->parse(Int,x),split(readline()))
ans=0
for i=1:N
	ans+=t=min(A[i],B[i])
	ans+=t=min(A[i+1],B[i]-t)
	A[i+1]-=t
end
println(ans)

Measured memory_bytes: 167388
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

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

    vector<double> v(N);
    for (int i = 0; i < N; i++)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.end());

    double mx = -1;
    double temp;
    do
    {
        for (int i = 0; i < N - 1; i++)
        {
            temp = (v[i] + v[i + 1]) / 2;
            v[i + 1] = temp;
            if (i == N - 2)
            {
                if (mx < v[N - 1])
                {
                    mx = v[N - 1];
                }
            }
        }
    } while (next_permutation(v.begin(), v.end()));

    double ans = mx;
    std::cout << std::fixed << std::setprecision(5);
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main() {
  int N, M; cin >> N >> M;
  
  vi a(N);
  rep(i,M) {
    int k; cin >> k;
    rep(j,k) {
      int s; cin >> s;
      s--;
      a[s] |= 1<<i;
    }
  }

  int p = 0;
  rep(i,M) {
    int x; cin >> x;
    p |= x<<i;
  }

  int ans = 0;
  rep(s,1<<N) {
    int t = 0;
    rep(i,N) {
      if(s>>i&1) {
        t ^= a[i];
      }
    }
    if(t==p) {
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define bp(x) __builtin_popcountll(x)
#define ll int64_t
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define fw(i, l, r, c) for(int i = l; i <= r; i += c)
#define bw(i, r, l, c) for(int i = r; i >= l; i -= c)
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<ll> vi;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;

ll n, k;
ll a[1001];
vi sum;

signed main() {
	//freopen("blu.inp", "r", stdin);
	//freopen("blu.out", "w", stdout);
	//fastio;
	cin >> n >> k;
	fw(i, 0, n - 1, 1){
		cin >> a[i];	
	}
	fw(i, 0, n - 1, 1){
		ll summ = 0;
		fw(j, i, n - 1, 1){
			summ += a[j];
			sum.pb(summ);
		}
	}
	sum.pb(a[n - 1]);
	ll res = 0;
	vi num;
	bw(i, 50, 0, 1){
		fw(j, 0, sum.size() - 1, 1){
			ll check = (sum[j] >> i) & 1;
			if(check){
				num.pb(sum[j]);
			} 
		}
		if(num.size() >= k){
			sum.clear();
			fw(j, 0, num.size() - 1, 1){
				sum.pb(num[j]);
			}
		}
		num.clear();
	}
	ll ans = LLONG_MAX;
	for(int i = 0; i < sum.size(); i++) {
		ans &= sum[i];
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 6384
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "functional"
using namespace std;

const int BORDER = 1000000;

int N, M, K, S;
int price[2];
bool status[100001];
bool dead[100001];
int box;
int s, e;
bool flag[100001];
list <int> edge[100001];
long long int dis[100001];
long long int NOW;

queue<int>Q;
priority_queue<long long int,vector<long long int>,greater<long long int> > town;

int main() {
	cin >> N >> M >> K >> S;
	cin >> price[0] >> price[1];
	for (int i = 1; i <= N; i++) {
		flag[i] = true;
		dis[i] = INT_MAX;
	}
	for (int i = 0; i < K; i++) {
		cin >> box;
		dead[box] = true;
		edge[0].push_back(box);
		flag[box] = false;
	}
	for (int i = 0; i < M; i++) {
		cin >> s >> e;
		edge[s].push_back(e);
		edge[e].push_back(s);
	}
	Q.push(0);
	while (!Q.empty()) {
		NOW = Q.front();
		for (auto i = edge[NOW].begin(); i != edge[NOW].end(); ++i) {
			if (dis[NOW] + 1 < dis[*i]) {
				Q.push(*i);
				dis[*i] = dis[NOW] + 1;
				if (dis[*i] <= S+1)status[*i] = true;
			}
		}
		Q.pop();
	}
	for (int i = 2; i <= N; i++)dis[i] = LLONG_MAX;
	dis[1] = 0;
	town.push(1);
	while (!town.empty()) {
		NOW = town.top() % BORDER;
		for (auto i = edge[NOW].begin(); i != edge[NOW].end(); ++i) {
			if (!dead[*i]) {
				if (dis[NOW] + price[status[*i]] < dis[*i]) {
					dis[*i] = dis[NOW] + price[status[*i]];
					town.push(dis[*i] * BORDER + *i);
				}
			}
		}
		town.pop();
	}
	cout << dis[N]-price[status[N]]<<"\n";
	return 0;
}

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

#include <cstdint>

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};



const int MAX = 100005;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}




using mint = modint<1000000007>;

int N, K;


int main(){
	cin >> N >> K;
	vector<ll> v(N);
	for ( int i = 0; i < N; i++ ){
		cin >> v[i];
	}
	sort(v.begin(),v.end());
	
	
	vector<mint> acc(N+1);
	mint tmp = 0;
	acc[0] = 0;
	for ( int i = 0; i < N; i++ ){
		tmp += (v[i]+MOD);
		acc[i+1] = tmp;
	}
	// v[a]～v[b] の合計は  acc[b+1]-acc[a]
	
	
	if ( K == 1 ){
		cout << "0" << endl;
	}
	else {
		COMinit();
		mint result = 0;
		
		for ( int d = K; d <= N; d++ ){
			// Sの minとmaxが v[i]とv[i+d-1] とする。
			// Sのパターンの数は (d-2)C(K-2)
			
			mint sum = 0;
			//for ( int i = 0; i+d-1 < N; i++ ){
			//	sum += v[i+d-1]-v[i];
			//}
			// i : 0 .. N-d
			
			sum = (acc[N]-acc[d-1]) - (acc[N-d+1]-acc[0]);
			
			result += sum * COM(d-2,K-2);
		}
		
		cout << result.value() << endl;
	}
	
	return 0;
}




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


#define SIZE 20000000
vector<bool> prime(SIZE,true);
vector<int> ps;

void init(){
    prime[0] = prime[1] = false;
    rep(i,SIZE){
        if(!prime[i]) continue;
        for(int j = i*2; j<SIZE; j+=i){
            prime[j] = false;
        }
    }
}

int main(){
    init();
    int n;
    cin>>n;
    int cnt = 0;
    rep1(i,n){
        if(prime[i] && prime[i+2]){
            cnt += 2;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 5040
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define ff first
#define ss second

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

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

	int n, m;
	cin >> n >> m;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	vector<vector<int>> adj(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		adj[a - 1].push_back(b - 1);
		adj[b - 1].push_back(a - 1);
	}
    int answer=0;
    for(int i=0; i<n; i++){
        bool check=true;
        for(int nxt : adj[i]) if(h[i]<=h[nxt]) check=false;
        if(check) answer+=1;
    }
	cout << answer;

	return 0;
}


Measured memory_bytes: 8740
//2019年12月8日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define souatari rep1(i,n-1)rep(j,i)
#define souatari1 for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
const ll BIG = 10000000000000000;


vi e[100005];
int taka[100005];
int aoki[100005];


int main(){ 
    int n,u,v;
    cin >> n >> u >> v;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        e[a].push_back(b);
        e[b].push_back(a);
    }


    rep1(i,n){taka[i] = -1;aoki[i] = -1;}

    stack<pii> q;
    q.push(mp(u,0));
    while(!q.empty()){
        pii tmp = q.top();
        q.pop();
        taka[tmp.F] = tmp.S;
        for(const auto& t : e[tmp.F]){
            if(taka[t] == -1){
                q.push(mp(t,tmp.S+1));
            }
        }
    }


    stack<pii> r;
    r.push(mp(v,0));
    while(!r.empty()){
        pii tmp = r.top();
        r.pop();
        aoki[tmp.F] = tmp.S;
        for(const auto& t : e[tmp.F]){
            if(aoki[t] == -1){
                r.push(mp(t,tmp.S+1));
            }
        }
    }

    // rep1(i,n) cout << aoki[i];
    // cout << endl;



    int ans = 0;
    rep1(i,n) if (aoki[i]>taka[i]) ans = max(ans,aoki[i]-1);
    
    prints(ans);


    return 0;
}


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

int main(void) {
	// in
	int n, m;
	cin >> n >> m;
	vector<long long> s(n);
	for(int i = 0; i < m; ++i) {
		int k;
		cin >> k;
		for(int j = 0; j < k; ++j) {
			int ss;
			cin >> ss;
			s[ss - 1] += 1 << i;
		}
	}
	long long p = 0;
	for(int i = 0; i < m; ++i) {
		int p_buf;
		cin >> p_buf;
		p += p_buf << i;
	}

	// debug
	//for(int i = 0; i < n; ++i) {
	//	cout << bitset<10>(s[i]) << endl;
	//}
	//cout << bitset<10>(p) << endl;

	// bit search
	int n_pattern_all = 1 << n;
	int n_pattern = 0;
	for(int i_p = 0; i_p < n_pattern_all; ++i_p) {
		long long result = 0;
		for(int i_sw = 0; i_sw < n; ++i_sw) {
			result = result ^ (s[i_sw] * ((i_p >> i_sw) & 1));
		}
		result = result ^ p;
		//cout << result << endl;
		if(result == 0) ++n_pattern;
	}

	cout << n_pattern << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#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;

ll n;

ll countBit(ll b) {  // bの立っているbitの数を返す
    ll res = 0;
    rep(i, n) {
        if(b & 1<<i) {
            res++;
        }
    }
    return res;
}

int main() {
    
    cin >> n;

    vvl a(n, vl(n));
    rep(i, n) {
        rep(j, n) {
            cin >> a[i][j];
        }
    }
    
    ll N = 1<<n;
    vl dp(N);  // dp[S] : 男性iまでで、いままで使用した女性の集合がSのときの場合の数
    dp[0] = 1;
    rep(S, N-1) {
        ll i = countBit(S);  // iはSの立っているbitの数として求める
        rep(j, n) {  // 男性iが女性jとペアを作れるかチェックする
            if(a[i][j] == 0) {  // 男性iと女性jの相性が悪いときはダメ
                continue;
            }
            if(S & 1<<j) {  // 女性jがすでに使用されているときもダメ
                continue;
            }
            dp[S | 1<<j] += dp[S];
            dp[S | 1<<j] %= mod;
        }
    }

    out(dp[N-1]);  // 女性を全員使用したときの値が答え
    re0;
}

Measured memory_bytes: 16640
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <unordered_map>

using namespace std;

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

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<string> s(n);
  for (auto &x: s) cin >> x;

  unordered_map<string, int> count;
  for (auto &x: s) count[x]++;

  int highest = 0;
  for (auto &x: count) {
    if (x.second > highest) highest = x.second;
  }

  vector<string> ans;
  for (auto &x: count) {
    if (x.second == highest) ans.push_back(x.first);
  }

  sort(ans.begin(), ans.end());

  for (auto &x: ans) cout << x << endl;

  return 0;
}


Measured memory_bytes: 26948
n, m = list(map(int, input().split()))

menu = [0] * m
for i in range(n):
    ka = list(map(int, input().split()))
    for a in ka[1:]:
        menu[a-1] += 1
res = 0
for i in menu:
    if i == n:
        res += 1
print(res)


Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head) << " ";
  print(tail...);
}

int main() {
  GS(s);
  GI(K);
  int i = 0;
  while (K > 0) {
    if (i >= s.size()) {
      K %= 26;
      s[s.size() - 1] += K;
      break;
    }
    if (s[i] > 'a' && 'z' + 1 - s[i] <= K) {
      K -= 'z' + 1 - s[i];
      s[i] = 'a';
      i++;
    } else {
      i++;
    }
  }
  print(s);
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <map>
#include <algorithm>    
#include <vector>       
#include <set>
#include <utility>  
#include <cstring>
#include <stdio.h>
#include <limits.h>
#include <queue>
#include <algorithm> 
#define MAX_DOUBLE  40000000000.0 
#include <math.h> 
#include <unistd.h>

using namespace std;


int min(int a, int b){
	if( a > b ) return b;
	return a; 
}

long long max(long long a, long long b){
	if( a < b ) return b;
	return a; 
}

long long values[100010];
long long weights[100010];

map<pair<int, int>, long long > res; 

long long knapSack(int W, int n) 
{ 
   int i, w; 
   long long K[n+1][W+1]; 
  
   for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (weights[i-1] <= w) 
                 K[i][w] = max(values[i-1] + K[i-1][w-weights[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
  
   return K[n][W]; 
} 


int main(){
	int n, w;
	cin>>n>>w;
	
	for(int i = 0; i < n; i++){
		cin>>weights[i]>>values[i];

	}

	cout<<knapSack(w, n);
}


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

main()
{
    int n,m,x,y;
    cin>>n>>m;
    int h[n+1],flag[n+1],ans=0;
    fill(flag,flag+n+1,1);
    for(int i=1;i<=n;i++) cin>>h[i];
    while(m--){
        cin>>x>>y;
        if(h[x]<=h[y]) flag[x]=0;
        if(h[y]<=h[x]) flag[y]=0;
    }
    for(int i=1;i<=n;i++)
        if(flag[i]) ans++;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 4420
n = int(input())
s = input()
jo_cnt = 0
oi_cnt = 0
j_cnt = 0
o_cnt = 0
i_cnt = 0
joi_cnt = 0
j_acc = []
o_acc = []
i_acc = []
for c in s:
  if c == "J":
    j_cnt += 1
  elif c == "O":
    o_cnt += 1
    jo_cnt += j_cnt
  else:
    i_cnt += 1
    oi_cnt += o_cnt
    joi_cnt += jo_cnt
  j_acc.append(j_cnt)
  o_acc.append(o_cnt)
  i_acc.append(i_cnt)

ji_cnt = max(j_acc[i] * (i_acc[-1] - i_acc[i]) for i in range(n))
print(joi_cnt + max(jo_cnt, oi_cnt, ji_cnt))


Measured memory_bytes: 11228
#include<iostream>
#include<map>
using namespace std;
using std::map;
int main() {
	map<string, int> a;
	int N = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		a[s]++;
	}
	cout << a.size();

}


Measured memory_bytes: 19224
#include<bits/stdc++.h>
#define fi                first
#define se                 second
#define ll               long long
#define mod              1000000007
#define endl              "\n"
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb                push_back
#define all(v)             v.begin(),v.end()
#define inp(V,n)      for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)     {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
using namespace std;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}
bool sortByVal(const pair<double,double> &a,
               const pair<double,double> &b)
{
    if(a.fi==b.fi)
    {
    return (a.se >b.se);
    }
    else
        return (a.fi<b.fi);
}
ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}
ll sumofdigit(ll n)
{
    ll c=0,d=0,sum=0,i;
    while(n>0)
    {
        c=n%10;
        sum+=c;
        n/=10;
    }
    return sum;
}
int main()
{
 fast;
     int t=1;
     //cin>>t;
     while(t--)
     {

       ll k,i=0,j=0,c=0,d=0,e=0,f=0,sum=0,g=0,h=0,n,maxi=0;
       cin>>n>>k;
       cout<<n*k;
      }


}



Measured memory_bytes: 3612
#include <iostream>
#include <stack>
using namespace std;
int main(){
	string s; stack<int> sta; int a, b;
	while(cin >> s){
			if (s == "+") { a = sta.top(); sta.pop(); b = sta.top(); sta.pop(); sta.push(a + b);}
			else if (s == "*") { a = sta.top(); sta.pop(); b = sta.top(); sta.pop(); sta.push(b * a);}
			else if (s == "-") { a = sta.top(); sta.pop(); b = sta.top(); sta.pop(); sta.push(b - a);}
			else sta.push(stoi(s));
	}
	printf("%d\n", sta.top());
}


Measured memory_bytes: 3268
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 99999999999999999;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;

int a, b, c, d, k[10];

int dfs(int n, int m, int o, int p) {
	if (n == a) {
		if (min({ m,o,p }) > 0) { return abs(m - b) + abs(o - c) + abs(p - d) - 30; }
		else { return INF; }
	}
	return min({ dfs(n + 1,m,o,p),dfs(n + 1,m + k[n],o,p) + 10,dfs(n + 1,m,o + k[n],p) + 10,dfs(n + 1,m,o,p + k[n]) + 10 });
}

int main() {
	cin >> a >> b >> c >> d;
	for (int i = 0; i < a; ++i) {
		cin >> k[i];
	}
	cout << dfs(0, 0, 0, 0) << endl;
}

Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

char mmem[2000000];
int dmem[1000000];

char *m[1000000];
int *d[1000000];

int s[1000000][2];
int main(void){
	int h=nextint();
	int w=nextint();
	int k=nextint();
	int x1=nextint()-1;
	int y1=nextint()-1;
	int x2=nextint()-1;
	int y2=nextint()-1;
	char *mpos=mmem;
	int *dpos=dmem;
	for(int i=0; i<h; i++){
		m[i] = mpos; mpos+=w+1;
		d[i] = dpos; dpos+=w;
		nextstr(m[i]);
	}
	int sl=0, sr=0;
	d[x1][y1]=1;
	s[sr][0]=x1; s[sr][1]=y1; sr++;
	while(sl<sr){
		int x=s[sl][0], y=s[sl][1]; sl++;
		int D=d[x][y]+1;
		{
			int X=x-1, Y=y;
			for(int i=0; i<k && X>=0 && m[X][Y]=='.' && (d[X][Y]==0||d[X][Y]>=D); i++){ if(d[X][Y]!=D){d[X][Y]=D; s[sr][0]=X; s[sr][1]=Y; sr++;} X--; }
		}
		{
			int X=x+1, Y=y;
			for(int i=0; i<k && X<h  && m[X][Y]=='.' && (d[X][Y]==0||d[X][Y]>=D); i++){ if(d[X][Y]!=D){d[X][Y]=D; s[sr][0]=X; s[sr][1]=Y; sr++;} X++; }
		}
		{
			int X=x, Y=y-1;
			for(int i=0; i<k && Y>=0 && m[X][Y]=='.' && (d[X][Y]==0||d[X][Y]>=D); i++){ if(d[X][Y]!=D){d[X][Y]=D; s[sr][0]=X; s[sr][1]=Y; sr++;} Y--; }
		}
		{
			int X=x, Y=y+1;
			for(int i=0; i<k && Y<w  && m[X][Y]=='.' && (d[X][Y]==0||d[X][Y]>=D); i++){ if(d[X][Y]!=D){d[X][Y]=D; s[sr][0]=X; s[sr][1]=Y; sr++;} Y++; }
		}
		//printf("%d %d %d ", x+1, y+1, D-1);
	}
	printf("%d\n", d[x2][y2]==0?-1:d[x2][y2]-1);
}


Measured memory_bytes: 12292
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n,m;cin>>n>>m;

	cout<<(1<<m)*(1900*(m)+100*(n-m))<<endl;











	
}

Measured memory_bytes: 256
N,M = map(int,input().split())
H = list(map(int,input().split()))
good = [True for i in range(N)]
for i in range(M):
	A,B = map(int,input().split())
	A -= 1
	B -= 1
	if H[A] <= H[B]:
		good[A] = False
	if H[B] <= H[A]:
		good[B] = False
print(sum([1 for x in good if x]))

Measured memory_bytes: 20108
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

bool isKomoji(char x) {
    for(char c = 'a'; c <= 'z'; c++) {
        if(c == x) {
            return true;
        }
    }
    return false;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    if(s[0] != 'A') {
        cout << "WA" << endl;
        return 0;
    }
    int cnt = 0;
    for(int i = 2; i <= n - 2; i++) {
        if(s[i] == 'C') {
            cnt++;
        }
    }
    if(cnt != 1) {
        cout << "WA" << endl;
        return 0;
    }
    int id;
    for(id = 2; id <= n - 2; id++) {
        if(s[id] == 'C') {
            break;
        }
    }
    for(int i = 0; i < n; i++) {
        if(i == 0 || i == id) {
            continue;
        }
        if(!isKomoji(s[i])) {
            cout << "WA" << endl;
            return 0;
        }
    }
    cout << "AC" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int par[100001];//親
int siz[100000];//サイズ

void ini(int n){ //初期化
  for(int i=0;i<=n;i++){
    par[i] = i;
    siz[i] = 1;
  }
}
int root(int x){ //根を返す
  if(par[x] == x) return x;
  else return par[x] = root(par[x]);
}

void uni(int x, int y){ //くっつける
  x = root(x);
  y = root(y);
  if(x != y){
    siz[x] += siz[y];
    par[y] = x;
  }
}

int same(int x,int y){
  return root(x) == root(y);
}

int size(int x){ //サイズを返す
  return siz[root(x)];
}

int main(void){
  int i,n,m,x,y,count=0;
  scanf("%d %d",&n,&m);
  int p[n+1];
  ini(n);
  for(i=1;i<=n;i++){
    scanf("%d",&p[i]);
  }
  for(i=0;i<m;i++){
    scanf("%d %d",&x,&y);
    uni(x,y);
  }
  for(i=1;i<=n;i++){
    if(same(i,p[i])) count++;
  }
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 2888
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  VEC<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(ALL(a));
  reverse(ALL(a));
  int ans = a[0] * 10 + a[1] + a[2];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 764
A, B, C = map(int, input().split())

if A == B and B == C and A % 2 == 0:
    print('-1')
    exit()

count = 0
for i in range(10**9):
    if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
        break
    count += 1
    a = A
    b = B
    c = C
    A = b // 2 + c // 2
    B = a // 2 + c // 2
    C = a // 2 + b // 2

print(count)


Measured memory_bytes: 38512
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s, ans;
    cin >> s;
    char str[4] = {'N', 'W', 'E', 'S'};
    int count[4] = {0, 0, 0, 0};
    for (int i=0; i<(int)s.length(); ++i){
        for (int j=0; j<4; ++j){
            if(str[j] == s[i]){
                count[j]++;
                break;
            }
        }
    }
    ans = "Yes";
    if((count[0] > 0 && count[3] == 0) || (count[0] == 0 && count[3] > 0)){
        ans = "No";
    }
    if((count[1] > 0 && count[2] == 0) || (count[1] == 0 && count[2] > 0)){
        ans = "No";
    }
    cout << ans << "\n";
    return 0;
}

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

#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,a,n) for(ll i=a;i<n;i++)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef pair<ll, ll> pll;

const int INF = 100000000;
const ll LINF = 1e18+5;

int main() {
    int N;
    int P[8] = {};
    int Q[8] = {};
    cin >> N;
    rep(i,N) {
        cin >> P[i];
    }
    rep(i,N) cin >> Q[i];
    vector<int> v(N);
    iota(v.begin(), v.end(), 1);
    int count = 0;
    int pcount = 0;
    int qcount = 0;
    do {  
        count++;
        bool Pflag = true;
        bool Qflag = true;
        rep(i,N) {
            if(v[i] != P[i]) Pflag = false;
            if(v[i] != Q[i]) Qflag = false;
        }
        if(Pflag) {
            pcount = count;
        }
        if(Qflag) {
            qcount = count;
        }
    } while( next_permutation(v.begin(), v.end()));
    cout << abs(pcount - qcount) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long ans = 0;
        if((a+b)%2 == 1){
            long min1 = Math.min(a-1,b-1);
            long max1 = Math.max(a-1,b-1);
            long minN = Math.min(n-a,n-b);
            long maxN = Math.max(n-a,n-b);
            ans = Math.min(min1 + (max1 - min1)/2 + (max1 - min1)%2 ,minN + (maxN - minN)/2 + (maxN - minN)%2);
        }else{
            ans = Math.abs((a-b)/2);
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
    int ans;
    int d,n; cin>>d>>n;
    if(n!=100){
        ans=n;
        FOR(i,0,d) ans*=100;
    }else{
        ans=101;
        FOR(i,0,d) ans*=100;
    }
    co(ans);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
struct Process
{
    char name[11];
    int tim;
};

struct Process dequeue(struct Process *Q,int *head)
{
    *head = *head + 1;
    return Q[*head - 1];
}

void enqueue(struct Process x,struct Process *Q,int *tail)
{
    Q[*tail] = x;
    *tail +=1;
}


int main()
{
    int n,c,cnt=0,box=0,ksn=0;
    scanf("%d %d",&n,&c);
    int tail=n,head=0;
    char nmtmp[11],tmp;
    struct Process p[n+1];
    for(int i=0;i<n;i++)
    {
        scanf("%s", p[i].name);
        scanf("%d", &p[i].tim);
       /* while((tmp=getchar())!=' ')
        {
            if(!(tmp=='\n'||tmp=='\r'))
            {
                nmtmp[cnt] = tmp;
                cnt++;
            }
        }
        strcpy(p[i].name,nmtmp);
        scanf("%d",&box);
        p[i].tim = box;
        cnt=0;
        box=0;*/
    }
    while(head!=tail)
    {
        if(tail > n) tail = 0;
        struct Process x = dequeue(p,&head);
        if(head > n) head =0;
        if(x.tim < c)
        {
            ksn += x.tim;
            x.tim = 0;
        }
        else 
        {
            ksn += c;
            box = x.tim;
            box -= c;
            x.tim = box;
        }
        if(x.tim == 0)
        {
            printf("%s %d\n", x.name,ksn);
        }
        else
        {
            enqueue(x,p,&tail);
        }
    }
    return 0;
}


Measured memory_bytes: 2516
#include<cstdio>
#include<cmath>
int main(){
    int n;
    for(;;){
        scanf("%d",&n);
        if(n==-1)break;
        double x=1,y=0;
        double rad=atan2(-y,-x);
        for(int i=2;i<=n;i++){
            rad-=M_PI_2;
            x+=cos(rad);
            y+=sin(rad);
            rad=atan2(-y,-x);
        }
        printf("%lf\n%lf\n",x,y);
    }
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  int n;
  scanf("%d", &n);

  vector<int> ar;

  for(int i=0; i<n; i++)
  {
    int temp;
    scanf("%d", &temp);
    ar.push_back(temp);
  }

  int l = 0;
  while(l!=n-1)
  {
    printf("%d ",ar[l]);
    l++;
  }
  printf("%d\n", ar[l]);

  for(int i=1; i<n; i++)
  {
    int medium = ar[i];
    for(int j=i-1; j>-1; j--)
    {
      if(medium <= ar[j])
       {
         ar[j+1] = ar[j];
         ar[j] = medium;
       }

      else if(medium > ar[j])
      {
        break;
      }
    }

    int l = 0;
    while(l!=n-1)
    {
      printf("%d ",ar[l]);
      l++;
    }
    printf("%d\n", ar[l]);

  }
  return 0;
}



Measured memory_bytes: 3272
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> x(n);
  for (int i = 0; i < n; i++) {
    int v;
    cin >> v;
    x[i] = make_pair(v, i);
  }
  sort(x.begin(), x.end());
  vector<int> m(n);
  for (int i = 0; i < x.size(); ++i) {
    int prev = x[i].second;
    m[prev] = i;
  }

  for (int i = 0; i < n; i++) {
    if (m[i] < n / 2) {
      cout << x[n / 2].first << endl;
    } else {
      cout << x[n / 2 - 1].first << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 4480
#include<iostream>

#define int long long
using namespace std;

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b == 0) return a;
	return gcd(a % b, b);
}

const long long MOD = 1e9 + 7;

int n;
string s;
long long dp[2];

signed main()
{
	cin >> s;
	dp[0] = 1;
	for (int i = 0; i < s.size(); i++)
	{
		int dp2[2];
		if (s[i] == '1')
		{
			dp2[0] = (2 * dp[0]) % MOD;
			dp2[1] = (dp[0] + 3 * dp[1]) % MOD;
		}
		else
		{
			dp2[0] = dp[0];
			dp2[1] = (3 * dp[1]) % MOD;
		}
		dp[0] = dp2[0];
		dp[1] = dp2[1];
	}
	cout << (dp[0] + dp[1]) % MOD;
}

Measured memory_bytes: 512
#include<stdio.h>
 
int D[107][7],i,j,N;
int G[55][6]={
    {1,2,3},{1,3,5},{1,5,4},{1,4,2},
    {2,1,4},{2,4,6},{2,6,3},{2,3,1},
    {3,1,2},{3,2,6},{3,6,5},{3,5,1},
    {4,1,5},{4,2,1},{4,6,2},{4,5,6},
    {5,1,3},{5,3,6},{5,4,1},{5,6,4},
    {6,2,4},{6,4,5},{6,5,3},{6,3,2}};
 
int ch(int a,int b)
{
    int i;
    for(i=0;i<24;i++)
    {
        if(D[a][1]==D[b][G[i][0]]&&
           D[a][2]==D[b][G[i][1]]&&
           D[a][3]==D[b][G[i][2]]&&
           D[a][6]==D[b][7-G[i][0]]&&
           D[a][5]==D[b][7-G[i][1]]&&
           D[a][4]==D[b][7-G[i][2]])
        return 1;
    }
    return 0;
}
 
int main()
{
    scanf("%d",&N);
    for(i=0;i<N;i++)
        for(j=1;j<=6;j++)
            scanf("%d",&D[i][j]);
    for(i=0;i<N;i++)
        for(j=i+1;j<N;j++)
        {
            if(ch(i,j))
            {
                puts("No");
                return 0;
            }
        }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  vector<ll> a(n), b(n);
  for (int i = 0; i < n; i++){
    cin >> a[i] >> b[i];
  }
  sort(a.begin(), a.end());
  
  sort(b.begin(), b.end());
  
  if (n % 2 == 1){
    cout << b[n/2] - a[n/2] + 1 << endl;
  }
  else {
    cout << b[n/2] + b[n/2 - 1] - (a[n/2] + a[n/2 - 1]) + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 6352
def main():
    X, N = (int(i) for i in input().split())
    P = {int(i) for i in input().split()}

    for i in range(200):
        if X-i not in P:
            print(X-i)
            break
        if X+i not in P:
            print(X+i)
            break


if __name__ == '__main__':
    main()


Measured memory_bytes: 61904
#include<stdio.h>

int main(){
  int i,a,b,find,fi;
  fi=1;
  do{
    scanf("%d %d",&a,&b);
    if(a==0&&b==0){
      break;
    }else if(!fi){
      printf("\n");
    }
    b++;
    for(i=a,find=0;i<b;i++){
      if(i%4==0){
	if(i%100==0){
	  if(i%400==0){
	    printf("%d\n",i);
	    find=1;
	  }
	}else{
	  printf("%d\n",i);
	  find=1;
	}
      }
    }
    if(fi) fi=0;
    if(!find) printf("NA\n");
  }while(1);
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf =1 << 30;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n, Q; cin >> n >> Q;
    using TOX = tuple<int, int, int>;
    vector<TOX> in;
    rep(loop, n){
        int s, t, x; cin >> s >> t >> x;
        s = max(0, s - x);
        t = t - x;
        if(t <= 0) continue;
        in.emplace_back(TOX(s, 1, x));
        in.emplace_back(TOX(t, -1, x));
    }
    sort(_all(in));
    int m = in.size();

    vi D(Q);
    for(auto& e : D) cin >> e;

    int i = 0;
    set<int> s = {inf};
    for(auto& e : D){
        while(i < m){
            int t, op, x; tie(t, op, x) = in[i];
            if(t > e) break;
            if(op == 1){
                s.insert(x);
            }
            else {
                s.erase(x);
            }
            i++;
        }
        int x = *begin(s);
        x = (x == inf ? -1:x);
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 16364
#define _CRT_SECURE_NO_WARNINGS
#include <array>
#include <cstdio>
#include <deque>
#include <utility>

using namespace std;

// 0-1 BFS
int main()
{
    int K;
    if (scanf("%d", &K) < 1) return 0;

    array<int, 100000> dist;
    dist.fill(100000);

    deque<int> deq;

    dist[1] = 1;

    deq.push_back(1);

    while (deq.size())
    {
        int u = deq.front();
        deq.pop_front();

        // コスト 0 の辺の遷移は deque の先頭に
        if (dist[u] < dist[u * 10 % K])
        {
            dist[u * 10 % K] = dist[u];
            deq.push_front(u * 10 % K);
        }
        // コスト 1 の辺の遷移は deque の末尾に
        if (dist[u] + 1 < dist[(u + 1) % K])
        {
            dist[(u + 1) % K] = dist[u] + 1;
            deq.push_back((u + 1) % K);
        }
    }

    printf("%d\n", dist[0]);
    return 0;
}


Measured memory_bytes: 816