akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;
int main(void){
    string s;
    while (cin >> s){
        for (int i=0; i<s.size(); i++){
            if (s[i] == '@'){
                for (int j=s[i+1]; j>'0'; j--)  cout << s[i+2];
                i+=2;
            }
            else    cout << s[i];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,zero,b)
#define ALL(c) c.begin(),c.end()
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int LL
#define zero 0LL
using namespace std;
template<typename T> inline void maximize(T &a,T b){a=max(a,b);}
template<typename T> inline void minimize(T &a,T b){a=min(a,b);}
template<typename T> inline bool middle(T a,T b,T c){return b<=a && a<=c;}
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
inline void outputVI(VI x){REP(i,SI(x)){cout << three(i," ","") << x[i];}OUT("");}
const int SIZE=1e6+1000;
const int SIZE2=5010;
const int SIZE3=400;
const LL p=7+1e9;
const LL INF=1LL<<60;
const long double EPS=1e-7;
string S;
ut N,M,K,X,L,W,H;
// ut A,B,C,D,E,F,G,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE],nums[SIZE],maps[SIZE2][SIZE2],answer=zero;
 
////////////////////////////////////////////////////////////////////////////////////////////
 
////////////////////////////////////////////////////////////////////////////////////////////
 
LL solve(){
	cin >> N >> K;
	VI A(N);
	REP(i,N){
		cin >> A[i]; 
	}
	sort(ALL(A));
	VI B;
	int now=0;
	REP(i,N){
		now++;
		if(i==N-1 || A[i]!=A[i+1]){
			B.PB(now);
			now=0;
		}
	}
	sort(ALL(B),greater<LL>());
	while(SI(B)>K){
		answer+=B.back();
		B.pop_back();
	}
	return answer;
}
signed main(){
	OUT(solve());
//	solve();
	return 0;
}

Measured memory_bytes: 28276
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>

#define INF 1000000

using namespace std;

unsigned int memo[100001];
unsigned int memb[100000];
int length = 0;

bool bisect(int left, int right, int target) {
	if (left > right) {
		return false;
	}
	else {
		int pivot = left + (right - left) / 2;
		if (memb[pivot] > target) {
			return bisect(left, pivot - 1, target);
		}
		else if (memb[pivot] < target) {
			return bisect(pivot + 1, right, target);
		}
		else {
			return true;
		}
	}
}

void bfib(int n) {
	if (bisect(0, length - 1, n)) {
		memo[n] = 0;
		return;
	}
	if (n == 1) {
		memo[n] = 1;
		return;
	}
	if (n == 2) {
		if (memb[0] == 1) {
			memo[n] = 1;
		}
		else {
			memo[n] = 2;
		}
		return;
	}
	else {
		memo[n] = (memo[n - 1] + memo[n - 2]) % 1000000007;
		return;
	}
}

int main(void)
{
	int n, nb, buf;
	n = nb = buf = 0;
	scanf("%d %d", &n, &nb);
	length = nb;
	for (int i = 0; i < nb; ++i) {
		scanf("%d", &buf);
		memb[i] = buf;
	}

	for (int i = 0; i < length - 1; ++i) {
		if (memb[i] == memb[i + 1] - 1) {
			cout << 0 << endl;
			return 0;
		}
	}

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

	return 0;

}

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

int main() {
    int N;
    cin >> N;
    vector<int> box(N+1);
    vector<int> ball(N+1,0);
    int count = 0;
    for(int i=1;i<=N;i++) cin >> box[i];

    for(int i=N;i>0;i--){
        int sum = 0;
        for(int j=i;j<=N;j+=i){
            sum += ball[j];
        } 
        if(sum%2 != box[i]) {
            ball[i] = 1;
            count += 1;
        }
    }
    int oco = 0;
    cout << count << endl;
    for(int i=1;i<=N;i++){
        if(ball[i] == 1) {
            cout << i;
            oco += 1;
            if(oco != count) cout << " ";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M = 2e5+5;
const ll mod = 998244353;
ll dp[M],cdp[M];
int L[M],R[M];
ll getSum(int l, int r)
{
	if(r <= 0)
		return 0;
	ll z = cdp[r];
	if(l > 0)
		z -= cdp[l-1];
	z = (z + mod)%mod;
	return z;
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=k;i++)
		cin>>L[i]>>R[i];
	cdp[1] = 1;
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			int r = i-L[j];
			int l = i-R[j];
			dp[i] += getSum(l,r);
		}
		dp[i] %= mod;
		cdp[i] = (cdp[i-1] + dp[i])%mod;
	}
	cout<<dp[n]<<"\n";
	return 0;
}

Measured memory_bytes: 6820
fun main(args: Array<String>) = println(run {
    tailrec fun gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)

    val (a, b) = readLine()!!.split(" ").map { it.toInt() }
    1L * a * b / gcd(a, b)
})

Measured memory_bytes: 37896
#include <iostream>

using namespace std;

int main(){
    int A,B,C,X,Y;
    cin>>A>>B>>C>>X>>Y;
    long int min=1000000000;
    long int value;
    if(X>=Y){
        for(int i=0;i<=2*X;i+=2){
            if(i/2>Y){
                value = C*i+(X-i/2)*A;
                if(value<min){
                    min = value;
                }
            }
            else{
                value = C*i+(X-i/2)*A+(Y-i/2)*B;
                if(value<min){
                    min = value;
                }
            }
        }
    }else{
        for(int i=0;i<=2*Y;i+=2){
            if(i/2>X){
                value = C*i+(Y-i/2)*B;
                if(value<min){
                    min = value;
                }
            }
            else{
                value = C*i+(X-i/2)*A+(Y-i/2)*B;
                if(value<min){
                    min = value;
                }
            }
        }
    }
    cout<<min<<endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    vector<ll> a(n),b(n),c(m),d(m);
    rep(i,n) cin>>a[i]>>b[i];
    rep(i,m) cin>>c[i]>>d[i];
    rep(i,n){
        ll now=inf,ans;
        rep(j,m){
            if(chmin(now,abs(a[i]-c[j])+abs(b[i]-d[j]))) ans=j;
        }
        cout<<ans+1<<endl;
    }
}

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

int main() {
    int H, W; cin >> H >> W;
    vector<vector<char>> pf(H+2, vector<char>(W+2, '#'));

    rep2(i, 1, H+1) {
        rep2(j, 1, W+1) {
            cin >> pf.at(i).at(j);
        }
    }

    rep(i, H+2) {
        rep(j, W+2) {
            cout << pf.at(i).at(j);
            if (j == W+1) {
                cout << endl;
            }
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N = 123456*2+1;
	bool so[N];
	FOR(i,0,N)so[i] = false;
	FOR(i,2,N){
		ll k = i;
		FOR(j,2,sqrt(i)+1){
			if(k%j==0){k=1;break;};
		}
		if(k==i)so[i] = true;
	}
  	so[2] = so[3] = so[5] = true;
	ll kosu[N];
	FOR(i,0,N)kosu[i] = 0;
	FOR(i,1,N){
		kosu[i] = kosu[i-1];
		if(so[i])kosu[i]++;
	}
	while(1){
		ll n;
		cin >> n;
		if(n==0)break;
		ll ans = kosu[2*n] - kosu[n];
		cout << ans << endl;
	}
}


Measured memory_bytes: 5324
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(150) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> S;
  rep(i,1,S.size())if(S[i]!=S[i-1])sum++;
  Out(sum);
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
  int ans=0;
  int n,i;
  int b[100];
  
  scanf("%d",&n);
  scanf("%d",&b[0]);
  for(i=0;i<n-2;i++){
    scanf("%d",&b[i+1]);
    ans+=b[i]>b[i+1] ? b[i+1]:b[i];
  }
  ans+=b[0]+b[n-2];
  
  printf("%d",ans);
  return 0;
  
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <numeric>
using namespace std;

#define repeat(i, x) for (int64_t i = 0; (i) < (int64_t)(x); ++(i))

const int inf = (1 << 28);

namespace TaskF {
    using Tree = vector<set<int>>;

    int n_;
    Tree aT_, bT_;
    vector<int> aParents_, bParents_;

    void DFSA(int u, int p) {
        aParents_[u] = p;
        for (int v : aT_[u]) {
            if (v != p) DFSA(v, u);
        }
    }

    void DFSB(int u, int p) {
        bParents_[u] = p;
        for (int v : bT_[u]) {
            if (v != p) DFSB(v, u);
        }
    }

    Tree inputTree() {
        Tree t(n_);
        repeat (i, n_ - 1) {
            int a, b;
            cin >> a >> b; a--; b--;
            t[a].insert(b);
            t[b].insert(a);
        }
        return t;
    }

    int solveWithFixed(int r) {
        DFSA(r, -1);
        DFSB(r, -1);

        vector<int> deg_(n_, 0);
        vector<bool> used_(n_, false);

        queue <int> que;
        int cnt = 0;
        que.push(r);

        while (!que.empty()) {
            int u = que.front(); que.pop();
            used_[u] = true;
            cnt++;

            for (int to : aT_[u]) {
                if(to != aParents_[u] and bParents_[to] == u) que.push(to);
            }
        }
        repeat (u, n_) {
            deg_[u] = aT_[u].size() - 1;
        }

        while (true) {
            int u = -1;
            repeat (v, n_) {
                if(!used_[v] and deg_[v]==0 and used_[bParents_[v]]) {
                    u = v;
                    break;
                }
            }
            if(u == -1) break;
            used_[u] = true;
            deg_[aParents_[u]]--;
        }

        bool up = true;
        repeat (u, n_) {
            if(!used_[u]) {
                up = false;
            }
        }
        return up ? n_ - cnt : inf;
    }

    void solve(int testNumber) {
        cin >> n_;

        aParents_.resize(n_, 0);
        bParents_.resize(n_, 0);

        aT_ = inputTree();
        bT_ = inputTree();

        int ans = inf;
        repeat (r, n_) {
            if (aT_[r].size() == 1) {
                int old = *aT_[r].begin();
                aT_[r].erase(old);
                aT_[old].erase(r);

                repeat (u, n_) {
                    if (r == u) continue;

                    aT_[r].insert(u);
                    aT_[u].insert(r);

                    ans = min(ans, solveWithFixed(r) + (old != u));

                    aT_[r].erase(u);
                    aT_[u].erase(r);
                }
                aT_[r].insert(old);
                aT_[old].insert(r);
            }
        }

        if (ans >= inf) ans = -1;
        cout << ans << endl;
    }
}

int main() {
    int T;
    cin >> T;

    repeat (_, T) {
        TaskF::solve(_);
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
#define rep(i,n) for (int i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    vector<vector<int> > x(N,vector<int>(N)),y(N,vector<int>(N));
    rep(i,N){
        cin>>A[i];
        rep(j,A[i]){
            cin>>x[i][j]>>y[i][j];
            x[i][j]--;
        }
    }
    int ans=0;
    bool f=true;
    rep(i,1<<N){
        f=true;
        rep(j,N){
            if (i&(1<<j)){
                rep(k,A[j]){
                    if (y[j][k]){
                        if (!(i&(1<<x[j][k]))) f=false;
                    }
                    else{
                        if(i&(1<<x[j][k])) f=false;
                    }
                }
            }
        }
        int n=0;
        rep(l,N){
            if (i&(1<<l)) n+=1;
        }
        if (f) ans=max(ans,n);
    }   

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

struct edge {
	int to, weight;
};

int N, u, v, w;
bool res[100000], vis[100000];
vector<edge>e[100000];

void dfs(int x, ll dis) {
	res[x] = dis & 1;
	vis[x] = true;
	for (edge E : e[x]) {
		if (!vis[E.to]) {
			dfs(E.to, dis + E.weight);
		}
	}
}

int main() {
	cin >> N;
	for (int i = 1; i < N; ++i) {
		cin >> u >> v >> w;
		--u;
		--v;
		e[u].push_back({ v,w });
		e[v].push_back({ u,w });
	}
	dfs(0, 0);
	for (int i = 0; i < N; ++i) {
		cout << res[i] << endl;
	}
}

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

using namespace std;

typedef long long ll;

int main() {
  typedef pair<string, int> P;
  int n, q;
  queue<P> p;

  cin >> n >> q;

  for (int i = 0; i < n; i++) {
    string s;
    int t;
    cin >> s >> t;
    p.push(make_pair(s,t));
  }

  int et = 0;
  while(p.size()) {
    P f = p.front(); p.pop();
    if(f.second > q) {
      f.second -= q;
      p.push(f);
      et += q;
    }
    else {
      et += f.second;
      cout << f.first << ' ' << et << endl;
    }
  }
}

Measured memory_bytes: 6276
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    string s;
    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 <iostream>
#include <algorithm>       // for next_permutation
#include <vector>
#include <string>

using std::cin;
using std::cout;
using std::endl;

int factorial(int n)
{
  int fact = 1;
  for (int i = n; i > 0;i--) fact *= i;
  return fact;
}

void count_order()
{
  int n;
  cin >> n;

  std::vector<int> p(n);
  std::vector<int> q(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  for (int i = 0; i < n; i++) cin >> q[i];


  int p_cnt = 0, q_cnt = 0;
  for (int i = 0; i < n; i++)
  {
    p_cnt += (p[i]-1) * factorial(n - 1 - i);
    for (int j = i + 1; j < n; j++) {
      if (p[j] > p[i]) p[j]--;
    }
  }
  for (int i = 0; i < n; i++)
  {
    q_cnt += (q[i] - 1) * factorial(n - 1 - i);
    for (int j = i + 1; j < n; j++) {
      if (q[j] > q[i]) q[j]--;
    }
  }
  cout << std::abs(p_cnt - q_cnt);
}

void welcome_atcoder()
{
  int n, m;
  cin >> n >> m;
  int pena = 0;
  std::vector<bool> ac(n + 1, 0);
  std::vector<int> wa(n + 1, 0);

  for (int i = 0; i < m; i++) 
  {
    int p; 
    std::string s;
    cin >> p >> s;

    if (ac[p] == 0 && s == "AC")
    {
      ac[p] = 1;
      pena += wa[p];
    }
    if (ac[p] == 1) continue;
    if (s == "WA") wa[p]++;
  }
  int ans = 0;
  for (int i = 0; i < (int)(n+1); i++) if (ac[i] == 1) ans++;
  cout << ans << " " << pena << endl;
}


int main() 
{
  count_order();
  //welcome_atcoder();
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  vector<int> b(n);
  for(int i = 0; i < n; i++){
    b.at(i) = a.at(i);
  }
  sort(b.begin(),b.end());
  int max1 = b.at(n-1);
  int max2 = b.at(n-2);
  for(int i = 0; i < n; i++){
    if(a.at(i) == max1)
      cout << max2 << endl;
    else
      cout << max1 << endl;
  }
}


Measured memory_bytes: 3200
def D():
    s = input()
    mods = [0]*2019
    mods[0] = 1
    mod = 0
    for i, element in enumerate(s[::-1]):
        mod += int(element)*pow(10,i,2019)
        mods[mod%2019] += 1
    print(sum(map(lambda x:int(x*(x-1)/2), mods)))
D()


Measured memory_bytes: 9388
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout << s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int n,k,x,y; cin>>n>>k>>x>>y;
    if(n-k<0)cout<<n*x<<endl;
    else cout<<k*x+(n-k)*y<<endl;
}

Measured memory_bytes: 256
# coding: UTF-8

s = input()
N = len(s)

head = 0
tail = 1

notfound = True
while head <= N-2:
    if s[head] == s[tail]:
        print(head+1, tail+1)
        notfound = False
        break

    if tail+1 < N and s[head] == s[tail+1]:
        print(head+1, tail+2)
        notfound = False
        break

    head = head+1
    tail = tail+1

if notfound:
    print(-1, -1)


Measured memory_bytes: 3188
n = int(input())
a = list(map(int,input().split()))
ruiseki = [0] * n
ruiseki[0] = a[0]
for i in range(1,n):
    ruiseki[i] += a[i] + ruiseki[i-1]
ans = 0
total = ruiseki[-1]
for i in range(n):
    ans += a[i] * (total-ruiseki[i])
print(ans%(10**9+7))

Measured memory_bytes: 31416
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> lpair;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A,B;
    cin >> A >> B;
    if(A <= 9 && B <= 9){
        print(A*B);
    }else{
        print(-1);
    }
    

}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
A_sort=sorted(A)
Alice=[]
Bob=[]
if N%2==0:
    for i in range(int(N/2)):
        Alice.append(A_sort[2*i+1])
        Bob.append(A_sort[2*i])
else:
    for i in range(int(N/2+1)):
        Alice.append(A_sort[2*i])
    for i in range(int(N/2)):
        Bob.append(A_sort[2*i+1])
Alice_sum=sum(Alice)
Bob_sum=sum(Bob)
ans=Alice_sum-Bob_sum
print(ans)

Measured memory_bytes: 3064
import time
start = time.time()
n = int(input())
a = [list(map(int,input().split())) for _ in range(n)]
s = [0 for i in range(n)] #それぞれ何試合目か
ans = 0
need = n*(n-1)//2
while need:
    c = [0 for i in range(n)] #今日試合をするかどうか
    ans += 1
    for first in range(n):
        if c[first] == 0 and s[first] < n-1:
            second = a[first][s[first]]-1 # firstが対戦したい相手
            second_num = s[second] # #secondの対戦番号
            if c[second] == 0 and a[second][second_num]-1 == first:
                c[first] = 1
                c[second] = 1
                s[first] += 1
                s[second] += 1
                need -= 1
    if sum(c) == 0:
        print(-1)
        exit()
    now = time.time()-start
    if now > 1.81:
        print(n*(n-1)//2)
        exit()
print(ans)

Measured memory_bytes: 60248
#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
#define P pair<int,int>
//printf("%.12Lf\n",);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}
int sankaku(int a){
	return a*(a+1)/2;
}
int a[4]={0,1,0,-1};
int b[4]={1,0,-1,0};
int d[114][114];
char c[114][114];
signed main(){
	ic(h) ic(w)
	rep(0,i,h)rep(0,j,w)cin>>c[i][j];
	int ans=0;
	rep(0,i,h){
		rep(0,j,w){
			rep(0,k,h){
				rep(0,l,w){
					if(c[i][j]=='.'&&c[k][l]=='.'){
						int sx=i;
						int sy=j;
						int gx=k;
						int gy=l;	
						queue<P>que;
						rep(0,i,h)rep(0,j,w)d[i][j]=inf;
						d[sx][sy]=0;
						que.push(P(sx,sy));
						while(que.size()){
							P p=que.front(); que.pop();
							if(p.first==gx&&p.second==gy)break;
							rep(0,i,4){
								int ny=p.first+a[i],nx=p.second+b[i];
								if(0<=ny&&ny<h&&0<=nx&&nx<w&&d[ny][nx]==inf&&c[ny][nx]!='#'){
									que.push(P(ny,nx));
									d[ny][nx]=d[p.first][p.second]+1;
								}
							}
						}
						ans=max(d[gx][gy],ans);
					}	
				}
			}
		}
	}						
	c(ans)
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a > b) swap(a, b);
  int diff = b - a;
  int ans;
  if (diff % 2 == 0) {
    ans = a + diff / 2;
    cout << ans << '\n';
  } else {
    cout << "IMPOSSIBLE" << '\n';
  }
  return 0;
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
int A[301],K[301];
int main(){
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++){
		cin>>A[i]>>K[i];
		int a=A[i],k=K[i];
		while(true){
			a=a/k*k+a%k%(a/k+1);
			if(a%k){
				a=a-(a/k+1);
			}
			else{
				ans^=(a/k);
				break;
			}
		}
	}
	if(ans)
		cout<<"Takahashi"<<endl;
	else
		cout<<"Aoki"<<endl;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val m = sc.nextInt()
  val ab = (1..m).map { Pair(sc.nextInt(), sc.nextInt()) }

  val map = mutableMapOf<Int, Int>()
  for (abi in ab) {
    val a = abi.first
    val b = abi.second

    val atmp = map.getOrElse(a) { 0 }
    val btmp = map.getOrElse(b) { 0 }

    map.put(a, atmp+1)
    map.put(b, btmp+1)
  }

  val list = mutableListOf<Int>()
  for (i in 1..n) {
    val tmp = map.getOrElse(i) { 0 }
    list.add(tmp)
  }

  println(list.joinToString("\n"))

}


Measured memory_bytes: 38676
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  int n;
  cin>>n;
  int ans=0;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    if(i%2==1) continue;
    if(a%2==0) continue;
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 10010010010010010;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    for (int i = 1; i < n; i++) {
        int ansi = 0, cnt = 0;
        for (int j = 0; (i+j < n); j++) {
            if (s[j] == s[i+j]) cnt++;
            else {
                ansi = max(ansi,cnt);
                cnt = 0;
            }
            //printf("i = %d j = %d ansi = %d cnt = %d ans = %d\n",i,j,ansi,cnt,ans);
        }
        ansi = max(ansi,cnt);
        ansi = min(ansi,i);
        ans = max(ans,ansi);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;


int sumdigits(int n)
{

	int sum=0,r;
	while(n!=0)
	{
        r=n%10;
        sum+=r;
        n=n/10;
	}
	return sum;
}
int main()

{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif */

    int n,ans=100010,i;
    cin>>n;
    if(n%10==0)
    {
    	cout<<"10";
         exit(0);
    }
    for(i=0;i<n;i++)
    {
    	ans=min(ans,sumdigits(i)+sumdigits(n-i));
    }
    cout<<ans;



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const ll MOD2=998244353;
const double PI=acos(-1);
const ll INF=1e18;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll n,s;
  cin >> n >> s;
  ll dp[n+1][s+1];
  rep(i,n+1){
    rep(j,s+1){
      dp[i][j]=0;
      if(i==0&&j==0){
        dp[i][j]=1;
      }
    }
  }
  rep(i,n){
    ll a;
    cin >> a;
    rep(j,s+1){
      if(j>=a){
        dp[i+1][j]=(2*dp[i][j]+dp[i][j-a])%MOD2;
      }
      else{
        dp[i+1][j]=2*dp[i][j]%MOD2;
      }
    }
  }
  cout << dp[n][s] << endl;
}

Measured memory_bytes: 73976
n=int(input())
xy=[list(map(int,input().split()))for _ in range(n)]
g=39
a=[]
if sum(xy[0])%2==0:a.append(1)
for i in range(g):a.append(1<<i)
g=len(a)
for x,y in xy:
  if (x+y)%2!=sum(xy[0])%2:exit(print(-1))
print(g)
print(*a)
def f(s):
  t=s
  ans=[]
  for i in a[::-1]:
    if abs(t-i)<abs(t+i):
      ans.append(-i)
      t-=i
    else:
      ans.append(i)
      t+=i
  return ans[::-1]
for x,y in xy:
  xpy=f(-(x+y))
  xmy=f(-(x-y))
  ans=""
  for p,m in zip(xpy,xmy):
    if 0<p and 0<m:ans+="R"
    if p<0 and m<0:ans+="L"
    if 0<p and m<0:ans+="U"
    if p<0 and 0<m:ans+="D"
  print(ans)

Measured memory_bytes: 3316
# D - RGB Triplets
from collections import defaultdict


def main():
    """
    character  A ---- B ---- C
    index     X-dx    X     X+dx
        -> A_index + C_index == 2 * B_index
    """
    _, S = open(0).read().split()
    indices = defaultdict(set)
    for i, c in enumerate(S):
        indices[c].add(i)

    cnt = len(indices["R"]) * len(indices["G"]) * len(indices["B"])
    for x, y, z in ("RGB", "RBG", "BGR"):
        cnt -= sum(
            (i + j) % 2 == 0 and (i + j) // 2 in indices[z]
            for i in indices[x]
            for j in indices[y]
        )
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9720
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
cs = Array.new(n + 1, 0)
i, x, y = 1, [], []
while cs[i] < 2
    (cs[i].zero? ? x : y) << i
    cs[i] += 1
    i = a[i - 1]
end
puts k < x.size ? x[k] : y[(k - x.size) % (y.size)]

Measured memory_bytes: 31992
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define MOD 1000000007
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long N;
    cin >> N;
    for(int i = 1; i <= 3500; i++){
        for(int l = 1; l <= 3500; l++){
            double calc = (N*i*l)/(4.0*i*l-N*i-N*l);
            if(int(calc) > 0 && int(calc)==calc){
                cout << int(calc) << " " << i << " " << l << "\n";
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s,t;
  cin >> s >> t;
  sort(ALL(s));
  sort(ALL(t), greater<char>());
  cout << (s<t ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
from math import hypot, factorial


def dfs(d, p):
    if all(used):
        return d
    res = 0
    for i in range(n):
        if used[i]:
            continue
        used[i] = True
        res += dfs(d + hypot(x[i] - x[p], y[i] - y[p]), i)
        used[i] = False
    return res


n = int(input())
x = [0] * n
y = [0] * n
for i in range(n):
    x[i], y[i] = map(int, input().split())

ans = 0
used = [False] * n
for i in range(n):
    used[i] = True
    ans += dfs(0, i)
    used[i] = False
ans /= factorial(n)

print(ans)


Measured memory_bytes: 9128
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n, l;
  cin >> n >> l;
  vector<string> s(n);
  rep(i, n) {
    string st;
    cin >> st;
    s.at(i) = st;
  }
  sort(s.begin(), s.end());
  rep(i, n) {
    cout << s.at(i);
  }
  cout << endl;
}


Measured memory_bytes: 3680
#include <iostream>
#include <bits/stdc++.h>
#define ll long long

using namespace std;
int a[200100];

int main()
{
    int n,Ans = 0,Last = 1,counter = 1; cin >> n;
    for(int i = 1;i<=n;i++)  cin >> a[i];
    for(int i =1 ;i<=n;i++){
        if(a[i] == counter){
            Ans+=i - Last;
            Last = i + 1;
            counter++;
        }
    }
    Ans+=(n + 1) - Last;
    if(counter == 1)  return cout << -1 , 0;
    cout << Ans;
    return 0;
}


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

int n;
long long ans;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	int lst = 0;
	for (int i = 1; i <= n; ++i) {
		int x; cin >> x;
		if (!x) { lst = 0; continue; }
		x -= lst;
		ans += lst;
		lst = x % 2;
		ans += x / 2;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#coding:utf-8

A, B = map(int,raw_input().split())
S = raw_input()

if S[A] != '-':
    print "No"

else:
    Flag = 0
    for i in range(A):
        if (S[i] >= '0' and S[i] <= '9') == False:
            Flag = 1
            #print "hello1"
    for i in range(A+1,len(S)):
        if (S[i] >= '0' and S[i] <= '9') == False:
            Flag = 1

    if Flag == 1:
        print "No"
    else:
        print "Yes"


Measured memory_bytes: 2568
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,M,S,T,U[200010],W[200010],D[200010],inf = 1e9+7;
vector<vector<P>> v(100010);
ll C[100010];

int main(){
	cin >> N >> M >> S >> T;
	for(int i=0;i<M;i++){
		cin >> U[i] >> W[i] >> D[i];
		v[U[i]].push_back({D[i],W[i]});
		v[W[i]].push_back({D[i],U[i]});
	}
	priority_queue<P> Q;
	Q.push(P(0,S));
	for(int i=1;i<=N;i++) C[i] = 1e18;
	C[S] = 0;
	while(!Q.empty()){
		P t = Q.top();
		ll s = t.second;
		Q.pop();
		if(C[s] > -t.first) continue;
		for(int i=0;i<v[s].size();i++){
			P e = v[s][i];
			if(C[e.second] > C[s] + e.first){
				C[e.second] = C[s] + e.first;
				Q.push(make_pair(-C[e.second],e.second));
			}
		}
	}
	ll dp1[N+1] = {0};
	int visited[N+1] = {0};	
	dp1[S] = 1;
	visited[S] = 1;
	Q.push({-C[S],S});
	while(!Q.empty()){
		P a = Q.top();
		ll s = a.second;Q.pop();
		for(int i=0;i<v[s].size();i++){
			ll t = v[s][i].second;
			if(C[s]+v[s][i].first==C[t]){
				dp1[t] += dp1[s];
				dp1[t] %= inf;
				if(visited[t]==0){
					Q.push({-C[t],t});
					visited[t] = 1;
				}
			}
		}
	}
	for(int i=0;i<=N;i++) visited[i] = 0;
	ll dp2[N+1] = {0};
	dp2[T] = 1;
	visited[T] = 1;
	Q.push({C[T],T});
	while(!Q.empty()){
		P a = Q.top();
		ll s = a.second;Q.pop();
		for(int i=0;i<v[s].size();i++){
			ll t = v[s][i].second;
			if(C[s]-v[s][i].first==C[t]){
				dp2[t] += dp2[s];
				dp2[t] %= inf;
				if(visited[t]==0){
					Q.push({C[t],t});
					visited[t] = 1;
				}
			}
		}
	}
	ll ans = (dp1[T]*dp1[T])%inf;
	for(int i=1;i<=N;i++){
		if(2*C[i]==C[T]){
			ll a = (dp1[i]*dp1[i])%inf,b = (dp2[i]*dp2[i])%inf;
			ans -= (a*b)%inf;
			ans = (ans+inf)%inf;
		}
	}
	for(int i=0;i<M;i++){
		if(2*C[U[i]]<C[T] && 2*C[W[i]]>C[T] && C[U[i]]+D[i]==C[W[i]]){
			ll a = (dp1[U[i]]*dp1[U[i]])%inf,b = (dp2[W[i]]*dp2[W[i]])%inf;
			ans -= (a*b)%inf;
			ans = (ans+inf)%inf;	
		}
		if(2*C[W[i]]<C[T] && 2*C[U[i]]>C[T] && C[W[i]]+D[i]==C[U[i]]){
			ll a = (dp1[W[i]]*dp1[W[i]])%inf,b = (dp2[U[i]]*dp2[U[i]])%inf;
			ans -= (a*b)%inf;
			ans = (ans+inf)%inf;	
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 21236
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProblemC
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var N = read[0];
            var K = read[1];

            var minPowGTK = 0;
            var temp = 1;
            var twoPows = new List<int>();
            twoPows.Add(1);
            while(K > twoPows[minPowGTK])
            {
                minPowGTK++;
                temp = temp * 2;
                twoPows.Add(temp);
            }

            var tempPow = minPowGTK;
            var ret = 0.0;
            var NltK = N < K;
            var roopEnd = NltK ? N + 1 : K;
            for(int i =1;i < roopEnd;i++ )
            {
                while (i * twoPows[tempPow - 1] >= K)
                    tempPow--;
                ret += 1.0 / N * 1.0 / twoPows[tempPow];
            }
            if (!NltK)
                ret +=  (double)(N - K + 1) / N;
            Console.WriteLine(ret);
        }
    }
}


Measured memory_bytes: 13396
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(LL i = (a); i < (LL)(n); ++i)
#define REM(i,a,n) for(LL i = ((n) - 1); i >= (a); --i)
#define FLOAT fixed << setprecision(16)
#define SPEEDUP {cin.tie(NULL); ios::sync_with_stdio(false);}
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }
template <class ForwardIterator, class T>
bool All_of(ForwardIterator first, ForwardIterator last, const T& value) {
	for (; first < last; ++first) if (*first != value) return false; return true;
}
// all_of

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#include "Tree.h"
#include "Suffix_Array.h"
#include "Geometry.h"
#include "Matrix.h"
#include "Segment_Tree.h"
#include "Rational.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
template <class T>
auto Is(const T& value) { return [value](const auto& comparand) -> bool { return comparand == value; }; }
#endif

int N;
int main() {
	cin >> N;
	cout << N / 3 << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int,int> pii;
typedef pair <db,db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD=998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=5005;





void solve()
{
    
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int l=h1*60+m1,r=h2*60+m2;
    int R=r-k;
    cout<<R-l<<endl;
    
    
    
   
}



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


Measured memory_bytes: 3644
#include <iostream>
#include <string>

using namespace std;

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

    bool issame = false;
    for (int i = 0; i < s.size()-1; i++) {
        for (int j = i+1; j < s.size(); j++) {
            if (s[i] == s[j]) {
                issame = true;
                goto end;
            }
        }
    }

end:
    if (!issame)
        cout << "yes" << endl;
    else
        cout << "no" << endl;

    return 0;
}

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

#define mod 1e9+7
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vll vector<long long>
#define ll long long
#define lli long long int
#define el '\n'
#define mem(a,b) memset(a, b, sizeof(a) )

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
/**/
int main()
{
    optimize();
    ll t,n,x,y,k,z,m,a,b;
    cin>>n;

    ll cnt=0;
    for(ll i=1; i<n; i++)
    {
        for(ll j=1; i*j<n; j++)
        {
            cnt++;
        }
    }
    cout<<cnt<<el;

    return 0;
}
/**/



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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

bool honest[20];
vector<pair<int, int>> in[20];

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

    int n;
    cin >> n;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        in[i].resize(a);
        for (int j=0; j<a; j++) {
            cin >> in[i][j].first >> in[i][j].second;
            in[i][j].first--;
        }
    }

    int ret = 0;
    for (int mask=0; mask<1<<n; mask++) {
        for (int i=0; i<n; i++)
            honest[i] = mask & (1 << i);
        int cnt = 0;
        for (int i=0; i<n; i++)
            if (honest[i]) {
                cnt++;
                for (auto [x, y] : in[i])
                    if (honest[x] != y)
                        goto done;
            }
        ret = max(ret, cnt);
        done:;
    }
    cout << ret << "\n";

    return 0;
}

Measured memory_bytes: 3612
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[110][100100]={0};
long long w[110],v[110];



int main() {
   int a;
   cin>>a;
   string s,t;
   cin>>s>>t;
   int cou=0;
   int ret=0;
   int fir=a-1;
   int las=0;
   rep(i,a){
       string tes,tas;
       for(int i=fir;i<a;i++){
           tes+=s.at(i);
       }
       //cout<<tes<<endl;
       fir--;
       rep(i,cou+1){
           tas+=t.at(i);
       }
       //cout<<tas<<endl;
       cou++;
       if(tes==tas){
           ret+=tes.size();
       }

   }
   if(s!=t){
    cout<<s.size()+t.size()-ret<<endl;
   }
   else{
       cout<<s.size()<<endl;
   }
}


Measured memory_bytes: 256