akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
  int n;
  cin >> n;
  vector<int> odd(100100, 0);
  vector<int> even(100100, 0);
  int odd_sum=0, even_sum=0;
  for(int i=0; i<n; i++){
    int a;
    cin >> a;
    if(i%2 == 0){
      odd[a]++;
      odd_sum++;
    }else{
      even[a]++;
      even_sum++;
    }
  }
  int j,k;
  int odd_max=0, even_max=0;
  for(int i=0; i<100010; i++){
    if(odd_max <= odd[i]){
      odd_max = odd[i];
      j=i;
    }
    if(even_max <= even[i]){
      even_max = even[i];
      k=i;
    }
  }
  if(j == k){
    int odd_max2=0, even_max2=0;
    odd[j] = 0;
    even[k] = 0;
    for(int i=0; i<100010; i++){
      if(odd_max2 <= odd[i]){
        odd_max2 = odd[i];
      }
      if(even_max2 <= even[i]){
        even_max2 = even[i];
      }
    }
    if(even_max2 >= odd_max2){
      cout << odd_sum-odd_max + even_sum-even_max2 << endl;
    }else{
      cout << odd_sum-odd_max2 + even_sum-even_max << endl;
    }
    return 0;
  }
  cout << odd_sum-odd_max + even_sum-even_max << endl;
  return 0;
}


Measured memory_bytes: 1152
S = input()
S_ki = S[0::2]
S_gu = S[1::2]

import sys
for k in S_ki:
    if k == "L":
        print("No")
        sys.exit()
for g in S_gu:
    if g == "R":
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int n, c;
    cin >> n >> c;
    int d[32][32];
    int C[510][510];
    for(int i = 1; i <= c; i++){
        for(int j = 1; j <= c; j++){
            cin >> d[i][j];
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            cin >> C[i][j];
        }
    }
    int cost[4][32];
    for(int i = 1; i <= 3; i++){
        for(int j = 1; j <= c; j++){
            cost[i][j] = 0;
            for(int k = 1; k <= n; k++){
                for(int l = 1; l <= n; l++){
                    if(((k + l) % 3) != (i % 3)){
                        continue;
                    }
                    cost[i][j] += d[C[k][l]][j];
                }
            }
        }
    }
    int ans = INF;
    for(int i = 1; i <= c; i++){
        for(int j = 1; j <= c; j++){
            if(i == j){
                continue;
            }
            for(int k = 1; k <= c; k++){
                if(i == k){
                    continue;
                }
                if(j == k){
                    continue;
                }
                ans = min(ans, cost[1][i] + cost[2][j] + cost[3][k]);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

int N;
long long int M;
long long int A[100005], B[100005], K[100005];

string SOLVE(void) {

	long long int U;
	U = (long long int) N*(N + 1); U /= 2;

	long long int TOTAL = 0;
	for (int i = 1; i <= N; i++) {
		TOTAL += A[i];
	}
	if (TOTAL%U != 0) { return "NO"; }

	M = TOTAL / U;

	A[0] = A[N];

	for (int i = 1; i <= N; i++) {
		if (A[i] - A[i - 1] <= 0) { K[i] = (M + A[i - 1] - A[i]) / N; }
		else { K[i] = 0; }
	}
	
	B[1] = K[1];
	for (int i = 2; i <= N; i++) {
		B[1] += K[i] * (N - i + 2); 
	}

	for (int i = 2; i <= N; i++) {
		B[i] = B[i - 1] + M - K[i] * N;
	}

	/*for (int i = 1; i <= N; i++) {
		cout << "B[" << i << "]= " << B[i] << endl;
	}*/

	for (int i = 1; i <= N; i++) {
		if (A[i] != B[i]) { return "NO"; }
	}
	return "YES";
}

int main(void) {

	cin >> N;

	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}

	cout << SOLVE() << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define cans cout << ans << endl
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
typedef long long ll;


int main(){
    ll n;
    cin >> n;
    vector<ll> a(5);
    rep(i,5) cin >> a[i];
    ll mi = 1e16;
    rep(i,5) mi = min(mi,a[i]);
    ll ans;
    ans = n/mi+4;
    if(n%mi!=0) ans++;
    cans;
    return 0;
}

Measured memory_bytes: 3536
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = n % 10;
        if (d == 3) {
            System.out.println("bon");
        }else if (d == 0 ||d == 1 ||d == 6 ||d == 8) {
            System.out.println("pon");
        } else {
            System.out.println("hon");
        }
    }

}

Measured memory_bytes: 35844
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
 
struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
    is>>p.first>>p.second;
    return is;
}

template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}

/*
自力考察のメモ
陽にグラフ作ると
    rep(i,1<<17){
        rep(j,17){
            g[i].push_back(i^(1<<j));
        }
    }
と作れるから|V|=(1<<17),|E|=(1<<17)*17
となって一応dfsなりは可能なグラフにはなるが，結局始点終点指定のTSPにしかならなくて困るので
もうちょっと言い換えがいりそう

これは実験の結果ですが偶奇性がありそう．
偶奇性チェックしてokなら全部作れそう
あと始点で全ての点をxorとることを考えると
000...00からスタートすると考えてよい

グレイコードの発想はやっぱりよくって，
00000...00の状態から1週してどこか1個立っている状態にできる．

00000000
0*******
00000001
10000001
10******
10000000
11000000
110*****
11000001
11100001
11100000

*/

signed main(){

    int n,A,B;cin>>n>>A>>B;
    int pa=__builtin_popcount(A),pb=__builtin_popcount(B);
    if(pa%2==pb%2){
        cout<<"NO"<<endl;
        return 0;
    }

    int a=0,b=(A^B);

    vector<int> match(n);
    {
        int i0=0,i1=n-1;
        rep(i,n){
            if((b>>i)&1){
                match[i1]=i;i1--;
            }else{
                match[i0]=i;i0++;
            }
        }
    }

    auto graycode_reverse=[&](int m){
        vector<int> ret;
        for(int i=0;i<(1<<m);i++){
            ret.push_back(i^(i>>1));
        }
        // rev
        for(int &x:ret){
            int y=0;
            rep(i,m)if((x>>i)&1){
                y+=(1<<(m-1-i));
            }
            x=y;
        }
        return ret;
    };

    int cnt=__builtin_popcount(b);
    int p=0;
    vector<int> res;
    for(int i=0;i<cnt;i++){
        auto r=graycode_reverse(n-1-i);
        for(auto x:r)res.push_back(x^p);
        p^=r.back();
        p^=(1<<(n-1-i));
    }
    auto r=graycode_reverse(n-cnt);
    for(auto x:r)res.push_back(x^p);

    for(auto &x:res){
        int y=0;
        rep(i,n)if((x>>i)&1){
            y+=(1<<match[i]);
        }
        x=y;
    }
    for(auto &x:res) x^=A;
    cout<<"YES"<<endl;
    cout<<res<<endl;
    return 0;
}

/*
8 0 7
*/

Measured memory_bytes: 4204
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1)
#define io  ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;
int main(){
    ll m ,n,sum=0,x;
    cin>>m>>n;
    while(n--){
        cin>>x;
        sum+=x;
    }
    sum=m-sum;
    if(sum<0)cout<<"-1"<<endl;
    else cout<<sum<<endl;

return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#define INF 1000000
using namespace std;
int dp[50000];
int main(){
  int n,m;
  int c[20];
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>c[i];
  }
  for(int i=0;i<=n;i++){
    dp[i]=INF;
  }
  dp[0]=0;
  for(int i=0;i<m;i++){
    for(int j=c[i];j<=n;j++){
      dp[j]=min(dp[j],dp[j-c[i]]+1);
    }
  }
  cout<<dp[n]<<endl;
}

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

int main()
{
	long N,a,ans=0,i;
	cin>>N;
	for(i=0;i<N;i++){
		cin>>a;
		while(a%2==0){
			a/=2;
			ans++;
		}
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dbg(x) cerr<<#x<<" = "<<x<<endl;
#define dbg_v(v,n) {cerr<<#v<<" = [";for(int III=0;III<=n;III++)cerr<<v[III]<<(III!=n?",":"]\n");}
#define ll long long
#define ld long double
#define pii pair<int,int>
#define MOD 1000000007
#define zeros(x) x&(x-1)^x

using namespace std;
int n;
int main(){
    ios::sync_with_stdio(false);
    cin >> n;
    cout << n * n * n << '\n';
    return 0;
}


Measured memory_bytes: 764
#include<stdio.h>
int main(){
	int a,b,c,d,p,x=0,y=0;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&p);
	x=p*a;
	if(p>c)y=y+(p-c)*d;
	y=y+b;
	if(x<y)printf("%d\n",x);
	else printf("%d\n",y);
	return 0;
}


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

#define ll long long
#define ull unsigned long long

using namespace std;

using Graph = vector<vector<int>>;
vector <ll> cnt;
vector <ll> sum;

void dfs(const Graph& graph, int v, int p, int val) {
	sum[v] = cnt[v] + val;
	for (auto nv : graph[v]){
		if (nv == p) continue;
		dfs(graph, nv, v, sum[v]);
	}
}

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

	Graph graph(N);
	for (int ii = 0; ii < N-1; ++ii){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	cnt.assign(N, 0);
	for (int ii = 0; ii < Q; ++ii){
		int p, x;
		cin >> p >> x;
		p--;
		cnt[p] += x;
	}

	sum.assign(N, 0);
	int root = 0;
	dfs(graph, /*v=*/root, /*p=*/-1, 0);

	for (int ii = 0; ii < N; ++ii){
		printf("%i ", sum[ii]);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 29824
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
#include <numeric>
#include <cmath>
#include <bitset>
#include <stack>
#include <algorithm>
#define llc (long long)
#define pm %1000000007
#define ldc (long double)
using namespace std;

struct ab{
	int a, b;
};
bool comp(ab x, ab y){
	return x.a+x.b<y.a+y.b;
}
int main(){
	int n;cin>>n;
	vector <ab> abab(n);
	long long tot=0;
	for(int i = 0;i < n;i ++){
		cin>>abab[i].a>>abab[i].b;
	}
	sort(abab.begin(), abab.end(), comp);
	for(int i = n-1;i >= 0;i --){
		if((n-i)&1){
			tot+=abab[i].a;
		}else{
			tot-=abab[i].b;
		}
	}
	printf("%lld\n", tot);
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
vector<P> x;
int main() {
  ll w,h;
  cin >> w >> h;
  for(int i = 0; i < w; i++) {
    ll p;
    cin >> p;
    x.push_back(P(p,0));
  }
  for(int i = 0; i < h; i++) {
    ll p;
    cin >> p;
    x.push_back(P(p,1));
  }
  sort(x.begin(),x.end());

  ll ans = 0;
  w++,h++;
  for(int i = 0; i < x.size(); i++) {
    if(x[i].second == 0) {
      ans += h * x[i].first; w--;
    }
    else {
      ans += w * x[i].first; h--;
    }
  }

  cout << ans << endl;
}
  


Measured memory_bytes: 6512
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }


int main() {    
    int n, a, b; string s; cin >> n >> a >> b >> s;
    int pass = 0, cnt = 1;
    for(char c: s){
        if(c == 'c') cout << "No" << ln;
        if(c == 'a'){
            if(pass < a+b){
                cout << "Yes" << ln;
                pass++;
            }else cout << "No" << ln;
        }
        if(c == 'b'){
            if(pass < a+b && cnt <= b){
                cout << "Yes" << ln;
                pass++, cnt++;
            }else cout << "No" << ln;
        }
    }

}


Measured memory_bytes: 896
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmin(T &a, T b) { return a>b?(a=b,true):false; }
template<class T> bool chmax(T &a, T b) { return a<b?(a=b,true):false; }
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define bs2int(bs) (int)((bs).to_ulong())
#define FOR(i,x,y) for(int i=(x);i<(int)(y);i++)
#define FORP(i,x,y) for(int i=(x);i<=(int)(y);i++)
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
#define REPB(i,n) for(int i=(int)(n)-1;i>=0;i--)
 
string s,t;
 
int main() {
  cin>>s;
  int n=s.length();
  int cur=0;
  for (char c : s)
    if (c!='x') t+=c;
 
  string p(t);
  reverse(all(p));
  if (t!=p) return 0*puts("-1");
 
  int l=0,r=n-1;
  int cnt=0;
  while(l<r)
  {
    if (s[l]=='x'&&s[r]!='x')
    {
      cnt++;
      l++;
      continue;
    }
    if (s[l]!='x'&&s[r]=='x')
    {
      cnt++;
      r--;
      continue;
    }
    l++,r--;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 640
open System
let tmp = Console.ReadLine().Split(' ')
let N = int (tmp.[0])
let K = int64 (tmp.[1])

let tmp_A = Array.map int64 (Console.ReadLine().Split(' '))
let tmp_F = Array.map int64 (Console.ReadLine().Split(' '))

let A = Array.sort tmp_A
let F = Array.rev (Array.sort tmp_F)

let required_training target a f=
    if a * f <= target then 0L
    else 
      let diff = a * f - target
      if diff % f = 0L then diff / f
      else diff / f + 1L
     
let rec f L R =
  if L >= R - 1L then R
  else
    let mid = (L + R) / 2L
    if K >= Array.sum (Array.map2 (required_training mid) A F) then f L mid
    else f mid R

if Array.sum (Array.map2 (required_training 0L) A F) <= K then
  Console.WriteLine(0)
else
  Console.WriteLine(f 0L (Array.max (Array.map2 (fun x y -> x * y) A F)))


Measured memory_bytes: 67224
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

template<int mod>
struct mint {
private:
    long long x;
public:
    mint(long long x = 0) :x(x%mod) {}
    mint(std::string s) {
        long long z = 0;
        REP(i, s.size()) {
            z *= 10;
            z += s[i] - '0';
            z %= mod;
        }
        this->x = z;
    }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    friend std::ostream& operator<<(std::ostream& os, const mint& n) {
        return os << n.x;
    }
    bool operator==(const mint a) const {
        return this->x == a.x;
    }
};

int main() {
    string s; cin >> s;
    int n = s.size();
    int d; cin >> d;
    // dp[i][j] : i番目まで見た時の数 j は未満フラグ
    vector<vector<vector<mint<MOD>>>> dp(n+1, vector<vector<mint<MOD>>>(d, vector<mint<MOD>>(2,0)));
    dp[0][0][0] = 1;
    REP(i, n) {
        REP(j, d) {
            dp[i + 1][(s[i] - '0' + j) % d][0] += dp[i][j][0];
            REP(k, 10) {
                if (k < s[i] - '0') dp[i + 1][(k + j) % d][1] += dp[i][j][0];
                dp[i + 1][(k + j) % d][1] += dp[i][j][1];
            }
        }
    }
    cout << dp[n][0][0] + dp[n][0][1] - 1 << endl;
    return 0;
}

Measured memory_bytes: 55296
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define F first
#define S second
#define SHN 1e9
#define lSHN 1e18
using namespace std;
int n,m;
int a[40][40];
int cnt[3][40];
int res=1e9;
int main() 
{
	cin >>n>>m;
	for (int i=0;i<m;i++)
	{
		for (int j=0;j<m;j++)
		    cin >>a[i][j];
	}
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<n;j++)
		{
			int x;
			cin >>x;
			cnt[(i+j)%3][x-1]++;
		}
	}
	for (int i=0;i<m;i++)
	{
		for (int j=0;j<m;j++)
		{
			for (int k=0;k<m;k++)
			{
				if (i==j || j==k || k==i) continue;
				int t=0;
				for (int it=0;it<m;it++)
				    t+=cnt[0][it]*a[it][i];
				for (int it=0;it<m;it++)
				    t+=cnt[1][it]*a[it][j];
				for (int it=0;it<m;it++)
				    t+=cnt[2][it]*a[it][k];
				//cout <<i<<" "<<j<<" "<<k<<" "<<t<<" "<<res<<" ##\n";
				res=min(res,t);
			}
		}
	}
	cout <<res;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define r(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;

int main(void){
  int x, i;
  cin >> x;
  for(i=1; x>0; i++){
    x-=i;
  }
  cout << i-1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
using lint  =                           long long int;
using pint  =                           pair<int, int>;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD                             1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(2); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                    bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T>                    bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }

lint pow_mod(lint base,lint expo) { 
   lint ret = 1;
   for(;expo;) { 
      if(expo&1)  ret = (ret*base)%MOD; 

      expo = (expo>>1);
      base = (base*base)%MOD;
   }
   return ret;
}

/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){  
  int r;
  cin >> r;

  cout << 3.14159265358979323846264338327950288419716939937510 * 2 * (float)r << endl;
}

int main(){   
  
    /// freopen("input.txt", "r", stdin);
     //freopen("output.txt", "w", stdout);

 solve();

 return 0;
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vp vector<pair<int,int>>
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define ull unsigned long long
#define ld long double
#define all(x) x.begin(),x.end()
#define cmp(t,x) [](const t& _a,const t& _b) {return _a.x<_b.x;}
#define pq priority_queue


int main(){
    ios::sync_with_stdio(true);
    cin.tie(NULL);
    ll a,b,c,d;cin>>a>>b>>c>>d;
    cout<<max(max(a*c,b*d),max(a*d,b*c));
    
    return 0;
}


Measured memory_bytes: 3604
//#pragma GCC optimize("O2")
//#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
const int maxn = 2e5 + 55;
const int mod = 1e9 + 7;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a, b;
	cin >> a >> b;
	if(b<a) swap(a, b);
	for(int i = 0; i < b; i++) cout << a;
}


Measured memory_bytes: 256
N, K = map(int, input().split())

height = []
for _ in range(N) :
    height.append(int(input()))

height.sort()
ans = float('inf')

for i in range(N-K+1) :
    diff = height[i + K - 1] - height[i]
    ans = min(ans, diff)

print(ans)

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

int main() {
    int n;
    cin >> n;
    vector<vector<int>> a(n,vector<int>(3));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            cin >> a.at(i).at(j);
        }
    }
    vector<vector<int>> dp(100010,vector<int>(3));
    dp[0][0] = 0;
    for(int i = 0; i < n; i++){  //重複回避のために重複が起きる条件の時にcontinueでスキップできるようにする
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(j == k){
                    continue;
                }
                dp[i+1][k] = max(dp[i+1][k], dp[i][j]+a[i][k]);
            }
        }
    }
    int happy = 0;
    for(int i = 0; i < 3; i++){
        happy = max(happy,dp[n][i]);
    }
    cout << happy << endl;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a<=0 and b>=0)
        cout << "Zero" << endl;
    else if(a>0 and b>0)
        cout << "Positive" << endl;
    else{
        if(abs(b-a)%2==0)
        cout << "Negative" << endl;
        else
        cout << "Positive" << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cfloat>
#include <algorithm>
#include <memory>
using namespace std; 

typedef long long ll; 
typedef unsigned long long ull;
typedef unsigned uint; 
typedef long double l_double;

#define vtr vector
#define PB push_back
#define EB emplace_back
#define gcd __gcd
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define st_ct static_cast // <>
#define TEST uint _ {}; cin >> _; while (_--)
#define PI (3.1415926535897932384626433832795)
#define MOD st_ct<int>(1e9 + 7)
#define EPS 1e-9
#define deb(x) cout<< #x << " --> " << x << endl;

template<typename T>
void vtrS(const vector<T> &ARR) 
{ for (T const &val: ARR) cout<<val<<" "; cout<<endl; }

template<typename T>
void vtrV(const vector<T> &ARR) 
{ for (T const &val: ARR) cout<<val<<endl; }

template<typename T>
void read_vvtr(vector<vector<T>> &ARR) 
{ for (vector<T> &i: ARR) for (T &j: i) cin >> j; }

template<typename T>
void vvtrS(const vector<vector<T>> &ARR) 
{ for (vector<T> const &i: ARR) { for (T const &j: i) cout<<j<<" "; cout<<endl; } }

template<typename T>
void vvtrNS(const vector<vector<T>> &ARR) 
{ for (vector<T> const &i: ARR) { for (T const &j: i) cout<<j; cout<<endl; } }

template<typename T>
T cntDigits(const T &N) { return (floor(log10(N)) + 1); }

template<typename T>
bool isPowOfTwo(const T &N) { return (N && (!(N&(N-1)))); }

template<typename T>
T lcm(T a, T b) { return ((a*b)/gcd(a, b)); }
// --------------------------------------------------------------------------------

//

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // cout.setf(std::ios::boolalpha);
    cout<<std::fixed<<std::setprecision(10); 
    // --------------------------------------
    
    int n {}, m {};
    cin >> n >> m;
    int sum {};
    for (int i {}; i < m; ++i) {
        int val {};
        cin >> val;
        sum += val;
    }
    if (n - sum >= 0) cout<<n - sum<<endl;
    else if (n - sum < 0) cout<< -1 << endl;
    return 0;
}

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



int main()
{
	int W, H, x, y, r;

	cin >> W >> H >> x >> y >> r;

	if (x - r >= 0 && x + r <= W && y + r <= H && y - r >= 0) {
		cout << "Yes" << endl;

	}else {
		cout << "No" << endl;

	}
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = (n-1); i >= 0; i--)
#define rea(i, a, b) for (int i = (a); i < (b); i++)
#define reab(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(),(a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;
/* END OF TEMPLATE */

int main()
{
    ll N;
    cin >> N;
    vll A(N);
    rep(i, N)
    {
        cin >> A[i];
    }
    ll g = A[0];
    rea(i, 1, N)
    {
        g = GCD(g, A[i]);
    }
    cout << g << endl;
}

Measured memory_bytes: 1024
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
#define REP(i, a) for (int i = 0; i < (a); i++)

int k, t;

int main() {
	int ans = 0;
	cin >> k >> t;
	int a;
	for (int i = 0; i < t; i++) {
		cin >> a;
		ans = max(ans, a - 1 - (k - a));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	char a;
	scanf("%c",&a);
	if(a=='A')
		printf("T\n");
	if(a=='T')
		printf("A\n");
	if(a=='C')
		printf("G\n");
	if(a=='G')
		printf("C\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define x first
#define y second
#define size(a) (ll)(a).size()

typedef long long ll;
typedef long double ld;

using namespace std;
ll n;
string s;

const ll MOD = 1e9 + 7;

ll binpow(ll number, ll stepen)
{
    ll result = 1;
    while(stepen)
    {
        if(stepen & 1)
        {
            result*=number;
            result %= MOD;
            stepen--;
        }

        number*=number;
        number %= MOD;
        stepen>>=1;
    }
    return result;
}

int main()
{
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");


    cin.tie(0);
    ios_base::sync_with_stdio(0);

    cin >> n;

    vector<ll> fact(n + 1, 1);
    vector<ll> secPow(n + 1, 1);
    vector<ll> eighthPow(n + 1, 1);

    for (ll i = 1; i <= n; ++i) {
        fact[i] = fact[i - 1] * i;
        fact[i] %= MOD;
        secPow[i] = (secPow[i - 1] * 2) % MOD;
        eighthPow[i]= (eighthPow[i - 1] * 8) % MOD;
    }

    ll ans = 0;
    for (ll i = 2; i <= n; ++i) {
        ll res = (fact[n] * binpow(fact[i], MOD - 2)) % MOD;
        res = (res * binpow(fact[n - i], MOD - 2)) % MOD;
        res = (res * eighthPow[n - i]) % MOD;
        res = (res * ((secPow[i] - 2 + MOD) % MOD)) % MOD;
        ans += res;
        ans %= MOD;
    }

    cout << ans;

}


Measured memory_bytes: 26600
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    ll A,B,C,D,N;
    ll ans=0;
    ll X[4];
    string S;
    bool F;
int main(){
    cin>>S;
    sort(ALL(S));
    F=(S[0]!=S[2]);
    cout<<(F?"Yes":"No")<<endl;

    return 0;
}


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

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

	if (s == "A") {
		cout << "T" << endl;
	}
	else if (s == "T") {
		cout << "A" << endl;
	}
	else if (s == "C") {
		cout << "G" << endl;
	}
	else{
		cout << "C" << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n,m;
    in>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>

using namespace std;

struct Cell {
    int e;
    int a;
};

double solve(vector<Cell>& cel, int pos, vector<int>& vs, int money,
             vector< map<int , double> >& mem){
    double retval = 0;
    int vl = vs.size();
    int cl = cel.size();
    if(!mem[pos].empty() && (mem[pos].find(money) != mem[pos].end())){
        return mem[pos][money];
    }
    if(pos >= cl) return money;
    for(int i=0; i<vl; ++i){
        int v = vs[i]; 
        if(pos+v >= cl) { retval += money; continue; }
        Cell& cur = cel[pos+v];
        if(cur.e == 0)
            retval += solve(cel, pos+v, vs, money, mem);
        else if(cur.e == 1) 
            retval += solve(cel, pos+v+cur.a, vs, money, mem);
        else if(cur.e == 2) 
            retval += solve(cel, pos+v, vs, money+cur.a, mem);
        else if(cur.e == 3) 
            retval += solve(cel, pos+v, vs, (money>cur.a) ? money-cur.a : 0, mem);
    }
    mem[pos][money] = retval/vl;
    return mem[pos][money];
}

int main(){
    while(1){
        int x,y,z;
        int i;
        int vl;
        cin >> x >> y >> z;
        if(x == 0 && y == 0 && z == 0) break;
        vector<int> vs(x);
        vector<Cell> cells(y);
        vector<map<int, double> > mem(y+100);
        for(i=0;i<x;++i){
            cin >> vs[i];
        }
        for(i=0;i<z;++i){
            int n;
            cin >> n;
            cin >> cells[n].e;
            cin >> cells[n].a;
        }
        cout << (int)solve(cells,0,vs,0,mem) << endl;
    }
}

Measured memory_bytes: 2388
s = gets.chomp.chars
a = ["A","C","G","T"]
max = 0

(0..s.size - 1).each do |i|
  sum = 0
  count = i
  dec = true
  while dec
    case s[count]
    when "A", "C", "G", "T"
      sum += 1
      count += 1
    else
      dec = false
    end
  end
  max = sum if max < sum
end

p max


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n,l;
	cin >> n;
	vector<ll> x(n);
	vector<ll> ans(n,0);
	ll counter = 0;
	for (ll i = 0;i < n;i++){
		cin >> l;
		x[i] = l;
	}
	for (ll i = n;i > 0;i--){
		ll m = 2;
		while(m* i <= n){
			ans[i - 1] += ans[m*i - 1];
			m++;
		}
		if (ans[i- 1] % 2 != x[i - 1]){
			ans[i - 1] = 1;
			counter++;
		}
		else{
			ans[i - 1] = 0;
		}
	}
	cout << counter <<endl;;
	for(ll i = 0;i < n;i++){
		if (ans[i] == 1)
		{
			cout << i+1 << ' ';
		}
	}
	return 0;
}

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

int main(){
	double a, b, x;
  	cin >> a >> b >> x;
  
  	double s = x/a;
  	double rad;
  	if(s >= a*b/2){
    	double h = (a*b-s)*2/a;
      	rad = atan2(h, a);
    } else {
    	double w = s*2/b;
      	rad = atan2(b, w);
    }
  	double PI = acos(-1);
  	double deg = rad/(2*PI)*360;
  	
  	printf("%.10f\n", deg);
}

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

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

    if(x<1200){
        cout<<"ABC"<<endl;
    }
    else {
        cout<<"ARC"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define ll long long int
#define pii pair<int, int>
#define mod 1000000007
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a == 1) a = 14;
    if (b == 1) b = 14;
    if (a > b) cout << "Alice\n";
    else if (a < b) cout << "Bob\n";
    else cout << "Draw\n";
}

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

int main() {
    int x;cin>>x;
    for (ll i=0;i<200;i++)
        for (ll j=-i;j<i;j++)
            if (i*i*i*i*i-j*j*j*j*j==x)
                cout<<i<<' '<<j<<endl;
    return 0;
}

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

int main()
{
        int n;
        cin >> n;
        double a[n];
      	double dp[n+1][n+1];
        int i,j;
        double sum = 0;
        for(i=0;i<n;i++)
        {
            cin >> a[i];
        }
        dp[0][0] = 1;
        for(i=1;i<=n;i++)
        {
            dp[0][i] = 0;
            dp[i][0] = (1-a[i-1])*dp[i-1][0];
        }
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=n;j++)
            {
                dp[i][j] = a[i-1]*dp[i-1][j-1] + (1-a[i-1])*dp[i-1][j];
            }
        }
        for(i=(n+1)/2;i<=n;i++)
        {
            sum += dp[n][i];
        }
        cout << setprecision(10) << sum;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    ll a,b;cin>>a>>b;
    out((a+b)/2);
}


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

//#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define LL long long

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

	int ans;
	if(k <= a) {
		ans = k;		
	} 
	else if(k <= a+b) {
		ans = a;
	} 
	else {
		k = k-(a+b);
		ans = a - k;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3652
import sys

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    count = [0] * (N + 1)
    for _ in range(M):
        a, b = map(int, input().split())
        count[a] += 1
        count[b] += 1

    if all(c % 2 == 0 for c in count):
        ans = "YES"
    else:
        ans = "NO"
    print(ans)


if __name__ == "__main__":
    main()


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

#define N 100000

int compare(const void *a, const void *b) {
	int ia = *(int *) a;
	int ib = *(int *) b;

	return ia - ib;
}

int main() {
	static int aa[N];
	int n, i, j, ans;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]);
	qsort(aa, n, sizeof *aa, compare);
	ans = 0;
	for (i = 0; i < n; ) {
		j = i;
		while (j < n && aa[j] == aa[i])
			j++;
		if ((j - i) % 2)
			ans++;
		i = j;
	}
	printf("%d\n", ans);
	return 0;
}


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

int x[100000];
int r[17][100000];
int main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%d", &x[i]);
	int l, q; scanf("%d%d", &l, &q);
	rep(i, n)r[0][i] = upper_bound(x, x + n, x[i] + l) - x - 1;
	for (int i = 1; i < 17; i++) {
		rep(j, n)r[i][j] = r[i - 1][r[i - 1][j]];
	}
	rep(i, q) {
		int a, b; scanf("%d%d", &a, &b); a--; b--;
		if (a > b)swap(a, b);
		int cnt = 0;
		for (int i = 16; i >= 0; i--) {
			if (r[i][a] < b) {
				a = r[i][a]; cnt += 1 << i;
			}
		}
		printf("%d\n", cnt + 1);
	}
}

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

int main()
{
    int A,B,C;
    while(scanf("%d %d %d",&A,&B,&C)!=EOF)
    {
        if(A==B)
            printf("%d\n",C);
        else
        {
            if(A==C)
                printf("%d\n",B);
            else
                printf("%d\n",A);
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int q;
  cin>>q;
  string fs,bs;
  int state;
  int rstate=0;
  while(q--)
  {
    cin>>state;
    if(state==2)
    {
      int f;
      char c;
      cin>>f>>c;
      if(rstate==0)
      {
        if(f==1)fs.push_back(c);
        else if(f==2) bs.push_back(c);
      }
      else
      {
        if(f==1)bs.push_back(c);
        else if(f==2) fs.push_back(c);
      }
    }
    else if(state==1) rstate=(rstate+1)%2;
  }
 
   if(rstate==0)
   {
     for(int i=fs.length()-1;i>=0;i--)cout<<fs[i];
     cout<<s;
     cout<<bs;
   }
   else
   {
     for(int i=bs.length()-1;i>=0;i--)cout<<bs[i];
     for(int i=s.length()-1;i>=0;i--)cout<<s[i];
     cout<<fs;
   }  
   return 0;
  }

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

int main(){
	string S;
	cin>>S;
	if(S.size()%2==0){
		rep(i,S.size()){
			if(i%2==0){
				if(S.at(i)=='h'){
					
				}else{
					cout<<"No"<<endl;
					return 0;
				}
			}else{
				if(S.at(i)=='i'){
					
				}else{
					cout<<"No"<<endl;
					return 0;
				}
			}
		}
	}else{
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
return 0;}

/*compile
g++ code.cpp
./a.out
run*/

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = 10**6#float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
ab = [LIST() for _ in range(N-1)]
c = sorted(LIST())
print(sum(c)-c[-1])

cnt = [0]*N
graph = [[] for _ in range(N)]

for a, b in ab:
	graph[a-1].append(b-1)
	graph[b-1].append(a-1)
	cnt[a-1] += 1
	cnt[b-1] += 1

ans = [0]*N

q = deque([cnt.index(max(cnt))])
while q:
	p = q.popleft()
	ans[p] = c.pop()
	for i in graph[p]:
		if ans[i] == 0:
			q.append(i)

print(*ans)

Measured memory_bytes: 13940
from itertools import accumulate

N = int(input())
A = [int(zz) for zz in input().split()][::-1]
B = [int(zz) for zz in input().split()][::-1]

B = list(accumulate(B))

for i in range(1,N):
    A[i] += max(A[i-1],B[i])

if N == 1:
    print(A[0]+B[0])
else:
    print(A[-1])

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

using namespace std;
typedef long long ll;


const int N=2e5+100;

ll cnt[N];
struct edge
{
    int to,next;
}ed[N*2];

int head[N];
int tot=1;
int vis[N];
void add_edge(int u,int v)
{
    ed[tot].to=v;
    ed[tot].next=head[u];
    head[u]=tot++;
}

void bfs()
{
    queue<int>q;q.push(1);
    vis[1]=1;
    while(q.size()){
        int k=q.front();q.pop();
        for(int i=head[k];i;i=ed[i].next){
            int kk=ed[i].to;
            if(!vis[kk]){
            cnt[kk]+=cnt[k];
            q.push(kk);
            vis[k]=1;
            }
        }
    }
}

int main()
{
    int n,m;
    int u,v;
    scanf("%d%d",&n,&m);
    for(int i=1;i<n;i++){
        scanf("%d%d",&u,&v);
        add_edge(u,v);
        add_edge(v,u);
    }
    for(int i=1;i<=m;i++){
        scanf("%d%d",&u,&v);
        cnt[u]+=v;
    }
    bfs();
    for(int i=1;i<=n;i++){
        printf("%lld ",cnt[i]);
    }
    return 0;
}


Measured memory_bytes: 10152
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

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


void Main(){
    int A, B, C;
    cin >> A >> B >> C;
    if(
        A == B && B != C ||
        B == C && A != B ||
        C == A && C != B
    ){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
}



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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

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

Measured memory_bytes: 3588
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    string s;
    cin >> s;

    ll x = 0, y = 0;
    ll len = s.size();

    // 0101010...
    for (int i = 0; i < len; i++) {
        if (i & 1) {
            if (s[i] != '1') {
                x++;
            }
        } else {
            if (s[i] != '0') {
                x++;
            }
        }
    }

    // 101010...
    for (int i = 0; i < len; i++) {
        if (i & 1) {
            if (s[i] != '0') {
                y++;
            }
        } else {
            if (s[i] != '1') {
                y++;
            }
        }
    }

    cout << min(x,y) << endl;



    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
 
int main(){
 
  int N;
  int K;
  char S[60];
  char T[60];
  cin >>N;
   cin >>K;
   cin >>S;
  
  if ((S[K-1] >= 'A') && (S[K-1] <= 'Z')) { 
     T[K-1]=S[K-1]+0x20;
  } else{
    T[K-1]=S[K-1];
  }
    S[K-1]=T[K-1];
   
  
   cout << S << endl;
     
    }

Measured memory_bytes: 256