akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
from itertools import product
from collections import defaultdict
def inpl(): return list(map(int, input().split()))

MOD = 10**9 + 7

N = int(input())
DP = defaultdict(int)
for a, b, c in product(range(4), repeat=3):
    DP[(a, b, c)] = 1

DP[(0, 2, 1)] = 0
DP[(0, 1, 2)] = 0
DP[(2, 0, 1)] = 0

for i in range(N-3):
    DP2 = defaultdict(int)
    for a, b, c in product(range(4), repeat=3):
        DP2[(b, c, 0)] = (DP2[(b, c, 0)] + DP[(a, b, c)])%MOD

        if (b, c) != (0, 2) and (a, c) != (0, 2) and (a, b) != (0, 2) and (b, c) != (2, 0):
            DP2[(b, c, 1)] = (DP2[(b, c, 1)] + DP[(a, b, c)])%MOD
        if (b, c) != (0, 1):
            DP2[(b, c, 2)] = (DP2[(b, c, 2)] + DP[(a, b, c)])%MOD

        DP2[(b, c, 3)] = (DP2[(b, c, 3)] + DP[(a, b, c)])%MOD
    DP = DP2
print(sum(DP.values())%MOD)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;

vi ABC(3);

int main() {
  scanf("%d %d %d", &ABC[0], &ABC[1], &ABC[2]);
  sort(ABC.begin(), ABC.end());

  printf("%d\n", ABC[2] * 10 + ABC[1] + ABC[0]);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long int A,B,K;
long long int aa, bb;
int main(){
    scanf("%lld%lld%lld", &A, &B, &K);
    if (A > K){
        aa = A-K;
        bb = B;
    } else {
        aa = 0;
        K -= A;
        if (B > K){
            bb = B-K;
        } else {
            bb = 0;
        }
    }

    printf("%lld %lld\n", aa, bb);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1000000000
#define MOD 1000000007
#define mod(x) ((x % MOD) + MOD) % MOD

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

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

  bool flag = false;
  while (true)
  {
    if (S.size() == 0) {
      flag = true;
      break;
    } else if (S.substr(0, 8) == "dreamera") {
      S.erase(S.begin(), S.begin() + 5);
      continue;
    } else if (S.substr(0, 7) == "dreamer") {
      S.erase(S.begin(), S.begin() + 7);
      continue;
    } else if (S.substr(0, 5) == "dream") {
      S.erase(S.begin(), S.begin() + 5);
      continue;
    } else if (S.substr(0, 6) == "eraser") {
      S.erase(S.begin(), S.begin() + 6);
      continue;
    } else if (S.substr(0, 5) == "erase") {
      S.erase(S.begin(), S.begin() + 5);
      continue;
    } else {
      flag = false;
      break;
    }
  }

  if (flag) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }

  return 0;
}


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

int main(){
	string a,b,c; cin>>a>>b>>c;
	char n=a[0]; a.erase(0,1);
	while(1){
		if(n=='a'){
			if(a.size()==0){cout<<'A'<<endl; return 0;}
			n=a[0];
			a.erase(0,1);
		}else if(n=='b'){
			if(b.size()==0){cout<<'B'<<endl; return 0;}
			n=b[0];
			b.erase(0,1);
		}else{
			if(c.size()==0){cout<<'C'<<endl; return 0;}
			n=c[0];
			c.erase(0,1);
		}
	}
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;

int main(){
    int N;
    cin>>N;
    for(int i=1;;i++){
        int a=(int)(double)i*1.08;
        if(a==N){
            cout<<i<<endl;
            return 0;
        }else if(a>N){
            cout<<":("<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[0]*n
x=[]
y=[]
z=[]
for i in range(n-1):
	p,pp,ppp=map(int,input().split())
	x.append(p)
	y.append(pp)
	z.append(ppp)
for i in range(n-2):
	ans=y[i]+x[i]
	for j in range(n-i-2):
		if ans<y[j+1+i]:
			ans=y[j+1+i]
		if (ans-y[j+1+i])%z[j+1+i]!=0:
			ans+=z[j+1+i]-((ans-y[j+1+i])%z[j+1+i])
		ans+=x[j+1+i]
	print(ans)
print(y[-1]+x[-1])
print(0)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
	ll x;
	cin>>x;
	return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 
 
vector <vector <int> > g;
vector <int> val;
vector <int> a;
 int dfs(vector <bool> &visited,int s);
 vector <int> test;
  vector <int> ans;
  void rerooting(int s,vector <bool> &visited);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll r=nxtl(),c=nxtl();
    if(r==1||c==1)
    {
        cout<<"1\n";
        return 0;
    }
    cout<<(r*c+1)/2<<endl;

    return 0;   
}


 
 


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

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

    vector<int64_t> as(n), bs(n), cs(n);
    for (auto& a : as)
    {
        cin >> a;
    }
    for (auto& b : bs)
    {
        cin >> b;
    }
    for (auto& c : cs)
    {
        cin >> c;
    }
    sort(as.begin(), as.end());
    sort(bs.begin(), bs.end());
    sort(cs.begin(), cs.end());

    int64_t ans = 0;
    for (auto b : bs)
    {
        const auto count_a = n - std::distance(lower_bound(as.begin(), as.end(), b), as.end());
        const auto count_c = std::distance(upper_bound(cs.begin(), cs.end(), b), cs.end());
        ans += count_a * count_c;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define MOD 1000000007
#define all(c) c.begin(), c.end()
#define rep(i, s, e) for (auto i = s; i < e; i++)
#define peek(v)      \
	for (auto i : v) \
		cout << i << ' ';

ll mul(ll a, ll b)
{
	return ((a % MOD) * (b % MOD)) % MOD;
}

void solve()
{
	int n, m;
	cin >> n >> m;
	if (abs(n - m) > 1)
		cout << 0;
	else
	{
		int ans = 1;
		rep(i, 1, n + 1)
			ans = mul(ans, i);
		rep(i, 1, m + 1)
			ans = mul(ans, i);
		if (m == n)
			cout << mul(ans, 2);
		else
			cout << ans;
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	cerr << "\n\n~" << 500 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 256
N = int(input())
K = int(input())
A = 0
keta = len(str(N))
if K ==1:
    A = 9*(keta-1)
if K ==2:
    A = 9*9*(keta-1)*(keta-2)//2
if K ==3:
    A = 9*9*9*(keta-1)*(keta-2)*(keta-3)//6
nc = 1
#    print(N,K,keta,A)
while nc <= 3 and keta >=1:
        # abcd... -> 1000000 - a0000000
    T = N//(10**(keta-1))%10
#        print(T,nc)
    if T == 0:
        keta -=1
    else:
        if (nc == 1 and K==1) or (nc==2 and K==2) or (nc==3 and K==3):
            A = A + (T)
        if ((nc == 1 and K ==2) or (nc ==2 and K==3)):
            A = A + int((T-1)*9*(keta-1))
        if (nc==2 and K==2) or (nc==3 and K==3):
            A = A + 9*(keta-1)
        if (nc==1 and K ==3):
            A = A + int((T-1)*9*9*(keta-1)*(keta-2)/2)
        if (nc==2 and K==3):
            A = A + int(9*9*(keta-1)*(keta-2)/2)
        nc +=1
        keta -=1
#        print(A)
        
print(A)


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
typedef vector<ii> vii;

#define solve imAwesome
#define for0(i,n) for(int i=0; i<(int)n; i++)
#define forn(i,n) for(int i=1; i<=(int)n; i++)
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define all(x) x.begin(),x.end()
#define endl cout << "\n";
#define debug cout << "Aqui\n";
#define deb(i) cout << "Aqui " << (ld) i << "\n";
#define pi 3.141592653589793238462643383279502884197169399375105820974944592307816406286L

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	//auto T=clock();
	
	ll a,b;
	cin >> a >>b;
	cout << a*b << "\n";

}


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

typedef long long ll;
int main()
{
  int a,b;
  cin>>a>>b;
  if((a<=8)&&(b<=8))
  {
    cout<<"Yay!"<<endl;
  }
  else
  {
    cout<<":("<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int K; cin >> K;
    int a[32] = {
        1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
    };
    cout << a[K-1] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}


int solve(string &num){
	if(num.size() <= 1) return 0;
	
	vector<vector<int>> dp(num.size()+1,vector<int>(2,INF));
	
	if((num[0] - '1')%3 <= (num[1] - '1')%3)dp[1][1] = 0;
	if((num[0] - '1')%3 >= (num[1] - '1')%3)dp[1][0] = 0;
	
	for(int i = 2; i < num.size(); i++){
		if((num[i] - '1')%3 >= (num[i-1] - '1')%3) dp[i][1] = min(dp[i-1][0],dp[i-1][1] + 1);
		if((num[i] - '1')%3 <= (num[i-1] - '1')%3) dp[i][0] = min(dp[i-1][1],dp[i-1][0] + 1);
	}
	
	return min(dp[num.size()-1][0],dp[num.size()-1][1]);
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	while(true){
		string num;
		
		cin>>num;
		
		if(num == "#") break;
		
		cout<<solve(num)<<endl;;
	}
	
	return 0;
}


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


signed main()
{
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 char s;
 cin>>s;
int n = s-'a';
 if(n < 0)
 {
   cout<<'A'<<"\n";
 }
 else
 {
   cout<<'a'<<"\n";
 }
 return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll inf = 1LL << 55;
ll mod = 1000000007;

int a[1000010];

using namespace std;

int main(){
    FAST;
    //freopen("in.in", "r", stdin);

    int n; cin >> n;

    int index = 1;
    int sofar = 0;
    while(true){
        if (index == 1) sofar = n;
        else {
            if (sofar%2 == 0) sofar /= 2;
            else sofar = sofar * 3 + 1;
        }
        if (a[sofar] != 0) {
            cout << index << endl;
            return 0;
        }
        a[sofar] = index;
        index++;
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] arr1 = br.readLine().split(" ");
            int n = Integer.parseInt(arr1[0]), m = Integer.parseInt(arr1[1]);
            // int n = 3, m = 4;

            int[][] A = new int[n][m];
            int[] b = new int[m];
            // A
            // String[] hoge = {"1 2 0 1", "0 3 0 1","4 1 1 0"};
            for(int i=0; i<n; i++) {
                String[] arr2 = br.readLine().split(" ");
                // String[] arr2 = hoge[i].split(" ");
                for(int j=0;j<m;j++){
                    A[i][j] = Integer.parseInt(arr2[j]);
                }
            }
            // b
            // int[] fuga = {1, 2, 3, 0};
            for(int i=0; i<m; i++) {
                b[i] = Integer.parseInt(br.readLine());
                // b[i] = fuga[i];
            }
            
            for(int i=0; i<n; i++) {
                int tmp = 0;
                for(int j=0; j<m; j++){
                    tmp += A[i][j]*b[j];
                }
                System.out.printf("%d\n", tmp);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 27824
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,k = readline() |> split |> parseMap
	h = readline() |> split |> parseMap |> sort
	s = 0
	for i in 1:n-k
		s += h[i]
	end
	println(s)
end

main()

Measured memory_bytes: 127108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	char s; scanf("%c", &s);
	printf("%c\n", s+1);
}


Measured memory_bytes: 764
from sys import stdin
input=stdin.readline
n=int(input())
l=[tuple(map(int,input().split())) for i in range(n)]
l.sort(key=lambda x:sum(x))
pre=-10**8
cnt=0
for i,j in l:
  if pre<=i-j:cnt+=1;pre=i+j
print(cnt)

Measured memory_bytes: 21396
#include<stdio.h>
#include<iostream>
#include<string>

using namespace std;
int main(){
    string t,w;
    int c = 0,i;
    size_t pos;
    cin >> w;
    while((cin >> t) && (t != "END_OF_TEXT")){
        for(int i = 0;i < t.length();i++){
            if(t[i] >= 'A' && t[i] <= 'Z') t[i] += 'a' - 'A';
        }
        pos = 0;
        if(t == w) c++;
    }
    printf("%d\n",c);
    return 0;
}



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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

const int SIZE=100000;
int N,W;
int w[SIZE],v[SIZE];

double f(double x){
    double ret=W*x;
    rep(i,N)ret+=max(0.0,v[i]-w[i]*x);
    return ret;
}

signed main(){
    scanf("%lld%lld",&N,&W);
    rep(i,N)scanf("%lld%lld",&w[i],&v[i]);

    double lb=0,ub=100000;
    rep(i,100){
        double m1=(lb*2+ub)/3,m2=(lb+ub*2)/3;
        if(f(m1)<f(m2))ub=m2;
        else lb=m1;
    }

    printf("%.20f\n",f(lb));
    return 0;
}

Measured memory_bytes: 3304
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 4005, mo = 1000000007 ;
using namespace std ;

int n, m, k, f[N][N] ;

inline void upd(int &x, int y) {
	x = (x + y) % mo ;
}

int main() {
	scanf("%d%d%d", &n, &m, &k) ;
	int L = (n + m - 1) / (k - 1) ;
	f[0][0] = 1 ;
	int res = 0 ;
	rep(i, 1, L) {
		rep(j, 0, k - 1) rep(p, 0, n) {
			if (p + j > n) continue ;
			upd(f[i][p + j], f[i - 1][p]) ;
			if (j == 0) continue ;
			int x = p + j ;
			if (x % (k - 1) != n % (k - 1)) continue ;
			if (i * (k - 1) - x + 1 > m) continue ;
			if ((i * (k - 1) - x + 1) % (k - 1) != m % (k - 1)) continue ;
			upd(res, f[i - 1][p]) ;
		} 
	}
	printf("%d\n", res) ;
	return 0 ;
}

Measured memory_bytes: 62080
T_1, T_2 = map(int, input().split())
A_1, A_2 = map(int, input().split())
B_1, B_2 = map(int, input().split())

f = (A_1 - B_1) * T_1
s = (A_2 - B_2) * T_2

if f * (f + s) > 0:
	ans = 0
elif f * (f + s) == 0:
	ans = 'infinity'
else:
	ans = 1
	if f < 0:
		f *= -1
		s *= -1
	d = f + s
	div, mod = divmod(f, abs(d))
	ans += div * 2
	if mod == 0:
		ans -= 1

print(ans)

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

int main(){

  int n, ans, cnt, valid;
  int team[101][2] = {0};

  while(scanf("%d, %d", &n, &ans) != EOF){
    if(n == 0 && ans == 0) break;
    team[n][0] = ans;
  }

  cnt = 1;
  for(int i=30; i>=0; i--){
    valid = 0;
    for(int j=1; j<101; j++){
      if(team[j][0] == i){
        valid = 1;
        team[j][1] = cnt;
      }
    }
    if(valid == 1) cnt++;
  }

  while(cin >> n){
    cout << team[n][1] << endl;
  }

  return 0;

}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N+1,0);
  vector<int> B(N,0);
  for(int i=1; i<N; i++){ cin >> B.at(i); }
  
  for(int i=2; i<N; i++){ A.at(i) = min(B.at(i),B.at(i-1));}
  A.at(1) = B.at(1);
  A.at(N) = B.at(N-1);
  cout << accumulate(A.begin(),A.end(),0) << endl;

  return 0;  
}
 

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

using namespace std;

int countDivisor(int num) {
    int count = 0;
    for (int i = 1; i <= num; i++) {
        if (!(num % i)) {
            count++;
        }
    }

    return count;
}

int main() {
    int N;  // 1 <= N <=200
    cin >> N;

    int res = 0;
    for (int i = 1; i <= N; i++) {
        bool isOdd = i % 2;
        int countOfDivisor = countDivisor(i);
        if (isOdd && countOfDivisor == 8) {
            res++;
        }
    }

    cout << res << endl;

    return 0;
}

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

using namespace std;

const int MAXN = 2e5 + 5;

int n , a ,b  , aa , bb , hi[MAXN] , t , hei[MAXN] , low[MAXN] , vis[MAXN] , up[MAXN][23];
long long sol ;

vector<int > adj[MAXN];
bool is_a(int a, int b)
{
    return low[b]>=low[a]&&hi[b]<=hi[a];
}
int lca(int a, int b)
{
    if(is_a(a,b))return a;
    if(is_a(b,a))return b;
    for(int i=21;i>=0;i--)
        if(!is_a(up[a][i],b) )
            a = up[a][i];
    return up[a][0];
}
int dfs(int x,int l,int h=0)
{
    vis[x]=1;
    low[x]=t++;
    up[x][0]=l;
    hei[x]=h;
    for(int i=1;i<22;i++)
        up[x][i] = up[ up[x][i-1] ][i-1];
    for(auto u : adj[x])
        if(u!=x&&!vis[u])
            dfs(u,x,h+1);
    hi[x]=t++;
}

int lift(int x ,int y)
{
    int ret=0;
    if(y==1)return hei[x];
    for(int i=21;i>=0;i--)
        if(is_a(y,up[x][i]))
        {
            x = up[x][i];
            ret+=(1<<i);
        }
    return ret;
}

int dist(int a , int b)
{
    int lc = lca(a,b);
    return lift(a,lc)+lift(b,lc);
}
int ans ;

int solve(int x , int l , int d)
{
    int D = dist(bb , x) -1 ;
    if( D >= d )
        ans = max(ans , D);
    for(auto u : adj[x])
    {
        if(u==l)
            continue;
        solve(u  , x , d+1) ;
    }
}

int main()
{
    cin>>n>>aa>>bb;
    for(int i = 0;i<n-1;i++)
    {
        cin>>a>>b;
        adj[a].push_back(b) ;
        adj[b].push_back(a) ;
    }
    dfs(1 , 1 , 0);
    solve(aa , aa , 0);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 24192
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(void) {
    int H, W;

    cin >> H >> W;

    vector<string> S(H);
    vector<vector<int>> P(H, vector<int>(W, 0));
    
    for (int h = 0; h < H; h++) {
        cin >> S.at(h);
        
        for (int w = 0; w < W; w++) {
            if (S.at(h).at(w) == '#') {
                if ((w - 1) >= 0 && (h - 1) >= 0 && P.at(h - 1).at(w - 1) != -1) {
                    P.at(h - 1).at(w - 1) += 1;
                }

                if ((w - 1) >= 0 && P.at(h).at(w - 1) != -1) {
                    P.at(h).at(w - 1) += 1;
                }

                if ((h + 1) < H && (w - 1) >= 0 && P.at(h + 1).at(w - 1) != -1) {
                    P.at(h + 1).at(w - 1) += 1;
                }

                if ((h + 1) < H && P.at(h + 1).at(w) != -1) {
                    P.at(h + 1).at(w) += 1;
                }

                if ((h + 1) < H && (w + 1) < W && P.at(h + 1).at(w + 1) != -1) {
                    P.at(h + 1).at(w + 1) += 1;
                }

                if ((w + 1) < W && P.at(h).at(w + 1) != -1) {
                    P.at(h).at(w + 1) += 1;
                }

                if ((h - 1) >= 0 && (w + 1) < W && P.at(h - 1).at(w + 1) != -1) {
                    P.at(h - 1).at(w + 1) += 1;
                }

                if ((h - 1) >= 0 && P.at(h - 1).at(w) != -1) {
                    P.at(h - 1).at(w) += 1;
                }

                P.at(h).at(w) = -1;
            }
        }
    }
    
    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            int s = P.at(h).at(w);
            if (s != -1) {
                cout << s;
            }
            else {
                cout << "#";
            }
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define mp make_pair
using namespace std;

using ll = long long;
using ii = pair<int, int>;
const int INF = (int)10e9;
int N;
vector<int> v;
vector<int> dp;

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> N;
    v.resize(N);
    dp.resize(N);
    fill(all(dp), 0);

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

    for(int i = 1; i < N; i++) {
        if(i == 1) dp[i] = abs(v[i] - v[i-1]) + dp[i-1];
        else dp[i] = min(abs(v[i] - v[i-1]) + dp[i-1], abs(v[i] - v[i-2]) + dp[i-2]);
    }

    cout << dp[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
//Biscuits

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define nxvarep(n,x,a) ll n,x;cin>>n>>x;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<ll,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    nxvarep(n,p,a);
    int guu=0,ki=0;
    ll ans=1;
    rep(i,0,n){
        if(a[i]%2==0)guu++;
        else ki++;
    }
    if(ki==0)if(p==1){cout<<0<<nnn;return 0;}
    rep(i,0,guu)ans*=2;
    rep(i,0,ki-1)ans*=2;
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict


def solve():
    n, k = map(int, input().split())
    d = defaultdict(int)
    for a, b in (map(int, input().split()) for _ in range(n)):
        d[a] += b
    bk = bin(k)[2:]
    lbk = len(bk)
    e = {k: 0}
    for i, c in enumerate(bk):
        if c == '1':
            e[int(bk[:i] + '0' + '1' * (lbk - i - 1), 2)] = 0

    for a, b in d.items():
        for c in e:
            if a | c == c:
                e[c] += b
    return max(e.values())


print(solve())


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;
typedef long double Double;

int n;
int a[100000], b[100000], c[100000], ord[100000], tmp[100000];

void re(int *a) {
    forn(i, n) tmp[i] = a[ord[i]];
    forn(i, n) a[i] = tmp[i];
}

inline bool cmpX(const int &lhs, const int &rhs) {
    return -a[lhs] * b[rhs] < -a[rhs] * b[lhs];
}

inline bool cmpY(const int &lhs, const int &rhs) {
    return -b[lhs] * a[rhs] < -b[rhs] * a[lhs];
}

pair<Double, int> p[100000];

int fen[100000];

void fenInc(int pos) {
    for (; pos < n; pos |= pos + 1) {
        ++fen[pos];
    }
}

int fenGet(int pos) {
    int res = 0;
    for (; pos >= 0; pos = (pos & (pos + 1)) - 1) {
        res += fen[pos];
    }
    return res;
}

int main() {
    scanf("%d", &n);
    forn(i, n) {
        scanf("%d%d%d", a + i, b + i, c + i);
        c[i] *= -1;
        if (b[i] < 0) {
            a[i] *= -1;
            b[i] *= -1;
            c[i] *= -1;
        }
    }

    forn(i, n) ord[i] = i;
    sort(ord, ord + n, cmpX);
    re(a);
    re(b);
    re(c);
    Double lo = -1e18, hi = 1e18, mid;
    forn(_, 200) {
        mid = (lo + hi) / 2;
        forn(i, n) p[i] = mp((-c[i] - a[i] * mid) / b[i], i);
        sort(p, p + n);
        LL cnt = 0;
        memset(fen, 0, sizeof fen);
        forn(i, n) {
            cnt += fenGet(p[i].second);
            fenInc(p[i].second);
        }
        if (cnt < ((LL)n * (n - 1) / 2 + 1) / 2) {
            lo = mid;
        } else {
            hi = mid;
        }
    }
    printf("%.15f ", (double) lo);

    forn(i, n) {
        if (a[i] < 0) {
            a[i] *= -1;
            b[i] *= -1;
            c[i] *= -1;
        }
    }
    forn(i, n) ord[i] = i;
    sort(ord, ord + n, cmpY);
    re(a);
    re(b);
    re(c);
    lo = -1e18, hi = 1e18;
    forn(_, 200) {
        mid = (lo + hi) / 2;
        forn(i, n) p[i] = mp((-c[i] - b[i] * mid) / a[i], i);
        sort(p, p + n);
        LL cnt = 0;
        memset(fen, 0, sizeof fen);
        forn(i, n) {
            cnt += fenGet(p[i].second);
            fenInc(p[i].second);
        }
        if (cnt < ((LL)n * (n - 1) / 2 + 1) / 2) {
            lo = mid;
        } else {
            hi = mid;
        }
    }
    printf("%.15f\n", (double) lo);
    return 0;
}


Measured memory_bytes: 4480
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	int N;
	scanf("%d\n", &N);
	char S[N];
	vector<int> alphabet[26];
	for (int i = 0; i < N; ++i){
		scanf("%c", &S[i]);
		alphabet[S[i] - 'a'].push_back(i);
	}
	int both[N];
	both[0] = 0;
	int answer = 0;
	for (int i = 0; i < N - 1; ++i)
	{
		if(*lower_bound(alphabet[S[i] - 'a'].begin(), alphabet[S[i] - 'a'].end(), 0) >= i && upper_bound(alphabet[S[i] - 'a'].begin(), alphabet[S[i] - 'a'].end(), i) != alphabet[S[i] - 'a'].end()) both[i + 1] = both[i] + 1;
		else if(*lower_bound(alphabet[S[i] - 'a'].begin(), alphabet[S[i] - 'a'].end(), 0) < i && upper_bound(alphabet[S[i] - 'a'].begin(), alphabet[S[i] - 'a'].end(), i) == alphabet[S[i] - 'a'].end()) both[i + 1] = both[i] - 1;
		else both[i + 1] = both[i];
		if(both[i + 1] > answer) answer = both[i + 1];
	}
	printf("%d\n", answer);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;

int main(){
  int z,x,y,ans;

  while(cin >> z && z){ans=0;
    for(x=1;pow((double)x,3)<=pow((double)z,3);x++){
      for(y=1;pow((double)x,3)+pow((double)y,3)<=pow((double)z,3);y++){ 
	if(pow((double)x,3)+pow((double)y,3) <= pow((double)z,3))ans = max(ans,(int)(pow((double)x,3)+pow((double)y,3)));
      }
    }
    cout << pow((double)z,3)-ans << endl;
  }
  return 0;
}

Measured memory_bytes: 924
# https://atcoder.jp/contests/abc155/tasks/abc155_b



N = gets.to_i
As = gets.split.map(&:to_i)

As.each do |a|
  if a.even? && a % 3 != 0 && a % 5 != 0
    puts 'DENIED'
    exit
  end
end
puts 'APPROVED'


Measured memory_bytes: 3836
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main{
    public static final int HIT = 0; // ??????????????????????????????
    public static final int BLOW = 1; // ??????????????????????????????

    public static void main(String[] args) throws IOException {

	Scanner sc = new Scanner(System.in);
	ArrayList<int[]> outList = new ArrayList<>();

	while (sc.hasNextLine()) {
	    int[] answer = getNumberArray(sc.nextLine().split(" ")); // ?????????????????????

	    int[] expected = getNumberArray(sc.nextLine().split(" ")); // ?§£??????????????????

	    int[] hitAndBlow = getHitAndBlow(answer, expected);

	    outList.add(hitAndBlow);
	}

	for (int[] hitAndBlow : outList) {
	    System.out.println(hitAndBlow[HIT] + " " + hitAndBlow[BLOW]);
	}
	sc.close();
    }

    /**
     * ??\???????????????????????????0???9???????????????????????????????????????????´??????????????????????
     * 
     * @param input
     * @return
     */
    public static int[] getNumberArray(String[] input) {
	int[] numbers = new int[10]; // 0???9?????°????????¶????????¨?????????
	Arrays.fill(numbers, 0); // 0??§?????????
	// ???????????°????????????????????????
	// ??????????????°????????????????????????????????????????????±??????????????????
	for (int i = 0; i < input.length; i++) {
	    // ???????????????????????????
	    int num = Integer.parseInt(input[i]);

	    for (int j = 0; j < 10; j++) {
		if (num == j) {
		    numbers[j] = i + 1;
		}
	    }
	}
	return numbers;
    }

    /**
     * ?????? ????????¨?§£????????¢???????????§?????????????????¨?????????????????????????´????????????????????????????
     * 
     * @param answer
     * @param expected
     * @return hitandblow?????????
     */
    public static int[] getHitAndBlow(int[] answer, int[] expected) {

	int[] hitAndBlow = new int[2]; // 0???hit 1???blow

	for (int i = 0; i < 10; i++) {
	    if (answer[i] == 0) {
		continue;
	    }
	    if (answer[i] == expected[i]) {
		hitAndBlow[HIT]++;
		continue;
	    }

	    if (answer[i] != 0 && expected[i] != 0) {
		hitAndBlow[BLOW]++;
		continue;
	    }
	}

	return hitAndBlow;
    }
}

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

int to9(int a)
{
	int cnt=0;
	while(a!=0)
	{
		int temp=a%9;
		cnt+=temp;
		a/=9;
	}
	return cnt;
}

int to6(int a)
{
	int cnt=0;
	while(a!=0)
	{
		int temp=a%6;
		cnt+=temp;
		a/=6;
	}
	return cnt;
}

int main()
{
	//cout<<to6(118);
	int n;
	cin>>n;
	int minn=1000000;
	for(int i=0; i<=n; i++)
	{
		if(i%9!=0) continue;
		int temp=n-i;
		int n=to9(i); int s=to6(temp); 
		minn=min(minn, n+s);
		//cout<<n <<" " <<s <<endl;
	}
	cout<<minn;
}


Measured memory_bytes: 256
using static System.Console;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadLine().ToCharArray();

            foreach (var item in n)
            {
                Write(item == '1' ? "9" : "1");
            }
            Write("\n");
        }
    }
}


Measured memory_bytes: 13140
x,y = map(int, input().split())
b = min((x, y))
a = max((x, y)) % b
if a == 0:
    print(b)
else:
    for i in range(1, a + 1):
        if a % i == 0 and b % (a / i) == 0:
            print(int(a / i))
            break


Measured memory_bytes: 5608
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int n,i; int a[100];
	scanf("%d",&n);
	for (i = 0; i < n; ++i) scanf("%d", &a[i]);
	for (i = n-1; i >=0; --i){
		if (i != n-1) printf(" ");
		printf("%d", a[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var B = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var A = Enumerable.Repeat(int.MaxValue, N).ToArray();

        for (int i = 0; i < N - 1; i++)
        {
            A[i] = Math.Min(A[i], B[i]);
            A[i + 1] = Math.Min(A[i + 1], B[i]);
        }

        var ans = A.Sum();

        WriteLine(ans);
    }
}


Measured memory_bytes: 28292
#include <iostream>
#include <vector>

using namespace std;
const int N = 1e5+1;

vector < int > g[N];
int dp[N];

int dfs(int v) {
	if(dp[v]) return dp[v];
	if(g[v].size() == 0) return 0;
	for(int u : g[v]) {
		dp[v] = max(dp[v], dfs(u) + 1);
	}

	return dp[v];
}

main() {
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
	  int a, b; cin >> a >> b;
		g[a].push_back(b);
	}

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

	cout << ans << endl;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};

int main(){
  int n,k,s; cin >> n >> k >> s;
  vi ans(n);
  rep(i,n) {
    if(s == 1e9) ans[i] = 1e9-1;
    else ans[i] = s+1;
  }
  rep(i,k) ans[i] = s;

  rep(i,n) cout << ans[i] << endl;

}

Measured memory_bytes: 1664
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskD {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = in.nextInt();
			}

			int[] sorted = a.clone();
			Arrays.sort(sorted);
			int l = -1;
			int r = n - 1;
			long total = (long) n * (n + 1) / 2;
			while (r - l > 1) {
				int m = (l + r) / 2;
				if (countSubstringsWithMedianLessThanOrEqualTo(a, sorted[m]) > total / 2) {
					r = m;
				} else {
					l = m;
				}
			}
			out.println(sorted[r]);
		}

		private long countSubstringsWithMedianLessThanOrEqualTo(int[] a, int m) {
			int n = a.length;
//		long res = 0;
//		for (int i = 0; i < n; i++) {
//			List<Integer> cur = new ArrayList<>();
//			for (int j = i; j < n; j++) {
//				cur.add(a[j]);
//				List<Integer> b = new ArrayList<>(cur);
//				Collections.sort(b);
//				if (b.get(b.size() / 2) <= m) {
//					++res;
//				}
//			}
//		}
//		return res;

			int[] s = new int[n + 1];
			for (int i = 0; i < n; i++) {
				s[i + 1] = s[i] + (a[i] <= m ? 0 : 1);
			}

			for (int i = 0; i < s.length; i++) {
				s[i] = 2 * s[i] - i + n;
			}

			return TaskD.InversionsCounter.countInversions(s, 3 * n);
		}

		static class InversionsCounter {
			public static long countInversions(int[] a, int k) {
				int n = a.length;

				int[] tree = new int[k];
				long ans = 0;
				for (int i = n - 1; i >= 0; i--) {
					ans += sum(tree, a[i] - 1);
					add(tree, a[i], 1);
				}
				return ans;
			}

			private static void add(int[] tree, int pos, int val) {
				while (pos < tree.length) {
					tree[pos] += val;
					pos |= pos + 1;
				}
			}

			private static long sum(int[] tree, int r) {
				long res = 0;
				while (r >= 0) {
					res += tree[r];
					r = (r & (r + 1)) - 1;
				}
				return res;
			}

		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

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

	}
}



Measured memory_bytes: 46316
def merge(l,r,a):
    l1 = len(l)
    r1 = len(r)
    i,j,k = 0,0,0
    while j<l1 and k<r1:
        if l[j]<r[k]:
            a[i] = l[j]
            j+=1
        elif l[j] == r[k]:
            a[i]=l[j]
            j+=1
            global res
            res = False
            return 0
        else:
            a[i] = r[k]
            k+=1
        i+=1
    while j<l1:
        a[i] = l[j]
        j+=1
        i+=1
    while k<r1:
        a[i] = r[k]
        k+=1
        i+=1
    return a

def mergeSort(a):
    n = len(a)
    if n == 1:
        return a
    else:
        mid = n//2
        left = []
        right = []
        for i in range(mid):
            left.append(a[i])
        for i in range(mid, n):
            right.append(a[i])
        mergeSort(left)
        mergeSort(right)
        merge(left,right,a)
        return a


n = int(input())
a = list(map(int,input().split()))
res = True
s = mergeSort(a)
if res:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 25548
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, N) for(i = 0; i < N; i++)
#define ll long long

int main() {

  string S, T;
  cin >> S;
  cin >> T;

  T.pop_back();

  if(S == T)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main()
{
	int A, B;

	scanf("%d",&A);
	scanf("%d",&B);

	int x = A + B;
	int y = A - B;
	int z = A * B;

	int a = 0;

	

	if (x > y) {
		if (x > z) {
			a=x;
		}
		else {
			a=z;
		}
	}

	if (x == y) {
		if (x >= z) {
			a=x;
		}
		else {
			a=z;
		}
	}

	if (y > z) {
		if (x >y) {
			a=x;
		}
		else {
			a=y;
		}
	}

	if (y == z) {
		if (x >= y) {
			a=x;
		}
		else {
			a=y;
		}
	}

	if (z > x) {
		if (z > y) {
			a=z;
		}
		else {
			a=y;
		}
	}

	if (z == x) {
		if (z >= y) {
			a=z;
		}
		else {
			a=y;
		}
	}


	printf("%d\n", a);

	


}


Measured memory_bytes: 128
import java.util.*;
import java.math.*;

public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    // static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    static long[] fact = new long[100];
        public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        int ans = 0;
        if(k < a){
            System.out.println(k);
            return;
        }
        ans = a;
        k-=a;
        k-=b;
        if(k<=0){
            System.out.println(ans);
            return;
        }
        ans -= k;
        System.out.println(ans);
    }
    
}


Measured memory_bytes: 35528
#include<bits/stdc++.h>
//#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long int
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
}
void printMp(mp m)
{
  mp ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void printUmp(ump m)
{
  ump ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void printSt(st s)
{
  st ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void printMst(mst s)
{
  mst ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void printVec(vector<int>v)
{
for(int i=0;i<v.size();i++)cout<<v[i]<<' ';
}
void printVec2(vector<int>v[],int n)
{
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<v[i].size();j++)
            cout<<v[i][j]<<' ';
        cout<<endl;
    }
}
 set<pair<int,int>> primeset;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primeset.insert(mkp(p,1));
}
int32_t main()
{
fastio;
string s;in s;
for(int i=0;i<3;i++){
  if(s[i]==s[i+1])
      {
        cout<<"Bad";
        exit(0);
      }
}
cout<<"Good";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	if (a == 1)
	{
		a = 14;
	}
	if (b == 1)
	{
		b = 14;
	}
	if (a == b)
	{
		cout << "Draw" << endl;
	}
	else if (a > b)
	{
		cout << "Alice" << endl;
	}
	else
	{
		cout << "Bob" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
using namespace std;
int main() {
  int A, B, ans = 1;
  while (cin >> A >> B) {
    int L = A + B;
    ans = 1;
    for (int i = 0;; i++) {
      L /= 10;
      if (L == 0)
        break;
      ans++;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(15);
    int N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> R(8);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        if(A[i] < 3200)
        {
            R[A[i] / 400]++;
        }
        else{
            R[8]++;
        }
    }
    ll ans = 0;
    for (int i = 0; i < 8;i++)
    {
        if(R[i] > 0){
            ans++;
        }
    }
    if(ans == 0){
        cout << 1 << " ";
        cout << R[8] << endl;
    }
    else{
        cout << ans << endl;
        cout << ans + R[8] << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

void rd_edge(vv_ll& g,ll M){
  for (ll i=0;i<M;i++){
    ll x,y; cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
}

ll N,K;
v_ll A,B,C;
vv_ll G;
int main(){
  MOD=1000000007;
  cin >> N >> K;
  A.assign(N+10,0);
  B.assign(N+10,0);
  C.assign(N+10,0);
  G.assign(N+10,v_ll());
  rd_edge(G,N-1);
  queue <ll> que;
  ll ans = 1;
  que.push(1);
  A[1]=1;

  //TEST=true;
  while (!que.empty()){
    ll f=que.front();
    if (f!=1){
      B[f]++;
      B[C[f]]++;
    }
    ans*=(K-B[C[f]]);
    ans%=MOD;
    que.pop();
    for (ll i=0;i<G[f].size();i++){
      ll moveto=G[f][i];
      if (A[moveto]==0){
        A[moveto]=1;
        C[moveto]=f;
        que.push(moveto);
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 10232
#include <iostream>

 

using namespace std;

 

int main()
{
   int i, h, m, s, a, b, c;
   cin >> i;
   h = i / 3600;
   a = i - h * 3600;
   m = a / 60;
   b = i - m * 60;
   s = i - a - b;
   cout << h << ":" << m << ":" << -s << endl; 
   
   return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define int long long

using namespace std;


signed main(){
  int N;
  cin>>N;
  int A[N];
  int median;
  rep(i,N) cin>>A[i];
  rep(i,N) A[i] = A[i] - (i+1);
  sort(A, A+N);
  
  median = A[N/2];
  //cout << median << endl;
  int abs_sum = 0;
  rep(i, N){
    abs_sum += abs(A[i]-median);
  }
  cout << abs_sum << endl;
  return 0;
}


Measured memory_bytes: 1792