akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int GCD(int m, int n)
{
	if (n == 0) return m;
	return GCD(n, m % n);
}

int dfs(int p,int q,int a,int n,int temp)
{
	if (a < temp || n == 0)
		return 0;
	int res = 0;
	int gcd = GCD(p,q);
	p /= gcd;
	q /= gcd;
	for (int i = max((q + p - 1) / p, temp); i <= a ; i++) {
		if (p == 1 && q == i) {
			res++;
		}
		else
			res += dfs(p * i - q, q * i, a / i, n - 1, i);
	}
	return res;
}

int main()
{
	int p, q, a, n;
	while (cin >> p >> q >> a >> n, p || q || a || n) {
		cout << dfs(p,q,a,n,1) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
N=gets.to_i
MOD = 10**9+7
require 'prime'
h=Hash.new(1)
2.upto(N) do |i|
    i.prime_division.each do |a,b|
        h[a] += b
    end
end

puts h.inject(1) {|r,(k,v)| r*v % MOD}

# 1 2 3 4 5 6
# 1 2 3 2 2 5 2 3
# [1,4,2,0,1]

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

int main() {
	int n;
	cin >> n;
	vector<ll> vs(n);
	rep(i, n) {
		cin >> vs[i];
	}
	int m;
	cin >> m;
	ll sum = 0;
	rep(_, m) {
		int c;
		cin >> c;
		auto u = std::lower_bound(vs.begin(), vs.end(), c);
		if (u != vs.end() && *u == c) {
			sum++;
		}
	}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 3636
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const int MINF = -1e9;;

int gcd(int a, int b) {
	if (b == 0) return a;

	return gcd(b, a%b);
}

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

int main() {
	int n;
	cin >> n;
	vector<int> a;
	rep(i, n) {
		int x;
		cin >> x;
		a.push_back(x);
	}
	sort(a.begin(), a.end());
	int ans = a[0];
	for (int i = 1; i < n; ++i) {
		ans = gcd(ans, a[i]);
	}

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


Measured memory_bytes: 892
#include<iostream>
#include<vector>
using namespace std;
vector<vector<int> >a(11,vector<int>(331));
void r(int n,int u,int s,int d){
a[n][s]++;
for(int i=10;i-->0;)
if(!(u>>i&1))r(n+1,u^1<<i,s+d*i,d+1);
}
main(){
r(0,0,0,1);
for(int n,s;cin>>n>>s;)cout<<a[n][s]<<endl;
}

Measured memory_bytes: 808
#include <algorithm>
#include <iterator>
#include <iostream>
#include <sstream>
#include <bitset>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <time.h>
#include <limits>
#include <math.h>
#include <climits>
#include <numeric>
#include <utility>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <functional>
#include<unordered_map>

using namespace std;
const double pi=acos(-1.0);
//memset ( a , 0 , n * sizeof(ll) ) ;

#define 	boost  		ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); // don't use if small inpts
#define 	endl 		'\n'
#define 	sl(n) 		scanf("%lld",&n)
#define		mp 			make_pair
#define 	pb 			push_back
#define 	ppb 		pop_back
#define 	fi 			first
#define 	se 			seconchutd
#define 	ll 			long long
#define     ld 			long double
#define 	ull 		unsigned long long
#define 	pii 		pair<int, int>
#define 	f(i,a,b) 	for(ll i = (ll)(a); i < (ll)(b); i++)
#define 	rf(i,a,b) 	for(ll i = (ll)(a); i > (ll)(b); i--)
#define 	ms(a,b) 	memset((a),(b),sizeof(a))
#define 	max(a,b) 	((a>b)?(a):(b))
#define 	min(a,b) 	((a<b)?(a):(b))
#define 	vec(g1) 	int temp;cin>>temp;g1,push_back(temp);
#define 	abs(x) 		((x<0)?(-(x)):(x))
#define 	MAX 		100005
#define 	inf 		LLONG_MAX
#define 	MIN 		INT_MIN

//typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;


int mod = 1e9 + 7 ;
ll gcd(ll a , ll b){return b==0?a:gcd(b,a%b);}
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}// ll fac[200005];
// ll inverse(ll n){return powmod(n, mod-2);}
// ll nCr(ll n, ll r){return (fac[n] * inverse(fac[r]) % mod * inverse(fac[n-r]) % mod) % mod;}

/**.................................................................................................................................*/
ll a[3010],n;
ll dp[3010][3010][2];
ll fun(ll i,ll j,ll k){
	ll ans=0;
	if(dp[i][j][k]!=-1)return dp[i][j][k]; 
	if(i==j){
		if(k)return a[i];
		if(!k) return -a[i];
	}
	if(k){
			ans=max(fun(i+1,j,!k)+a[i],fun(i,j-1,!k)+a[j]);
		return dp[i][j][k]=ans;
	}
	if(!k){
		ans=min(fun(i+1,j,!k)-a[i],fun(i,j-1,!k)-a[j]);
		return dp[i][j][k]=ans;
	}
}

int main() {

  boost;
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  ms(dp,-1);
  for(int i=0;i<n;i++){
         dp[i][i][1]= a[i];
         dp[i][i][0]=-a[i];
  }
  	
  fun(0,n-1,1);
   cout<<dp[0][n-1][1]<<endl;
     return 0;
}


Measured memory_bytes: 142080
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
typedef long long ll;
typedef long double ld;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main(){
  ll n,m,k,i,j,result=0,d;
  int a[200010]={0};
  string s;
  cin >> n >> d;
  result = (n+2*d)/(2*d+1);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	ll n;
	rl(n);
	string str;
	cin>>str;
	if(n%2==1)
		cout<<"No"<<endl;
	else
	{
		int flag=1;
		fr(i,0,n/2)
		{
			if(str[i]!=str[n/2+i])
				flag=0;
		}
		if(flag)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
const ll ARR = 1e5 + 2;
const ll MOD = 1e9+7;
const ll INF = MOD;
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define gof for(long long int i = 0 ; i < n ; i++)

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

ll gcd(ll a,ll b) { if (a == 0) return b; return gcd(b%a, a);}
ll max(ll a,ll b){if(a>b) return a; else return b;}
ll min(ll a,ll b){if(a<b) return a; else return b;}
ll max(ll a[], ll n){ll ans = 0; for(ll i = 0 ; i < n ; i++) ans = max(ans,a[i]); return ans;}

ll min(ll a[], ll n){ll ans = INF; for(ll i = 0 ; i < n ; i++) ans = min(ans,a[i]); return ans;}  
bool isPrime(ll N){ for(int i=2;i*i<=N;++i){if(N%i==0) return false;}return true;}


void solve(){
    ll n,a[ARR][3],dp[ARR][3]={0};
    cin >> n;
    gof{
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    dp[0][0] = a[0][0], dp[0][1] = a[0][1], dp[0][2] = a[0][2];
    for(ll i = 1 ; i < n ; i++){    

        dp[i][0] = a[i][0] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = a[i][1] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = a[i][2] + max(dp[i-1][1],dp[i-1][0]);
        
    }

    cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) << endl;

    return;

}

int main(){
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=0;i<(n);++i)
#define rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep4(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vec vector<ll>
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

void solve(){
    ll h,n;cin>>h>>n;
    vec a(n),b(n);
    rep(i,n){
        cin>>a[i]>>b[i];
    }

    vec dp(h+1,INF);
    dp[0]=0;
    rep(i,h){
        rep(j,n){
            ll to=min(h,i+a[j]);
            chmin(dp[to],dp[i]+b[j]);
        }
    }
    cout<<dp[h]<<endl;
}

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


Measured memory_bytes: 512
/*
* Author : MaxSally
*/
/********   All Required Header Files ********/
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i <= k ; ++i)
#define rrep(i, j, k) for (int i = j; i >= k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
#define inf (int) (1e9 + 7)
#define epsi 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define read(type) readInt<type>()
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define left tuyiuoi
#define right fgjhk
#define ss second
#define ff first
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) rep(i, l, r) cout << a[i] << " "; cout << endl
#define Flag(n) cout << "here " << n << endl
const double pi=acos(-1.0);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

const int N = 200005;
int a[30], b[30];

int main(){
    io;
    //freopen("input.txt", "r", stdin);
    string s, t;
    cin >> s >> t;
    int n = s.length();
    rep(i, 0, n - 1){
        a[s[i] - 'a']++;
        b[t[i] - 'a']++;
    }
    sort(a, a + 26);
    sort(b, b + 26);
    rep(i, 0, 25){
        if(a[i] != b[i]){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 916
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    P = list(map(int, input().split()))
    minimum = float('inf')
    answer = 0
    for i in P:
        if minimum >= i:
            answer += 1
            minimum = i
    print(answer)


if __name__ == '__main__':
    main()


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


int a[52], b[52];
int N;
ll bit;
bool visited[52];

bool dfs(int v, int target){
    if(visited[v]) return false;
    if(v == target) return true;
    if(v < target) return false;
    visited[v] = true;
    for(int k=1;k<=50;k++){
        if((bit>>k)&1){
            if(dfs(v % k, target)) return true;
        }
    }
    return false;
}

bool check(){
    bool ok = true;
    for(int i=0;i<N;i++){
        memset(visited, 0, sizeof(visited));
        if(!dfs(a[i], b[i])){
            ok = false;
            break;
        }
    }
    return ok;
}

int main(){
    cin >> N;

    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    for(int i=0;i<N;i++){
        cin >> b[i];
    }

    bit = (1LL << 51) - 1;
    if(check()){
        ll ans = 0;
        for(int k=50;k>=1;k--){
            bit ^= (1LL << k);
            if(!check()){
                ans += 1LL << k;
                bit |= 1LL << k;
            }
        }
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    string s;
    cin >> s;
    set<char> t(all(s));

    if (t.size() == 1) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

struct edge {
    ll to;
    ll cost;
};

int N;
vector<vector<edge>> G;
vector<bool> seen;

ll prim() {
    priority_queue<pll, vector<pll>, greater<pll>> que;
    que.push({0, 0});
    ll ans = 0;

    while (!que.empty()) {
        pll p = que.top();
        que.pop();
        ll v = p.second;
        if (seen[v])
            continue;
        ans += p.first;
        seen[v] = true;
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (!seen[e.to])
                que.push({e.cost, e.to});
        }
    }
    return ans;
}

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

    cin >> N;
    G.resize(N);
    seen.resize(N, false);
    rep(i, N) {
        rep(j, N) {
            ll a;
            cin >> a;
            if (a == -1)
                continue;
            else
                G[i].push_back({j, a});
        }
    }

    cout << prim() << endl;
}


Measured memory_bytes: 3292
import java.io.*;

class Main{
  
  public static void main(String[] args){
   
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );
                                           
                                           try{
                                           
                                           String str = br.readLine();
                                           int num = Integer.parseInt(str);
                                           
                                           double p = 3.14;
                                           
                                           System.out.println(2.0*p*num);
                                           }catch(Exception e){
                                           }
  }
}

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

const int N_MAX=1030;
const int V_MAX=100005;

vector<vector<int64_t>> dp(N_MAX,vector<int64_t>(V_MAX,0));
vector<pair<int64_t,int64_t>> p;

int64_t query(int v,int L){
  
  int64_t res=0;
  
  if(v<=1028) res=dp[v][L];
  else{
    if(p[v].second>L) res=query(v/2,L);
    else res=max(query(v/2,L),query(v/2,L-p[v].second)+p[v].first);
  }
  
  return res;
  
}

int main(){
  
  int N;
  cin>>N;
  
  p.resize(N+1);
  
  for(int i=1;i<=N;++i){
    cin>>p[i].first>>p[i].second;
  }

  for(int i=1;i<N_MAX;++i){
    for(int j=0;j<V_MAX;++j){
      if(p[i].second>j) dp[i][j]=dp[i/2][j];
      else dp[i][j]=max(dp[i/2][j],dp[i/2][j-p[i].second]+p[i].first);
    }
  }

  int Q;
  cin>>Q;
  for(int i=0;i<Q;++i){
    int v,L;
    cin>>v>>L;
    cout<<query(v,L)<<endl;
  }

}


Measured memory_bytes: 814892
#include<iostream>
using namespace std;
int main(){
  bool num[1000000]={true,true};
  for(int i=2; i<1000; i++)
    if(!num[i])
      for(int j=i*i; j<1000000; j+=i)
	num[j] = true;
  int n;
  while(cin >>n,n){
    int ans = 0;
    for(int i=2; n>0; i++){
      if(!num[i]){
	ans+=i;
	n--;
      }
    }
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 2144
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF = 1e18;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (int i = (int)((b)-1); i >= (int)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T>
inline void chmax(T &a, const T &b) {
    if ((a) < (b)) (a) = (b);
}
template <class T>
inline void chmin(T &a, const T &b) {
    if ((a) > (b)) (a) = (b);
}

#define divceil(a, b) ((a) + (b)-1) / (b)
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x)    \
    sort(all(x)); \
    x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int, int> pii;
typedef tuple<int, int, int> iii;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
    }
} fast;
void check_input() {
    assert(cin.eof() == 0);
    int tmp;
    cin >> tmp;
    assert(cin.eof() == 1);
}

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"

signed main() {
    //input
    int n,m;cin>>n>>m;
    check_input();

    //solve
    vi e;
    vi o;
    rep(d, 1, m+1){
        if (d%2==1) o.pb(d);
        else e.pb(d);
    }
    dump(o);
    dump(e);

    vector<pii> ans;
    {
        int l = 1;
        int r = 1 + o.back();
        while(1){
            ans.pb(mp(l, r));
            l++;r--;
            if (r-l==-1) break;
        }
    }
    {
        if (sz(e)>0){
            int l = 1 + o.back() + 1;
            int r = l + e.back();
            while(r-l>1){
                ans.pb(mp(l, r));
                l++;r--;
                if (r-l==0) break;
            }
        }
    }
    dump(ans);

    each(el, ans) {
        cout << el.first << " " << el.second << endl;
    }

    return 0; 
}


Measured memory_bytes: 5940
#include<bits/stdc++.h>
using namespace std;
typedef struct E{
  int to,cost,tim;
}edge;
vector<vector<edge> >root(310);
int d[2][301];
void dijkstraco(int s){
  priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >que;
  d[0][s] = 0;
  que.push(pair<int,int>(0,s));
  while(!que.empty()){
    pair<int,int> p=que.top();que.pop();
    int v = p.second;
    if(d[0][v]<p.first)continue;
    for(int j=0;j<root[v].size();j++){
      edge t = root[v][j];
      if(d[0][t.to]>d[0][v]+t.cost){
	d[0][t.to]=d[0][v]+t.cost;
	que.push(pair<int,int>(d[0][t.to],t.to));
      }
    }
  }
}
void dijkstrati(int s){
  priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >que;
  d[1][s] = 0;
  que.push(pair<int,int>(0,s));
  while(!que.empty()){
    pair<int,int> p=que.top();que.pop();
    int v = p.second;
    if(d[1][v]<p.first)continue;
    for(int j=0;j<root[v].size();j++){
      edge t = root[v][j];
      if(d[1][t.to]>d[1][v]+t.tim){
	d[1][t.to]=d[1][v]+t.tim;
	que.push(pair<int,int>(d[1][t.to],t.to));
      }
    }
  }
}
int main(){
  int n,m;
  while(cin>>n>>m,n+m!=0){
    for(int j=0;j<2;j++){
      for(int a=0;a<301;a++)
	d[j][a]=1000000000;
    }
    for(int i=0;i<301;i++)
      root[i].clear();
    for(int i=0;i<n;i++){
      int f;cin>>f;
      edge e;cin>>e.to>>e.cost>>e.tim;
      root[f].push_back(e);
      int tmp=f;
      f=e.to;
      e.to=tmp;
      root[f].push_back(e);
    }
    int k;cin>>k;
    for(int i=0;i<k;i++){
      int p,q,r;cin>>p>>q>>r;
      if(r==0)
	dijkstraco(p);
      else
	dijkstrati(p);
      cout<<d[r][q]<<endl;
    for(int j=0;j<2;j++){
      for(int a=0;a<301;a++)
	d[j][a]=1000000000;
    }
    }
  }
  return 0;
}

Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
const int DX[4] = {0, 0, +1, -1};
const int DY[4] = {+1, -1, 0, 0};
const int TYPE[4] = {1, 2, 4, 8};
int main() {
    int H, W, K; cin >> H >> W >> K;
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    x1--, y1--, x2--, y2--;
    vector<string> C(H); for (auto &c : C) cin >> c;
    vector<vector<int>> done(H, vector<int>(W));
    vector<vector<int>> cost(H, vector<int>(W, 1e9));
    queue<tuple<int, int, int>> Q;
    Q.emplace(0, x1, y1);
    cost[x1][y1] = 0;
    while (!Q.empty()) {
        auto [c, x, y] = Q.front(); Q.pop();
        if (cost[x][y] != c) continue;
        if (x == x2 && y == y2) {
            cout << c << '\n';
            return 0;
        }
        for (int i = 0; i < 4; i++) {
            if ((done[x][y] & TYPE[i]) != 0) continue;
            int nx = x, ny = y, rest = K;
            while (rest) {
                nx += DX[i], ny += DY[i], rest--;
                if (!(0 <= nx && nx < H && 0 <= ny && ny < W)) break;
                if (C[nx][ny] != '.') break;
                if (cost[nx][ny] < c) break;
                if (cost[nx][ny] == c && (done[nx][ny] & TYPE[i]) == 0) {
                    done[nx][ny] |= TYPE[i];
                    rest = K;
                }
                if (cost[nx][ny] > c + 1) {
                    cost[nx][ny] = c + 1;
                    Q.emplace(c + 1, nx, ny);
                }
            }
            done[x][y] |= TYPE[i];
        }
    }
    cout << -1 << '\n';
    return 0;
}


Measured memory_bytes: 16016
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define mp1(a,b,c) P1(a,P(b,c))
#define pque(a) priority_queue<a>
#define rpque(a) priority_queue<a,vector<a>,greater<a>>

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
const int kaijou[10]={1,1,2,6,24,120,720,5040,40320,362880};

int main(){
	while(1){
		int n;
		int x[3010],y[3010];
		
		scanf("%d",&n); if(n == 0)break;
		rep(i,n){
			scanf("%d%d",&x[i],&y[i]);
		}
		
		vector<P> S;
		rep(i,n){
			S.pb( P ( x[i] , y[i] ) );
		}
		sor(S);
		
		int ret = 0;
		rep(i,n){
			rep(j,n){
				if(i == j)continue;
				bool t = true;
				P p = P ( x[j] + y[j] - y[i] , y[j] - x[j] + x[i] );
				P q = P ( x[i] + y[j] - y[i] , y[i] - x[j] + x[i] );
				t &= *lb( S , p ) == p;
				t &= *lb( S , q ) == q;
				if(t){
					ret = max( ret , (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) );
				}
			}
		}
		
		printf("%d\n",ret);
	}
}
	

Measured memory_bytes: 1252
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {

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

    int n; cin >> n;
    int x = ceil(n/1.08);
    floor(x*1.08) <= n ? cout << x << endl : cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
void yes(){
  cout << "Yes" << endl;
  exit(0);
}

void no(){
  cout << "No" << endl;
  exit(0);
}
int main() {
  ll n,m,k; cin >> n >> m >> k;
  REP(i,n+1) REP(j,m+1){
    ll t = m*i+n*j-2*i*j;
    if(t==k) yes();
  }
  no();
}


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

int main(void){
    int n;
    cin>>n;
    vector<int> mina(26,50);
    rep(i,n){
        string s;
        cin>>s;
        int cnt[26]={};
        for(char c : s){
            cnt[c-'a']++;
        }
        rep(j,26){
            mina[j] = min(cnt[j],mina[j]);
        }
    }
    rep(i,26){
        cout<<string(mina[i],'a'+i);
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class ETravelByCar {
public:
	void solve(std::istream& in, std::ostream& out) {
        int N, M, L, Q;
        in >> N >> M >> L;
        vector<int> A(M), B(M), C(M);
        REP(i,0,M) in >> A[i] >> B[i] >> C[i];
        in >> Q;
        vector<int> s(Q), t(Q);
        REP(i,0,Q) in >> s[i] >> t[i];

        vector<vector<ll>> distance(N+1, vector<ll>(N+1, (ll)INT_MAX * N));
        REP(i,0,N) distance[i][i] = 0;
        REP(i,0,M) {
            if (C[i] > L) continue;
            distance[A[i]][B[i]] = C[i];
            distance[B[i]][A[i]] = C[i];
        }

        REP(k,1,N+1) {
            REP(i,1,N+1) {
                REP(j,1,N+1) {
                    distance[i][j] = min(distance[i][j], (ll)distance[i][k] + (ll)distance[k][j]);
                }
            }
        }

        vector<vector<int>> count(N+1, vector<int>(N+1, 1e5));
        REP(i,1,N+1) count[i][i] = 0;
        REP(i,1,N+1) {
            REP(j,1,N+1) {
                if (distance[i][j] <= L && i!=j) {
                    count[i][j] = 1;
                }
            }
        }
        REP(k,1,N+1) {
            REP(i,1,N+1) {
                REP(j,1,N+1) {
                    count[i][j] = min(count[i][j], count[i][k] + count[k][j]);
                }
            }
        }
        REP(i,0,Q) {
            if (count[s[i]][t[i]] >= 1e5) out << -1 << "\n";
            else out << count[s[i]][t[i]] -1 << "\n";
        }
	}
};


int main() {
	ETravelByCar solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 2688
N = int(input())

A=[]
for i in range(N):
    a, b, c = map(int, input().split())
    A.append([a, b, c])

A.sort(key=lambda x:-x[2])

for x in range(0, 101):
    for y in range(0, 101):
        H = A[0][2]+abs(A[0][0]-x)+abs(A[0][1]-y)
        Flag = True
        for i in range(1, N):
            if A[i][2] != 0:
                    if H != A[i][2]+abs(A[i][0]-x)+abs(A[i][1]-y):
                        Flag = False
                        break
            else:
                if H > abs(A[i][0]-x)+abs(A[i][1]-y):
                    Flag = False
                    break
        if Flag == True:
            print(x, y, H)

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG

#include"bits/stdc++.h"
using namespace std;

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define ZeroToN(i,n) for(int i=0;i<(ll)(n+1);i++)
#define AToB(i,a,b) for(int i=a;i<(ll)(b+1);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//bitsearch
#define BITSEARCH(bit, n) for (int bit = 0; bit < (1<<n); ++bit)
#define isOne(bit, i) bit & (1<<i)


//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back

template<typename T>
std::vector<T> slice(std::vector<T> const &v, int m, int n)
{
    auto first = v.cbegin() + m;
    auto last = v.cbegin() + n + 1;

    std::vector<T> vec(first, last);
    return vec;
}

#define remove_unique(v) v.erase(unique(ALL(v)), v.end())

//comparision
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

//pair
#define fir first
#define sec second
#define mp make_pair

//types
#define ll long long
#define vec vector
#define cord2d pair<int,int>
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(long long a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(char a){ cout << a << endl; }
void print(double a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T = int>
void print(vec<T> v){ cout << v << endl; }

template <class T = int>
void print2dVec(vec<vec<T>> v2d){for(vec<T> v: v2d) {print(v);}}

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"YES":"NO"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

//maths
int factorial(int k){ int sum = 1; for (int i = 1; i <= k; ++i) { sum *= i; } return sum; }
int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

////////////////////

void Main() {
    //code here
    double r = gi;
    print(2*r * 3.1415926535);
}


signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Main();
}


Measured memory_bytes: 3840
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def cnt0(n):
    return 0 if n&1 else 1 + cnt0(n//2)

def solve():
    n = f()
    a = f()

    min0 = int(1e9)

    for i in a:
        min0 = min(min0, cnt0(i))
    
    print(min0)

solve()


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

signed main(){
	long long n,a,b;	cin>>n>>a>>b;
	if(a>b){
		cout<<0<<endl;
		return 0;
	}

	//long long tmp=b-a+1;
	long long ans;
	if(n==1){
		if(a!=b)ans=0;
		else ans=1;
	}else{
		long long M=a + b*(n-1);
		long long m=a*(n-1) + b;

		ans=max(0LL, M-m+1);
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.nio.charset.IllegalCharsetNameException;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        FastReader in = new FastReader();
        test a=new test();
        a.solve(in,out);
        out.close();
    }
}

class test {
    public void solve(FastReader in, PrintWriter out) {
        int k=in.nextInt();
        String s =in.next();
       int n=s.length();

       if(n<=k){
           out.println(s);
       }
       else{
           out.print(s.substring(0,k));
           out.println("...");
       }
    }


}


class FastReader{
    BufferedReader br;
    StringTokenizer st;

    public FastReader(){
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next(){
        while(st==null || !st.hasMoreElements()){
            try{
                st=new StringTokenizer(br.readLine());
            }
            catch(IOException e){
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt(){
        return Integer.parseInt(next());
    }

    Long nextLong(){
        return Long.parseLong(next());
    }

    double nextDouble(){
        return Double.parseDouble(next());
    }
    String nextLine(){
        String str="";
        try{
            str=br.readLine();
        }
        catch(IOException e){
            e.printStackTrace();
        }
        return str;
    }
}


Measured memory_bytes: 32792
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

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

  vector<vector<int>> g(n);
  for(int i = 0; i < n; i++){
    g[a[i]].push_back(i);
  }

  vector<int> ans(n, -1);
  auto dfs = [&](auto&& dfs, int u, int par)->void{
    if(ans[u] != -1) return;
    int res = 0, child = 0;
    for(int v : g[u]){
      if(v == par) continue;
      dfs(dfs, v, u);
      res += ans[v];
      child++;
    }
    ans[u] = child;
    if(u == 0) ans[u] = child-1;
    return;
  };
  dfs(dfs, 0, -1);

  for(int i = 0; i < n; i++){
    if(ans[i] == -1) dfs(dfs, i, -1);
  }

  for(int i = 0; i < n; i++){
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 35996
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int D[101000], D2[101000], n;
vector<int>E[101000];
void DFS(int a, int pp, int d) {
  D[a] = d;
  int i;
  for (i = 0; i < E[a].size(); i++) {
    if (E[a][i] != pp)DFS(E[a][i], a, d + 1);
  }
}
int main() {
  int i, a, b;
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d%d", &a, &b);
    E[a].push_back(b);
    E[b].push_back(a);
  }
  DFS(n, 0, 0);
  for (i = 1; i <= n; i++)D2[i] = D[i];
  DFS(1, 0, 0);
  int r1 = 0, r2 = 0;
  for (i = 1; i <= n; i++) {
    if (D[i] <= D2[i])r1++;
    else r2++;
  }
  if (r1 > r2)printf("Fennec\n");
  else printf("Snuke\n");
}


Measured memory_bytes: 12800
#include<stdio.h>
#include<string.h>
int main(){
    char s[11];
    int i,count=0,max=0;
    
    scanf("%s",&s);
    
    
    for(i=0;i<strlen(s);i++){
        if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G'){
            count++;
            if(count>=max){
            max=count;
            }
        }
        else{
            count=0;
        }
    }
    printf("%d",max);
    
    return 0;
}

Measured memory_bytes: 128
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let a = v[0];
	let b = v[1];
	if a > 8 || b > 8 {
		println!(":(");
	}else{
		println!("Yay!");
	}
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
using Graph = vector<vector<int>>;

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

    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> dist(N, -1); 
    queue<int> que;
    vector<int> ans(N-1);
    dist[0] = 0;
    que.push(0); 

    while (!que.empty()) {
        int v = que.front(); 
        que.pop();

        for (int nv : G[v]) {
            if (dist[nv] != -1) continue;

            dist[nv] = dist[v] + 1;
            ans[nv-1]=v+1;
            que.push(nv);
        }
    }

    cout << "Yes" << endl;
    for (int v = 1; v < N; ++v) cout << ans[v-1] << endl;
}

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

void equ(string S,int n,int k){
  if(n==0){
    cout<<S<<endl;
  }else{
    if(S==""){
      equ("a",n-1,1);
    }else{
      char c='a';
      for(int i=0;i<=k;i++){
        if(i==k)equ(S+c,n-1,k+1);
        else equ(S+c,n-1,k);
        c+=1;
      }
    }
  }
}


int main() {
  int N;cin>>N;
  equ("",N,0);
}



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

int main() {
  int n;
  scanf("%d",&n);
  
  vector<int>v(n);
  vector<int>c(n);
  
  for(int i = 0; i<n; i++){
    cin >>v[i];
  }
  
  for(int i = 0; i<n;i++){
    cin >>c[i];
  }
   
  int sum =0;
  
  for(int i = 0; i<n; i++){
    if(v.at(i) > c.at(i)){
      sum += v.at(i)-c.at(i);
    }
  }

 cout <<sum <<endl;

}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int N;
    int H[N - 1];
    scanf("%d", &N);
    for (int i = 0; i < N; i++){
        scanf("%d", &H[i]);
    }

    int ans = 0;
    for (int i = 0; i < N; i++){
        int tmp = 0;
        for (int j = 0; j < i; j++){
            if (H[j] <= H[i]){
                tmp += 1;
            }
        }
        if (tmp == i){
            ans += 1;
        }
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int k[100030];
int s[100030];
int main() {
	string S;
	cin >> S;
	char c = 'R';
	int left = 0;
	int right = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == c) {
			if (c == 'R') {
				left = left + 1;
			}
			else {
				right = right + 1;
			}
		}
		else {
			if (c == 'R') {
				c = 'L';
				k[i - 1] = left;
				left = 0;
				right = 1;
			}
			else {
				c = 'R';
				k[i - right] = right;
				right = 0;
				left = 1;
			}
		}
	}
	k[S.size() - right] = right;
	for (int i = 0; i < S.size(); i++) {
		int a = 0;
		int b = 0;
		if (k[i] != 0) {
			a = k[i];
			b = k[i + 1];
			k[i] = (a + b) / 2;
			k[i + 1] = (a + b) / 2;
			if ((a+b)%2 != 0) {
				if (a % 2 == 1) {
					k[i] = k[i] + 1;
				}
				else {
					k[i + 1] = k[i + 1] + 1;
				}
			}

			i = i + 1;
		}
	}

	for (int i = 0; i < S.size(); i++) {
		cout << k[i] << " ";
	}

}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
ans = 1
m = 0
for i in range(1, n):
    if (a[i] - a[i - 1]) * m < 0:
        ans += 1
        m = 0
    elif a[i] - a[i - 1] != 0:
        m = a[i] - a[i - 1]
print(ans)

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

#define SIZE_OF_ARRAY(array) sizeof(array)/sizeof(array[0])
typedef long long ll;

int main() {
    ll A, B, V, W, T;
    cin >> A >> V >> B >> W >> T;
    if(A == B){
        cout << "YES" << endl;
    } else if(W >= V){
        cout << "NO" << endl;
    } else {
        ll dA = V*T;
        ll dB = W*T;
        ll d = abs(A-B);
        if(d <= dA - dB){
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;

void solve()
{
	int n;
	cin>>n;
	ll ans = 0;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(n);
	REP(i, n)
	{
		cin>>a[i];
	}
	REP(i,n)
		cin>>b[i];
	REP(i,n-1)
		cin>>c[i];
	int prev = -1;
	REP(i,n)
	{
		if(i+1<n && a[i]+1==a[i+1])
			ans+=c[a[i]-1];
		ans+=b[a[i]-1];
	}
	cout<<ans<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
	string s;
	cin >> s;
	int flag=0;
	if((s[0]-'0')-(s[1]-'0')-(s[2]-'0')-(s[3]-'0')==7){
		cout << s[0] << "-" << s[1] << "-" << s[2] << "-" << s[3] << "=7" << endl;
		return 0;
	}
	if((s[0]-'0')+(s[1]-'0')-(s[2]-'0')+(s[3]-'0')==7){
		cout << s[0] << "+" << s[1] << "-" << s[2] << "+" << s[3] << "=7" << endl;
		return 0;
	}
	if((s[0]-'0')+(s[1]-'0')+(s[2]-'0')-(s[3]-'0')==7){
		cout << s[0] << "+" << s[1] << "+" << s[2] << "-" << s[3] << "=7" << endl;
		return 0;
	}
	if((s[0]-'0')+(s[1]-'0')-(s[2]-'0')-(s[3]-'0')==7){
		cout << s[0] << "+" << s[1] << "-" << s[2] << "-" << s[3] << "=7" << endl;
		return 0;
	}
	if((s[0]-'0')-(s[1]-'0')-(s[2]-'0')+(s[3]-'0')==7){
		cout << s[0] << "-" << s[1] << "-" << s[2] << "+" << s[3] << "=7" << endl;
		return 0;
	}
	if((s[0]-'0')-(s[1]-'0')+(s[2]-'0')-(s[3]-'0')==7){
		cout << s[0] << "-" << s[1] << "+" << s[2] << "-" << s[3] << "=7" << endl;
		return 0;
	}
	if((s[0]-'0')-(s[1]-'0')+(s[2]-'0')+(s[3]-'0')==7){
		cout << s[0] << "-" << s[1] << "+" << s[2] << "+" << s[3] << "=7" << endl;
		return 0;
	}
	if((s[0]-'0')+(s[1]-'0')+(s[2]-'0')+(s[3]-'0')==7)cout << s[0] << "+" << s[1] << "+" << s[2] << "+" << s[3] << "=7" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
//const i64 smod = 998244353ll;

//const i64 inf = mod;

const long double eps = 1e-8;

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed); cerr.precision(15); cerr.setf(ios::fixed);

    i64 n;
    cin >> n;

    vector<pair<i64, i64>> a(n);

    for (i64 i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }

    for (i64 i = 0; i < n - 2; i++) {
        if (a[i].first == a[i].second && a[i + 1].first == a[i + 1].second && a[i + 2].first == a[i + 2].second) {
            cout << "Yes" << endl;
            return 0;
        }
    }


    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3660