akhauriyash/Code-Regression huggingface dataset:
local function solve(a)
  local cnt = 0
  while 2 < a do
    a = (a - 1) // 2
    cnt = cnt + 1
  end
  return cnt
end

local x = io.read("*n")
local a = 2

local min, max = 2, 100000000000000000
while 1 < max - min do
  local mid = (min + max) // 2
  if solve(mid) <= x then
    min = mid
  else
    max = mid
  end
end
print(max - 1)


Measured memory_bytes: 256
//go:generate echo "https://atcoder.jp/contests/dp/tasks/dp_c"
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

type scanner struct{ *bufio.Scanner }

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 100000000)
	return &scanner{s}
}

func (s *scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *scanner) IntSlice(l int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := range sl {
		sl[i] = s.Int()
	}
	return sl
}

func (s *scanner) IntSlice2(l, n int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := 0; i < n; i++ {
		sl[i] = s.Int()
	}
	return sl
}

func solve(n int, u [][]int) int {
	t := make([][]int, n+1, n+1)
	for i := range t {
		t[i] = make([]int, 3, 3)
	}
	for i := 0; i < n; i++ {
		for j := 0; j < 3; j++ {
			for k := 0; k < 3; k++ {
				if j == k {
					continue
				}
				if v := t[i][j] + u[i][k]; t[i+1][k] < v {
					t[i+1][k] = v
				}
			}
		}
	}
	max := math.MinInt64
	for _, v := range t[n] {
		if max < v {
			max = v
		}
	}
	return max
}

func main() {
	scan := newScanner(os.Stdin)
	n := scan.Int()
	u := make([][]int, n+1, n+1)
	for i := 0; i <= n; i++ {
		u[i] = []int{scan.Int(), scan.Int(), scan.Int()}
	}
	fmt.Println(solve(n, u))
}


Measured memory_bytes: 13708
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>

struct max_min
{
    int64_t max = 0;
    int64_t min = 0;
};

const int64_t cc = pow( 10, 9 ) + 7;
//std::cout<< std::fixed << std::setprecision(10) << ( double )( max ) / 2;
bool sort_pair( std::pair< std::string, int64_t > origin, std::pair< std::string, int64_t > another )
{
    return origin.second  > another.second;
}


int main()
{
    std::string word = "aa";
    int64_t a,b,c,d,e,f;
    std::cin>> a;

    c = a / 2;

    c += a % 2;
    std::cout<< c;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

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

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)1e5+11;
ll const LG=(ll)log2(N)+1;


void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        
        cin>>n;
        
        vll a(n);
        ll fl=0;
        ll sum=0;
        for(i=0;i<n;i++){
                cin>>a[i];
                if(a[i]<0){
                        fl++;
                }
                sum+=abs(a[i]);
        }
        ll ans=0;
        // cout<<sum<<endl;
        if(fl%2==1){
                for(i=0;i<n;i++){
                        ans=max(ans,sum - 2*abs(a[i]));
                }
        }else{
                ans=sum;
        }
        cout<<ans<<endl;
        
        
        
        
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}

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

int main(){
  signed long long int N,M,sum,ans;
  cin>>N>>M;
  signed long long int num[M];
  for(int i=0;i<M;i++){
    cin>>num[i];
  }
  sum=0;
  for(int j=0;j<M;j++){
    sum+=num[j];
  }
  ans=N-sum;
  if(ans>=0){
    cout<<ans<<endl;
  }else{
    cout<<-1<<endl;
  }
}


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

int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  for(auto& l : L)
    cin >> l;
  int ans = 0;
  for(int i = 0; i < N; ++i){
    for(int j = i+1; j < N; ++j){
      for(int k = j+1; k < N; ++k){
        if(L[i] == L[j] or L[j] == L[k] or L[k] == L[i])
          continue;
        int ll = max({L[i],L[j],L[k]});
        if(ll >= L[i]+L[j]+L[k]-ll)
          continue;
        ++ans;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3604
# -*- coding: utf-8 -*-

nums=[int(i) for i in input().rstrip().split()]

cnt={}
for i in nums:
  cnt.setdefault(i,0)
  cnt[i] += 1

if cnt[5] == 2 and cnt[7] == 1:
  print("YES")
else:
  print("NO")

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

int main(){
  string a,b;
  cin >> a >> b;
  if (a == b) printf("H\n");
  else printf("D\n");
}


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

        int main() {
          string S;
          cin>> S; 
          if(S=="Sunny"){
            cout<< "Cloudy";  
          }else if(S=="Cloudy"){
            cout<< "Rainy";  
          }else if(S=="Rainy"){
            cout<< "Sunny";  
          }
        }

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector<int> data;
  	int n;
  	cin >> n;
  	for(int i = 0; i < n; i++){
      int t;
      cin >> t;
      data.push_back(t);
    }
  sort(data.begin(), data.end());
  int ans = data[n/2]-data[n/2-1];
  cout << ans << endl;
}

Measured memory_bytes: 892
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	int h,w,a,b ;
	cin >> h >> w >> a >> b ;
	for(int i=0;i<h;i++){
		if(i<b){
			for(int j=0;j<w;j++){
				if(j<a) cout << 0 ;
				else cout << 1 ;
			}
		}else{
			for(int j=0;j<w;j++){
				if(j<a) cout << 1 ;
				else cout << 0 ;
			}
		}
		cout << endl ;
	}
}


Measured memory_bytes: 1280
def char_range(c1, c2):
    """
    Generates the characters from `c1` to `c2`, inclusive.
    Taken from: https://stackoverflow.com/questions/7001144/range-over-character-in-python
    """
    for c in range(ord(c1), ord(c2)+1):
        yield chr(c)

class Solver(object):
    def __init__(self):
        self.s = input()
        self.t = input()

    def solve(self):
        self.s_to_t = {}
        self.t_to_s = {}
        for c in char_range('a', 'z'):
            self.s_to_t[c] = None
            self.t_to_s[c] = None
        
        for i in range(len(self.s)):
            cs = self.s[i]
            ct = self.t[i]
            if self.s_to_t[cs] is None:
                self.s_to_t[cs] = ct
            if self.t_to_s[ct] is None:
                self.t_to_s[ct] = cs
            if self.s_to_t[cs] != ct:
                print("No")
                return
            if self.t_to_s[ct] != cs:
                print("No")
                return
        print("Yes")


if __name__ == "__main__":
    s = Solver()
    s.solve()

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	double a, b, c, n;
	cin >> a >> b >> c;
	if (a == b && b == c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	cin >> n;
}

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

main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int ans=min(b,d)-max(a,c);
  if(ans<0){
    cout << 0 << endl;
    return 0;
  }else {
    cout << ans << endl;
    return 0;
  }
}

Measured memory_bytes: 3608
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <math.h> 
#include <iomanip>
#include <string.h>
#include<sstream>
#include <vector>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define PI 3.14159265358979323846264338327950L

#define INF 0x3f3f3f3f
//const int N = 2e5 + 5;

 
int a[51], b[51], c[51],q[51];
int N, M, Q;

int ans = 0;

vector<int> v;

int check() {
	int total = 0;
	for (int i = 0; i < Q; i++) {

		if (v[b[i]] - v[a[i]] == c[i]) {

			total += q[i];

		}

	}
	return total;
}

void dfs(int i, int cur) {

	if (i >= N) {

		ans = max(ans, check());
		return;
	}
	 
	for (int j = cur; j <= M; j++) {

		v.push_back(j);
		dfs(i + 1, j);
		v.pop_back();
	}

}


int32_t  main() {

	IOS;
  
  
 
	cin >> N >> M >> Q;


	for (int i = 0; i < Q; i++) {

		cin >> a[i] >> b[i] >> c[i] >> q[i] ;
		a[i]--;
		b[i]--;
	}

	dfs(0, 1);

	cout << ans << endl;
}

Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <utility>
#include <set>
#include <numeric>
#include <queue>
#include <sstream>
#include <map>
#include <unordered_map>
#include <cmath>
using namespace std;
using LLI = long long int;

#define Rep(i, N) for (int i = 0; i < N; i++)

vector<int> v(11);

void out(int m) {
    for (int i = 0; i < m; i++) {
        cout << char('a' + v[i]);
    }
    cout << endl;
}

void f(/*桁 0...9*/int k, int m, int n) {
    if (k == m) {
        
        out(m);
        return;
    }
    for (int i = 0; i < n+1; i++) {
        v[k] = i;
        //cout << "[" << k << ", " << m << ", " << i << ", " << n << "]";
        f(k + 1, m, max(n, i + 1));
    }
}

int main()
{
    int N;
    cin >> N;
    v[0] = 0;
    f(1, N, 1);
}



Measured memory_bytes: 1536
while line = gets
  sentence = line.chomp
  condition = -> {
    !sentence.include?('the') &&
     !sentence.include?('this') &&
     !sentence.include?('that')
  }

  while condition.call
    sentence = sentence.chars.map { |char|
      if ?a <= char && char <= ?z
        if char == ?z
          ?a
        else
          char.succ
        end
      else
        char
      end
    }.join('')
  end

  puts sentence
end

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

#define PI 4*atan(1)
#define INF 1e8

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

int main(){
  int n;
  cin >> n;
  vector<string> S(n);
  for(int i = 0; i < n; i++){
    cin >> S[i];
  }
  bool flag = true;
  char tmp = 'a';
  string ans = "";
  while(flag){
    for(int i = 0; i < n; i++){
      bool _flag = false;
      for(int j = 0; j < S[i].size(); j++){
        if(tmp == S[i][j])_flag = true;
      }
      if(_flag == false){
        if(tmp == 'z')flag = false;
        tmp++;
        break;
      }
      if(_flag && i == n - 1){
        ans.push_back(tmp);
        for(int k = 0; k < n; k++){
          for(int l = 0; l < S[k].size(); l++){
            if(tmp == S[k][l]){
              S[k][l] = '0';
              break;
            }
          }
        }
      } 
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#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;
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 k;cin>>k;
	vector<ll> a(k);
	for(int i = 0; i < k; i++) {
		cin>>a[i];
	}
	ll l = 2,r = 2;
	for(int i = k - 1; i >= 0; i--) {
		if ((l + a[i] - 1) / a[i] * a[i] >= l && (l + a[i] - 1) / a[i] * a[i] <= r){
			l = (l + a[i] - 1)/ a[i] * a[i];
			r = (r / a[i]) * a[i] + a[i] - 1;
		}
		else{
			cout << -1 << endl;
			return 0;
		}
	}
	cout << l << " " << r << endl;
	return 0;
}

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

int main() {
  // ここにプログラムを追記
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if(A+B>C+D){
    
    cout << "Left" << endl;
    
  }
  
  else if (A+B==C+D){
    
    cout << "Balanced" << endl;
    
  }
  
  else{
    
    cout << "Right" << endl;
  }
  
 
  return 0;
  
}

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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};
int N;
int a[112];
int b[112];
typedef vector<int> V;
typedef vector<V> VV;
constexpr int rpar = -1;
void dfs(int v, int p, int d, VV &g, V& branch) {
	int br = g[v].size();
	if (p != rpar)br--;
	if (branch.size() == d)branch.push_back(br);
	else chmax(branch[d], br);
	for (int u : g[v]) {
		if (u == p)continue;
		dfs(u, v, d + 1, g, branch);
	}
}
constexpr LL INF = 1e18;
void solve() {
	VV g(N);
	pair<LL, LL> ret(INF, INF);
	for (int i : range(N-1)) {
		g[a[i]].push_back(b[i]);
		g[b[i]].push_back(a[i]);
	}
	for (int i : range(N)) {
		V x;
		dfs(i, rpar, 0, g, x);
		LL node = x.size();
		LL num = 1;
		for (auto &it : x)if(it!=0)num *= it;
		chmin(ret, { node,num });
	}
	for (int v : range(N)) {
		for (int u : g[v]) {
			V x;
			dfs(v, u, 0, g, x);
			dfs(u, v, 0, g, x);
			LL node = x.size();
			LL num = 2;
			for (auto &it : x)if(it!=0)num *= it;
			chmin(ret, { node,num });
		}
	}

	cout << ret.first << " " << ret.second << endl;
}

int main() {
	while (cin >> N) {
		for (int i : range(N-1)) {
			cin >> a[i] >> b[i];
			a[i]--;
			b[i]--;
		}
		solve();
	}
	return 0;
}


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

const int MOD = (int)1e9+7;
void solve()
{
    int n;
    cin >> n;
    vector<int> dp(3);
    for(int days=0;days<n;days++)
    {
        vector<int> tasks(3);
        for(int i=0;i<3;i++)
            cin >> tasks[i];
        if(!days)
            dp = tasks;
        else
        {
            vector<int> temp_dp(3);
            temp_dp[0] = max(dp[1],dp[2])+tasks[0];
            temp_dp[1] = max(dp[0],dp[2])+tasks[1];
            temp_dp[2] = max(dp[0],dp[1])+tasks[2];
            dp = temp_dp;
        }
    }
    cout << *max_element(dp.begin(),dp.end());
    
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
}

Measured memory_bytes: 3580
#include <iostream>
#include <unordered_map>
#include <algorithm>

using namespace std;

int main() {
	int N;
	cin >> N;
	unordered_map <int, bool> uniques;
	int a, count = 0;
	for (int i = 0; i < N; i++) {
		cin >> a;
		
		if (uniques[a] == false) {
			uniques[a] = true;
		} else {
			count += 1;
		}
	}
	
	cout << (count % 2 == 0 ? N - count : N - count - 1);

	return 0;
}

Measured memory_bytes: 4388
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

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

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

long long E[2][100005];

int main(void) {
    string s;
    for (int i = 0; i < 200010; i++) {
        s.push_back('#');
    } 
    int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
    for (int i = 1; i <= N; i++) {
        char tmp; cin >> tmp;
        s[i] = tmp;
    }

    int flag = 1;
    if (C < D) {
        for (int i = A; i < C; i++) {
            if (s[i] == '#' && s[i+1] == '#'){
                flag = 0;
                break;
            }
        }
        for (int i = B; i < D; i++) {
            if (s[i] == '#' && s[i+1] == '#') {
                flag = 0;
                break;
            }
        }
    } else {
        flag = 0;
        for (int i = B; i <= D; i++) {
            if (s[i] != '#' && s[i-1] != '#' && s[i+1] != '#') {
                flag = 1;
                break;
            }
        }

        for (int i = A; i < C; i++) {
            if (s[i] == '#' && s[i+1] == '#') {
                flag = 0;
                break;
            }
        }
    }

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}   

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>
#define   INF  100000
using namespace std;

int getTheNumberOfCoin(int n, int m, vector<int> c){
	vector<int> t;
	for(int i=0;i<=n;i++){
		t.push_back(INF);
	}
	t[0] = 0;

	for(int i=0;i<m;i++){
		for(int j=c[i];j<=n;j++){
			t[j] = min(t[j], t[j-c[i]]+1);
		}
	}

	return t[n];
}

int main(){
	int n, m, num;
	vector<int> c;

	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>num;
		c.push_back(num);
	}

	cout<<getTheNumberOfCoin(n, m, c)<<endl;

	return 0;
}

Measured memory_bytes: 1536
L=[]
def search(x):
  if x>3234566667:
    return
  L.append(x)
  search(10*x+x%10)
  if x%10!=0:
    search(10*x+x%10-1)
  if x%10!=9:
    search(10*x+x%10+1)
for i in range(1,10):
  search(i)
L.sort()
k=int(input())
print(L[k-1])

Measured memory_bytes: 7572
#!/usr/bin/env python3
sx, sy, tx, ty = map(int, input().split())
x = tx - sx
y = ty - sy
h = abs(sx - tx)
v = abs(sy - ty)
if h * v > 0:
    ans = [[1, 0]] * h + [[0, 1]] * v + [[-1, 0]] * h + [[0, -1]] * v
    ans += [[0, -1]] + [[1, 0]] * -~h + [[0, 1]] * -~v + [[-1, 0]]
    ans += [[0, 1]] + [[-1, 0]] * -~h + [[0, -1]] * -~v + [[1, 0]]
elif h < 1:
    ans = [[0, 1]] * v
    ans += [[1, 0]] + [[0, -1]] * v + [[-1, 0]]
    ans += [[-1, 0]] + [[0, 1]] * v + [[1, 0]]
    ans += [[0, 1]] + [[1, 0]] * 2 + [[0, -1]] * \
        (v + 2) + [[-1, 0]] * 2 + [[0, 1]] * 2
elif v < 1:
    ans = [[1, 0]] * h
    ans += [[0, 1]] + [[-1, 0]] * h + [[0, -1]]
    ans += [[0, -1]] + [[1, 0]] * h + [[0, 1]]
    ans += [[1, 0]] + [[0, 1]] * 2 + [[-1, 0]] * \
        (h + 2) + [[0, -1]] * 2 + [[1, 0]] * 2

if x < 0 and y < 0:
    ans = [*map(lambda x: [-x[0], -x[1]], ans)]
elif x < 0:
    ans = [*map(lambda x: [-x[1], x[0]], ans)]
elif y < 0:
    ans = [*map(lambda x: [x[1], -x[0]], ans)]

for i in ans:
    if i == [1, 0]:
        print("R", end="")
    elif i == [-1, 0]:
        print("L", end="")
    elif i == [0, 1]:
        print("U", end="")
    else:
        print("D", end="")
print("")


Measured memory_bytes: 75768
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

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

struct Fish
{
    ll beauty;
    ll taste;
};

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

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

    ll ans = 753;
    for (ll i = 0; i < S.size() - 2; i++)
    {
        string s = S.substr(i, 3);
        ll n = stoi(s);
        if (ans > abs(753 - n)) {
            ans = abs(753 - n);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
x,k,d=map(int,input().split())

a=abs(x)//d

if x<0:
  d=d*(-1)

if a>=k:
  x=x-(d*k)
  print(abs(x))
else:
  x=x-(d*a)
  b=k-a
  if abs(x)<abs(x-d):
    if b%2==0:
      print(abs(x))
    else:
      print(abs(x-d))
  else:
    x=x-d
    b-=1
    if b%2==0:
      print(abs(x))
    else:
      print(abs(x+d))


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

  const int MOD = 1000000007;

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

  //for
  #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }

int K(int x){
int res = 1;
for(int i = 2; i <= x; i++){
  res = (ll)res * i % MOD;
}

  return res;
}

int main(){
  int N, M;
  cin >> N >> M;
  ll ans;
  if(N == M){
    ans = ((2LL * K(N)) % MOD) * K(M) % MOD;
  }else if(abs(N - M) == 1){
    ans = (ll)K(N) * K(M) % MOD;
  }else ans = 0;
  print(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> mochi(N);
  for (int i = 0; i < N; i++){
    cin >> mochi.at(i);
  }
  sort(mochi.begin(), mochi.end());
  int val; int ret = 0, tmp = 0;
  while (mochi.size() > 0){
    tmp = mochi.at(mochi.size()-1);
    if (val != tmp){
      ret++;
      val = tmp;
      mochi.pop_back();
    }
    else{mochi.pop_back();}
  }
  cout << ret << endl;  
}

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

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<int>> ab(n);
	for (int i = 0; i < m; i++) {
		int a_in, b_in;
		cin >> a_in >> b_in;
		ab.at(a_in - 1).push_back(b_in - 1);
		ab.at(b_in - 1).push_back(a_in - 1);
	}

	vector<bool> seen(n, false);
	vector<int> parents(n);
	queue<int> q;

	q.push(0);
	while (!q.empty()) {
		int num = q.front();
		q.pop();
		for (auto ab_ele : ab.at(num)) {
			if (seen.at(ab_ele) == false) {
				seen.at(ab_ele) = true;
				q.push(ab_ele);
				parents.at(ab_ele) = num;
			}
		}
	}

	cout << "Yes" << endl;
	for (int i = 1; i < n; i++) {
		cout << parents.at(i) + 1 << endl;
	}
}


Measured memory_bytes: 10116
#include <stdio.h>
#define N 100
int main(void)
{
  int i,j,n,m,ct=0,k[N]={0},a[N][N]={0},sum[N]={0};
  scanf("%d%d",&n,&m);
  for(i=0;i<n;i++)
  {
    scanf("%d",k+i);
    for(j=0;j<k[i];j++)
    {
      scanf("%d",&a[i][j]);
    }
  }
  for(i=0;i<n;i++)
  {
    for(j=0;j<k[i];j++)
    {
      sum[a[i][j]-1]++;
    }
  }
  for(i=0;i<m;i++)
  {
    if(sum[i]==n)
    {
      ct++;
    }
  }
  printf("%d\n",ct);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    string s;
    cin >> s;
    if (s.at(0) == '9' || s.at(1) == '9') {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
#define NUM 100005
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int GCD(int a,int b){int c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){return a*b/GCD(a,b);}
int POW(int a,int n){int i;LL x=a;if(n==0)return 1;else if(n==1)return a;else FOR(i,0,n-1){x=x*a;if(x>MOD)x%=MOD;}return (int)x;}
int cmp(const void* a,const void* b){return *(int*)a-*(int*)b;}

int main() {
  int N,D,i,j,k,a,ans=0;
  scanf("%d%d",&N,&D);
  int X[N][D];
  FOR(i,0,N)FOR(j,0,D)scanf("%d",&X[i][j]);
  FOR(i,0,N-1)FOR(k,i+1,N){
    a=0;
    FOR(j,0,D)a+=(X[k][j]-X[i][j])*(X[k][j]-X[i][j]);
    if((int)sqrt(a)*(int)sqrt(a)==a)ans++;
  }

  printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
/// Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;

const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf

#define sf scanf

#define ALL(x) x.begin(),x.end()
#define pb push_back

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define for0(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=n-1;i>=0;i--)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}

int main()

{
    IOS;
    //freopen("input.txt", "r", stdin);
     //freopen("output.txt", "w", stdout);
     int r,g,a,b,c;
     while(cin>>r>>g>>a>>b>>c){
        ll ans=0;
        ll arra[a],arrb[b],arrc[c];
        for(int i=0;i<a;i++){
            cin>>arra[i];
        }
        for(int i=0;i<b;i++){
            cin>>arrb[i];
        }
        for(int i=0;i<c;i++){
            cin>>arrc[i];
        }
        sort(arra,arra+a);
        reverse(arra,arra+a);
        sort(arrb,arrb+b);
        reverse(arrb,arrb+b);
        sort(arrc,arrc+c);
        reverse(arrc,arrc+c);
        int cc=0;
        vector<ll>vec;
        for(int i=0;i<r;i++) vec.pb(arra[i]);
        for(int i=0;i<g;i++) vec.pb(arrb[i]);
        for(int i=0;i<c;i++) vec.pb(arrc[i]);
         sort(ALL(vec));
         reverse(ALL(vec));
         for(int i=0;i<r+g;i++){
            ans+=vec[i];
         }
        cout<<ans<<endl;
     }

     return 0;

}
///Alhamdulillah


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

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

	vector<int> v(n) ;
	
	rep(i,0,n){
		cin>>v[i] ;
	}

	ll count=0 ;

	rep(i,0,n){
		rep(j,i+1,n){
			rep(k,j+1,n){
				if(v[i]+v[j]>v[k] && v[i]+v[k]>v[j] && v[j]+v[k]>v[i]&& v[i]!=v[j] && v[j]!=v[k] && v[k]!=v[i]){
					count++ ;
					//cout<<i+1<<" "<<j+1<<" "<<k+1<<"\n" ;
				}
			}
		}
	}

	cout<<count ;

}

int main(){

	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

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

using namespace std;

const int N = 1e5+7;

int n, m;
int nex[N];
string s;
vector<int> res;

int main()
{
    cin >> n >> m >> s;
    m = min(m, n);
    nex[n] = n;
    for (int i = n-1; i >= 0; --i) {
        if (s[i] == '1') nex[i] = nex[i+1];
        else nex[i] = i;
    }
    int p = n;
    while (p) {
        int q = max(0, p-m);
        q = nex[q];
        if (p == q) {
            cout << -1 << endl;
            return 0;
        }
        res.emplace_back(p-q);
        p = q;
    }
    reverse(res.begin(), res.end());
    for (int i : res) cout << i << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 1528
n,a,b=map(int,input().split())
mod=10**9+7
res=pow(2,n,mod)-1
p=1
for i in range(n,n-a,-1):
    p=p*i%mod
q=1
for i in range(n,n-b,-1):
    q=q*i%mod
for i in range(1,a+1):
    p=p*pow(i,mod-2,mod)%mod
for i in range(1,b+1):
    q=q*pow(i,mod-2,mod)%mod
print((res-p-q)%mod)

Measured memory_bytes: 39280
#include<iostream>
#include<numeric>
#include<cmath>
#include<vector>
#include<string>

using namespace std;
/*
int main() {
	int A, N,answer;
	cout << "N,Aを入力。" << endl;
	cin >> N >> A;
	answer = N % 500;
	if (A>=1)
	{
		answer %= 1;
		if (answer==0)
		{
			cout << "Yes" << endl;
		}
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}
*/
int main() {
	int N, sad, tmp = 0; 
	string str;

	for (int i = 0; i < 4; i++)
	{
		cin >> str;
	}

	for (int i = 0; i < 4; i++)
	{
		if (str[i]== '+')
		{
			tmp++;
		}
		else
		{
			tmp--;
		}
	}

	cout << tmp;

	return 0;
}

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

using namespace std;
#define int long long
int cnt[100319];
#undef int
int main(){
	#define int long long
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;cin>>n;
	for(int i=0;i<n;i++){
		int t;cin>>t;t++;
		cnt[t-1]++;cnt[t+2]--;
	}
	int ans=0;
	for(int i=1;i<100319;i++){
		cnt[i]=cnt[i-1]+cnt[i];
		ans=max(ans,cnt[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1152
import java.util.*;

public class Main {
    public static void main(String[] args){
     Scanner sc= new Scanner(System.in);
     while(true){
String a= sc.next();
    
     if(a.equals("0")) 
         break;
     
     
     int sum= 0;
     
     
     for(int i= 0;i<a.length();i++)
{ 
    sum+= Character.getNumericValue(a.charAt(i));
              
     } 
     
     System.out.println(sum); 
    

   
}}}




Measured memory_bytes: 26420
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
mat_original = [[int(c) for c in input()[:-1]] for _ in range(N)]
mat = [[1 if v == 1 else float('inf') for v in m] for m in mat_original]
for i in range(N):
    mat[i][i] = 0


def is_nibugurahu():
    visited = [0]*N
    visited[0] = 1
    Q = [0]
    while Q:
        q = Q.pop()
        for next in range(N):
            if mat_original[q][next] == 1:
                if visited[next] == 0:
                    visited[next] = visited[q]*(-1)
                    Q.append(next)
                elif visited[next] == visited[q]:
                    return False
                else:
                    pass
    return True


if not is_nibugurahu():
    print(-1)
    exit()


for k in range(N):
    for i in range(N):
        for j in range(N):
            mat[i][j] = min(mat[i][j], mat[i][k]+mat[k][j])

print(max([max(m) for m in mat])+1)



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

long long gcd(long long a,long long b){
  if(b>a) gcd(b,a);
  long long r;
  while((r=a%b)){
    a=b;
    b=r;
  }
  return b;
}

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

  vector<long long> city(100100);
  long long x;

  for(int i=0;i<N;i++) {
    cin >> x;
    city[i]=abs(X-x);
  }
  long long alp;
  for(int i=0;i<N;i++){
    if(i==0) alp=city[0];
    else{
      alp=gcd(city[i],alp);
    }
  }
  cout << alp << endl;
}

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

using namespace std;

int main()
{
    int w,a,b;
    cin >> w >> a >> b;
    int astart=a;
    int afinish=a+w;
    int bstart=b;
    int bfinish=b+w;
    if(bstart>=astart && bstart<=afinish) cout << 0;
    else if(bfinish>=astart && bfinish<=afinish) cout << 0;
    else
    {
        int d1=abs(bstart-afinish);
        int d2=abs(astart-bfinish);
        cout << min(d1,d2);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18,MOD = 1e9 + 7;
const int INT_INF = 1e9,INT_MOD=1e9+7;
#define rep(i, N) for(int i = 0; i < N; i++)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
signed main(){
    int n;cin>>n;
    vector<int> a;
    rep(i,n){
        int p;cin>>p;
        a.push_back(p);
    }
    sort(a.begin(),a.end());
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;


    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
set<int> s;
int n,x;
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		cin>>x;
		if(s.count(x))
			s.erase(x);
		else
			s.insert(x);
	}
	cout<<s.size();
	return 0;
}

Measured memory_bytes: 4864
words = gets.split

hash = {}
max = 0
max_word = ""
words.each{|w|
  if w.size > max
    max = w.size
    max_word = w
  end
  hash[w] = 0 unless hash[w]
  hash[w] += 1
}

ans = hash.max {|x, y| x[1] <=> y[1]}

puts "#{ans[0]} #{max_word}"

Measured memory_bytes: 8704
from collections import Counter
N, li = int(input()), list(map(int, input().split()))
cnt_dict, cnt_total = Counter(li), 0
cnt_total =sum([i[1] * (i[1]-1) // 2 for i in cnt_dict.items()])
for k in range(N):
    print(cnt_total - cnt_dict[li[k]]*(cnt_dict[li[k]]-1)//2 + (cnt_dict[li[k]]-1)*(cnt_dict[li[k]]-2)//2)

Measured memory_bytes: 90444
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    long long a,v,b,w,p;
    cin >> a >> v >> b >> w >> p;
    long long wdnmd = abs(b-a);
    long long xswl = (v-w)*p;
    if ( wdnmd <= xswl) {
      cout << "YES" <<endl;
    }
  else {
    cout << "NO" <<endl;
  }
}


Measured memory_bytes: 3580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;

class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		Integer[] input = new Integer[10];
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		for(int i=0; i<10; i++){
			input[i] = Integer.parseInt(br.readLine());
		}
		Arrays.sort(input, Collections.reverseOrder());
		
		for(int i=0; i<3; i++){
			System.out.println(input[i]);
		}
	}
}

Measured memory_bytes: 17012
#include<bits/stdc++.h>
using namespace std;
int main(){
    double r;
    cin>>r;
    double p=3.141592653589793;
    double a,b;
    a=r*r*p*1.0;
    b=r*2*p*1.0;
    printf("%8lf",a);cout<<' ';printf("%8lf\n",b);
}


Measured memory_bytes: 3164
#include <iostream>

using namespace std;
#define REP(i,n) for (int i = 0; i < n; ++i)
typedef long long ll;
const int MAX = 2e5+10;
const int MOD = 1e9+7;

int N;
int C[MAX];
ll dp[MAX];
int last[MAX];

int main() {
    cin >> N >> C[0];
    int idx = 1;
    int c;
    REP (n, N-1) {
        int c;
        cin >> c;
        if (c != C[idx-1]) C[idx++] = c;
    }
    N = idx;

    dp[0] = 1;
    last[C[0]] = 1;
    REP (i, N-1) {
        int j = last[C[i+1]]-1;
        (dp[i+1] = dp[i]) %= MOD;
        if (j >= 0) (dp[i+1] += dp[j]) %= MOD;
        last[C[i+1]] = i+2;
    }

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

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

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    ll cnt = N / (A+B);
    if (N % (A+B) >= A) {
        cout << cnt * A + A << endl;
    }
    else {
        cout << cnt * A + N % (A+B) << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n,l;
  cin >> n >> l;
  vector<string> s(n);
  rep(i,n) cin >> s[i];
  
  sort(s.begin(),s.end());
  
  rep(i,n) cout << s[i];
  
  return 0;
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

mod = 10**9+7


A,B = map(int,input().split())


if A+B >= 10:
    print("error")
else:
    print(A+B)


Measured memory_bytes: 6340
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int maxn=10005;

struct edge {
    int to,cost;
};

int n,h[maxn],hs[maxn],tag[maxn];
vector<edge>G[maxn];

void dfs1(int u,int p) {
    for (edge e:G[u]) {
        if (e.to==p) continue;
        dfs1(e.to,u);
        if (h[u]<h[e.to]+e.cost) {
            hs[u]=h[u];
            h[u]=h[e.to]+e.cost;
        }
        else hs[u]=max(hs[u],h[e.to]+e.cost);
    }
}

void dfs2(int u,int p) {
    for (edge e:G[u]) {
        if (e.to==p) continue;
        if (tag[u] && h[u]==h[e.to]+e.cost)
            tag[e.to]=1,
            h[e.to]=max(h[e.to],hs[u]+e.cost);
        else h[e.to]=max(h[e.to],h[u]+e.cost);
        hs[e.to]=max(hs[e.to],hs[u]+e.cost);
        dfs2(e.to,u);
    }
}

int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n;
    for (int i=0;i<n-1;i++) {
        int u,v,w; cin>>u>>v>>w;
        G[u].pb((edge){v,w});
        G[v].pb((edge){u,w});
    }
    dfs1(0,-1);
    tag[0]=1;
    dfs2(0,-1);
    for (int i=0;i<=n-1;i++) cout<<h[i]<<'\n';
}


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

int main() {
  double h,N,T,A,M=999999;
  cin >> N >> T >> A;
  int i = 1, ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> h;
    if(M > fabs(T - A - h * 0.006)) {
      M = fabs(T - A - h * 0.006);
      ans = i + 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"	
	typedef long long LL;
	#define ld long double
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define mod2 998244353
	#define INFINITE 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)	
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define read(a) ll a; cin >> a;
	#define reads(s) string s; cin >> s;
	#define readb(a, b) ll a, b; cin >> a >> b;
	#define readc(a, b, c) ll a, b, c; cin >> a >> b >> c;
	#define readarr(a, n) int a[(n) + 1] = {}; forab(i, 0, (n-1)) {cin >> a[i];}
	#define readmat(a, n, m) int a[n + 1][m + 1] = {}; forab(i, 1, n) {forab(j, 1, m) cin >> a[i][j];}
	#define readv(A,n) vll A(n,0); forn(i,n) cin>>A[i]; 
	#define print(a) cout << a << endl;
	#define printarr(a, n) forab (i, 1, n) cout << a[i] << " "; cout << endl;
	#define printv(v) for (int i: v) cout << i << " "; cout << endl;
	#define printmat(a, n, m) forab(i, 1, n) {forab (j, 1, m) cout << a[i][j] << " "; cout << endl;}
	#define precision(a) cout<<fixed<<setprecision(a);
	#define INF (1e18+5)
	#define inf (1e9+5)
	int dx[4] = { 0, 0, 1, -1 };
	int dy[4] = { 1, -1, 0, 0 };
	// 8-directions
	//int dx[]={1,1,1,0,0,-1,-1,-1};
	//int dy[]={-1,0,1,-1,1,-1,0,1};
	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	int begtime = clock();
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	mt19937_64 rngb(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too
	bool isPowerOfTwo(int x) {
    return x && (!(x & (x - 1)));
	}
	int takemod(int x) {
    return (x % mod + mod) % mod;
	}
 
	ll fpow(ll base, ll power, ll MOD) {
    ll result = 1;
    base = base % MOD;
    while (power) {
        if (power & 1)
            result = (result * base) % MOD;
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result;
	}
 
	ll modinv(ll x,ll MOD) {return fpow(x, MOD - 2, MOD);}
	void solve()
	{
		string A;
		cin>>A;
		ll n=sz(A);
		if(A[n-1]!='s')
		{
			A+='s';
		}		
		else
		{
			A+="es";
		}
		cout<<A<<endl;
	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
	//	cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		#ifndef ONLINE_JUDGE
    		cerr << "Time elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
    		#endif
		return 0;
	}

	
	
	
	

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define PI 2*acos(0.0)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
///................Graph's Move.................
///const int dx[] = {+1,-1,+0,+0}; ///Rock's Move
///const int dy[] = {+0,+0,+1,-1}; ///Rock's Move
///const int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move
///const int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int dx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's Move
///const int dy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's Move
///*.....................-_-........................*///
int main()
{
    FIO;
    ///freopen("in.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    int x,y;
    cin>>x>>y;
    bool ok=0;
    int i,j,k;
    for(i=0; i<=x; i++)
    {
        j = i;
        k = x-i;
        if(y==j*2+k*4){ok=1;break;}
    }
    if(ok)yes;
    else no;
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector<int>   vi;
typedef vector<long long> vll;
typedef vector<pair<int,int> > vii;
#define ll long long
#define pb push_back
#define mp  make_pair
#define ff first
#define ss second
#define pq priority_queue
#define sf1(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
int inf = (1e9) + 7;


int main(){

	int n;
	int aux;
	cin >> n;
	set<int> st;
	for (int i = 0; i < n; ++i)
	{
		sf1(aux);
		if(st.count(aux))
			st.erase(aux);
		else
			st.insert(aux);
	}

	printf("%ld\n", st.size() );
}	

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll n , l ; cin >> n >> l;
    ll aji = 0;
    ll mnm = INF;
    ll minus;
    rep(i,n){
        aji += l + i;
        if(mnm>abs(l+i)){
        mnm = min(mnm,abs(l+i));
        minus = l + i;
        }
    }
    cout << aji - minus << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<int>>;
using P = pair<pair<int,int>,int>;
//int dy[4] = {-1,0,1,0};
//int dx[4] = {0,-1,0,1};

void dfs()
{
    
}


int main()
{
    int N,M;
    cin >> N >> M;
    
    int temp = 0;
    vector<int> data(N,0);
    if(N%2 == 0)
    {
        data[N/2] = 1;
    }
    for(int i=0;i<M;i++)
    {
        while(data[(N-i-temp) - (i+1)] == 1 || data[2*i + 1 + temp] == 1)
        {
            
            temp++;
        }
        cout << i+1 << " " << N-i-temp << endl;
        data[(N-i-temp) - (i+1)] = 1;
        data[2*i + 1 + temp] = 1;
    }
    
    /*
    int N,M,Q;
    cin >> N >> M >> Q;
    
    vector<int> data(N,-1);
    
    
    
    for(int i=0;i<Q;i++)
    {
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        a--;
        b--;
        
        bool A = a==-1;
        bool B = b==-1;
        if(A&&B)
        {
            data[a] = 0;
            data[b] = c;
        }
        else if(A)
        {
            
        }
        else if(B)
        {
            
        }
        else
        {
            
        }
        
    }
    
    //sort(p.begin(),p.end());
    
    for(int i=0;i<Q;i++)
    {
        
    }
        
    */
    
    return 0;
}
/*
 if(data[a] == data[b])
 {
 cout << "Yes" << endl;
 }
 else
 {
 cout << "No" << endl;
 }
 */

/*
 int main()
 {
 int N;
 cin >> N;
 
 
 return 0;
 }
 */


Measured memory_bytes: 3816
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int no,nom1=0,nom2=0,nom3=0;
		for (int n=1;n<=3;n++){
			no=sc.nextInt();
			if (nom1<no){
				nom3=nom2;nom2=nom1;nom1=no;
			}else if (nom2<no){
				nom3=nom2;nom2=no;
			}else if (nom3<no){
				nom3=no;
			}	
		}
		System.out.println(nom3 +" "+ nom2 +" "+ nom1);
			}
}

Measured memory_bytes: 17176