akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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; }

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};

int D;
LL C[26];
VVL S;

void input(){
    cin >> D;
    REP(i,26) cin >> C[i];
    S.assign(D,VL(26));
    REP(i,D) REP(j,26) cin >> S[i][j];
}

void solve(){
    // last days
    LL L[26] = {};

    LL score = 0;
    REP(day,D){

        LL best = -LINF;
        LL choice = -1;

        REP(cand, 26){
            LL tmp = L[cand];
            L[cand] = day+1;

            LL gain = S[day][cand];
            REP(i,26){
                LL interval = day+1 - L[i];
                gain -= C[i] * (interval + interval+12) * 13 / 2;
                //gain -= C[i] * (day+1 - L[i]);
            }

            if(best < gain){
                best = gain;
                choice = cand;
            }


            L[cand] = tmp;
        }

        L[choice] = day+1;
        cout << choice+1 << "\n";

    }

}


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    input();
    solve();

}

Measured memory_bytes: 3696
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

long long N,m = 0,a = 0,r = 0,c = 0,h = 0;
string S;

int main(){
	cin >> N;
	long long ans = 0;
	for(int i=0;i<N;i++){
		cin >> S;
		if(S[0] == 'M') m++;
		if(S[0] == 'A') a++;
		if(S[0] == 'R') r++;
		if(S[0] == 'C') c++;
		if(S[0] == 'H') h++;
	}
	ans = m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h;
	cout << ans << endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize("O3")

#include <bits/stdc++.h>
//#include <ctime>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 500100, MAXK = 20;
const ll MOD = 1e9+7;
const ll INF = 1e18;
const ld PI = asin(1) * 2;

void setIO () {
    FAST_IO;
}

void setIO (string s) {
    setIO();
 	freopen((s+".in").c_str(),"r",stdin);
 	freopen((s+".out").c_str(),"w",stdout);
}



int main() {
    setIO();

    int n; cin >> n;
    vi l;
    REP(n) {int x; cin >> x; l.pb(x);}
    sort(l.begin(), l.end());

    int ans =0;
    FOR(i, 0, n-1) FOR(j, i+1, n-1) FOR(k, j+1, n-1) {
        if (l[i] == l[j] || l[j] == l[k]) continue;
        if (l[i] + l[j] > l[k]) ans++;
    }
    cout << ans << "\n";

	return 0;
}


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

int main() {
    int n, m;
    cin>>n>>m;
    int k[n];
    int a[n][m];
    for(int i=0;i<n;i++) {
        cin>>k[i];
        for(int j=0;j<k[i];j++) {
            cin>>a[i][j];
        }
    }
    int like[m+1]={};
    for(int i=0;i<n;i++) {
        for(int j=0;j<k[i];j++) {
            if(a[i][j]!=0) like[a[i][j]]++;
        }
    }
    int ans=0;
    for(int i=0;i<m+1;i++) {
        if(like[i]==n) ans++;
      	//cout<<like[i];
       	//i==m? cout<<endl: cout<<' ';
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#再提出
import bisect
n,m = map(int, input().split( ))

t = m//n

fct_sup = int(m**(1/2)) + 1

fct = []
fct2 = []
for f in range(1,fct_sup+1):
    if m%f == 0:
        fct.append(f)
        fct2.append(m//f)
if fct[-1] == fct2[-1]:
    fct.pop()
fct2.reverse()
fct += fct2
i = bisect.bisect_right(fct,t)
print(fct[i-1])



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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll>sum(n+2,0);
    rep(i,0,n+1){
        sum.at(i+1)=sum.at(i)+i;
    }
    ll ans=0;
    rep(i,k,n+2){
        ans+=(sum.at(n+1)-sum.at(n+1-i))-sum.at(i)+1;
        //cout<<ans<<endl;
    }
    cout<<ans%1000000007<<endl;
return 0;
}

Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fr(i, a, b) for (int i = a; i < b; i++)
int main(){
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif

    int n;cin>>n;
    int h[n+1];
    fr(i,1,n+1) cin>>h[i];
    int dp[n+1];
    dp[1]=0;
    fr(i,2,n+1){
        int one = abs(h[i]-h[i-1])+dp[i-1];
        int two = (i==2) ? INT_MAX : abs(h[i]-h[i-2])+dp[i-2];
        dp[i] = min(one,two);
    }
    cout<<dp[n]<<endl;

}

Measured memory_bytes: 1024
import numpy as np

N = int(input())
s = input()
t = input()

moji = s
count = 0
while True:
    if moji[len(moji)-len(t)+count:] == t[0:len(t)-count]:
        moji += t[len(t)-count:]
        print(len(moji))
        break
    else:
        count += 1

Measured memory_bytes: 13224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<string, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)

vector<P> vec;
inline bool cmp1(int a, int b){
    return vec[a-1].second > vec[b-1].second;
}
inline bool cmp2(int a, int b){
    return vec[a-1].first < vec[b-1].first;
}
int main(){
    int n; sc(n);
    vec.resize(n);
    vector<int> order(n);
    for (int i = 0; i < n; i++) cin >> vec[i].first, sc(vec[i].second);
    for (int i = 0; i < n; i++) order[i] = i+1;
    sort(order.begin(), order.end(), cmp1);
    stable_sort(order.begin(), order.end(), cmp2);
    for (int i = 0; i < n; i++) cout << order[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>


using namespace std;

typedef long long LL;


int fu[100020];
int dis[100020];
bool success;

int findfu(int i)
{
    if (fu[fu[i]] == fu[i])
        return fu[i];
    
    int h = findfu(fu[i]);
    dis[i] = dis[i] + dis[fu[i]];
    fu[i] = h;
    
    return fu[i];
}
/*int dis(int i)
{
    return 1;
}*/

int hebing(int a,int b,int d)
{
    int fua = findfu(a);
    int fub = findfu(b);
    if (fua != fub)
    {
        fu[fub] = fua;
        dis[fub] = dis[a] + d - dis[b];
    }
    else
    {
        if (dis[b] - dis[a] != d)
        {
            success =false;
        }
    }
}

int main()
{
    int n,m;
    while (cin >>n >>m)
    {
        success =true;
        int l,r,d;
        for (int i=0; i<100005; i++)
        {
            fu[i] =i;
            dis[i] = 0;
        }
        for (int i=0; i<m; i++)
        {
            scanf("%d%d%d",&l,&r,&d);
            hebing(l,r,d);
        }
        if (success)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
        /*for (int i=0; i<100005; i++)
        {
            findfu(i);
            if (dis[i] != 0)
            {
                cout <<i<<' '<<dis[i]<<endl;
            }
        }*/
    }




#ifdef VSCode
    system("pause");
#endif
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main() {
	int n,m;
	int A[100];
	int i = 0;
	int j = 1;

	cin >> n;

	while (i<n) {
		cin >> A[i];
		i++;
	}

	while (j<n) {
		m = n - j;
		cout << A[m] <<" ";
		j++;
	}

	cout << A[0] << endl;

	return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include <utility>

using namespace std;
#define intt long long

int main() {

	intt N, M;
	long long B, C;
	cin >> N >> M;
	vector<pair<intt,long long>> spair;
	vector<long long> a, b;
	long long ans = 0;
	a.resize(N);
	b.resize(N);
	spair.resize(M);
	for (auto i = 0; i < N; i++) {
		cin >> a[i];
	}

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

	for (auto i = 0; i < M; i++) {
		cin >> B >> C;
		spair[i] = make_pair(B, C);
	}

	sort(spair.begin(), spair.end(), [](const pair<intt, long long>& x, const pair<intt, long long>& y) {return x.second > y.second; });
	int ch = 0;
	for (auto i = 0; i < M; i++) {
		for (auto j = 0; j < spair[i].first; j++) {
			b[ch] = spair[i].second;
			ch++;
			if (ch == N)break;
		}
		if (ch == N)break;

	}

	for (auto i = 0; i < N; i++) {
		if (i < ch) {
			if (a[i] < b[i]) {
				ans += b[i];
			}
			else
			{
				ans += a[i];
			}
		}
		else {
			ans += a[i];
		}
	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3328
def main():
    N = int(input())
    H = list(map(int, input().split()))
    prev = float('inf')
    count = 0
    ans = 0
    for i in range(N):
        if H[i] <= prev:
            count += 1
        else:
            ans = max(count-1, ans)
            count = 1
        prev = H[i]
    ans = max(count-1, ans)
    return ans
if __name__ == '__main__':
    print(main())

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

int main(){
  int N;
  cin>>N;
  int ans=0;
  int A[N];
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  for(int i=1;i<N;i++){
    if(A[i]==A[i-1]){
      ans++;
      if(i>=N-2) break;
      i++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int P, N;

	public static void main(String[] args) {
		while (true) {
			P = sc.nextInt();
			N = sc.nextInt();
			if (N == 0) break;
			ArrayList<Rational> low = new ArrayList<Rational>();
			ArrayList<Rational> high = new ArrayList<Rational>();
			for (long den = 1; den <= N; ++den) {
				double numf = Math.sqrt(den * den * P);
				long lo = (long) numf;
				if (lo <= N && gcd(lo, den) == 1) {
					low.add(new Rational(lo, den));
				}
				long hi = lo + 1;
				if (hi <= N && gcd(hi, den) == 1) {
					high.add(new Rational(hi, den));
				}
			}
			Collections.sort(low);
			Collections.sort(high);
			Rational l = low.get(low.size() - 1);
			Rational r = high.get(0);
			System.out.printf("%d/%d %d/%d\n", r.num, r.den, l.num, l.den);
		}
	}

	static long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	static class Rational implements Comparable<Rational> {
		long num, den;

		Rational(long n, long d) {
			num = n;
			den = d;
		}

		public int compareTo(Rational o) {
			long v1 = num * o.den;
			long v2 = den * o.num;
			if (v1 < v2) return -1;
			if (v1 > v2) return 1;
			return 0;
		}

	}

}

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

using namespace std;

int main()
{
    int N;
    string S;

    int i;

    cin >> N;
    cin >> S;

    string S_halfA = S.substr(0,(N/2));
    string S_halfB = S.substr((N/2),N-1);

    //cout << S_halfA << "\n" << S_halfB;
    if(N != 1)
    {
            if(S_halfA == S_halfB)
        {
            cout << "Yes";
        }
        else
        {
            cout << "No";
        }
    }
    else
    {
        cout << "No";
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int M = 10;

vector<pair<int, int>> solve_knapsack(vector<int> cost, vector<int> w) {
	vector<pair<int, int>> ans;
	int n = (int)cost.size();
	for (int mask = 0; mask < (1 << n); mask++) {
		int sum_cost = 0;
		int sum_w = 0;
		for (int i = 0; i < n; i++) {
			if ((mask >> i) & 1) {
				sum_cost += cost[i];
				sum_w += w[i];
			}
		}
		ans.push_back({sum_w, sum_cost});
	}
	sort(ans.begin(), ans.end());
	vector<pair<int, int>> nans;
	int mx = -1;
	for (auto [wt, cst] : ans) {
		if (mx < cst) {
			nans.push_back({wt, cst});
			mx = cst;
		}
	}
	return nans;
}

int solve(vector<int> cost, vector<int> w, vector<pair<int, int>> &lp, int L) {
	auto rp = solve_knapsack(cost, w);
	int pnt = (int)rp.size() - 1;
	int ans = 0;
	for (auto [sw, sc] : lp) {
		while (pnt >= 0 && sw + rp[pnt].first > L) {
			pnt--;
		}
		if (pnt >= 0) {
			ans = max(ans, sc + rp[pnt].second);
		}
	}
	return ans;
}

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

	int n;
	cin >> n;
	vector<int> h(n + 1);
	vector<int> cost(n + 1);
	vector<int> w(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> cost[i] >> w[i];
		if (i > 1) {
			h[i] = h[i / 2] + 1;
		}
	}
	vector<vector<pair<int, int>>> knacks(n + 1);
	for (int i = 1; i <= n; i++) {
		if (h[i] <= M) {
			vector<int> cc;
			vector<int> cw;
			int v = i;
			while (v > 0) {
				cc.push_back(cost[v]);
				cw.push_back(w[v]);
				v /= 2;
			}
			// cerr << "+ " << i << endl;
			knacks[i] = (solve_knapsack(cc, cw));
		}
	}
	int q;
	cin >> q;
	while (q--) {
		int v, L;
		cin >> v >> L;
		vector<int> cc;
		vector<int> cw;
		while (h[v] > M) {
			cc.push_back(cost[v]);
			cw.push_back(w[v]);
			v /= 2;
		}
		// assert(h[v] <= M);
		// cerr << v << endl;
		cout << solve(cc, cw, knacks[v], L) << '\n';
	}
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

int N,K;
vint G[111111];

struct BinaryIndexedTree{
	int n;
	vector<int>dat;
	BinaryIndexedTree(int n=0):n(n){
		dat.resize(n+1);
	}
	void add(int k,int x){
		for(k++;k<=n;k+=k&-k)dat[k]+=x;
	}
	int sum(int k){
		int ret=0;
		for(k++;k;k-=k&-k)ret+=dat[k];
		return ret;
	}
};

const int SIZE=100000;
int par[SIZE],dep[SIZE],hev[SIZE],pos[SIZE],head[SIZE],sz[SIZE];
BinaryIndexedTree bit;
map<pint,int>mp;
int sum[111111];

void dfs(){
    vint vs={0};
    par[0]=-1;
    dep[0]=0;
    rep(i,N){
        int v=vs[i];
        for(auto u:G[v]){
            if(u==par[v])continue;
            par[u]=v;
            dep[u]=dep[v]+1;
            vs.pb(u);
        }
    }

    for(int i=vs.size()-1;i>=0;i--){
        int v=vs[i];
        sz[v]=1;
        hev[v]=-1;
        int ma=0;
        for(auto u:G[v]){
            if(u==par[v])continue;
            if(ma<sz[u]){
                ma=sz[u];
                hev[v]=u;
            }
            sz[v]+=sz[u];
        }
    }
}


void init(){
    dfs();
    int idx=0;
    rep(i,N){
        if(~par[i]&&hev[par[i]]==i)continue;
        for(int j=i;~j;j=hev[j]){
            head[j]=i;
            pos[j]=idx++;
        }
    }

    /*
        ????????§seg??¨?????´??°
    */
    bit=BinaryIndexedTree(N);
}

//??????????????¨???????????????
int query(int a,int b){
    int ret=0;
    while(head[a]!=head[b]){
        if(dep[head[a]]<dep[head[b]])swap(a,b);
        ret+=bit.sum(pos[a])-bit.sum(pos[head[a]]);
        a=head[a];
        int tmp=mp[pint(par[a],a)]+sum[par[a]]+sum[a];
        if(tmp%K)ret+=tmp;
        a=par[a];
    }
    if(dep[a]>dep[b])swap(a,b);
    ret+=bit.sum(pos[b])-bit.sum(pos[a]);
    return ret;
}

void add(int a,int b,int d){
    bit.add(pos[b],-(bit.sum(pos[b])-bit.sum(pos[b]-1)));
    mp[pint(a,b)]+=d;
    if(mp[pint(a,b)]%K)bit.add(pos[b],mp[pint(a,b)]);
}

signed main(){
    cin>>N>>K;
    vint A(N-1),B(N-1),C(N-1);
    rep(i,N-1){
        cin>>A[i]>>B[i]>>C[i];
        G[A[i]].pb(B[i]);
        G[B[i]].pb(A[i]);
    }

    init();
    rep(i,N-1){
        if(dep[A[i]]>dep[B[i]])swap(A[i],B[i]);
        if(head[B[i]]!=B[i])add(A[i],B[i],C[i]);
        else mp[pint(A[i],B[i])]=C[i];
    }


    int Q;cin>>Q;
    while(Q--){
        string s;
        int a,b;
        cin>>s>>a>>b;
        if(s=="add"){
            if(head[a]!=a)add(par[a],a,b);
            if(hev[a]!=-1)add(a,hev[a],b);
            sum[a]+=b;
        }
        else{
            cout<<query(a,b)<<endl;
        }
    }
}

Measured memory_bytes: 24320
#include<stdio.h>
int main(void)
{
	int a,b;

	scanf("%d",&a);
	scanf("%d",&b);

	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}

	return 0;
}


Measured memory_bytes: 2136
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <stack>
#include <queue>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
#define ll long long
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

    ll a = n/k;

    if(k%2==1){
        cout << a*a*a << endl;
        return 0;
    }else{
        ll b = n/(k/2);
        b-=a;
        cout << (a*a*a)+(b*b*b) << endl;
        return 0;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
struct dice{
           int a[6];
       };
struct dice dice1;
struct dice dice2;
 
void tate(){
            int cmp=dice2.a[0];
            dice2.a[0]=dice2.a[4];
            dice2.a[4]=dice2.a[5];
            dice2.a[5]=dice2.a[1];
            dice2.a[1]=cmp;
             }
void yoko(){
            int cmp=dice2.a[1];
            dice2.a[1]=dice2.a[2];
            dice2.a[2]=dice2.a[4];
            dice2.a[4]=dice2.a[3];
            dice2.a[3]=cmp;
             }
 
 
int main(){
    int i,j;
    for(i=0;i<6;i++){
           scanf("%d",&dice1.a[i]);
                     }
for(i=0;i<6;i++){
           scanf("%d",&dice2.a[i]);
                     }
 
for(i=0;i<5;i++){
 
              for(j=0;j<5;j++){
                              if(dice1.a[0]==dice2.a[0])break;
                               tate();
                               }
              for(j=0;j<5;j++){
                                if(dice1.a[1]==dice2.a[1])break;
                                yoko();
                                }
                  }
 
if(dice1.a[0]==dice2.a[0]&&dice1.a[1]==dice2.a[1]&&dice1.a[2]==dice2.a[2])printf("Yes\n");
else printf("No\n");
  
return 0;
}


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

#ifndef __TOPCYBERFLOWER
#define debug(...) 0
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif

#define TYPEMAX(type)   numeric_limits<type>::max()
#define TYPEMIN(type)   numeric_limits<type>::min()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main(void){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n,k; cin>>n>>k;
    vector<vl> cyc;
    vi vst(n+5,0), per(n+5,0);
    vl sco(n+5);
    for(int i=1;i<=n;i++) cin>>per[i];
    for(int i=1;i<=n;i++) cin>>sco[i];
    for(int i=1;i<=n;i++){
        if(vst[i]) continue;
        vl tmp;
        int x=i;
        while(vst[x]==0){
            vst[x]=1;
            x=per[x];
            tmp.push_back(sco[x]);
        }
        cyc.push_back(tmp);
    }
    int sz=cyc.size();
    ll ans=TYPEMIN(ll);
    for(int i=0;i<sz;i++){
        int m=cyc[i].size();
        int xx=k/m, yy=k%m;
        vl pre(2*m,0ll);
        for(int j=0;j<2*m;j++){
            if(j==0) pre[j]=cyc[i][j%m];
            else pre[j]=pre[j-1]+cyc[i][j%m];
            //debug(i,j,pre[j]);
        }
        //debug(i,m,pre[m-1]);
        if(xx && pre[m-1]>0ll){
            if(yy==0){
                xx--;
                yy=m;
            }
            if(xx) ans=max(ans,(ll)xx*pre[m-1]);
            for(int j=1;j<=yy;j++){
                for(int k=0;k+j<=2*m;k++){
                    if(k==0) ans=max(ans,(ll)xx*pre[m-1]+pre[k+j-1]);
                    else ans=max(ans,(ll)xx*pre[m-1]+pre[k+j-1]-pre[k-1]);
                    //debug(ans);
                }
            }
        }
        else{
            for(int j=1;j<=min(m,k);j++){
                for(int k=0;k+j<2*m;k++){
                    if(k==0) ans=max(ans,pre[k+j-1]);
                    else ans=max(ans,pre[k+j-1]-pre[k-1]);
                }
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3872
import java.util.*;

public class Main{
    
    public static final int MOD = (int)1e9+7;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        ModLcm ml = new ModLcm((int)1e6+6);
        
        for(int i=0; i<n; i++){
            a[i] = Integer.parseInt(sc.next());
            ml.lcm(a[i]);
        }
        
        int lcm = ml.getModLcm(MOD);
        //System.out.println(lcm);
        
        long ans = 0;
        for(int i=0; i<n; i++){
            long inv = ModLcm.mod_pow(a[i], MOD-2, MOD);
            ans += lcm * inv;
            ans %= MOD;
        }
        
        System.out.println(ans);
        
    }
    
}

class ModLcm{
    private int max;
    private int[] exponent;
    //private TreeSet<Integer> base;
    
    public ModLcm(int max){
        this.max = max;
        exponent = new int[max];
        //base = new TreeSet<>();
    }
    
    public void lcm(int n){
        for(int i=2; i*i<=n; i++){
            int ex = 0;
            while(n%i==0){
                ex++;
                n /= i;
                //base.add(i);
            }
            exponent[i] = Math.max(exponent[i], ex);
        }
        if(n!=1){
            exponent[n] = Math.max(1, exponent[n]);
            //base.add(n);
        }
    }
    
    public static long mod_pow(long x, long p, long m){
        long a = 1;
        while(p>0){
            if(p%2==1){
                a = a*x%m;
            }
            x = x*x%m;
            p /= 2;
        }
        return a;
    }
    
    public int getModLcm(int mod){
        long res = 1;
        /*
        for(int prm : base){
            res *= mod_pow(prm, exponent[prm], mod);
            res %= mod;
        }
        */
        for(int i=0; i<max; i++){
            if(exponent[i]==0){
                continue;
            }
            res *= mod_pow(i, exponent[i], mod);
            res %= mod;
        }
        return (int)res;
    }
}

Measured memory_bytes: 36652
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int ac = 0,wa = 0,tle = 0,re = 0;
        int t = sc.nextInt();
        for (int i = 0; i < t; i++) {
            String next = sc.next();
            if(next.equals("AC")){
                ac++;
            }else if(next.equals("WA")){
                wa++;
            }else if(next.equals("TLE")){
                tle++;
            }else if(next.equals("RE")){
                re++;
            }
        }
        System.out.println("AC x "+ac);
        System.out.println("WA x "+wa);
        System.out.println("TLE x "+tle);
        System.out.println("RE x "+re);
    }
}


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

int main() {

	int a, b; cin >> a >> b;
	int ans = -1;
	for (int i = 1; i <= 1100; i++) {
		if (i * 8 / 100 == a && i * 10 / 100 == b) {
			ans = i;
			break;
		}
	}	
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
#define pi 3.141592653589793
#define mod 1000000007
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, greater_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	fast_io;
	int n, k;;
	cin >> n >> k;
	vi a(n + 1);
	for (int i = 1;i <= n;i++)
		cin >> a[i];
	ll dp[n + 1][k + 1] = {};
	for (int j = 0;j <= k;j++)
		dp[0][j] = 1;
	for (int i = 1;i <= n;i++) {
		dp[i][0] = 1;
		for (int j = 1;j <= k;j++) {
			dp[i][j] = dp[i][j - 1] + dp[i - 1][j];
			if (j > a[i])
				dp[i][j] -= dp[i - 1][j - a[i] - 1];
			if (dp[i][j] < 0)
				dp[i][j] += mod;
			if (dp[i][j] >= mod)
				dp[i][j] -= mod;
		}
	}
	ll ans = dp[n][k];
	if (k > 0)
		ans -= dp[n][k - 1];
	if (ans < 0)
		ans += mod;
	cout << ans << '\n';
}


Measured memory_bytes: 79104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        var answer = new int[n];

        for (int i = 0; i < n; i++)
        {
            answer[a[i] - 1] = i + 1;
        }

        Console.WriteLine(string.Join(" ", answer).Trim());
    }
}

Measured memory_bytes: 27868
import math

def partition(A, p, r):
    x = int(A[r][2:])
    i = p-1
    for j in range(p, r):
        if int(A[j][2:]) <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]

    return i+1

def quicksort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quicksort(A, p, q-1)
        quicksort(A, q+1, r)


def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    L = [None for _ in range(n1+1)]
    R = [None for _ in range(n2+1)]
    for i in range(n1):
        L[i] = A[left + i]
    for i in range(n2):
        R[i] = A[mid + i]

    L[n1] = math.inf
    R[n2] = math.inf

    i = 0
    j = 0

    for k in range(left, right):
        try:
            v1 = int(L[i][2:])
        except:
            v1 = L[i]

        try:
            v2 = int(R[j][2:])
        except:
            v2 = R[j]

        if v1 <= v2:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1


def merge_sort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)

    return A


if __name__ == "__main__":
    n = int(input())
    cards = []
    for i in range(n):
        cards.append(input())

    reference = merge_sort(cards.copy(), 0, n)
    quicksort(cards, 0, n-1)

    if cards == reference:
        print('Stable')
    else:
        print('Not stable')

    for card in cards:
        print(card)




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

int main() {
    int n; cin >> n;
    int t, a; cin >> t >> a;
    vector<int> h(n);
    rep(i, h.size()) cin >> h.at(i);
    vector<double> h_d(n);

    int ans = 0;
    int sa = 0;
    rep(i, n) {
        h_d.at(i) = abs((double)a - (double)((double)t - (double)h.at(i) * 0.006));

        if (h_d.at(i) < h_d.at(sa))
            sa = i;
    }
    cout << sa + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (playerNumber, startPoint, countAnswer) = readLine()!!.split(" ").map { it.toInt() }
    abc141c(playerNumber, startPoint, countAnswer)
}

fun abc141c(playerNumber: Int, startPoint: Int, countAnswer: Int) {
    val playerScore = mutableListOf<Int>()
    repeat(playerNumber) {
        playerScore.add(startPoint)
    }

    repeat(countAnswer) {
        playerScore[readLine()!!.toInt() - 1]++
    }

    for (i in playerScore) {
        when {
            i > countAnswer -> println("Yes")
            else -> println("No")
        }
    }
}

Measured memory_bytes: 48368
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;

int main(){
  int A[110], N, minj, cnt=0;
  cin>>N;
  for(int i=0;i<N;i++) cin>>A[i];
  for(int i=0;i<N;i++){
    minj = i;
    for(int j=i+1;j<N;j++){
      if(A[j]<A[minj]) minj = j;
    }
    if(minj != i){
      int v = A[i];
      A[i] = A[minj];
      A[minj] = v;
      cnt += 1;
    }
  }
  for(int i=0;i<N-1;i++) cout<<A[i]<<" ";
  cout<<A[N-1]<<endl;
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
template<class T>
inline void read(T &x) {
    static char ch;
    static bool opt;
    while (!isdigit(ch = getchar()) && ch != '-');
    x = (opt = ch == '-') ? 0 : ch - '0';
    while (isdigit(ch = getchar()))
        x = x * 10 + ch - '0';
    if (opt)
        x = ~x + 1;
}
 
const int MaxN = 2e5 + 5;
const int MaxS = MaxN << 2;
 
const int INF = 0x3f3f3f3f;
 
#define lcc x << 1, l, mid
#define rcc x << 1 | 1, mid + 1, r
 
int n, m, cur;
int seg[MaxS], tag[MaxS];
 
inline void upt(int x) {
    seg[x] = std::min(seg[x << 1], seg[x << 1 | 1]);
}
 
inline void nodeCover(int x, int l, int r, int val) {
    seg[x] = l - val;
    tag[x] = val;
}
 
inline void dnt(int x, int l, int r) {
    if (tag[x]) {
        int mid = (l + r) >> 1;
        nodeCover(lcc, tag[x]);
        nodeCover(rcc, tag[x]);
        tag[x] = 0;
    }
}
 
inline void segCover(int u, int v, int t, int x = 1, int l = 1, int r = m) {
    if (u <= l && r <= v) {
        nodeCover(x, l, r, t);
        return;
    }
    dnt(x, l, r);
    int mid = (l + r) >> 1;
    if (u <= mid) segCover(u, v, t, lcc);
    if (v > mid) segCover(u, v, t, rcc);
    upt(x);
}
 
inline int segQuery(int p, int x = 1, int l = 1, int r = m) {
    if (l == r)return p - seg[x];
    dnt(x, l, r);
    int mid = (l + r) >> 1;
    return p <= mid ? segQuery(p, lcc) : segQuery(p, rcc);
}
 
int main() {
    read(n), read(m);
    cur = 1;
    for (int i = 1; i <= n; ++i) {
        int l, r;
        read(l), read(r);
        if (cur >= l && cur <= r) 
            segCover(cur, r, -INF),cur = r + 1;
        else if (cur < l) 
            segCover(l, r, segQuery(l - 1));
        if (cur > m) {
            for (int j = i; j <= n; ++j) {
                puts("-1");
            }
            return 0;
        }
        printf("%d\n", i + seg[1]);
    }
    return 0;
}


Measured memory_bytes: 7784
#include <iostream>
#include <stack>

using namespace std;

int main()
{
	stack<char> s;
	char check;
	string x;

	cin>>x;

	int cnt = 0;

	s.push('s');

	for (int i=0; i<x.size(); i++)
	{
		check = s.top();
		s.push(x[i]);
		cnt++;

		if (s.top() == 'T' && check == 'S')
		{
			s.pop();
			s.pop();
			cnt -= 2;
		}
	}

	cout<<cnt;

	return 0;
}


Measured memory_bytes: 644
import sys 

buildings = tuple(i for i in range(4)) 
floors = tuple(i for i in range(3)) 
rooms = tuple(i for i in range(10)) 
occupant = [[[0 for r in rooms] for f in floors] for b in buildings] 

n = input()  

for line in sys.stdin: 
	b, f, r, v = map(int, line.split()) 
	occupant[b - 1][f - 1][r - 1] += v 

for b in buildings: 
	if b: 
		print('####################') 
	for f in floors: 
		print("", *occupant[b][f])


Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<30;
const ll LLINF = 1LL<<62;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, b;
  cin >> n;
  vector<int> vec;
  vector<int> ans;
  REP(i,n){
      cin >> b;
      vec.push_back(b);
  }
  

  
  while(vec.size()>0){
    bool flag = false;
    int s = vec.size();
    for(int i=s;i>0;i--){
      if (vec[i-1] == i){
          vec.erase(vec.begin()+i-1);
          flag = true;
          ans.push_back(i);
          break;

      }
    }
    if (!flag){
        cout << -1 << endl;
        return 0;
    }
    // for(auto x: vec){
    //     cout << x;
    // }
    // cout << endl;
  }
  
  REV(ans);
  for(auto x: ans){
      cout << x << endl;
  }
}


Measured memory_bytes: 256
N,x = map(int, raw_input().split())

if x==1 or x==2*N-1:
    print "No"
else:
    print "Yes"
    if N==2:
        T = [1,2,3]
    else:
        T = range(1, 2*N)
        T[N-1] = x
        if x<N:
            T[N-3] = 2*N-1
            T[N-2] = 1
            T[N]   = 2*N-2
        else:
            T[N-3] = 1
            T[N-2] = 2*N-1
            T[N]   = 2
        S = set(range(1, 2*N))
        for t in T[N-3:N+1]:
            S.remove(t)
        for i in range(N-3):
            T[i] = S.pop()
        for i in range(N+1, 2*N-1):
            T[i] = S.pop()
    for t in T:
        print t


Measured memory_bytes: 27640
#include <stdio.h>
#define N 500000
int H;
void maxHeapify(int *,int);
void buildMaxHeap(int *);
int left(int);
int right(int);
int main()
{
  int n,i,j;
  int A[N];
  scanf("%d",&n);
  H=n;
  for(i=1;i<=n;i++)
    scanf("%d",&A[i]);
  buildMaxHeap(A);
  for(i=1;i<=n;i++)
    printf(" %d",A[i]);
  printf("\n");
  return 0;
}
void buildMaxHeap(int *A)
{
  int i;
  for(i=H/2;i>=1;i--)
    maxHeapify(A,i);
}
void maxHeapify(int *A, int i)
{
  int l,r,largest,t;
  l=left(i);
  r=right(i);
  if(l<=H&&A[l]>A[i])
    largest=l;
  else largest=i;
  if(r<=H&&A[r]>A[largest])
    largest=r;
  if(largest!=i)
    {
      t=A[i];
      A[i]=A[largest];
      A[largest]=t;
      maxHeapify(A,largest);
    }
  
}
int left(int i)
{
  return 2*i;
}
int right(int i)
{
  return 2*i+1;
}



Measured memory_bytes: 3660
solve 0 100 = 101
solve 0 a = a
solve 1 100 = 10100
solve 1 a = a * 100
solve 2 100 = 1010000
solve 2 a = a * 10000


main = do
  conts <- getContents
  let [a,b] = map read $ words conts
      answer = solve a b
  putStrLn $ show answer


Measured memory_bytes: 508
#include<bits/stdc++.h>
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 ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int dp[5005][5005];
int main(){
    int n; string s; cin >> n >> s;
    rep(i,n){
        rep(j,n){
            dp[i][j] = 0;
        }
    }

    int ans = 0;
    for(int i = n-1; i >= 0; i--){
        for(int j = n-1; j > i; j--){
            if(s[i] == s[j]) dp[i][j] = max(dp[i][j], dp[i+1][j+1] + 1);
            ans = max(ans, min(dp[i][j], j-i));
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 98048
#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define emp emplace
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	int n; cin >> n;

	map<string, int> m;

	while (n--) {
		string s; cin >> s;
		m[s]++;
	}

	int cur = 0;
	for (auto x : m) {
		if (x.se > cur) cur = x.se;
	}

	vector<string> ans;
	for (auto x : m) {
		if (x.se == cur) ans.eb(x.fi);
	}
	sort(ans.begin(), ans.end());

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

	return 0;
}



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

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] + n > 'Z') {
			s[i] = 'A' + s[i] + n - 'Z' - 1;
		}
		else {
			s[i] += n;
		}
	}
	cout << s;
}


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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (auto &i : a) cin >> i;
	sort(a.begin(),a.end());
	cout << accumulate(a.begin(),a.begin()+k,0) << "\n";
	
	return 0;
}


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

int top,S[1000];

void push(int x){
  S[++top]=x;
}

int pop(){
  return S[top--];
}

int main(){
  int a,b;
  char s[100];
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      b=pop();
      a=pop();
      push(a+b);
    }
    else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }
    else if(s[0]=='*'){
      b=pop();
      a=pop();
      push(a*b);
    }
    else{
      push(atoi(s));
    }
    }
  printf("%d\n",pop());
  return 0;
  }

Measured memory_bytes: 548
#include "bits/stdc++.h"
using namespace std;

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int D, c[27];
int s[366][27];

chrono::steady_clock::time_point program_begin;

double runtime() {
	chrono::steady_clock::time_point program_end = chrono::steady_clock::now();

	return chrono::duration_cast<chrono::microseconds>(program_end - program_begin).count() / 1000000.0;
}

int calc(vector<int> sc) {
	vector<int> last(27, 0);
	int val = 0;
	rep(d, 1, D + 1) {
		val += s[d][sc[d]];
		last[sc[d]] = d;
		rep(i, 1, 27)
			val -= c[i] * (d - last[i]);
	}
	return val;
}

int myrand(int a, int b) {
	return a + rand() % (b - a + 1);
}

void solve() {
	vector<int> ans(366), best_ans(366);
	int best_ans_val = -50000000;
	int cur_val = calc(ans);

	for (int i = 1; i <= 365; i++)
		ans[i] = i % 26 + 1;

	while (runtime() <= 1.8) {
		int d = myrand(1, 365), n = myrand(1, 26);
		if (ans[d] == n)
			continue;
		vector<int> new_ans = ans;
		new_ans[d] = n;
		int new_val = calc(new_ans);
		double base_proc = exp(-5.0 * runtime() / 1.8);
		double rand_double = 1.0 * rand() / RAND_MAX;
		bool accept =
			rand_double < base_proc * (1.0 * new_val / best_ans_val);
		if (new_val > cur_val || accept) {
			ans = new_ans;
			cur_val = new_val;

			if (chmax(best_ans_val, cur_val)) {
				best_ans_val = cur_val;
				best_ans = ans;
			}
		}
	}

	rep(i, 1, D + 1)
		write(best_ans[i]);
}

void test() {}

int main(int argc, char *argv[]) {
	//cin.tie(0)->sync_with_stdio(0);
	//cin.exceptions(cin.failbit);

	srand(time(NULL));

	program_begin = chrono::steady_clock::now();

	read(D);
	rep(i, 1, 27) read(c[i]);
	rep(i, 1, D + 1) rep(j, 1, 27) read(s[i][j]);
	
	solve();
}


Measured memory_bytes: 4264
#include<cstdio>
static const int M = (int)1e5+5;
struct node{
	int to;
	node *nxt;
	void add(int v){
		node *p=new node;
		p->to=v,p->nxt=nxt,nxt=p;
	}
}head[M];
int SG[M];
void dfs(int u,int f){
	SG[u]=0;
	for(node *i=head[u].nxt;i;i=i->nxt){
		int v=i->to;
		if(v==f)continue;
		dfs(v,u);
		SG[u]^=SG[v]+1;
	}
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1,u,v;i<n;++i){
		scanf("%d%d",&u,&v);
		head[u].add(v);
		head[v].add(u);
	}
	dfs(1,0);
	puts(SG[1]?"Alice":"Bob");
	return 0;
}

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

#define len(x)  (int((x).size()))
#define append push_back
#define pp make_pair
#define ff(a, b)    for (int a = 0; a < int(b); ++a)
#define kk(n)    ff(k, n)
#define xx(n)    ff(x, n)
#define yy(n)    ff(y, n)
#define ii(n)    ff(i, n)
#define fff(a, b, c) for (int a = int(b); a < int(c); ++a)
#define kkk(a, b) fff(k, a, b)
#define xxx(a, b) fff(x, a, b)
#define yyy(a, b) fff(y, a, b)
#define iii(a, b) fff(i, a, b)
#define bb begin()
#define ee end()
#define uu first
#define vv second
#define all(x)  (x).bb, (x).ee
#define ite(v)   decltype((v).bb)
#define fe(i, v) for(ite(v) i = (v).bb; i != (v).ee; ++i)
#define err(...)    { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
#define zz(array, byte)   memset(array, byte, sizeof(array));

using LL = long long;
using DD = long double;
using pii = pair<int, int>;



const LL  INFLL  = 0x7f7f7f7f7f7f7f7fLL;
const int INFint = 0x7f7f7f7f;  //Works with memset(..).
 
     


void dfs(int from, vector<vector<int> > &al, vector<int> &colours, int colour) {
    if (-1 != colours[from])
        return;
    colours[from] = colour;
    ii (len(al[from]))
        dfs(al[from][i], al, colours, colour);
}



int main() {
    ios_base::sync_with_stdio(false);     cin.tie(NULL);
    //cout << '\n';
    cout.precision(16);
    

    int N, K, L;
    cin >> N >> K >> L;

    vector<vector<int> > road_al(N);
    vector<vector<int> > railway_al(N);
    ii (K) {
        int p, q;
        cin >> p >> q;
        --p, --q;
        road_al[p].append(q);
        road_al[q].append(p);
    }
    ii (L) {
        int p, q;
        cin >> p >> q;
        --p, --q;
        railway_al[p].append(q);
        railway_al[q].append(p);
    }


    vector<int> road_segment(N, -1);
    vector<int> rail_segment(N, -1);
    ii (N) {
        dfs(i, road_al, road_segment, i);
    }
    ii (N) {
        dfs(i, railway_al, rail_segment, i);
    }

    map<pii, int> both_segments;
    ii (N)
        both_segments[pp(road_segment[i],
                          rail_segment[i])]++;

    ii (N)
        cout << (0 == i ? "" : " ") << both_segments[pp(road_segment[i],
                                                      rail_segment[i])];
    cout << '\n';




    

    return 0;
}



Measured memory_bytes: 27776
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cassert>
#include <utility>
#include <numeric>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define rep(i,n) for (int i=0; i<(n); ++i)

using namespace std;
using ll = long long;
int main (){
    int N;
    string S;

    cin >> N;
    cin >> S;

    for(int i=0;i<S.size();i++){
        if (int(S[i] + N ) < 'A' + 26){
            S[i] = S[i] + N;
        }
        else {
            
            S[i] = S[i] + N  - 'Z'+ 'A' -1  ;
        }
    }
    cout << S;

    



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;

typedef pair <long long, int> pli;

struct Node{
	long long b, l, u;
}a[100010];

long long n, X;

bool check(long long mid){
	long long maxj = mid / X, kkk = mid % X;
	if (maxj >= n) return 1;
	vector <pli> v;
	for (int i = 0; i < n; i++){
		v.push_back(mp((X - a[i].b) * a[i].u + a[i].b * a[i].l, i));
	}
	sort(v.rbegin(), v.rend());
	long long sum = 0, tot = 0;
	for (int i = 0; i < n; i++){
		if (i < maxj) sum += a[v[i].se].b * a[v[i].se].u, tot += X * a[v[i].se].u;
		else sum += a[v[i].se].b * a[v[i].se].l;
	}
	long long pos = v[maxj].se;
	if (kkk == 0) return tot >= sum;
	for (int i = 0; i < n; i++){
		int x = v[i].se;
		if (i < maxj){
			long long nsum = 0, ntot = 0;
			if (kkk < a[x].b){
				ntot = tot - X * a[x].u + kkk * a[x].l + X * a[pos].u;
				nsum = sum - a[x].b * a[x].u + a[x].b * a[x].l - a[pos].b * a[pos].l + a[pos].b * a[pos].u;
			} else {
				ntot = tot - X * a[x].u + kkk * a[x].u + X * a[pos].u;
				nsum = sum - a[pos].b * a[pos].l + a[pos].b * a[pos].u;
			}
			if (ntot >= nsum) return 1;
		} else {
			long long nsum = 0, ntot = 0;
			if (kkk < a[x].b){
				ntot = tot + kkk * a[x].l;
				nsum = sum;
			} else {
				ntot = tot + kkk * a[x].u;
				nsum = sum - a[x].b * a[x].l + a[x].b * a[x].u;
			}
			if (ntot >= nsum) return 1;
		}
	}
	return 0;
}

int main(){
	scanf("%lld", &n);
	scanf("%lld", &X);
	for (int i = 0; i < n; i++){
		scanf("%lld%lld%lld", &a[i].b, &a[i].l, &a[i].u);
	}
	long long l = 0, r = 1ll * n * X;
	while (l < r){
		long long mid = l + r >> 1;
		if (check(mid)) r = mid;
		else l = mid + 1;
	}
	printf("%lld\n", l);
	return 0;
}


Measured memory_bytes: 6356
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = []
from functools import reduce
import fractions
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


#odd and even
m1 = False
m2 = False
for e in A:
    if (e//2)%2 == 0:
        m1 = True
    else:
        m2 = True
    if m1 and m2:
        print(0)
        exit()
#even and even
if m1:
    l = gcd_list(A)
    for e in A:
        if (e//l)%2 == 0:
            print(0)
            exit()

s = lcm_list(A)
x = s//2
if x > M:
    print(0)
else:
    print((M-x)//s+1)

Measured memory_bytes: 83168
#include<stdio.h>

int main()
{
  int a , b , c;
  scanf("%d %d %d\n", &a, &b, &c);

  if(a <= b && b <= c)
    printf("%d %d %d\n", a , b, c);

  else if(a <= c && c <= b)
    printf("%d %d %d\n", a , c , b);

  else if(b <= a && a <= c)
    printf("%d %d %d\n", b , a , c);

  else if(b <= c && c <= a)
    printf("%d %d %d\n", b , c , a);

  else if(c <= a && a <= b)
    printf("%d %d %d\n", c , a , b);

  else
    printf("%d %d %d\n" , c , b , a);
return 0;
}


Measured memory_bytes: 2068
//
// Created by bytedance on 2020/4/10.
//


#include <bits/stdc++.h>

using namespace std;
const int maxn = 200005;
char shit[maxn];

int main() {
    int n;
    scanf("%d", &n);
    scanf("%s", shit);
    int l = 0, r = n - 1;
    int ans = 0;
    while (l <= r) {
        while (l < n && shit[l] == 'R') l++;
        while (r >= 0 && shit[r] == 'W') r--;
        if (l >= r) break;
        swap(shit[l], shit[r]);
        ans++;
    }
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 3980