akhauriyash/Code-Regression huggingface dataset:
/*
ID: tohoast1
TASK: gymnastics
LANG: C++
*/
#include <bits/stdc++.h>
#define speedup ios_base::sync_with_stdio(NULL)
#define fin freopen("gymnastics.in", "r", stdin)
#define fout freopen("gymnastics.out", "w", stdout)
#define FILENAME
#define PUBG push_back
#define p_b pop_back
#define mp make_pair
#define fi first
#define se second
#define cls clear
#define INF const int ci = 1e6 + 100
#define K_INF 1e9 + 7
#define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define MIN_INT -999999999
#define MOD 1000000007
#define d109 1000000000

using namespace std;
typedef long long LL;
typedef long L;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef string STR;
int a1, b1, a2, b2, a3, b3, ch1, ch2, ch3, ch4, h1, h2;
vector <int> vc;

int main() {
    #ifdef FILENAMEs
        fin;
        fout;
    #endif // FILENAME
    cin >> a1 >> b1 >> a2 >> b2 >> a3 >> b3;
    if (a1 == 1) ch1 ++;
    if (a2 == 1) ch1 ++;
    if (a3 == 1) ch1 ++;
    if (b1 == 1) ch1 ++;
    if (b2 == 1) ch1 ++;
    if (b3 == 1) ch1 ++;
    if (a1 == 2) ch2 ++;
    if (a2 == 2) ch2 ++;
    if (a3 == 2) ch2 ++;
    if (b1 == 2) ch2 ++;
    if (b2 == 2) ch2 ++;
    if (b3 == 2) ch2 ++;
    if (a1 == 3) ch3 ++;
    if (a2 == 3) ch3 ++;
    if (a3 == 3) ch3 ++;
    if (b1 == 3) ch3 ++;
    if (b2 == 3) ch3 ++;
    if (b3 == 3) ch3 ++;
    if (a1 == 4) ch4 ++;
    if (a2 == 4) ch4 ++;
    if (a3 == 4) ch4 ++;
    if (b1 == 4) ch4 ++;
    if (b2 == 4) ch4 ++;
    if (b3 == 4) ch4 ++;
    vc.PUBG(ch1);
    vc.PUBG(ch2);
    vc.PUBG(ch3);
    vc.PUBG(ch4);
    for (int i = 0 ; i < 4 ; ++ i) {
        if (vc[i] == 1) {
            h1 ++;
        }
        else if (vc[i] == 2) {
            h2 ++;
        }
    }
    if (h1 == 2 && h2 == 2) cout << "YES";
    else cout << "NO";
    ///time;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double esp=1e-8;
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define cle(a) while(!a.empty())a.pop()
#define mem(p,c) memset(p,c,sizeof(p))
#define mp(A, B) make_pair(A, B)
#define pb push_back
typedef long long int LL;
const long double PI = acos((long double)-1);
const LL INF=0x3f3f3f3fll;
const int MOD =1e9+7ll;
const int maxn=21000;
vector<int>A;
int f[110][110];
int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("pentagon.in", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int h,w,n;
    scanf("%d%d%d",&h,&w,&n);
    A.clear();
    for(int x=1;x<=n;x++)
    {
        int t;
        scanf("%d",&t);
        A.pb(t);
    }
    for(int x=1;x<=h;x++)
    {
        if(x&1)
        {
            for(int y=1;y<=w;y++)
            {
                f[x][y]=A.size();
                A.back()--;
                if(A.back()==0)
                    A.pop_back();
            }
        }
        else
        {
            for(int y=w;y>=1;y--)
            {
                f[x][y]=A.size();
                A.back()--;
                if(A.back()==0)
                    A.pop_back();
            }
        }
    }
    for(int x=1;x<=h;x++)
        for(int y=1;y<=w;y++)
            printf("%d%c",f[x][y]," \n"[y==w]);
    return 0;
}


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

int main()
{
	double a, b, c, d, e, f, x, y;

	while (cin >> a >> b >> c >> d >> e >> f) {
		if (e * c == b * f)
			x = 0;
		else
			x = (e * c - b * f) / (a * e - b * d);

		if (d * c == a * f)
			y = 0;
		else
			y = (- d * c + a * f) / (a * e - b * d);

		cout << setiosflags(ios::fixed | ios::showpoint) << setprecision(3)
			<< x << " " << y << endl;
	}

	return 0;
}


Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  vector<int64_t>B(N+1);
  B.at(0)=0;
  for(int i=1;i<=N;i++)
    B.at(i)=B.at(i-1)+A.at(i-1);
  int64_t a=B.at(N)/2;
  auto itr=lower_bound(B.begin(),B.end(),a);
  int k=distance(B.begin(),itr);
  int64_t ans=max(B.at(k-1),B.at(N)-B.at(k));
  ans=B.at(N)-2*ans;
  cout<<ans<<endl;
  
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

#include<vector>

class Combination{
    long long int maxn;
    long long int mod;
    std::vector<long long int> factorial;
    std::vector<long long int> inverse;

    public:

    Combination(long long int n,long long int m):maxn(n),mod(m){
        factorial.push_back(1);
        inverse.push_back(1);

        for(long long int i = 1; i <= n; i++){
            factorial.push_back((factorial.back()*i)%mod);
            inverse.push_back([&](long long int x,long long int n) -> long long int{
                long long int ret = 1;
                while(n > 0){
                    if(n&1)ret = (ret*x)%mod;
                    x = (x*x)%mod;
                    n >>= 1;
                }
                return ret;
            }(factorial.back(),mod-2));
        }
    }

    long long int comb(long long int n,long long int r){
        return (((factorial[n]*inverse[n-r])%mod)*inverse[r])%mod;
    }
};

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

    ll ans = 0;

    vector<ll> t;
    while(n > 0){
        t.push_back(n%10);
        n /= 10;
    }

    vector<vector<vector<ll>>> dp(t.size()+1,vector<vector<ll>>(8,vector<ll>(2,0)));
    dp[t.size()][0][1] = 1;

    vector<ll> x = {0,0,0,1,0,2,0,4};

    for(int i = t.size() - 1; i >= 0; i--){
        dp[i][0][0] = 1;
        for(int j = 3; j < 8; j += 2){
            if(j == t[i]){
                for(int k = 0; k < 8; k++){
                    dp[i][k|x[j]][0] += dp[i+1][k][0];
                    dp[i][k|x[j]][1] += dp[i+1][k][1];
                }
            }else if(j < t[i]){
                for(int k = 0; k < 8; k++){
                    dp[i][k|x[j]][0] += dp[i+1][k][0];
                    dp[i][k|x[j]][0] += dp[i+1][k][1];
                }
            }else{
                for(int k = 0; k < 8; k++){
                    dp[i][k|x[j]][0] += dp[i+1][k][0];
                }
            }
        }
    }

    cout << dp[0][7][0] + dp[0][7][1] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { 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; }

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}


void execute()
{
    string T;
    cin >> T;

    for(int i = 0; i < T.length(); i++){
        if(T[i] == '?') T[i] = 'D';
    }
    cout << T << endl; 
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define FOR(k,m,n) for(int(k)=(m);(k)<(n);(k)++)
#define REP(k,n) FOR((k),0,(n))
using namespace std;
typedef long long ll;
typedef vector<ll> VLL;
const int MOD=1000000007;

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if(b < c || d < a){
        cout << 0 << endl;
        return 0;
    }

    if(a <= c){
        if(b <= d){
            cout << b - c << endl;
            return 0;
        }else{
            cout << d - c << endl;
            return 0;
        }
    }else{
        if(b <= d){
            cout << b - a << endl;
            return 0;
        }else{
            cout << d - a << endl;
            return 0;
        }
    }
}

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

int n,m,z;
int a[100010],b[100010];
int out = 1000000,min2 = 1000000;

int main()
{
	cin>>n>>m>>z;
	for(int i = 1;i <= n;i++)
	{
		cin>>a[i];
		out = min(out,a[i]);
	}
	for(int i = 1;i <= m;i++)
	{
		cin>>b[i];
		min2 = min(min2,b[i]);
	}
	out += min2;
	for(int i = 1;i <= z;i++)
	{
		int in1,in2,in3;
		cin>>in1>>in2>>in3;
		out = min(out,a[in1] + b[in2] - in3);
	}
	cout<<out;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int bubbleSort(int s[],int N){
    int flag=1;
    int count=0;
    int tmp;
    int i;
    
    while(flag){
        flag=0;
        for(i=N-1;i>=1;i--){
            if(s[i]<s[i-1]){
                tmp=s[i];
                s[i]=s[i-1];
                s[i-1]=tmp;
                count++;
                flag=1;
            }
        }
    }
    return count;
}
int main(void){
    int i;
    
    int N;
    scanf("%d",&N);
    int s[N];
    for(i=0;i<N;i++)scanf("%d",&s[i]);
    
    int count;
    count=bubbleSort(s,N);
    
    printf("%d",s[0]);
    for(i=1;i<N;i++)printf(" %d",s[i]);
    printf("\n%d\n",count);
    
    return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#define ll long long
using namespace std;
int main() {
	int n;
	cin>>n;
	ll *a=new ll[n+1];
	ll *b=new ll[n];
	for(int i=0; i<=n; i++) {
		cin>>a[i];  //monster
	}
	for(int i=0; i<n; i++) {
		cin>>b[i];  // hero
	}
	ll sum=0;
	for(int i=0; i<n; i++) {
		if(a[i]>=b[i]) {
			sum+=b[i];
			a[i]-=b[i];
		} else {
			sum+=a[i];
			b[i]-=a[i];
			if(a[i+1]>=b[i]) {
				sum+=b[i];
				a[i+1]-=b[i];
			} else {
				sum+=a[i+1];
				a[i+1]=0;
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;
#define MOD 1000000007
#define MSG(a) cout << #a << " " << a << endl;
#define print(a) cout << a << endl;
template <class T, class C>
void chmax(T &a, C b) { if(a <= b) a = b; }
template <class T, class C>
void chmin(T &a, C b) { if(a >= b) a = b; }

template <class T>
T sum(const vector<T> &v)
{
    T res = 0;
    for (size_t i = 0; i < v.size(); ++i)
        res += v[i];
    return res;
}
// vector の出力
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v)
{
    size_t last = v.size() - 1;
    for (size_t i = 0; i < v.size(); ++i)
    {
        out << v[i];
        if (i != last)
            out << " ";
    }
    return out;
}

void f(const vector<vector<int>> &edges, vector<int> &costs, int c)
{
    for (auto u : edges[c])
    {
        // int u = edges[c][i];
        if (costs[u] >= 0)
            continue;
        costs[u] = costs[c] + 1;
        f(edges, costs, u);
    }
}

int main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //////////////////////////////////////////

    int n;
    cin >> n;
    vector<vector<int>> edge(n);
    rep(i, n)
    {
        int a, b;
        cin >> a >> b;
        edge[a - 1].push_back(b - 1);
        edge[b - 1].push_back(a - 1);
    }
    vector<int> costs1(n, -1);
    costs1[0] = 0;
    f(edge, costs1, 0);
    vector<int> costs2(n, -1);
    costs2[n - 1] = 0;
    f(edge, costs2, n - 1);
    int ans = 0;
    // cout << costs1 << endl;
    // cout << costs2 << endl;
    rep(i, n)
    {
        if (costs1[i] <= costs2[i])
            ans += 1;
        else
            ans -= 1;
    }
    if (ans <= 0)
    {
        print("Snuke");
    }
    else
    {
        print("Fennec")
    };

    return 0;
}


Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

int main() {
    int N;
    ll K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i]--;
    }

    set<int> visit;
    vector<int> circle;
    int last = 0;
    visit.insert(last);
    circle.push_back(last);
    for (int i = 0; i < N; i++) {
        last = A[last];
        circle.push_back(last);
        if (visit.find(last) != visit.end()) {
            break;
        }
    }
    int r = 0;
    int l = -1;
    for (int i = 0; i < (int)circle.size(); i++) {
        if (circle[i] == last && l == -1) {
            l = i;
        }
        if (circle[i] == last && l != -1) {
            r = i;
        }
    }

    if (l >= K) {
        cout << circle[K] + 1 << endl;
        return 0;
    }

    K -= l;
    int p = r - l;
    cout << circle[l + K % p] + 1 << endl;
}


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

using namespace std;

#define int long long 
#define M 1000000007

signed main(){
//	int t;
//	cin >> t;
//	while(t--){
		int n,x,t;
		cin >> n >> x >> t;
		int temp=ceil((double)n/(double)x);
		cout << t*temp << endl;
//	}
}
 

Measured memory_bytes: 3740
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

int main()
{
    double n, t, a, h, dif=999999999;
    int ans;
    cin>>n>>t>>a;
    for (int i=1; i<=n; i++)
    {
        cin>>h;
        if (abs(a-(t-h*0.006))<dif)
        {
            dif=abs(a-(t-h*0.006));
            ans=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> p(n),q(n);
	rep(i,n) std::cin >> p[i];
	rep(i,n) std::cin >> q[i];
	int pi,qi;
	std::vector<int> io(n);
	std::iota(all(io),1);
	int c = 0;
	do {
		if(io==p) pi=c;
		if(io==q) qi=c;
		c++;
	} while(std::next_permutation(all(io)));
	print(std::abs(pi-qi));

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl

using ld = double;
using P = complex<ld>;
using G = vector<P>;
const ld pi = acos(-1);
const ld eps = 1e-10;
const ld inf = 1e12;

ld cross(const P& a, const P& b) { return a.real()*b.imag() - a.imag()*b.real(); }
ld dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }

using C = pair<ld, P>;
#define rad first
#define pnt second

C smallest_enclosing_disc(vector<P> ps){
    auto c3 = [](const P &a, const P &b, const P &c){
        ld A = norm(b - c);
        ld B = norm(c - a);
        ld C = norm(a - b);
        ld S = abs(cross(b - a, c - a));
        P p = (A*(B+C-A)*a + B*(C+A-B)*b + C*(A+B-C)*c) / (4*S*S);
        ld r = abs(p - a);
        return make_pair(r, p);
    };

    auto c2 = [](const P &a, const P &b){
        P c = (a + b) / (ld)2;
        ld r = abs(a - c);
        return make_pair(r, c);
    };

    auto in_circle = [](const P &a, const C &c){
        return norm(a - c.pnt) <= c.rad*c.rad + eps;
    };

    int n = ps.size();
    random_shuffle(ps.begin(), ps.end());
    C c = c2(ps[0], ps[1]);
    for(int i = 2; i < n; ++i){
        if(!in_circle(ps[i], c)){
            c = c2(ps[0], ps[i]);
            for(int j = 1; j < i; ++j){
                if(!in_circle(ps[j], c)){
                    c = c2(ps[j], ps[i]);
                    for(int k = 0; k < j; ++k){
                        if(!in_circle(ps[k], c)){
                            c = c3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}

// http://www.spoj.com/problems/QCJ4/
// http://www.spoj.com/status/ns=18116289

int main(){
     srand(time(0));
     int n;
     cin >> n;
     vector<P> ps(n);
     for(int i = 0; i < n; ++i){
         ld x,y;
         cin >> x >> y;
         ps[i] = P(x,y);
     }

     printf("%.8lf\n", (double)smallest_enclosing_disc(ps).rad);
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const int N = 2e5 + 10;
bool mark[N];
int ans[N], sum[N];
vector<int> adj[N];
 
void dfs(int root, int extra) {
  	mark[root] = true;
  	ans[root] = sum[root] + extra;
  	for (int i = 0; i < adj[root].size(); i++) {
      	int u = adj[root][i];
      	if(!mark[u])
			dfs(u, extra + sum[root]);
    }
}
int main() {
  	int n, u, v, q, x , p;
  	cin >> n >> q;
  	for (int i = 1; i < n; i++) {
      	cin >> u >> v;
      	u--;
      	v--;
      	adj[u].push_back(v);
      	adj[v].push_back(u);
    }
  	for (int i = 0; i < q; i++) {
    	cin >> x >> p;
      	sum[x - 1] += p;
    }
	dfs(0, 0);
    for (int i = 0; i < n; i++)
      	cout << ans[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 24448
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	int64_t a, b; cin >> a >> b;
	if ((a - b) & 1) {
		cout << "IMPOSSIBLE" << endl;
	}
	else {
		cout << (a + b) / 2 << endl;
	}

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  string s;
  cin >> s;
  int ans1 = 0;
  int ans2 = 0;
  for (int i = 0; i < s.length(); ++i) {
    if ((i % 2 == 0 && s[i] == '1') || (i % 2 == 1 && s[i] == '0')) ans1++;
    if ((i % 2 == 0 && s[i] == '0') || (i % 2 == 1 && s[i] == '1')) ans2++;
  }
  int ans = min(ans1, ans2);
  if (s.length() == 1) ans = 0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#n = int(input())
#s = input()
n,a,b= map(int,input().split())
#da = list(map(int,input().split()))
#a = [int(input()) for i in range(n)]

ans = n//(a+b)
n -= ans*(a+b)
ans *= a
ans += min(n, a)
print(ans)

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

using namespace std;
int n;
long long c, x[100001], v[100001], p[100001], s[100002], px[100001], sx[100002];
int main(){
    cin >> n >> c;
    for(int i = 1; i <= n; i++){
        cin >> x[i] >> v[i];
        p[i] = p[i - 1] + v[i] - (x[i] - x[i - 1]);
    }
    for(int i = n; i >= 1; i--){
        if(i == n){
            s[i] = s[i + 1] + v[i] - (c - x[i]);
        }
        else{
            s[i] = s[i + 1] + v[i] - (x[i + 1] - x[i]);
        }
    }
    for(int i = 1; i <= n; i++){
        px[i] = max(px[i - 1], p[i] - x[i]);
    }
    for(int i = n; i >= 1; i--){
        sx[i] = max(sx[i + 1], s[i] - (c - x[i]));
    }
    long long mx = 0;
    for(int i = 1; i <= n; i++){
        mx = max(mx, max(max(p[i], s[i]), max(px[i - 1] + s[i], sx[i + 1] + p[i])));
    }
    cout << mx;
}


Measured memory_bytes: 4992
def make_divisors(n):
    divisors = [n]
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    divisors.sort()
    return divisors


def main():
    N = int(input())
    if N == 2:
        print(1)
        exit()
    n = make_divisors(N)
    m = make_divisors(N - 1)
    answer = m[:]
    cnt = len(answer)
    for i in n:
        tmp = N
        while tmp % i == 0:
            tmp //= i
        if tmp % i == 1:
            cnt += 1
            answer.append(i)
    answer.sort()
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
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;
}

int main(){
    ll N;
    cin>>N;
    vector<ll>A(N);
    vector<ll>D(N);
    vector<bitset<31>>B(N);
    vector<bitset<31>>C(N);
    rep(i,N){
        cin>>A[i];
        B[i]=bitset<31>(A[i]);
    }
    bitset<31>M=B[0];
    for(int i=1;i<N;i++){
        M=M^B[i];
    }
    rep(i,N){
        C[i]=M^B[i];
    }
    rep(i,N){
        D[i]=C[i].to_ullong();
    }
    rep(i,N){
        cout<<D[i]<<" ";
    }
}

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

typedef long long int ll;
using ii= pair<ll,ll>;
#define all(o) (o).begin(),(o).end()
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ld long double
#define eps 0.00000000001

class prioritize{
    public: bool operator() (ii &p1,ii &p2){
        return p1.F<p2.F;
    }
};

int main()
{
    
    #ifndef ONLINE_JUDGE
        freopen("input1.txt","r", stdin);
        freopen("output1.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    ll x;
    cin>>x;
    if(x>=30) cout<<"Yes\n";
    else cout<<"No\n";
  

}

Measured memory_bytes: 3632
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    LL n,m,d;cin>>n>>m>>d;

    double p;
    if(d==0){
        p = 1.0/n;
    }
    else{
        p = 2.0*max(0LL,n-d)/n/n;
    }

    cout<<p*(m-1)<<endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

int main() {
  //input
  string S, T;
  int A, B;
  string U;
  cin >> S >> T >> A >> B >> U;
  //calc
  if ( S == U ) {
    A--;
  }
  else {
    B--;
  }
  //output
  cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
    ll n, m; cin >> n >> m;
    cout << (n-1) * (m-1) << endl;
}

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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
int mod = 998244353;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  

double eps = .000000001;

int main ()
{
  prep();
  int n;
  vector<pair<int, int> > v;
  cin >> n;
  for (int i=0; i<n; i++){
      int num;
      cin >> num;
      v.push_back({num, i+1});
  }
  sort(v.begin(), v.end());
  for (int i=0; i<n; i++){
      cout << v[i].second << " ";
  }
  return 0; 
}


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

int main(){
	int N;
  	cin >> N;
  	vector<int> vec(N);
  
  	for(int i=0;i<N;i++){
    	cin >> vec.at(i);
    }
  
  	int count=0;
  
  	for(int i=0;i<N;i++){
    	if(vec.at(i) != i+1){
        	count++;
        }
    }
    
    if(count <= 2){
    	cout << "YES" << endl;
    }
  	else{
    	cout << "NO" << endl; 
    }
      
  	return 0;
}


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

int main() {
  string s;
  cin >> s;
  
  int ans = 0;
  for(int i=0; i<int(s.length())/2; i++) {
    if (s[i] != s[s.length()-i-1]) ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
using System;

namespace Test
{
	class Program
	{
		static void Main(string[] args)
		{
			int top1 = 0;
			int top2 = 0;
			int top3 = 0;
			for (int i = 0; i < 10; i++)
			{
				int n = int.Parse(Console.ReadLine());


				if (n > top1)
				{
					top3 = top2;
					top2 = top1;
					top1 = n;
				}
				else if (n > top2)
				{
					top3 = top2;
					top2 = n;
				}
				else if (n > top3)
				{
					top3 = n;
				}
			}
			Console.WriteLine(top1);
			Console.WriteLine(top2);
			Console.WriteLine(top3);
		}
	}
}

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
int main() {
  string S,sub;
  cin>>S;
  sub=S.substr(5,2);
  if(sub=="01"||sub=="02"||sub=="03"||sub=="04"){
  cout<<"Heisei"<<endl;
  }else{
  cout<<"TBD"<<endl;
  }
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int A, B; cin >> A >> B;
    int Q; cin >> Q;
    ll SH[A+2], TE[B+2];
    rep(i, A) cin >> SH[i];
    rep(i, B) cin >> TE[i];
    SH[A] = LLINF; SH[A+1] = -LLINF;
    TE[B] = LLINF; TE[B+1] = -LLINF;
    sort(SH, SH + (A+2));
    sort(TE, TE + (B+2));
    ll X[Q]; rep(i, Q) cin >> X[i];
    rep(i, Q){
        int tok = -1, tng = B+2, sok = -1, sng = A+2;
        int tm = (tok+tng)/2, sm = (sok+sng)/2;
        while(abs(tok-tng) > 1){
            if(TE[tm] <= X[i]) tok = tm;
            else tng = tm;
            tm = (tng+tok)/2;
        }
        while(abs(sok-sng) > 1){
            if(SH[sm] <= X[i]) sok = sm;
            else sng = sm;
            sm = (sok+sng)/2;
        }
        ll ans[4];
        ans[0] = max(SH[sok+1]-X[i], TE[tok+1]-X[i]);
        ans[3] = max(X[i]-SH[sok], X[i]-TE[tok]);
        ans[1] = min((X[i]-SH[sok])*2 + TE[tok+1]-X[i], (TE[tok+1]-X[i])*2 + X[i]-SH[sok]);
        ans[2] = min((X[i]-TE[tok])*2 + SH[sok+1]-X[i], (SH[sok+1]-X[i])*2 + X[i]-TE[tok]);
        sort(ans, ans+4);
        cout << ans[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
from collections import deque

n, k = map(int, input().split())

MOD = 1000000007

g = [[] * 1 for i in range(n)]

for i in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

d = [-1 for i in range(n)]

q = deque([])
num = k-1
d[0] = k
for to in g[0]:
    if d[to] == -1:
        d[to] = num
        num -= 1
        if num < 0:
            num = 0
        q.append(to)

while q:
    v = q.popleft()
    num = k-2
    for to in g[v]:
        if d[to] == -1:
            d[to] = num
            num -= 1
            if num < 0:
                num = 0
            q.append(to)

ans = 1
for i in d:
    ans *= i
    ans %= MOD

print(ans)

Measured memory_bytes: 27048
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<ll,pll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll n;
    cin>>n;
    string str[n];
    for(ll i=0;i<n;i++)
    {
        cin>>str[i];
        sort(str[i].begin(),str[i].end());
    }
    sort(str,str+n);
    ll count1=1;
    ll ans=0,store;
    string temp=str[0];
    for(ll i=1;i<n;i++)
    {
        if(str[i]==temp)
        {
            count1++;
        }
        else
        {
            store=(count1*(count1-1)/2);
            ans+=store;
            count1=1;
            temp=str[i];
        }
    }
    store=(count1*(count1-1)/2);
    ans+=store;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5760
from math import trunc
import sys
import copy
from collections import deque
import collections
import itertools
stdin = sys.stdin
import math

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()

ans1 = []
ans2 = []
max_xy = 10**9
for _ in range(n):
    x, y = na()
    ans1.append(x+y)
    ans2.append((max_xy-x)+y)

print(max(max(ans1) - min(ans1), max(ans2) - min(ans2)))


Measured memory_bytes: 94296
local mfl, mce = math.floor, math.ceil
local bls, brs = bit.lshift, bit.rshift
local mmi, mma = math.min, math.max
local n = io.read("*n")
local t = {}
_u = io.read("*n")
for i = 1, n - 1 do
  t[i] = io.read("*n")
end
n = n - 1
local ret = 0
local lim = brs(n - 1, 1)
for i = 1, n do
  local lim2 = mfl(lim / i)
  local c = 0
  for j = 1, n do
    if n % i == 0 then
      if n - i * j <= i * j then break end
    end
    if n - i * j < i then break end
    c = c + t[i * j] + t[n - i * j]
    ret = mma(ret, c)
  end
end
print(ret)


Measured memory_bytes: 1280
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
int h,n,f[20005],a[1005],b[1005];
int main(){
	cin>>h>>n;
	for(int i=1;i<=n;i++)cin>>a[i]>>b[i];
	memset(f,0x3f,sizeof(f));
	f[0]=0;
	for(int i=1;i<=n;i++){
		for(int j=a[i];j<=20000;j++)f[j]=min(f[j],f[j-a[i]]+b[i]);
	}
	int ans=0x3f3f3f3f;
	for(int i=h;i<=20000;i++)ans=min(ans,f[i]);
	cout<<ans;
}

Measured memory_bytes: 384
#include <stdio.h>

int
gcd(int x, int y)
{
    if(y == 0) return x;
    else return gcd(y, x % y);
}

int
main(void)
{
    int x, y;

    scanf("%d %d", &x, &y);
    printf("%d\n", gcd(x, y));
}



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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll x,hoge,ans,temp,count;
    cin >> x;
    hoge = 100;
    ans = 0;
    count = 0;
    temp = (int)(log(x / 100.0) / log(1.1))+1;
    for(int i = 1; i < temp+1; i++){
        hoge +=  hoge/100;
    }
    while(hoge < x){
        hoge += hoge/100;
        count += 1;
    }
    ans = count + temp;
    //ans = (int)(log(x / 100.0) / log(1.1))+1;
    /*while(hoge < n){
        hoge += hoge/100;
        ans += 1;
    }*/
    cout << ans << endl;

    
}

Measured memory_bytes: 3824
#include<stdio.h>

int main()
{
	int h,w,n;
	scanf("%d%d%d",&h,&w,&n);
	int a[h][w];
	int b[n];
	
	for(int i=0;i<n;i++)
	{
		scanf("%d",&b[i]);
	}
	int k=0,num=1;
	for(int i=0;i<h;i++)
	{
		
		if(!(i&1))
		{
			for(int j=0;j<w;j++)
			{
				if(b[k]>0)
				{
					a[i][j]=num;
					b[k]--;
				}
				else if(b[k]==0)
				{
					k++;
					num++;
					a[i][j]=num;
					b[k]--;
				}
			}
		
		}
		else
		{
			for(int j=w-1;j>=0;j--)
			{
				if(b[k]>0)
				{
					a[i][j]=num;
					b[k]--;
				}
				else if(b[k]==0)
				{
					k++;
					num++;
					a[i][j]=num;
					b[k]--;
				}
			}
		}
		
	}
	
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			printf("%d ",a[i][j]);	
		} 
		printf("\n");	
	}
	
	return 0;
}

Measured memory_bytes: 256
##!/usr/bin/env python3
import sys
# from operator import itemgetter
# gcd
# from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
# from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# 提出時はコメントアウト+上のshebangを有効にする
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template

YES = "Yes"  # type: str
NO = "No"  # type: str

def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


if __name__ == '__main__':

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]" 
    B = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))

    # write code
    Work = [[A[i], B[i]] for i in range(N)]
    Work.sort(key=lambda x: x[1])
    # print(Work)
    last = 0
    for i in range(N):
        last += Work[i][0]
        if last > Work[i][1]:
            print('No')
            break
        else:
            continue
    else:
        print('Yes')




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


int main() {
    int n;
    cin >> n;
    vector<tuple<string, int, int> > X(n);
    rep(i, n) {
        string s;
        int t;
        cin >> s >> t;
        X[i] = make_tuple(s, 100-t, i);
    }
    sort(X.begin(), X.end());
    rep(i, n) {
        cout << get<2>(X[i])+1 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define pi acos(-1)
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{

    string s, t;
    cin>>s>>t;

    vector<lli> f[26];

    for(int i = 0; i < s.size(); i ++) {
        f[s[i] - 'a'].push_back(i);
    }

    lli prev = -1;
    lli ans = 0;
    for(int i = 0; i < t.size(); ) {
        lli x = t[i] - 'a';
        lli idx = lower_bound(f[x].begin(), f[x].end(), prev + 1) - f[x].begin();
        if(idx < f[x].size() and f[x][idx] > prev) {
            prev = f[x][idx];
            i ++;
            if(i == t.size()) {
                ans += prev + 1;
                break ;
            }
        }
        else {
            if(prev == -1) {
                cout<<-1;
                return ;
            }
            prev = -1;
            ans += s.size();
        }
//        cout<<prev<<endl;
    }
    cout<<ans;
    cout<<"\n";
    return ;
}

/*
*/

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

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


Measured memory_bytes: 1736
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define clr(x, y) memset(x,y,sizeof(x));
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i, m, n) for(int i=m ; i<n ; i++)
#define forr(i, m, n) for(int i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
const int N = 1e3 + 5;
const ll OO = 1e9 + 7;
using namespace std;
set<ll> ans;
void solve(ll n) {
    if (n > (ll) 1e11) re;
    ans.insert(n);
    for (ll i = n % 10 - 1; i <= n % 10 + 1; i++) {
        if (i >= 0 && i <= 9)
            solve(n * 10 + i);
    }
}

int main() {
    IO;
    int k;
    cin >> k;
    forr(i, 1, 9) {
        solve(i);
    }
    int cur = 1;
    for (auto i:ans) {
        if (cur == k) re cout << i, 0;
        cur++;
    }


}


Measured memory_bytes: 27520
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<long double,int> P;

int n;
long double a[50001],b[50001],c[50001];

int n_=1<<16;

class segtree{
public:
	int dp[1<<17];
	segtree(){
		memset(dp,0,sizeof(dp));
	}
	void init(){
		memset(dp,0,sizeof(dp));
	}
	void update(int k,int v){
		while(k<=n){
			dp[k]+=v;
			k+=(k&(-k));
		}
	}

	int query(int a,int b,int k=0,int l=0,int r=n_){
		int res=0;
		while(b>0){
			res+=dp[b];
			b-=(b&(-b));
		}
		return res;
	}
};

segtree seg;

vector<P> vec;
vector<P> vec2;
int ord[50001];

bool C(long double v){
	vec.clear();
	vec2.clear();
	for(int i=0;i<n;i++){
		long double val=(long double)c[i]/b[i]-(a[i]/b[i])*(-1000000005.0);
		vec.push_back(P(val,i));
	}
	sort(vec.begin(),vec.end());
	seg.init();
	for(int i=0;i<n;i++){
		ord[vec[i].second]=i;
		long double val=(long double)c[i]/b[i]-(a[i]/b[i])*v;
		vec2.push_back(P(val,i));
		seg.update(i+1,1);
	}
	sort(vec2.begin(),vec2.end());
	ll cnt=0;
	for(int i=0;i<n;i++){
		cnt+=(ll)seg.query(0,ord[vec2[i].second]);
		seg.update(ord[vec2[i].second]+1,-1);
	}
	ll val=(ll)n*(n-1)/2LL;
	if(val%2LL==0)return cnt>=(val/2LL);
	return cnt*2LL>=val;
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		double ff,tt,cc;
		scanf("%lf%lf%lf",&ff,&tt,&cc);
		a[i]=ff;
		b[i]=tt;
		c[i]=cc;
	}
	long double l=-1000000005.0,r=1000000005.0;
	for(int i=0;i<200;i++){
		long double mid=(l+r)/2.0;
		if(C(mid))r=mid;
		else l=mid;
	}
	for(int i=0;i<n;i++){
		swap(a[i],b[i]);
	}
	long double l2=-1000000005.0,r2=1000000005.0;
	for(int i=0;i<200;i++){
		long double mid=(l2+r2)/2.0;
		if(C(mid))r2=mid;
		else l2=mid;
	}
	printf("%.15f %.15f\n",(double)r,(double)r2);

	return 0;
}

Measured memory_bytes: 7536
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using P = pair<int, int>;
using MATRIX = vector< vector<ll> >;
template <class T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <class T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}

int N;
int a[200000];
int b[200000];
int c[200001] = {0};
int d[200000] = {0};

int main() {
  cin >> N;
  rep(i, N) {
    cin >> a[i];
    c[a[i]]++;
  }
  rep(i, N) {
    cin >> b[i];
    d[b[i]]++;
  }
  rep(i, N) {
    if(c[i+1] + d[i+1] > N) {
      cout << "No" << endl;
      return 0;
    }
  }
  rep(i, N) {
    c[i+1] += c[i];
    d[i+1] += d[i];
  }
  int x = 0;
  rep(i, N) {
    x = max(x, c[i+1]-d[i]);
  }
  cout << "Yes" << endl;
  rep(i, N) {
    cout << b[(i-x+N)%N] << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 6712
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

// 最大公約数
ll gcd(ll m, ll n) {
  if (n==0) return abs(m);
  else return gcd(n, m%n);
}

// 最小公倍数
ll lcm(ll m, ll n) {
  return abs(m*n)/gcd(m, n);
}

int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  ll numC, numD, numCD; // N(A<=N<=B)のうち，C，D，lcm(C，D)で割り切れるものの個数
  if (A%C==0) numC = B/C-A/C+1;
  else numC = B/C-A/C;
  if (A%D==0) numD = B/D-A/D+1;
  else numD = B/D-A/D;
  if (A%(C*D)==0) numCD = B/(lcm(C, D))-A/(lcm(C, D))+1;
  else numCD = B/(lcm(C, D))-A/(lcm(C, D));
  ll ans = B-A+1-(numC+numD-numCD);
  cout << ans << endl;
}

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


int main () {
    string s,t,u;
    int a,b;
    cin>>s>>t>>a>>b>>u;
    if(u==s){
        cout<<a-1<<' '<<b;
    }else{
        cout<<a<<' '<<b-1;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    ll x;
    cin >> x;

    ll ans = x-1;
    while (true) {
        ans++;
        bool flag = true;
        for(int i = 2; i <= (ans+1)/2; i++) {
            if (ans % i == 0) {
                flag = false;
                break;
            }
        }
        if(flag) break;
    }

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

Measured memory_bytes: 256
#include<cstring>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cmath>
#define writ(x,c) write(x),putchar(c);
typedef long long ll;
using namespace std;
inline int read()
{
    char c;int x=0;bool f=0;
    for(;!isdigit(c);c=getchar()) if(c=='-') f=1;
    for(;isdigit(c);c=getchar()) x=(x<<1)+(x<<3)+(c^48);
    return (f ? -x : x);
}
template <class _T>
void write(_T x)
{
	if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
struct city
{
	int p,y,pos;
}a[1000001];
int n,m;
int ans[100001];
bool cmp(city xx,city yy)
{
	if(xx.p==yy.p)
	{
		return xx.y<yy.y;
	}
	return xx.p<yy.p;
}
void print(int x)
{
	if(x<10) printf("00000");
	else if(x<100) printf("0000");
	else if(x<1000) printf("000");
	else if(x<10000) printf("00");
	else if(x<100000) printf("0");
	printf("%d",x);
}
bool cmp2(city xx,city yy)
{
	return xx.pos<yy.pos;
}
int main()
{
	n=read(),m=read();
	for(int i=1;i<=m;i++)
	{
		a[i].p=read(),a[i].y=read(),a[i].pos=i;
	}
	sort(a+1,a+m+1,cmp);
	for(int i=1;i<=m;i++)
	{
		int j=i,k=i;
		while(a[j].p==a[j+1].p) j++;
		for(;i<=j;i++) ans[a[i].pos]=i-k+1;
		i--;
	}
	sort(a+1,a+m+1,cmp2);
	for(int i=1;i<=m;i++)
	{
		print(a[i].p);print(ans[i]);
		putchar('\n');
	}
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
using namespace std;
using ll=int64_t;
using pii=pair<int,int>;
using vi=vector<int>;
using vis=vector<string>;
using vvi=vector<vi>;
//pとqの最大公約数
int gcd(int p,int q){
    if(p%q==0)
    return q;
    return gcd(q,p%q);
}
int main(){
    int a,b;
    cin>>a>>b;
    for(int i=1;1009>=i;++i){
        if((i*8/100)==a&&(i/10)==b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 256
n=int(input())
zyunnretu=[i for i in range(1,n+1)]
from itertools import permutations
list=list(permutations(zyunnretu,n))

p=tuple(map(int,input().split(" ")))
q=tuple(map(int,input().split(" ")))
for i in range(len(list)):
    if p==list[i]:
        a=i
    if q==list[i]:
        b=i
print(abs(a-b))



Measured memory_bytes: 8052
#include<iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

int main(){
    char a[1200];
    char b[1200];
    int len;
    int i;
    
    fgets(a,1200,stdin);
    
    len = strlen(a);
    
    for (i=0;i<len;i++){
        if (0x40 < a[i] && a[i] < 0x5b){
            b[i]=a[i] + 0x20;
        }else if(0x60 < a[i] && a[i] < 0x7b){
            b[i]=a[i] - 0x20;
        }else{
            b[i]=a[i];
        }
    }
    
    for (i=0;i<len;i++){
        cout << b[i];
    }
    
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int& i : v) cin >> i;
  
  long sum = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      sum += v[i] * v[j];
    }
  }
  
  cout << sum << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn=1005;
ll n,W,w[maxn],v[maxn];
ll dp[100005];
ll ans;
int main()
{
	cin>>n>>W;
	for(ll i=0;i<n;i++)
	cin>>w[i]>>v[i];
	
	memset(dp,inf,sizeof(dp));
	dp[0]=0;
	
	for(ll i=0;i<n;i++)
	{
		for(ll j=100000;j>=v[i];j--)
		{
			
			dp[j]=min(dp[j],dp[j-v[i]]+w[i]);//价值不超过j的最大重量    
			if(dp[j]<=W) 
			ans=max(ans,j);		
		}
		                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
	string s = ReadLine();
	string ans="";
	switch(s[0])
	{
	    case 'S':
		ans = "Cloudy"; break;
	    case 'C':
		ans = "Rainy"; break;
	    case 'R':
		ans = "Sunny"; break;
	}
	WriteLine(ans);
    }
}


Measured memory_bytes: 9044