akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int n;

vector<char> v, r;

vector<pair<vector<char>, int> > v1, v2;

inline int solve()
{
	r = v; sort(r.begin(), r.end());

	int ln = n / 2 - 1, rn = n - ln - 1;

	if (n == 10) { rn--; }

	map<vector<char>, int> d1; d1[v] = 1;

	queue<vector<char> > que1; que1.push(v);

	while (!que1.empty())
	{
		vector<char> v3 = que1.front(); que1.pop();

		v1.push_back(make_pair(v3, d1[v3] - 1));

		if (d1[v3] < ln + 1)
		{
			for (int i = 0; i < n; i++)
			{
				for (int j = i + 1; j < n; j++)
				{
					vector<char> v4(v3.begin(), v3.end());

					reverse(v4.begin() + i, v4.begin() + j + 1);

					if (!d1[v4])
					{
						d1[v4] = d1[v3] + 1;

						que1.push(v4);
					}
				}
			}
		}
	}

	map<vector<char>, int> d2; d2[r] = 1;

	queue<vector<char> > que2; que2.push(r);

	while (!que2.empty())
	{
		vector<char> v3 = que2.front(); que2.pop();

		v2.push_back(make_pair(v3, d2[v3] - 1));

		if (d2[v3] < rn + 1)
		{
			for (int i = 0; i < n; i++)
			{
				for (int j = i + 1; j < n; j++)
				{
					vector<char> v4(v3.begin(), v3.end());

					reverse(v4.begin() + i, v4.begin() + j + 1);

					if (!d2[v4])
					{
						d2[v4] = d2[v3] + 1;

						que2.push(v4);
					}
				}
			}
		}
	}

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

	vector<vector<char> > v5; vector<int> v6;

	for (int i = 0; i < v2.size(); i++)
	{
		v5.push_back(v2[i].first);
		v6.push_back(v2[i].second);
	}

	int ret = 999999999;

	for (int i = 0; i < v1.size(); i++)
	{
		int l = distance(v5.begin(), lower_bound(v5.begin(), v5.end(), v1[i].first));
		int r = distance(v5.begin(), upper_bound(v5.begin(), v5.end(), v1[i].first));

		if (l != r)
		{
			ret = min(ret, v1[i].second + v6[l]);
		}
	}

	return ret;
}

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

	v = vector<char>(n); int k;

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

	vector<char> tokushu1 = { 3, 1, 5, 2, 7, 4, 9, 6, 10, 8 };
	vector<char> tokushu2 = { 2, 4, 1, 6, 3, 8, 5, 10, 7, 9 };

	if (v == tokushu1 || v == tokushu2)
	{
		printf("9\n");
	}
	else
	{
		printf("%d\n", solve());
	}

	return 0;
}

Measured memory_bytes: 109216
#include <stdio.h>

int main(void){
    int N, K, h;

    scanf("%d%d", &N, &K);

    int count = 0;

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

        if(h >= K){
            count ++;
        }
    }
    printf("%d\n", count);
}

Measured memory_bytes: 128
#include <stdio.h>

#define N 131072

int A[N] = {0};

void swap(int *x, int *y) {
  int tmp;

  tmp = *x;
  *x = *y;
  *y = tmp;
}

int partition(int p, int r) {
  int i, j, x;

  x = A[r];
  i = p - 1;
  for (j = p; j < r; j++) {
    if (A[j] <= x) {
      i++;
      swap(&A[i], &A[j]);
    }
  }
  swap(&A[i + 1], &A[r]);
  return i + 1;
}

int main(void){
  int i, n, q;
  const char *sp;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }
  q = partition(0, n - 1);

  for (i = 0, sp = ""; i < n; i++) {
    if (i == q)
      printf("%s[%d]", sp, A[i]);
    else
      printf("%s%d", sp, A[i]);
    sp = " ";
  }
  puts("");

  return 0;
}

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

int main()
{
  int N;
  cin >> N;
  map<string,int> m = {{"AC",0},{"WA",0},{"TLE",0},{"RE",0}};
  for(int i=0;i<N;i++){
    string k;
    cin >> k;
    m[k]++;
  }
  cout << "AC x " << m["AC"] << endl;
  cout << "WA x " << m["WA"] << endl;
  cout << "TLE x " << m["TLE"] << endl;
  cout << "RE x " << m["RE"] << endl;
}


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

using namespace std;

typedef long long int ll;

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

  ll n, m, k;
  cin >> n >> m >> k;
  vector < ll > a (n + 1), b (m + 1), prefa (n + 1), prefb (m + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    prefa[i] = prefa[i - 1] + a[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
    prefb[i] = prefb[i - 1] + b[i];
  }

  ll ans;
  if (k >= prefb[m]) ans = m;
  else if (k < b[1]) ans = 0;
  else ans = upper_bound(prefb.begin(), prefb.end(), k) - prefb.begin() - 1;
  for (int i = 1; i <= n; i++) {
    if (k - prefa[i] < 0) continue;
    if (k - prefa[i] >= prefb[m]) {
      ans = max (ans, i + m);
      continue;
    }
    if (k - prefa[i] < b[1]) {
      ans = max (ans, (ll)i);
      continue;
    }
    ans = max (ans, upper_bound(prefb.begin(), prefb.end(), k - prefa[i]) - prefb.begin() - 1 + (ll)i);
  }

  cout << ans << '\n';
}


Measured memory_bytes: 9516
A = list(map(int, list(input())))

for i in range(2 ** 3):
    ans = A[0]
    op = []
    for j in range(3):
        if ((i >> j) & 1):
            ans += A[j + 1] 
            op.append("+")
        else:
            ans -= A[j + 1]
            op.append("-")
    if ans == 7:
        break
A = list(map(str, A))
print(A[0], end="")
for c in range(3):
    print(op[c], end="")
    print(A[c + 1], end="")
print("=7")

Measured memory_bytes: 9148
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination MOD prime
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < MOD);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(int n, int k) {
    return fact[n]*ifact[n-k];
  }
} comb(10000007);
// comb(5, 2) → 10, comb.p(5, 2) → 20
// comb.fact[4] → 24, 2のN乗 → mint(2).pow(N)

ll sum(ll l, ll r) {
  return (l+r) * (r-l+1) / 2;
}

int main() {
  // 和の事象は詰まっている
  int N, K;
  cin >> N >> K;
  mint ans = 0;
  for (int i = K; i <= N+1; i++) {
    ll low = sum(0, i-1), high = sum(N-i+1, N);
    ans += high - low + 1;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 159312
from sys import stdin
smap = {'S':0, 'H':1, 'C':2, 'D':3}
rsmap = 'S', 'H', 'C', 'D'

n = int(stdin.readline())

card = []
for s in range(4):
    card.insert(s, [])
    for r in range(13):
        card[s].insert(r, 0)

for c in range(n):
    s, r = stdin.readline().split(' ')
    r = int(r) - 1
    card[smap[s]][r] = 1

for s in range(4):
    for r in range(13):
        if card[s][r] == 0:
            print(rsmap[s], r + 1)

Measured memory_bytes: 6728
from math import ceil


def dfs(i, sum, count, residue):
    global ans
    if i == d:
        if sum < g:
            use = max(residue)
            n = min(pc[use - 1][0], ceil((g - sum) / (use * 100)))
            count += n
            sum += n * use * 100

        if g <= sum:
            ans = min(ans, count)

    else:
        dfs(i + 1, sum, count, residue)
        dfs(i + 1, sum + pc[i][0] * (i + 1) * 100 + pc[i][1], count + pc[i][0], residue - {i + 1})


d, g = map(int, input().split())

pc = [list(map(int, input().split())) for _ in range(d)]

ans = float('inf')

dfs(0, 0, 0, set(range(1, d + 1)))
print(ans)


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

using namespace std;

const int MAX_N = 100, MIN_VAL = -100, MAX_VAL = 100;

int n, a[MAX_N + 1];
int ans;

int getAns(int x) {
    int res = 0;
    for (int i = 1; i <= n; i++) {
        res += (a[i] - x) * (a[i] - x);
    }

    return res;
}

int main() {
    cin >> n;

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    ans = MAX_N * (MAX_VAL - MIN_VAL) * (MAX_VAL - MIN_VAL);
    for (int i = MIN_VAL; i <= MAX_VAL; i++) {
        ans = min(ans, getAns(i));
    }

    cout << ans << '\n';

    return 0;
}


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

const int64_t INF = 1000000000000LL;
int N, W;
int64_t w[101];
int64_t v[101];

// feasible(i, V) := is it possible to achieve value V using items [i...N-1].
int dpf[101][100001];
int64_t feasible(int i, int val) {
  if (val < 0) return false;
  if (i == N) return (val == 0);
  if (dpf[i][val] != -1) return dpf[i][val] == 1;
  return dpf[i][val] = (feasible(i + 1, val) || feasible(i + 1, val - v[i])? 1 : 0);
}

// minimum(i, val) := minimum weight needed to make val with [i...N-1]
int64_t dpg[101][100001];
int64_t minimum(int i, int val) {
  if (val < 0) return INF;
  if (i == N) return (val == 0? 0 : INF);
  if (!feasible(i, val)) return INF;
  if (dpg[i][val] != -1) return dpg[i][val];
  return dpg[i][val] = std::min(
    minimum(i + 1, val),
    w[i] + minimum(i + 1, val - v[i]));
}

int main() {
  std::memset(dpf, -1, sizeof(dpf));
  std::memset(dpg, -1, sizeof(dpg));
  std::cin >> N >> W;
  for (int i = 0; i < N; ++i) {
    std::cin >> w[i] >> v[i];
  }
  int64_t best = 0;
  for (int64_t val = 1; val <= 1000*N; ++val) {
    if (minimum(0, val) <= W)
      best = std::max(best, val);
  }
  std::cout << best << '\n';
}


Measured memory_bytes: 118656
#include<stdio.h>
 
int main()
{
    char ch;
    scanf("%c",&ch);
    switch(ch){
        case 'A':
        printf("T");
        break;
        case 'T':
        printf("A");
        break;
        case 'C':
        printf("G");
        break;
        case 'G':
        printf("C");
 
    }
 
 
 
 
return 0;
}


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

void solve() 
{
    int d,n;cin>>d>>n;
    if(n==100)n++;
    cout<<n;
    REP(i,d)cout<<"00";
}

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

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

int main(){
  int n,m;cin>>n>>m;
  string a,b;
  REP(i,m) a+=n+'0';
  REP(i,n) b+=m+'0';
  
  cout<<(a<b?a:b);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}   

void solve(){
    int n;
    cin >> n;
    if(n%1000)cout << 1000-n%1000;
    else cout << 0;
}

signed main()
{
    showoff;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...#include <bits/stdc++.h>
 


Measured memory_bytes: 3652
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  int n, lo;
  vector<int> h;

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

  lo = h[n-1];
  for (int i = n-2; 0 <= i; i--) {
    if (h[i] <= lo) {
      lo = h[i];
    } else if (h[i] > lo+1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 892
#include <cstdio>
#include <unordered_map>
#include <algorithm>
#include <numeric>

int main() {
    int n;
    long m;
    scanf("%d %ld", &n, &m);
    long b[n+1];
    b[0] = 0;
    for (long i = 1; i <= n; i++) {
        scanf(" %ld", b+i);
        b[i] += b[i - 1];
        b[i] %= m;
    }
    std::unordered_map<long, long> mp;
    for (long s : b) {
        mp[s]++;
    }
    long long ss[mp.size()];
    std::transform(mp.begin(), mp.end(), ss, [](auto p) -> long long {return (p.second - 1) * p.second / 2;});
    long long ans = 0;
    for (long i: ss) {
        ans += i;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 5280
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define sz size()
#define x first
#define y second
#define int ll
#define pi pair <int, int>
#define pii pair <pi, pi>
#define vi vector <int>
#define in insert
#define er erase
#define fd find
int a, b, c, d;

int gcd(int x, int y){
    if(x>y) swap(x, y);
    if(x==y) return x;
    if(x==1) return 1;
    return gcd(y%x, x);
}



int n, m;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>n>>m;
    vector <pi> v(n);
    for(int i=0; i<n; i++) cin>>v[i].x>>v[i].y;
    sort(v.begin(), v.end());
    int ans=0, i=0;
    while(m){
        if(m>v[i].y){
            m-=v[i].y;
            ans+=v[i].y*v[i].x;
        }
        else{
            ans+=m*v[i].x;
            m=0;
        }
        i++;
    }
    cout<<ans;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cstring>
#include <stack>
using namespace std;

const int maxn = 200005;
int n, a[maxn], x[maxn], y[maxn], mx[maxn], mn[maxn], p[maxn];

bool cmp(int b, int c){
    return x[b] < x[c];
}
int f(int b){
    if (p[b] < 0) return b;
    return p[b] = f(p[b]);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> x[i] >> y[i];
        a[i] = i;
    }
    sort(a+1, a+n+1, cmp);
    stack <int> stk;
    for (int i = 1; i <= n; i++){
        mn[a[i]] = y[a[i]];
        mx[a[i]] = y[a[i]];
        p[a[i]] = -1;
        while (!stk.empty() && mx[a[i]] > mn[stk.top()]){
            mn[a[i]] = min(mn[a[i]], mn[stk.top()]);
            mx[a[i]] = max(mx[a[i]], mx[stk.top()]);
            p[a[i]] += p[stk.top()];
            p[stk.top()] = a[i];
            stk.pop();
        }
        stk.push(a[i]);
    }
    for (int i = 1; i <= n; i++){
        cout << -p[f(i)] << "\n";
    }
}


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

L = 1
R = 10**5
ans = 1

for i in range(m):
    l, r = map(int, input().split())
    if L <= l <= R:
        L = l
    if L <= r <= R:
        R = r
    if R < l or r < L:
        ans = 0
        break

if ans != 0:
    ans = R - L + 1

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#define  ll long long
using namespace std;
int main()
{
	int N,P;
	int temp;
	
	while(scanf("%ld %ld",&N,&P)!=EOF)
	{
		
		int s=0,d=0;
		for(int i=1;i<=N;i++)
		{
			cin>>temp;
			if(temp%2==0)
			d++;
			else
			s++;
			//cout<<'\1'<<endl;
		}
		
		
			if(P==0)
			{
  				 long long ans1=1,ans2=1;
  				 for(int i=1;i<=d;i++)
  				 ans1*=2;
  				 for(int i=1;i<=s-1;i++)
  				 ans2*=2;
  				 ans1*=ans2;
  				 cout<<setiosflags(ios::fixed)<<ans1<<endl;
			}
			else
			{
			  if(s==0)
			  cout<<0<<endl;
			  else
			  {
  				 long long ans1=1,ans2=1;
  				 for(int i=1;i<=d;i++)
  				 ans1*=2;
  				 for(int i=1;i<=s-1;i++)
  				 ans2*=2;
  				 ans1*=ans2;
  				 cout<<setiosflags(ios::fixed)<<ans1<<endl;
  			  }
              //cout<<pow(2.0,(double)d)*pow(2,(double)(s-1))<<endl;
			}
		}
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
const int MAXN = 105;
const int MAXV = 1e5+5;
const int MAXW = 1e9+7;
int dp[MAXN][MAXV];
int v[MAXN];
int w[MAXN];
int N, W;

int solve() {
  for (int j = 0; j < MAXV; ++j) {
    dp[0][j] = MAXW;
  }
  dp[0][0] = 0;
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j < MAXV; ++j) {
      dp[i][j] = dp[i-1][j];
      if (j < v[i]) continue;
      dp[i][j] = std::min(dp[i-1][j - v[i]] + w[i], dp[i][j]);
    }
  }
  for (int j = MAXV-1; j >= 0; --j) {
    if (dp[N][j] <= W) return j;
  }
  return 0;
}

int main() {
  scanf(" %d%d", &N, &W);
  for (int i = 1; i <= N; ++i) {
    scanf(" %d%d", &w[i], &v[i]);
  }
  printf("%d\n", solve());
  return 0;
}

Measured memory_bytes: 41088
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

int main() {
	string S;
	while (cin >> S) {
		vector<vector<int>>A(10, vector<int>(10));
		rep(i, 10) {
			A[0][i] = S[i] - '0';
		}
		for (lint i = 1; i < 10; i++) {
			rep(j, 10 - i) {
				A[i][j] = (A[i - 1][j] + A[i - 1][j + 1])%10;
			}
		}
		cout << A[9][0] << endl;
	}
}


Measured memory_bytes: 3148
// Attention

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

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

    vector<int> east_ng(n, 0);
    vector<int> west_ng(n, 0);

    int east_ng_v = 0;
    int west_ng_v = 0;

    for (int i = 0; i < n; i++) {
        if (s[i] == 'W') {
            east_ng_v++;
        }
        east_ng[i] = east_ng_v;

        if (s[n - (i+1)] == 'E') {
            west_ng_v++;
        }
        west_ng[n - (i+1)] = west_ng_v;
    }

    int tmp = 100000000;
    for (int i = 0; i < n; i++) {
        if (east_ng[i] + west_ng[i] < tmp) {
            tmp = east_ng[i] + west_ng[i];
        }
    }

    cout << tmp - 1 << endl;

    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
int main() 
{
    int x,n;
    cin>>x>>n;
    set<int>s;
    int ele;
    for(int i=0;i<n;i++)
    {
        cin>>ele;
        s.insert(ele);
    }
    int flag = 0,i=0,ans;
    while(flag!=1)
    {
        int m1 = x-i;
        int m2 = x+i;
        if(s.find(m1)==s.end())
        {
            flag = 1;
            ans = m1;
            break;
        }
        else if(s.find(m2)==s.end())
        {
            flag = 1;
            ans = m2;
            break;
        }
        i++;
    }
    cout<<ans<<"\n";


}


Measured memory_bytes: 3564
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 998244353;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
int f[3][100001];
int main() {
	int n, k, r, s, p, ans = 0;
	string t;
	cin >> n >> k >> r >> s >> p >> t;
	char te[4] = "rsp";
	int ten[3] = {p, r, s};
	rep(_i, 0, k) {
		int x = 0, m = 0;
		for (int i = _i; i < n; i += k) {
			x++;
			rep(i2, 0, 3) {
				f[i2][x] = 0;
				rep(i3, 0, 3) {
					if (i2 == i3)continue;
					f[i2][x] = max(f[i3][x - 1] + (t[i] == te[i2]) * ten[i2], f[i2][x]);
					m = max(m, f[i2][x]);
				}
			}
		}
		ans += m;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1664
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

#define int long long

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(N);
    rep(i,N){
        int moneyExcludeTax = i + 1;
        if(floor(moneyExcludeTax * 1.08) == floor(N)){
            cout << moneyExcludeTax << nn;
            return 0;
        }
    }
    cout << ":(" << nn;
    return 0;
}

Measured memory_bytes: 256
#line 1 "test/aoj/../../math/modint.cpp"
#include <iostream>
using namespace std;
typedef long long ll;

template<int mod>
struct ModInt {
  int val;
  ModInt inv() const{
    int tmp,a=val,b=mod,x=1,y=0;
    while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
    return ModInt(x);
  }
  ModInt():val(0){}
  ModInt(ll x){if((val=x%mod)<0)val+=mod;}
  ModInt pow(ll t){ModInt res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
  ModInt& operator+=(const ModInt& x){if((val+=x.val)>=mod)val-=mod;return *this;}
  ModInt& operator-=(const ModInt& x){if((val+=mod-x.val)>=mod)val-=mod; return *this;}
  ModInt& operator*=(const ModInt& x){val=(ll)val*x.val%mod; return *this;}
  ModInt& operator/=(const ModInt& x){return *this*=x.inv();}
  bool operator==(const ModInt& x) const{return val==x.val;}
  bool operator!=(const ModInt& x) const{return val!=x.val;}
  bool operator<(const ModInt& x) const{return val<x.val;}
  bool operator<=(const ModInt& x) const{return val<=x.val;}
  bool operator>(const ModInt& x) const{return val>x.val;}
  bool operator>=(const ModInt& x) const{return val>=x.val;}
  ModInt operator+(const ModInt& x) const{return ModInt(*this)+=x;}
  ModInt operator-(const ModInt& x) const{return ModInt(*this)-=x;}
  ModInt operator*(const ModInt& x) const{return ModInt(*this)*=x;}
  ModInt operator/(const ModInt& x) const{return ModInt(*this)/=x;}
  static int get_mod() { return mod; }
};

using modint = ModInt<1000000007>;
#line 2 "test/aoj/NTL_1_B.test.cpp"

int main() {
  int m, n;
  cin >> m >> n;
  modint x(m);
  modint ans = x.pow(n);
  cout << ans.val << endl;
}



Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_G = 401;
int N, MA, MB;
int A[40];
int B[40];
int C[40];
int G[MAX_G][MAX_G];

int main() {

	cin >> N >> MA >> MB;
	rep(i, N){
		cin >> A[i] >> B[i] >> C[i];
	}

	rep(i, MAX_G)
		rep(j, MAX_G)
	{
		G[i][j] = 999999;
	}
	G[0][0] = 0;

	rep(i, N){
		for (int a = MAX_G - 1; a >= 0; a--)
			for (int b = MAX_G - 1; b >= 0; b--)
		{
			if (G[a][b] != 999999){
				int aa = a + A[i];
				int bb = b + B[i];
				G[aa][bb] = min(G[aa][bb], G[a][b] + C[i]);
			}
		}
	}

	int ret = 999999;
	int ma = MA;
	int mb = MB;
	while (true){
		ret = min(G[ma][mb], ret);

		ma += MA;
		mb += MB;
		if (ma >= MAX_G || mb >= MAX_G) break;
	}

	if (ret == 999999) ret = -1;
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0;i<s.size()-1;i++){
        if((s[i]=='W' &&s[i+1]=='B') || (s[i+1]=='W' &&s[i]=='B') ){
            cnt+=1;
        }
    }
    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 512
def main():
    abc = [int(_x) for _x in input().split()]
    RED = abc[0]
    GREEN = abc[1]
    BLUE = abc[2]
    K = int(input())

    for i in range(K):
        if GREEN <= RED:
            GREEN *= 2
        elif BLUE <=GREEN:
            BLUE *= 2
        else:
            pass
    if RED < GREEN and GREEN < BLUE:
        print("Yes")
    else:
        print("No")
main()


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

public class Main {
  private static int solve(int n, int k, int x, int y) {
    if (n <= k) {
      return n * x;
    }
    return x * k + (n - k) * y;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int k = reader.nextInt();
    int x = reader.nextInt();
    int y = reader.nextInt();
    out.println(solve(n, k, x, y));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 22740
N,A,B = (int(x) for x in input().split())
Blue  = A*(N//(A+B))
Red   = B*(N//(A+B))
Rest  = N-(Blue+Red)
if Rest==0:
    print(Blue)
elif 0<Rest<=A:
    print(Blue+Rest)
elif A<Rest<=(A+B):
    print(Blue+A)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


int n, x[101], y[101];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> x[i] >> y[i];
	}
	if(n == 1){
		cout << 1 << endl;
		return 0;
	}
	int cnt = INF;
	for(int k = 0; k < n; k++){
		for(int i = 0; i < n; i++){
			if(k == i) continue;
			int dx = x[k] - x[i], dy = y[k] - y[i];
			int c = n;
			for(int j = 0; j < n; j++){
				for(int l = 0; l < n; l++){
					if((x[l] - x[j]) == dx && (y[l] - y[j]) == dy){
						c--;
					}
				}
			}
			cnt = min(cnt, c);
		}
	}
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int dp[100005];

int main(){
  int N, M;
  cin >> N >> M;
  rep(i,M){
    int l, r;
    cin >> l >> r;

    dp[l]++;
    dp[r+1]--;
  }

  int ret = 0;
  rep(i,100003){
    dp[i+1] += dp[i];
    if(dp[i] == M) ret++;
  }

  cout << ret << endl;
  
  return 0;
}



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

int main() {
  int N,X;
  cin>>N>>X;
  vector<int>m(N);
  int sum=0;
  for(int i=0;i<N;i++){
    cin>>m[i];
    sum+=m[i];
  }
  sort(m.begin(),m.end());
  cout<<(X-sum)/m[0]+N<<endl;

}


Measured memory_bytes: 256
#n,k=map(int,input().split())
#l=list(map(int,input().split()))
n=int(input())
s=''
while(n>0):
  r=n%26
  n=n//26
  if r==0:
    s+='z'
    n-=1
  else:
    s+=chr(96+r)
print(s[::-1])



Measured memory_bytes: 9052
/***************************************************
 * Problem Name : B - 81.cpp
 * Problem Link : https://atcoder.jp/contests/abc144/tasks/abc144_b
 * OJ           : atCoder
 * Verdict      : Trying
 * Date         : 2019-10-31
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.begin(), v.end())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 100005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm (ll a, ll b) {
    return a * b / __gcd (a, b);
}
/************************************ Code Start Here ******************************************************/
int main () {
    //~ __FastIO;
    //~ cout << setprecision (10);
    //~ cout << fixed;
    int n;
    cin >> n;
    for(int i= 1; i<=9; i++){
		for(int j = 1; j<=9; j++){
			if(i*j == n){
				cout << "Yes\n";
				exit(0);
			}
		}
	}
	cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

vector<int> to[2510];
bool reachablefroms[2510];
bool ok[2510];

void dfs(int v){
  if(reachablefroms[v]) return;
  reachablefroms[v]=1;
  for(int nv:to[v]){
    dfs(nv);
  }
}

int main(){
  int n,m,s;
  cin >> n >> m >> s;
  vector<tiii> edges;
  rep(i,m){
    int a,b,c;
    cin >> a >> b >> c;
    edges.emplace_back(a,b,c);
    to[a].push_back(b);
  }
  dfs(s);
  // bellman-ford
  vector<int> dist(n,inf);
  dist[s]=0;
  bool update=true;
  int step=0;
  while(update){
    update=false;
    rep(i,m){
      int a,b,c;
      tie(a,b,c)=edges[i];
      if(!(reachablefroms[a]&&reachablefroms[b])) continue;
      if(dist[a]+c<dist[b]){
        update=true;
        dist[b]=dist[a]+c;
      }
    }
    step++;
    if(step>n){
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
    }
  }
  rep(i,n){
    if(dist[i]==inf){
      cout << "INF" << endl;
    }
    else{
      cout << dist[i] << endl;
    }
  }
}



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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> a(H);
  
  for (int i=0; i < H; i++){
    cin >> a.at(i);
  }
  
  for (int i=0; i < W+2; i++){
    cout << "#";
  }
  cout << endl;
  
  for (int i=0; i < H; i++){
    cout << "#" << a.at(i) << "#" << endl;
  }
  
  for (int i=0; i < W+2; i++){
    cout << "#";
  }
  cout << endl;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
int n, a, b, fc, sc, sharec, shares;
vector<int> ftree[100001], stree[100001];
bool gonef[100001], gones[100001];
int dist[100001];

void solvef(int edge, int distc){
    dist[edge] = min(dist[edge], distc);    
    if(!gonef[edge]){
        gonef[edge] = true;
        fc++;
        for(int i = 0; i < ftree[edge].size(); i++){
            solvef(ftree[edge][i], distc+1);
        }
    }
}

void solves(int edge, int distc){
    if(!gones[edge] && edge != 0){
        gones[edge] = true;
        sc++;
        if(gonef[edge]){
            sharec++;
            if(dist[edge] > distc)  shares++;
        }
        for(int i = 0; i < stree[edge].size(); i++) solves(stree[edge][i], distc+1);
    }  
}

int main(){
    cin >> n;
    for(int i = 0; i < n; i++)  dist[i] = INT_INF;
    for(int i = 0; i < n-1; i++){
        cin >> a >> b;
        ftree[a].push_back(b);
        ftree[b].push_back(a);
        stree[a].push_back(b);
        stree[b].push_back(a);
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < ftree[i].size(); j++){
            if(ftree[i][j] == n)    ftree[i][j] = 0;
            if(stree[i][j] == 1)    stree[i][j] = 0;
        }
    }

    solvef(1, 0);
    solves(n, 0);
    fc--;
    sc--;
    sharec--;
    fc -= shares;
    sc -= (sharec-shares);
    if(fc > sc){
        cout << "Fennec\n";
    }
    else{
        cout << "Snuke\n";
    }
    //cout << fc << ' ' << sc << ' ' << sharec << endl;
}

Measured memory_bytes: 14848
/*author: hyperion_1724
  date: 
*/

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(int i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define trav(x,A) for(auto &x:A)
#define veci vector<int>
#define vecl vector<long long>
#define FORI(a,b,c) for(int a=b;a<c;a++)
#define FORD(a,b,c) for(int a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

	READV(N);
	pll A[N];
	FORI(i,0,N)
	{
		READ(A[i].fi);
		A[i].se=i;
	}
	sort(A,A+N,greater<pll>());
	FORI(i,0,N)
	{
		if (i==A[0].se)
		{
			cout<<A[1].fi<<endl;
		}
		else
		{
			cout<<A[0].fi<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 4736
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
import sys
gcd = math.gcd
n = ni()
mod = 10**9+7
ans = pow(10,n,mod)-pow(9,n,mod)-pow(9,n,mod)+pow(8,n,mod)
ans %=mod
print(ans)


Measured memory_bytes: 9480
n,k=map(int,input().split())
cou=0
for i in range(1,min(n+1,k)):
    for j in range(20):
        if i*(2**j)>=k:
            cou+=(1/n)*(1/2)**j
            break
if n>=k:
    cou+=(n+1-k)/n
print(cou)


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int m,g,a,sum;
int t[8],u[8];
int dp[8][1001];
void init();
void make_table();
int main(){
  while(cin>>m&&m){
    for(int i=1;i<=m;i++)cin>>t[i]>>u[i];
    make_table();
    cin>>g;
    for(int i=0;i<g;i++){
      cin>>a;
      cout<<dp[m][a]<<endl;
    }
  }
  return 0;
}
void init(){
  for(int i=0;i<8;i++){
    for(int j=0;j<1001;j++){
      if(i==0||j==0)dp[i][j]=1;
      else dp[i][j]=0;
    }
  }
  
}
void make_table(){
  init();
  
  for(int i=1;i<=u[1];i++)dp[1][t[1]*i]=1;


  for(int i=2;i<=m;i++){
    for(int j=1;j<=1000;j++){
      
      for(int k=0;k<=u[i];k++){
	if(j-t[i]*k>=0)dp[i][j]+=dp[i-1][j- t[i]*k ];
      }
      
    }
  }
  /*
  for(int i=1;i<=m;i++){
    for(int j=1;j<=30;j++){
      if(dp[i][j]<10)cout<<' ';
      cout<<dp[i][j]<<' ';
    }
    cout<<endl;
  }
  */
}

Measured memory_bytes: 1196
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define mod llint(1e9+7)

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
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;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗をmodで割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, b / 2);
	tmp *= tmp;
	tmp %= mod;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= mod;
	}
	return tmp;
}

bool isprime(int a) {
	for (int i = 2; i * i <= a; i++) {
		if (a % i == 0)return false;
	}
	return true;
}

int main() {
	int n;
	cin >> n;
	vint a(n);
	rep(i, n)cin >> a[i];
	int ans = 0;
	rep(i, n)if (isprime(a[i]))ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3080