akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
    ll ans=0;
    string s,t;
    cin>>s>>t;
    vector<vector<int>>ch(26);
    rep(i,s.size())ch[s[i]-'a'].pb(i);
    rep(i,s.size())ch[s[i]-'a'].pb(i+(int)s.size());//sの長さの2倍分とすると楽
    int n=0;
    rep(i,t.size()){
        if(!ch[t[i]-'a'].size()){
            cout<<-1<<endl;
            return 0;
        }
        n= *lower_bound(ch[t[i]-'a'].begin(),ch[t[i]-'a'].end(),n)+1;//lower_boundだと前の区切りになるため、+1してその文字の後ろに移動
        if(n>=(int)s.size()){
            ans+=(int)s.size();
            n-=(int)s.size();
        }
    }
    ans+=n;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1724
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n  = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
		int chocolate = 0;

		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			for(int j = 0; j <=d; j++) {
				int temp  = a*j+1;
				if(temp <= d) {
					chocolate++;
				}
				else {
					break;
				}
			}
		}
		System.out.println(chocolate+x);
	}

}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define le length()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (__typeof(n) i = 0; i < n; i++)
#define repo(i, n) for (__typeof(n) i = 1; i <= n; i++)
#define eps 1e-6
#define pi 3.141592653589793
#define c(a) cout << a << "\n";
#define a(a)         \
    for (auto i : a) \
        cout << i << " ";
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int INF = 1e9;
int main()
{
    ll n, ans = 1;
    cin >> n;
    string s;
    cin >> s;
    ll a[26] = {0};
    rep(i, n) a[s[i] - 'a']++;
    rep(i, 26)
    {
        ans *= a[i] + 1;
        ans = ans % MOD;
    }
    c(ans - 1)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int n,l,i,j;
string s[100],a;
int main()
{
  for(cin>>n>>l;i<n;i++){
    cin>>s[i];
    for(j=0;j<l;j++){
      s[i][j]-='a';
    }
  }
  sort(s,s+n);
  for(i=0;i<n;i++)for(int j=0;j<l;j++)s[i][j]+='a';
  for(i=0;i<n;i++)cout<<s[i];
}

Measured memory_bytes: 256
#include <stdio.h>

int selectionSort(int A[], int N) {
    int i, j, t, sw =0, minj;
    for(i=0;i<N-1;i++) {
        minj = i;
        for(j=i;j<N;j++) {
            if(A[j]<A[minj]) minj = j;
        }
        t=A[i]; A[i]=A[minj]; A[minj]=t;
        if(i!=minj) sw++;
    }
    return sw;
}

int main(void) {
    int A[100], N, i, sw;

    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    sw = selectionSort(A,N);

    for(i=0;i<N;i++) {
        if(i>0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",sw);

    return 0;
}





Measured memory_bytes: 2096
#include<stdio.h>
int main()
{
  int i,h,a[250];
  
  scanf("%d",&h);
  for(i=1;i<=h;i++){
    scanf("%d",&a[i]);

  }

  for(i=1;i<=h;i++){
    printf("node %d: key = %d, ",i,a[i]);
    if(i!=1){
      printf("parent key = %d, ",a[i/2]);
    }
    if(2*i<=h){
      printf("left key = %d, ",a[2*i]);
    }
    if(2*i+1<=h){
      printf("right key = %d, ",a[2*i+1]);
    }
    printf("\n");
  }
  return 0;
}

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

int main() {
  int n; cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];

  int ans = 0;
  while(*max_element(h.begin(), h.end()) > 0) {
    ans++;

    bool first = false, end = false;
    for (int i=1; i<n-1; i++) {
      if (h[i]<=0 && h[i-1]>0) first = true;
      if (h[i]<=0 && h[i+1]>0 && first) end = true;
      if (first && end) {
        ans++;
        first = false;
        end = false;
      }
    }
    rep(i,n) h[i]--;
  }
  cout << ans << 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>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#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 = 998244353;
const ll INF = 1e16;
const ll MAX_N = 100010;

// aのn乗を求める。計算量はO(logn)
ll modpow(ll a, ll n) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1))%mod;
    }
    return (modpow(a, n/2) * modpow(a, n/2))%mod;
}

ll inv(ll a) {
    return modpow(a, mod-2);
}

ll fact[1100000];
ll invfact[1100000];

void init() {
    fact[0] = 1;
    invfact[0] = 1;
    for(ll i = 1; i < 1100000; i++) {
        fact[i] = (i*fact[i-1])%mod;
        invfact[i] = inv(fact[i]);
    }
}
 
ll Comb(ll n, ll r) {
    if(r < 0 || n < 0 || n < r) {
        return 0;
    }
    ll res = fact[n];
    res = (res * invfact[r])%mod;
    res = (res * invfact[n-r])%mod;
    return res;
}

int main() {
    ll n, a, b, k;
    cin >> n >> a >> b >> k;

    init();

    ll ans = 0;
    exrep(x, 0, n) {
        if((k - a*x)%b != 0) {
            continue;
        }
        ll y = (k - a*x)/b;
        if(y < 0 || n < y) {
            continue;
        }
        ans += Comb(n, x)*Comb(n, y);
        ans %= mod;
    }

    out(ans);
    re0;
}

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

typedef long long LL;

LL rt[30];

int main(){
    LL D;
    scanf("%lld", &D);
    rt[0] = 1;
    for (int i = 1; i < 30; i++) rt[i] = rt[i - 1] * 10LL;
    LL ret = 0;
    for (int i = 2; i <= 20; i++){
        int k = i / 2;
        for (int S = 0; S < (1 << k); S++){
            LL way = (i & 1) ? 10 : 1, zan = D;
            for (int j = 0; j < k; j++){
                LL d = llabs(zan) % 10LL;
                if (zan < 0){
                    d = 10 - d;
                    d %= 10;
                }
                if ((S >> j) & 1){
                    LL nm = 10LL - d;
                    if (j == 0) nm--;
                    way *= nm;
                    zan += d * rt[i - 2 * j - 1];
                    zan -= d;
                } else {
                    LL nm = d;
                    if (j == 0) nm--;
                    if (nm < 0){
                        way = 0;
                        break;
                    }
                    way *= nm;
                    zan -= (10LL - d) * rt[i - 2 * j - 1];
                    zan += (10LL - d);
                }
                zan /= 10LL;
            }
            if (zan == 0) ret += way;
        }
    }
    printf("%lld\n", ret);
    return 0;
}

Measured memory_bytes: 3828
#include <iostream>

using namespace std;
using ll = long long;

#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
const ll INF = 1e18;
int w[100], v[100];
ll dp[101][100001];
ll dfs(int i, int W) {
  if (W < 0) return -INF;
  if (i == 0) return 0;
  if (dp[i][W] != -INF) return dp[i][W];
  return dp[i][W] = max(dfs(i-1, W), dfs(i-1, W-w[i-1])+v[i-1]);
}

int main() {
  int in(N); int in(W);

  rep(i, N)
    cin >> w[i] >> v[i];

  rep(i, N+1) rep(j, 1e5+1) dp[i][j] = -INF;

  cout << dfs(N, W) << endl;


  return 0;
}


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

int main() {
    int n, x;
    cin >> n;
    
    for(int i = 1; i <= n; i++) {
        x = i;
        if ( x % 3 == 0) {
            cout << " " << i;
            continue;
        }
        while(x) {
            if ( x % 10 == 3) {
                cout << " " << i;
                break;
            }
            x /= 10;
        }
    }
    cout << endl;
    
    return 0;
}



Measured memory_bytes: 3108
#include <stdio.h>

int main() {
	int i, ii, a, b, c;
	int iii = 0;
	scanf("%d%d%d", &a, &b, &c);
	for (i = a; i <= b; i++)
	{
		for (ii = i; ii <= c; ii += i)
		{
			if (ii == c) {
				iii++;
				break;
			}
		}
	}
	printf("%d\n", iii);
	return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
int main() {
    int c, last;
    while (scanf("%d", &c) != EOF) {
        last = (c <= 39) ? c : c % 39;
        if (last == 0) last = 39;
        printf("3C%.2d\n", last);
    }
    return 0;
}



Measured memory_bytes: 2664
n,k,q = list(map(int,input().split()))

anser = [0 for i in range(n)]

for i in range(q):
        a = int(input())
        
        anser[a-1] += 1

for i in anser:
        if k - q + i > 0:
                print('Yes')
        else:
                print('No')

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


int main(){
  int N, K;
  cin >> N >> K;

  vector<int> h(N);
  for(int i=0; i<N; i++){
    cin >> h.at(i);
  }

  vector<int> dp(N+K,INT_MAX);
  dp[0] = 0;
  for(int i=0; i<N; i++){
    for(int j=1; j<K+1; j++){
      dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
    }
  }

  cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int a,b,c; cin >> a >> b >> c;
  int sum = a+b+c;
  if(sum>=22) cout << "bust" << endl;
  else cout << "win\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    int n; cin >> n;
    ll ans = 0LL;
    repp(i,n,1){
        ans += (n-1) / i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
    int a,b,sum,i;
    scanf("%d %d",&a,&b);
    sum=0;
    for(i=a;i<=b;i++)
    {
        if(i%10==i/10000&&(i/1000)%10==(i/10)%10)
        {
            sum++;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

ll isPrime(ll num){
    if(num == 2) return 1;
    if(num == 3) return 1;
    if(num == 4) return 0;
    if(num == 5) return 1;
    
    for (ll i = 2; i*i <= num; i++) {
        if (num % i == 0) {
            return 0;
        }
    }
    return 1;
}

ll minfactor(ll n){
    ll i;
    
    if (isPrime(n)) return n;
    
    for (i = 2; i <= n ; i++) {
        if(n % i == 0) break;
    }
    return i;
}

/*
 eulerphi
 ????????????????????¶??° n ???????????????????????????????¢??°?????? ??(n) ????±??????????
 */
long eulerphi(long n)
{
    long phi = n;
    long m;
    long m0 = 0;
    
    // n ??? 0 ????????°?????´?????????????????????????????????????????? 0 ?????????
    if (n < 1) return(0);
    
    // ??(1) = 1 ??¨??????
    if (n == 1) return(1);
    
    do {
        m = minfactor(n);
        n /= m;
        
        if (m0 != m){
            phi = phi * (m-1) / m;
            m0 = m;
        }
    } while (n != 1);
    
    return(phi);
}


int main(){
    
    ll n, ans = 0;
    
    cin >> n;
    
    ans = eulerphi(n);
    
    cout << ans << endl;
    
    return 0;
}

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

using namespace std;

vector<int> adj[100000+1];

int indegree[100000+1];
int visited[100000+1];
int dist[100000+1];

void dfs(int n){
 if(visited[n]){
   return;
 }
 visited[n] = 1;
 for(auto x: adj[n]){
   dist[x] = max(dist[x], dist[n]+1);
   --indegree[x];
   if(indegree[x] == 0)
     dfs(x);
 }
}

int main(){
 int N, M; cin >> N >> M;
 for(int i=0; i<M; ++i){
    int x, y; cin >> x >> y;
    adj[x].push_back(y);
    ++indegree[y];
 }
 for(int i=1; i<=N; ++i){
   if(!visited[i] && indegree[i] == 0)
      dfs(i);
 }
 int res = 0;
 for(int i=1; i<=N; ++i)
  res = max(res, dist[i]);
 cout << res << "\n";
 return 0;
}


Measured memory_bytes: 9984
#include <iostream>

int main(){

  int n,k;
  std::cin>>n>>k;
  if(n%k==0)std::cout<<0<<std::endl;
  else {
    int a=0;
    int cookie[101]={0};
    while(a<n){
      cookie[a%k]++;
      a++;
    }
    std::cout<<cookie[0]-cookie[k-1]<<std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
/*
Author : N_o_o_B
Created : April 22 2020 21:06:26 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

ll f(ll h){
    if(h==1) return 1;
    return 1+2*f(h/2);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    ll h;
    cin >> h;

    cout << f(h) << endl;



    time_taken();
    return 0;
}

Measured memory_bytes: 256
n,m=[int(_) for _ in input().split()]
h=[int(_) for _ in input().split()]
p=[[int(_)-1 for _ in input().split()] for __ in range(m)]
f=[1 for _ in range(n)]
for i in range(m):
    if h[p[i][0]]>h[p[i][1]]:
        f[p[i][1]]=0
    elif h[p[i][0]]<h[p[i][1]]:
        f[p[i][0]]=0
    else:
        f[p[i][0]]=0
        f[p[i][1]]=0
print(f.count(1))


Measured memory_bytes: 30480
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

struct ShortestPath {
    struct edge { int to, cost; };
    int v;
    vector<vector<edge> > g;
    ShortestPath(int _v): v(_v), g(v) {}
    void add_edge (int from, int to, int cost) {
        g[from].push_back((edge){to, cost});
    }
    vector<int> shortest_path(int init) {
        vector<int> min_cost(v, 1 << 29);
        priority_queue<pair<int, int> > q;
        min_cost[init] = 0;
        q.push(make_pair(0, init));
        while (not q.empty()) {
            int cost = -q.top().first;
            int pos = q.top().second;
            q.pop();

            for (int i = 0; i < g[pos].size(); ++i) {
                int npos = g[pos][i].to;
                int ncost = cost + g[pos][i].cost;
                if (ncost < min_cost[npos]) {
                    min_cost[npos] = ncost;
                    q.push(make_pair(-ncost, npos));
                }
            }
        }
        return min_cost;
    }

    int shortest_path(int s, int t) {
        return shortest_path(s)[t];
    }
};


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

    li n, x, y;
    cin >> n >> x >> y;

    ShortestPath sp(n);
    for (int i = 0; i < n - 1; ++i) {
        sp.add_edge(i, i + 1, 1);
        sp.add_edge(i + 1, i, 1);
    }
    sp.add_edge(x - 1, y - 1, 1);
    sp.add_edge(y - 1, x - 1, 1);

    vector<li> ans(n);
    for (int root = 0; root < n; ++root) {
        auto dists = sp.shortest_path(root);
        for (int i = 0; i < n; ++i) {
            ans[dists[i]]++;
        }
    }
    for (int k = 1; k <= n - 1; ++k) {
        cout << ans[k] / 2 << '\n';
    }
    return 0;
}

Measured memory_bytes: 384
using System;

class Program {
    private static int Main() {
        while( true ) {
            var input = Console.ReadLine();
            var values = input.Split( ' ' );

            int H = int.Parse( values[ 0 ] );
            int W = int.Parse( values[ 1 ] );

            if( H == 0 && W == 0 ) { break; }

            var output = new string( '#', W );
            for( int i = 0; i < H; ++i ) {
                Console.WriteLine( output );
            }
            Console.WriteLine();
        }

        return 0;
    }
}

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

int main(){
  int N;
  cin>>N;
  int i;
  int minimum;
  int maximum;
  vector<int> A(N);
  
  for(i=0;i<N;i++){
    cin>>A[i];
  }
  
   minimum=A[0];
   maximum=A[0];
  for(i=0;i<N;i++){
    if(minimum>A[i])minimum=A[i];
    if(maximum<A[i])maximum=A[i];
 
  }
    cout<<maximum-minimum<<endl;
}


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

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

string s;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> s;
  if (s == "Sunny") {
    cout << "Cloudy" << endl;
  } else if (s == "Cloudy") {
    cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fo(p,n) for(int i=p;i<n;i++)
#define FIO ios_base::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);
#define endl "\n"
#define mp make_pair
#define pb push_back
#define M 1000000007
ll mod(ll x){
return ((x%M + M)%M);
}
ll add(ll a,ll b){
return mod(mod(a)+mod(b));
}
ll mul(ll a,ll b){
return mod(mod(a)*mod(b));
}

// ....................................................................................
int dp[100001];
int fun(int a[],int i,int k){
    if(i==0)
    return 0;
    if(dp[i]!=-1)
    return dp[i];
    dp[i]=INT_MAX;
    for(int j=1;j<=k;j++){
        if(i-j>=0)
        dp[i]=min(dp[i],abs(a[i]-a[i-j])+fun(a,i-j,k));
        else break;
    }
    return dp[i];
}
int main()
{
    FIO
    ll t;
    t=1;
    // cin>>t;
    while(t--)
    {
     int n,k;
     cin>>n>>k;
     int a[n];
     fo(0,n)
     cin>>a[i];
     memset(dp,-1,sizeof(dp));
     dp[0]=0;
     cout<<fun(a,n-1,k)<<endl;
    }
}

Measured memory_bytes: 12232
using System;
using System.Collections.Generic;
using System.Linq;

class A
{
	static long[] Read() => Console.ReadLine().Split().Select(long.Parse).ToArray();
	static void Main()
	{
		var h = Read();
		int nx = (int)h[0], ny = (int)h[1], sv = nx + ny, ev = sv + 1;
		var es = new int[h[2]].Select(_ => Read()).Select(x => new[] { x[0], nx + x[1], 1 }).ToList();

		es.AddRange(Enumerable.Range(0, nx).Select(i => new[] { sv, i, 1L }));
		es.AddRange(Enumerable.Range(0, ny).Select(j => new[] { nx + j, ev, 1L }));
		Console.WriteLine(MaxFlow(ev, sv, ev, es.ToArray()));
	}

	static long MaxFlow(int n, int sv, int ev, long[][] dg)
	{
		var map = Array.ConvertAll(new int[n + 1], _ => new List<long[]>());
		foreach (var e in dg)
		{
			map[e[0]].Add(new[] { e[0], e[1], e[2], map[e[1]].Count });
			map[e[1]].Add(new[] { e[1], e[0], 0, map[e[0]].Count - 1 });
		}

		long M = 0, t;
		while ((t = Bfs(n, sv, ev, map)) > 0) M += t;
		return M;
	}

	static long Bfs(int n, int sv, int ev, List<long[]>[] map)
	{
		var from = new long[n + 1][];
		var minFlow = Enumerable.Repeat(long.MaxValue, n + 1).ToArray();
		var q = new Queue<long>();
		q.Enqueue(sv);

		while (q.Any())
		{
			var v = q.Dequeue();
			if (v == ev) break;
			foreach (var e in map[v])
			{
				if (from[e[1]] != null || e[2] == 0) continue;
				from[e[1]] = e;
				minFlow[e[1]] = Math.Min(minFlow[v], e[2]);
				q.Enqueue(e[1]);
			}
		}

		if (from[ev] == null) return 0;
		for (long v = ev; v != sv; v = from[v][0])
		{
			var e = from[v];
			e[2] -= minFlow[ev];
			map[e[1]][(int)e[3]][2] += minFlow[ev];
		}
		return minFlow[ev];
	}
}



Measured memory_bytes: 23512
#include <bits/stdc++.h>
#define ll long long 
#define ull unsigned long long 
#define f(i,x,n) for(ll int i=x;i<n;i++) 
#define re(j,x,n) for(ll int j=x;j>=n;j--)
#define f1(k,x,n) for(ll int k=x;k<=n;k++)
#define mp make_pair
#define pb push_back
#define mod 1000000007
using namespace std;
int main(){
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   ll int n;
   cin>>n;
   ll int a[9]={1,8,27,64,125,216,343,512,729};
   cout<<a[n-1];
}


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

int main(int argc, char *argv[])
{
    int N;
    std::cin >> N;
    std::vector<int> square;
    for (int i = 0; i < 4 * 10000; i++) {
        square.push_back(i*i);
    }

    bool flag = false;
    int ans = 0;
    for (int i = 0; i < 4*10000; i++) {
        if (N <= square[i]) {
            if (i == 0) {
                ans = 0;
            } else if ((N - square[i]) == 0) {
                ans = square[i];
            } else {
                ans = square[i-1];
            }
            flag = true;
        }
        if (flag) {
            break;
        }
    }

    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <bitset>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <utility>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto&e:c)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){
    rep(i,v.size()) os << v[i] << (i+1==v.size()?"":" ");
    return os;
}

typedef bitset<24> bs;
// kテ、ツコツコテ」ツつ暗」ツつ甘・ツ可催」ツ?ァSテ・ツ淞凝」ツ?セテ」ツ?」テ」ツ?ヲテ」ツつ?
ll dp[101][1<<16];

int n;
vector<ll> s, d;

ll rec(int k, int S){
    ll & res = dp[k][S];
    if(res!=-1) return res;
    // dump(k, bs(S));
    res = 0;
    loop(i,k,n){
        if(S&d[i]) continue;
        res = max(res, rec(i,S|d[i])+s[i]);
    }
    return res;
}

int main(){
    while(cin>>n && n){
        memset(dp,-1,sizeof(dp));
        s.resize(n), d.resize(n);
        rep(i,n){
            int m;
            cin >> m >> s[i];
            int date = 0;
            rep(j,m){
                int b,e; cin >> b >> e;
                b-=6; e-=6;
                loop(k,b,e){
                    date |= (1<<k);
                }
            }
            // dump(bs(date));
            d[i] = date;
        }

        vi used(n);
        cout << rec(0,0) << endl;
    }
}

Measured memory_bytes: 52932
import java.util.Scanner;

public class Main {
    static int[] fibo = new int[44 + 1];
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        fibo[1] = fibo[0] = 1;
        
        int n = sc.nextInt();
        System.out.println(f(n));
    }
    
    static int f(int n) {
        if (fibo[n] != 0) return fibo[n];
        return fibo[n] = f(n -1) + f(n - 2);
    }
}


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

using namespace std;

typedef long long ll;

int main() {
        ios::sync_with_stdio(false);
        cin.tie(0);
        string s;
        cin >> s;
        deque<char> dq;
        for (auto &ch : s)
                dq.push_back(ch);
        int q, rot = 0;
        cin >> q;
        while (q--) {
                int t;
                cin >> t;
                if (t == 1)
                        rot ^= 1;
                else {
                        int f;
                        string t;
                        cin >> f >> t;
                        f %= 2;
                        f ^= rot;
                        f ^= 1;
                        if (f)
                                dq.push_back(t[0]);
                        else
                                dq.push_front(t[0]);
                }
        }
        s = "";
        for (auto &ch : dq)
                s += ch;
        if (rot)
                reverse(s.begin(), s.end());
        cout << s << "\n";
        return 0;
}


Measured memory_bytes: 1168
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

void solve(){  
    string s;
    cin>>s;
    rep(i,0,sz(s)){
        if(s[i]=='?') s[i]='D';
    }  
    cout<<s<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int INF=1<<29;

int main(){
    ios::sync_with_stdio(false);
	int N,Ans=0;
	cin>>N;
	vector<int> a(N+1);
	for(int i=1;i<=N;i++) cin>>a[i];
	for(int i=1;i<=N;i++){
		if(i==a[a[i]]) Ans++;
	}
	cout<<Ans/2<<endl;
	return 0;
}



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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
// constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n;
    cin >> n;
    vec<ll> a(n);
    ll con = 0;
    REP(i, n) {
        cin >> a[i];
        if(i % 2 == 0 and a[i] % 2) {
            con++;
        }
    }
    cout << con << en;
}

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

    solve();
    // ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int n,m,q;
vector<tuple<int,int,int,int> > v;
int ans;

void dfs(int p,vi hoge){
	if(p==n){
		int sum=0;
		REP(i,q){
			int a,b,c,d;
			tie(a,b,c,d)=v[i];
			if(hoge[b]-hoge[a]==c) sum+=d;
		}
		ans=max(ans,sum);
		return;
	}
	
	for(int i=hoge[p];i<=m;++i){
		hoge[p+1]=i;
		dfs(p+1,hoge);
	}
}

//解説参考.
int main(){
	cin>>n>>m>>q;
	
	REP(i,q){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		v.emplace_back(a,b,c,d);
	}
	
	vi hoge(n+1,1);
	dfs(0,hoge);
	
	cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N (100000)
#define INF (9223372036854775807)

struct edge{
	int to;
	long long dis;
};

int n, m;
vector<edge>e[N];
long long d[N];
bool dec[N];

void init(void){
	f(i, N){
		d[i] = INF;
		dec[i] = false;
	}
}


void dijkstra(int s){
	int xv;
	d[s] = 0;
	priority_queue<pair<long long, int> >pq;
	pq.push(make_pair(0, s));
	while (!pq.empty()){
		while (dec[pq.top().second]){
			pq.pop();
			if (pq.empty())return;
		}
		xv = pq.top().second;
		dec[xv] = true;
		f(i, e[xv].size()){
			if (d[e[xv][i].to] > (d[xv] + e[xv][i].dis)){
				d[e[xv][i].to] = d[xv] + e[xv][i].dis;
				pq.push(make_pair(-d[e[xv][i].to], e[xv][i].to));
			}
		}
	}
	return;
}



int main(void){
	int x, y, k;
	long long z;
	scanf("%d %d %d", &n, &m, &k);
	init();
	f(i, m){
		scanf("%d %d %lld", &x, &y, &z);
		e[x].push_back({ y, z });
	}
	dijkstra(k);

	f(i, n){
		if(d[i]!=INF)printf("%lld\n", d[i]);
		else printf("INF\n");
	}

	return 0;
}



Measured memory_bytes: 19128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
V<ll>fac,rfac;void setFac(int n, int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int x, a;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> x >> a;
  cout << (x>=a)*10 << endl;
}

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

using namespace std;

int main(){
  int N; cin >> N;
  vector<int> a(N);
 
  int ma = 1e8; int Ma = 0;
  for(int i = 0; i < N; i++){ 
    cin >> a[i]; ma = min(ma,a[i]); Ma = max(Ma,a[i]);

  }
  
  if( Ma-ma > 1){ cout << "No" << endl; return 0;}
  
    if( Ma == ma){
    
    //全員aloneか、全員aloneでない
    
    if( a[0] == N-1 || 2*a[0] <= N){ cout << "Yes" << endl;}
    else{ cout << "No" << endl;}
    
    
  } //aloneがいないとき
  
  else{
    
    int x = 0;
    
    for(int i = 0 ; i < N; i++){
      if( a[i] == ma){ x++;}
    }
   
    if( 2*Ma <= N+x &&  0 < x && x < Ma){ cout << "Yes" << endl;}
    
    else{ cout << "No" << endl;}
    
   
  }
  
  return 0;
  
}
  

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define endl 		"\n"
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define trace(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1) {std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " : " << arg1;
	ZZ(comma, args...);
}
void solve() {
	ll x;
	cin >> x;
	for (ll a = -120; a <= 120; a++) {
		for (ll b  = -119; b <= 120; b++) {
			ll ans = pow(a, 5) - pow(b, 5);
			if (ans == x) {
				cout << a << " " << b;
				return;
			}
		}
	}
}
int main() {
	fast_io;
	int t = 1;
	// cin>>t;
	while (t--) {
		solve();
	}
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 4036
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  string s; cin >> s;
  rep(i,s.size()-1) {
    if (s[i] == s[i+1]) {
      cout << i+1 << ' ' << i+2 << endl;
      return 0;
    }
  }
  rep(i,s.size()-2) {
    if (s[i] == s[i+2]) {
      cout << i+1 << ' ' << i+3 << endl;
      return 0;
    }
  }
  cout << -1 << ' ' << -1 << endl;
  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
//if(strcmp(s[i],"AC")==0)
//if(s[l]=='#')
/*小文字判定
if((moji>= 'a') && (moji<='z')){
    printf("a\n");
    return 0;
  }
  */

long long int W_Length(char *str){
	long long int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

void swap(long long int *a, long long int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}
//swap(&a, &b)

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

long long int cmp( const void *p, const void *q ) {
    return *(long long int*)p - *(long long int*)q;
}//ちいさい順
//qsort(a,n,sizeof(long long int),cmp);


int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);
//char s[n][11]

long long int GCD(long long int a, long long int b){
  long long int L=a,S=b;
  while(1){
    if(S>L){
      L=S+L;
      S=L-S;
      L=L-S;
    }
    if(L%S==0){
      return S;
    }
    L=L%S;
  }
  
}

long long int LCM(long long int a, long long int b){
  return a*b/(GCD(a,b));
}

int main (void)
{
	long long int p[5005],b,c,n,i,k,a[120000]={0},max,j=1,get[5005]={0},temp1,k_temp;
scanf("%lld",&n);
  
  for(i=2;i<120000;i++){
   if(a[i]==1){
     continue;
   }
    a[i]=1;
    if(i>=n){
      printf("%lld",i);
      return 0;
    }
    
    for(j=2;i*j<120000;j++){
      a[j*i]=1;
    }
    
  }
  
return 0;
}


Measured memory_bytes: 2664
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
def primes(n):
    m=int(pow(n,0.5))
    is_prime=[True]*(n+1)
    is_prime[0]=False
    is_prime[1]=False
    for i in range(2,m+1):
        if not is_prime[i]:
            continue
        for j in range(i*2,n+1,i):
            is_prime[j]=False
    return [i for i in range(n+1) if is_prime[i]]
s=set(primes(55555))
ans=[]
c=0
for i in s:
    if i%5==1:
        c+=1
        ans.append(i)
    if c==n:
      break
print(*ans)

Measured memory_bytes: 10356
#include <stdio.h>
#define DOT(v1, v2) (v1.x * v2.x + v1.y * v2.y)
#define NORM(v) (v.x * v.x + v.y * v.y)

typedef struct { double x, y; } point_t;
typedef point_t vector_t;
typedef struct { point_t p0, p1; } segment_t;
typedef segment_t line_t;

static vector_t plus(vector_t v1, vector_t v2) {
  vector_t ret = { v1.x + v2.x, v1.y + v2.y };
  return ret;
}

static vector_t minus(vector_t v1, vector_t v2) {
  vector_t ret = { v1.x - v2.x, v1.y - v2.y };
  return ret;
}

static vector_t multiple(vector_t v, double s) {
  vector_t ret = { v.x * s, v.y * s };
  return ret;
}

static point_t project(line_t l, point_t p) {
  vector_t base = minus(l.p1, l.p0);
  double r = DOT(minus(p, l.p0), base) / NORM(base);
  return plus(l.p0, multiple(base, r));
}

static point_t reflect(line_t l, point_t p) {
  return plus(p, multiple(minus(project(l, p), p), 2.0));
}

int main(int argc, char **argv) {
  line_t l;
  point_t p;
  int q, i;

  scanf("%lf %lf %lf %lf", &l.p0.x, &l.p0.y, &l.p1.x, &l.p1.y);
  scanf("%d", &q);
  for (i = 0; i < q; ++i) {
    scanf("%lf %lf", &p.x, &p.y);
    p = reflect(l, p);
    printf("%.10lf %.10lf\n", p.x, p.y);
  }
}


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

#define N 10010

int n, k;
char s[N], st[N];

int id[N], x[N], y[N], c[N];
void build(char *s) {
    int n = strlen(s) + 1, m = 256;
    for (int i = 0; i < m; i ++) c[i] = 0;
    for (int i = 0; i < n; i ++) c[x[i] = s[i]] ++;
    for (int i = 1; i < m; i ++) c[i] += c[i - 1];
    for (int i = n - 1; i >= 0; i --) id[--c[x[i]]] = i;
    for (int j = 1, p = 1; p < n; j <<= 1, m = p) {
        p = 0;
        for (int i = n - j; i < n; i ++) y[p++] = i;
        for (int i = 0; i < n; i ++) if (id[i] >= j) y[p++] = id[i] - j;
        for (int i = 0; i < m; i ++) c[i] = 0;
        for (int i = 0; i < n; i ++) c[x[i]] ++;
        for (int i = 1; i < m; i ++) c[i] += c[i - 1];
        for (int i = n - 1; i >= 0; i --) id[--c[x[y[i]]]] = y[i];
        swap(x, y);
        x[id[0]] = 0, p = 1;
        for (int i = 1; i < n; i ++) {
            x[id[i]] = (y[id[i]] == y[id[i - 1]] && y[id[i] + j] == y[id[i - 1] + j]) ? p - 1 : p ++;
        }
    }
}
int main() {
    scanf("%d %d %s", &n, &k, s);
    strcpy(st, s);
    reverse(st, st + strlen(st));
    strcat(s, st);
    k --; build(s);
    int t = 1;
    for (; id[t] >= n; t ++);
    t = id[t];
    int l = 1;
    while (l < n && s[t+l] == s[t]) l ++;
    vector <char> vec;
    for (int i = l; i < n; i ++) vec.push_back(s[t+i]);
    while (k --) {
        l <<= 1;
        if (l >= n) break;
    }
    for (int i = 0; i < min(n, l); i ++) putchar(s[t]);
    for (int i = l; i < n; i ++) putchar(vec[i-l]); puts("");
}


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

int n;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	if(n == 25){
		cout<<"Christmas"<<endl;
	}else if(n == 24){
		cout<<"Christmas Eve"<<endl;
	}else if(n == 23){
		cout<<"Christmas Eve Eve"<<endl;
	}else{
		cout<<"Christmas Eve Eve Eve"<<endl;
	}
}


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

int main() {
	int n;
	cin >> n;
	int arry[4][3][10] = { 0 };
	int t, x, y, v;
	for (int i = 0; i < n; i++) {
		cin >> t >> x >> y >> v;
		arry[t-1][x-1][y-1] += v;
	}

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				cout << " " << arry[i][j][k];
			}
			cout << endl;
		}
		if(i != 3)cout << "####################" << endl;
	}
}




Measured memory_bytes: 3092
istr = input()
iq = int(input())
arr = []
for i in range(0, iq):
	arr.append(list(input().split()))

#print(arr)

for i in arr:
	cmd = i[0]
	a, b = int(i[1]), int(i[2])
	if cmd == 'print':  # strのa文字目からb文字目までを出力する。
		print(istr[a:b + 1])
	elif cmd == 'reverse':  # strのa文字目からb文字目までを逆順にする。
		stemp = ''
		for i in range(b, a - 1, -1):
			stemp = stemp + istr[i]
		istr = istr[:a] + stemp + istr[b + 1:]
	elif cmd == 'replace':  # strのa文字目からb文字目までをpに置き換える。
		p = i[3]
		istr = istr[:a] + p + istr[b + 1:]

#print(istr)



Measured memory_bytes: 5620
S = list(input())

even_zero_list = list('0' * len(S))
odd_zero_list = list('0' * len(S))
for i in range(len(S)):
    if i % 2 != 0:
        even_zero_list[i] = '1'
    else:
        odd_zero_list[i] = '1'

even_diff = 0
odd_diff = 0
for i in range(len(S)):
    if S[i] != even_zero_list[i]:
        even_diff += 1
    if S[i] != odd_zero_list[i]:
        odd_diff += 1
print(min(even_diff, odd_diff))


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

#define MAX_V 105

/* UNION-FIND library */
int id[MAX_V], size[MAX_V];
void init(int n) { int i; for (i = 0; i < n; i++) id[i] = i, size[i] = 1; }
int root(int i) { while (i != id[i]) id[i] = id[id[i]], i = id[i]; return i; }
int connected(int p, int q) { return root(p) == root(q); }
void unite(int p, int q)
{
    int i = root(p), j = root(q); if (i == j) return;
    if (size[i] < size[j]) id[i] = j, size[j] += size[i]; else id[j] = i, size[i] += size[j];
}

typedef struct { int s, t, w; } EDGE;
EDGE edge[5100];

int cmp(EDGE *a, EDGE *b) { return a->w - b->w; }

int kruskal(int V, int E)
{
    int ans;
    EDGE *ep;

    qsort(edge, E, sizeof(EDGE), cmp);
    init(V);
    ans = 0;
    ep = edge; while (E--) {
        if (!connected(ep->s, ep->t)) {
            unite(ep->s, ep->t);
            ans += ep->w;
        }
        ep++;
    }
    return ans;
}

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int in()
{
    int n = 0, c = gc();
    while (c <= ' ') c = gc();
    if (c == '-') { c = gc();
        do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
        return -n;
    }
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}

int main()
{
    int n, a, i, j;
    EDGE *ep;

    n = in();
    ep = edge;
    for (i = 0; i < n; i++) for (j = 0; j < n; j++) {
        a = in();
        if (j > i && a >= 0) {
            ep->s = i, ep->t = j, ep->w = a;
            ep++;
        }
    }
    printf("%d\n", kruskal(n, ep-edge));
    return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}

int main() {
  ll n,c,k;
  cin>>n>>c>>k;
  ll vec[n];
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  sort(vec,vec+n);
  int ans=1;
  int p,q=0;
  for(int i=0;i<n;i++){
    if(i==0){
      p=vec[i]+k;
      q++;
      continue;
    }
    if(vec[i]<=p&&q<c){
      q++;
      continue;
    }
    else{
      p=vec[i]+k;
      q=1;
      ans++;
      continue;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024