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

using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    cin >> s;
    int n = sz(s);
    cout << (((sz(s) + 1) % 2) ^ (s[0] == s[sz(s) - 1]) ? "Second" : "First") << EOL;

}



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

int main () {
    int x, y;
    cin >> x >> y;
    int days = 0;
    rep(i, y) {
        int a;
        cin >> a;
        days += a;
    }
    if (x - days < 0) cout << -1 << endl;
    else cout << x - days << endl;

}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

#define int long long

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string str;
    
    cin >> str;
    
    cout << (700 + (str[0] == 'o')*100 + (str[1] == 'o')*100 + (str[2] == 'o')*100) << endl;
 
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2,147,483,647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cint(n) int n;cin>>n;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
    ll n,a,b;cin>>n>>a>>b;
    if(a+b==0){
        cout<<0;
        return 0;
    }
    ll rec=(n-n%(a+b))/(a+b);
    if(n%(a+b)<=a)cout<<rec*a+n%(a+b);
    else cout<<rec*a+a;
    return 0;
}


Measured memory_bytes: 3648
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	u, v := make([]int, N), make([]int, N)
	for i := 0; i < N-1; i++ {
		u[i], v[i] = getInt(), getInt()
		if u[i] > v[i] {
			u[i], v[i] = v[i], u[i]
		}
	}

	ans := 0
	for i := 1; i <= N; i++ {
		ans += (N + 1 - i) * i
	}

	// out(ans)

	for i := 0; i < N-1; i++ {
		ans -= u[i] * (N - v[i] + 1)
		// out(u[i], v[i], u[i]*(N-v[i]+1))
	}

	out(ans)
}


Measured memory_bytes: 7432
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    s64 n, k;
    cin >> n >> k;

    s64 s[n + 2];
    s[0] = 0;
    rep (i, n + 1)
    {
        s[i + 1] = s[i] + i;
    }

    s64 ans = 0;
    for (int i = k; i <= n + 1; ++i)
    {
        ans += (s[n + 1] - s[n + 1 - i]) % MOD + MOD - (s[i] - s[0]) % MOD + 1;
        ans %= MOD;
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 5180
/**
 *      purpose : 
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

int pow_over(int n) {
  int ret = 1;
  while (ret <= n) {
    ret *= 2;
  }
  return ret;
}

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

  int n; cin >> n;
  vector<int> a(n);
  map<int, int> mp;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ++mp[a[i]];
  }

  sort(a.rbegin(), a.rend());
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (mp[a[i]] == 0) continue;
    int pow_pair = pow_over(a[i]) - a[i];
    if (a[i] == pow_pair) {
      if (mp[a[i]] >= 2) {
        ++cnt;
        mp[a[i]] -= 2;
      }
    } else if (mp[pow_pair] > 0) {
      ++cnt;
      --mp[a[i]];
      --mp[pow_pair];
    } else {
      ;
    }
  }

  cout << cnt << endl;

  return 0;
}


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

int main()
{
    int i, j;
    bool dislike[10] = {false};

    int n, k;
    cin >> n >> k;

    int d;
    for (i = 0; i < k; i++)
    {
        cin >> d;
        dislike[d] = true;
    }

    int answer = n;
    int a;
    bool ok;
    while (true)
    {
        a = answer;
        ok = true;
        while (true)
        {
            if (dislike[a % 10])
            {
                ok = false;
                break;
            }
            if (a < 10)
            {
                break;
            }
            a /= 10;
        }
        if (ok)
        {
            break;
        }
        answer += 1;
    }
    cout << answer << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(ll N){
  ll l = 0;
  ll r = N-1;
  ll c;
  string x, y, z;
  std::cout << l << std::endl;
  cin>>x;
  if(x=="Vacant")
    return;
  std::cout << r << std::endl;
  cin>>z;
  if(z=="Vacant")
    return;
  while(true){
    c=(l+r)/2;
    std::cout << c << std::endl;
    cin>>y;
    if(y=="Vacant")
      return;

    if((c-l)%2) {
      if(x==y) {
	r=c;
	z=y;
      } else {
	l=c;
	x=y;
      }
    } else {
      if(x==y) {
	l=c;
	x=y;
      } else {
	r=c;
	z=y;
      }
    }
  }
}

int main(){
  ll N;
  std::cin >> N;
  solve(N);
  return 0;
}



Measured memory_bytes: 852
#include <iostream>
using namespace std;
int main(){
	double data;
	while(cin>>data){
		if(data<=48)cout<<"light fly"<<endl;
		else if(data<=51)cout<<"fly"<<endl;
		else if(data<=54)cout<<"bantam"<<endl;
		else if(data<=57)cout<<"feather"<<endl;
		else if(data<=60)cout<<"light"<<endl;
		else if(data<=64)cout<<"light welter"<<endl;
		else if(data<=69)cout<<"welter"<<endl;
		else if(data<=75)cout<<"light middle"<<endl;
		else if(data<=81)cout<<"middle"<<endl;
		else if(data<=91)cout<<"light heavy"<<endl;
		else cout<<"heavy"<<endl;
	}
	return 0;
}
		

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define CFS cin.tie(nullptr);ios::sync_with_stdio(false);
#define CST(x) cout<<fixed<<setprecision(x);
using namespace std;
const int IINF = 1 << 30;
const long LINF = 1LL << 60;
const int MOD = (int) 1e9 + 7;
// const int MOD = 998244353;

int main(){
    int k, n;
    cin >> k >> n;
    vector<int> a;
    for (size_t i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        a.push_back(x);
    }
    vector<int> d;
    for (size_t i = 0; i < n - 1; i++)
    {
        d.push_back(a[i + 1] - a[i]);
    }
    d.push_back(k - a.back() + a[0]);
    sort(d.begin(), d.end());
    int ans = 0;
    for (size_t i = 0; i < n - 1; i++)
    {
        ans += d[i];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{

    ll n;
    cin >> n;
    //n--;
    VI v;
    while (n != 0)
    {
        if (n % 26)
        {
        }
        v.push_back(n % 26);
        n /= 26;
    }
    rep(i, v.size() - 1)
    {
        if (v[i] <= 0)
        {
            v[i] += 26;
            v[i + 1]--;
        }
    }
    for (int i = v.size() - 1; i >= 0; i--)
    {
        if (v[i] <= 0)
        {
            continue;
        }
        //cerr << v[i] << endl;
        cout << (char)('a' + v[i] - 1);
    }
    cout << endl;
    return 0;
}

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

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

	int ans = 1;
	for (int b = 2; b <= x; b++) {
		int v = b * b;
		while (v <= x) {
			ans = max(ans, v);
			v *= b;
		}

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  Int n,k;
  cin>>n>>k;
  Int x=3*n/2;
  if(k+x>2*n) drop(-1);

  for(Int i=0,j=0;i<n;i++){
    if(i+x<2*n){
      cout<<k+i<<" "<<k+x+i<<" "<<k+n+n+i*2<<"\n";
    }else{
      cout<<k+i<<" "<<k+n+j<<" "<<k+n+n+j*2+1<<"\n";
      j++;
    }
  }
  return 0;
}


Measured memory_bytes: 2304
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
using namespace std;
using lint = long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };

const lint INF = 1ll << 60;
const int mod = 1000000007;
const int inf = INT_MAX;
void speed() {
	std::cin.tie(nullptr);
	std::ios::sync_with_stdio(false);
	return;
}



int main(void) {
	speed();
	string s; cin >> s;
	lint k = s.length();
	lint o = k - 1;
	if (k == 1) cout << stoi(s) << endl;
	else {
		lint ans = 0;
		for (lint a = 0; a < (1 << o); a++) {
			lint cnt = 0;
			lint count = 0;
			for (int i = 0; i < o; i++) {
				if ((!((a >> i) & 1)) && i == o - 1) {
					cnt += stoll(s.substr(count));
				}
				if (((a >> i) & 1) && i == o - 1) {
					cnt += stoll(s.substr(count, i + 1 - count));
					cnt += stoll(s.substr((int)s.length() - 1));
					break;
				}
				if (!((a >> i) & 1)) continue;
				cnt += stoll(s.substr(count, i + 1 - count));
				count = i + 1;
			}
			ans += cnt;
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3516
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
	int x;
	cin>>x;
	if(x==7||x==5||x==3)cout<<"YES\n";
	else cout<<"NO\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		String[] a = new String[H];
		for(int i = 0 ; i < H ; i++) {
			a[i] = sc.next();
		}
		for(int i = 0 ; i < W + 2 ; i++) {
			System.out.print("#");
		}
		System.out.println();
		for(int i = 0 ; i < H ; i++) {
			System.out.println("#" + a[i] + "#");
		}
		for(int i = 0 ; i < W + 2; i++) {
			System.out.print("#");
		}
		System.out.println();
	}
}


Measured memory_bytes: 24020
#include <iostream>
#include <string>
#include <vector>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
using namespace std;

int main()
{
  int A,B;
  cin >> A >> B;
  int C = A+B;

  if (C<10) cout << C;
  else cout << "error";
  cout << endl;

  return 0;
}


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

#include <string.h>

using namespace std;

typedef long long ll;

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

bool solve(const string S) {
    vector<char> stack;

    for (int i = 0; i < (int) S.size(); i++) {
        char c = S[i];
        if (c == '(') {
            stack.push_back(c);
        } else if (c == ')') {
            if (stack.size() == 0) {
                return false;
            }

            char prev = stack.back();
            stack.pop_back();

            if (prev != '(') {
                return false;
            }
        } else if (c == '[') {
            stack.push_back(c);
        } else if (c == ']') {
            if (stack.size() == 0) {
                return false;
            }

            char prev = stack.back();
            stack.pop_back();

            if (prev != '[') {
                return false;
            }
        }
    }

    if (stack.size() > 0) {
        return false;
    }

    return true;
}

int main(void) {
    while (true) {
        char buf[128];
        fgets(buf, 128, stdin);
        int len = strlen(buf);
        if (buf[len - 1] == '\n') {
            buf[len - 1] = '\0';
            len--;
        }

        string S(buf);
        if (S == ".") {
            break;
        }

        if (solve(S)) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
 
using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;
 
int main() {
 
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
 
	Int N;
	cin >> N;
 
	Int m = 0;
	Int a = 0;
	Int r = 0;
	Int c = 0;
	Int h = 0;
	string temp;
	for (Int i = 0; i < N; i++) {
		cin >> temp;
		if (temp[0] == 'M') {
			m++;
			continue;
		}
		if (temp[0] == 'A') {
			a++;
			continue;
		}
		if (temp[0] == 'R') {
			r++;
			continue;
		}
		if (temp[0] == 'C') {
			c++;
			continue;
		}
		if (temp[0] == 'H') {
			h++;
			continue;
		}
	}
 
	Int ans = 0;
	ans += m * (a * (r + c + h) + r * (c + h) + c * h) + a * (r * (c + h) + c * h) + r * c * h;
 
	cout << ans << endl;
}

Measured memory_bytes: 256
void main(){
	int n, r;
	readf("%d %d\n", &n, &r);
	if( 10<=n ) r.writeln();
	else (r + 100*(10-n)).writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


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

typedef struct drink{
  long price;
  long stock;
}drink;

int compare(const void *a,const void *b){
  drink *A =(drink *)a;
  drink *B =(drink *)b;
  return A->price - B->price;
}

int main(){
  int N,M;
  scanf("%d%d",&N,&M);
  drink* D =(drink*)malloc(sizeof(drink)*N);
  for(int i=0;i<N;i++){
    scanf("%d%d",&D[i].price,&D[i].stock);
  }
  qsort(D,N,sizeof(drink),compare);

  long cost = 0;
  long item = 0;
  for(int j=0;j<N;j++){
    if(item + D[j].stock < M){
      cost += (D[j].price)*(D[j].stock);
      item += D[j].stock;
    }else if(item + D[j].stock >= M){
      cost += (D[j].price)*(M - item);
      item += M;
      j = N+1;
    }
  }
  printf("%ld\n",cost);
  
  return 0;
}

Measured memory_bytes: 3452
//root -> 頂点vの情報を事前に計算. dfsしながら差分計算.
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

struct Edge {
	int to, color, cost;
	Edge() { }
	Edge(int to, int color, int cost) { this->to = to; this->color = color; this->cost = cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int n, q;
Graph tree;
int x[100000], y[100000], u[100000], v[100000];

int parent[100000];
int depth[100000];
int length[100000];				//length[頂点v] = 頂点0->vの長さ
int parents[20][100000];

void dfs(int p, int v, int dep = 0, int len = 0) {
	int i;
	
	parent[v] = p;
	depth[v] = dep;
	length[v] = len;
	
	for (Edge e : tree[v]) {
		if (e.to == p) continue;
		dfs(v, e.to, dep + 1, len + e.cost);
	}
}

void prepare() {
	int i, j;
	rep(i, n) parents[0][i] = parent[i];
	rep(i, 19) {
		rep(j, n) {
			parents[i + 1][j] = parents[i][parents[i][j]];
		}
	}
}

int lca(int u, int v) {
	if (depth[u] < depth[v]) { swap(u, v); }
	
	int d = depth[u] - depth[v];
	for (int i = 19; i >= 0; i--) {
		if ((d >> i) & 1) {
			u = parents[i][u];
		}
	}
	
	for (int i = 19; i >= 0; i--) {
		if (parents[i][u] != parents[i][v]) {
			u = parents[i][u];
			v = parents[i][v];
		}
	}
	
	if (u == v) return u;
	return parent[u];
}

vector<int> queryC[100000];
map<int, int> cntMp[100000];	//cntMp[頂点v] = (色c, 頂点0->vで出現する本数)
map<int, int> costMp[100000];	//costMp[頂点v] = (色c, 頂点0->vでの合計長さ)
int cntC[100000];
int costC[100000];

void dfs2(int p, int v) {
	for (int c : queryC[v]) {
		cntMp[v][c] = cntC[c];
		costMp[v][c] = costC[c];
	}
	
	for (Edge e : tree[v]) {
		if (e.to == p) continue;
		
		cntC[e.color]++;
		costC[e.color] += e.cost;
		dfs2(v, e.to);
		cntC[e.color]--;
		costC[e.color] -= e.cost;
	}
}

int main() {
	int i;
	
	cin >> n >> q;
	tree.resize(n);
	
	rep(i, n - 1) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		a--; b--;
		tree[a].push_back(Edge(b, c, d));
		tree[b].push_back(Edge(a, c, d));
	}
	
	dfs(0, 0);
	prepare();
	
	rep(i, q) {
		cin >> x[i] >> y[i] >> u[i] >> v[i];
		u[i]--; v[i]--;
		int l = lca(u[i], v[i]);
		queryC[u[i]].push_back(x[i]);
		queryC[v[i]].push_back(x[i]);
		queryC[l].push_back(x[i]);
	}
	
	dfs2(0, 0);
	
	rep(i, q) {
		int l = lca(u[i], v[i]);
		int res = length[u[i]] + length[v[i]] - 2 * length[l];
		int honsu = cntMp[u[i]][x[i]] + cntMp[v[i]][x[i]] - 2 * cntMp[l][x[i]];
		int sumCost = costMp[u[i]][x[i]] + costMp[v[i]][x[i]] - 2 * costMp[l][x[i]];
		cout << res + honsu * y[i] - sumCost << endl;
	}
	return 0;
}

Measured memory_bytes: 60344
n,k=map(int,input().split())
z=[list(map(int,input().split()))for _ in range(n)]
z.sort()
a=10**20
for i in range(n):
    for j in range(i+1,n):
        x=z[j][0]-z[i][0]
        l=sorted(t[1]for t in z[i:j+1])
        for u,v in zip(l,l[k-1:]):
            a=min(a,x*(v-u))
print(a)

Measured memory_bytes: 3064
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;
const ll MOD = 1e9+7;

int N;

ll add(ll a, ll b){
	return (a + b) % MOD;   
}

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

ll powMOD(ll a, ll x){ // a^x % MOD を返す 
  	if(x == 0) return 1;
  	else if(x == 1) return a;
  	else if(x%2==0) return mul(powMOD(a,x/2),powMOD(a,x/2));
  	else return mul(a,mul(powMOD(a,(x-1)/2),powMOD(a,(x-1)/2))); 
}

ll reverse (ll n){ // n^(MOD-2) を返す
	return powMOD(n, MOD-2);
}
                          
void Main()
{
  	cin >> N;
  	vector<int> x(N);
  	rep(i,N) cin >> x[i];

  	vector<ll> fact(N+1);
	fact[0] = 1;
  	fact[1] = 1;
  	rep3(i,2,N) fact[i] = mul(i,fact[i-1]);

	ll coef = fact[N-1];
    //cout << 0 << ": " << coef << endl;
  	ll temp = x[1]-x[0];
  	ll sum = mul(coef,temp);
  	rep3(k,1,N-2){
  		coef += mul(fact[N-1], reverse(k+1)); ;
      	//cout << k << ": " << coef << endl;
  		temp = x[k+1]-x[k];
  		sum = add(sum,mul(coef,temp));
    }
  	cout << sum << endl;
	return;
}
  
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

const double TAU = atan2(0, -1) * 2.0;
const double PI  = atan2(0, -1);

int main() {
	IN(int, n);
	OUT(TAU * n);
}


Measured memory_bytes: 3784
def main():
    n = int(input())
    p = [int(pn) for pn in input().split()]
    ans = 0
    is_changed = False
    for i in range(n):
        if is_changed:
            is_changed = False
        elif p[i] == i + 1:
            is_changed = True
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19940
import java.io.File;
import java.io.FileInputStream;
import java.util.Scanner;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();
		int dx = x2 - x1;
		int dy = y2 - y1;
		
		int x3 = x2 - dy;
		int y3 = y2 + dx;
		int x4 = x3 - dx;
		int y4 = y3 - dy;
		
		System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}

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

int main() {
  int n;
  cin >> n;
  int cnt_ab = 0, cnt_ba = 0, cnt_b = 0, cnt_a = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < s.size(); j++) {
      if (s[j] == 'A' && s[j + 1] == 'B') {
        cnt_ab++;
      }
    }
    if (s.at(0) == 'B' && s.at(s.size() - 1) == 'A') {
      cnt_ba++;
      continue;
    }
    if (s.at(0) == 'B') {
      cnt_b++;
      continue;
    }
    if (s.at(s.size() - 1) == 'A') {
      cnt_a++;
      continue;
    }
  }
  if (cnt_ba == 0) {
    cout << min(cnt_a, cnt_b) + cnt_ab << endl;
  } else if (cnt_a + cnt_b > 0) {
    cout << min(cnt_a, cnt_b) + cnt_ba + cnt_ab << endl;
  } else {
    cout << cnt_ba - 1 + cnt_ab << endl;
  }
}

Measured memory_bytes: 256
x,n=map(int,input().split())
if n==0:
  print(x)
else:
  plist=list(map(int,input().split()))
  if x not in plist:
    print(x)
  else:
    
    for i in range(100000):
      if x-i-1 not in plist:
        print(x-i-1)
        break
      elif x+i+1 not in plist and x-i-1 in plist:
        print(x+i+1)
        break
            
  



Measured memory_bytes: 9184
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>



int main() {
    int n; std::cin >> n;
    std::vector<long long> a(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    std::sort(a.begin(), a.end());
    std::deque<long long> b, ans;
    auto func = [&](bool t) {
        ans.clear();
        for (int i = t; i < n - !t; i++) b.push_back(a[i]);
        ans.push_back(a[t ? 0 : n - 1]);
        bool flag = t;
        while (!b.empty()) {
            if (flag) {
                ans.push_front(b.back()), b.pop_back();
                if (!b.empty()) ans.push_back(b.back()), b.pop_back();
            }
            else {
                ans.push_front(b.front()), b.pop_front();
                if (!b.empty()) ans.push_back(b.front()), b.pop_front();
            }
            flag = !flag;
        }
        long long sum = 0;
        for (int i = 0; i < n - 1; i++) {
            sum += std::abs(ans[i] - ans[i + 1]);
        }
        return sum;
    };
    std::cout << std::max(func(true), func(false)) << std::endl;
    return 0;
}

Measured memory_bytes: 1920
#include <cstdio>

using namespace std;

char s[111111];

int main(void) {
  scanf("%s", s);
  int res = 0;
  for (int i = 0; s[i+1]; i++) {
    res += s[i] != s[i+1];
  }
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//
constexpr ll MOD = 1e9 + 7;
/*/
const ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll ans = 0;
  rep(i, n-2){
    dump(s.substr(i, 3));
    if(s.substr(i, 3) == "ABC"){
      ans++;
    }
  }
  print(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9 + 7, A = 2e3 + 2;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n, k;
    cin >> n >> k;
    ld ans = 0, val = 0, expect[n];
    for (int i = 0, x; i  < n; i++)
    {
        cin >> x;
        expect[i] = (x * (x + 1) / 2.0) / ((ld)x);
        val += expect[i];
        if (i >= k) val -= expect[i - k];
        ans = max(ans, val);
    }
    cout << fixed << setprecision(6) << ans;
    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using P = pair<ll, ll>;
const int INF = 1001001001;

int main(void){
  ll n;
  cin >> n;
  vector<ll> x(n);
  vector<P> y(n);
  REP(i, n) cin >> x[i], y[i] = P(x[i], i);
  sort(ALL(y));
  map<ll, ll> mp;
  REP(i, n) mp[y[i].second] = i;
  ll m = n/2;
  REP(i, n){
    if(mp[i] < m) cout << y[m].first << endl;
    else  cout << y[m-1].first << endl;
  }
  return 0;
}

Measured memory_bytes: 19328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c,d;
int main() {
	// your code goes here
	cin >>a>>b>>c>>d;
    
    ll maxi = max(max(a*c,a*d),max(b*c,b*d));
    cout << maxi ;    
       
}

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

int main()
{
	LL A, B;
	cin >> A >> B;
	if (A % 2 == 0) {
		int a = (B - A) / 2 % 2;
		if (B % 2 == 0) {
			cout << (a ^ B) << endl;
		}
		else {
			cout << (a ^ 1) << endl;
		}
	}
	else {
		int a = (B - A - 1) / 2 % 2;
		if (B % 2 == 0) {
			cout << (A ^ a ^ B) << endl;
		}
		else {
			cout << (A ^ a ^ 1) << endl;
		}
	}
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func main() {
	scanner.Split(bufio.ScanWords)
	t := nextString()
	p := nextString()
	// fmt.Println(t)
	// fmt.Println(p)
	sizeP := len(p)

	for i := 0; i < len(t)-sizeP+1; i++ {
		// fmt.Println(i, p, t[i:(i+sizeP)])
		if p == t[i:(i+sizeP)] {
			fmt.Println(i)
		}
	}
}



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

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;

typedef long long ll;
int main() {
	int n, ans = 0;
	cin >> n;
	vector< int > a(n);
	vector< int > b(1000111);
	for (auto& e:a) cin >> e, b[e]++;
	for (int i=0; i<n; i++) {
		bool f = 1;
		for (int j=1; j*j<=a[i]; j++) {
			if (a[i] % j == 0) {
				int x = j, y = a[i]/j;
				int nn = b[x];
				if (x == a[i]) nn--;
				if (nn > 0) {
					f=0;
					break;
				}
				
				nn = b[y];
				if (y == a[i]) nn--;
				if (nn > 0) {
					f=0;
					break;
				}
			}
		}
		
		if (f) ans++;
	}
	cout << ans << '\n';

	return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<long long> L){
    sort(ALL(L));
    int cnt = 0;
    REP(i, L.size()-1){
        cnt += L[i];
    }

    cout << (L[L.size()-1] < cnt ? YES : NO) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> L(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&L[i]);
    }
    solve(N, std::move(L));
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;

import static java.lang.System.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		C(sc);
	}

	

	public static void C(Scanner sc) {
		int N = sc.nextInt();
		int gd;
		int[] A = new int[N];
		gd = A[0] = sc.nextInt();
		for(int i=1;i<N;i++) {
			A[i] = sc.nextInt();
			gd = gcd(gd, A[i]);
		}
		int except=0;
		boolean alec = false;
		int ngd1 = A[0]/gd;
		int ngd2 = A[1]/gd; //0 except
		for(int i=1;i<N;i++) {
			A[i] /= gd;
			ngd2 = gcd(ngd2,A[i]);
			if(alec==false && gcd(ngd1,A[i])==1) {
				alec = true;
				except = i;
			}
			else ngd1 = gcd(ngd1,A[i]);
		}
		
		for(int i=except-5;i<except;i++) {
			int ngd = A[0]/gd;
			for(int j=1;j<N;j++) {
				if(j==i) continue;
				ngd = gcd(ngd,A[j]);
			}
			if(ngd>ngd1) ngd1 = ngd;
		}
		out.println(gd*Math.max(ngd1, ngd2));
	}
	public static int gcd(int a, int b) {
		if(b==0) return a;
		return gcd(b,a%b);
	}

}


Measured memory_bytes: 50272
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  ll X;
  cin>>X;
  ll Y=X/105;
  ll Z=X/100;
  int F=0;
  ll XX=X;
  rep(i,10000){
    if(Y+i<=Z){
      X=XX;
      X-=((Y+i)*100);
      if(X>=0&&X<=5*(Y+i)){
        cout<<1<<endl;
        F=1;
        break;
      }
    }else break;
  }
  if(F==0) cout<<0<<endl;
}





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

using namespace std;
typedef long long ll;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b;
    string s = "";
    for(ll i=0;i<n;i++) cin >> a[i];
    if(n%2==1) {
        for(ll i=n;i>=0;i-=2) b.push_back(a[i-1]);
        for(ll i=2;i<=n;i+=2) b.push_back(a[i-1]);
    } else {
        for(ll i=n;i>=1;i-=2) b.push_back(a[i-1]);
        for(ll i=1;i<n;i+=2) b.push_back(a[i-1]);
    }
    for(int i=0;i<b.size();i++) {
        if(i==b.size()-1)
            cout << b[i] << endl;
        else
            cout << b[i] << " ";
    }

}


Measured memory_bytes: 5488
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if (a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) {
			System.out.println("Possible");			
		}
		else {
			System.out.println("Impossible");
		}
	}
}


Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
 
#define int long long
#define ll long long 
#define F first
#define sqr(x) ((x) * (x))
#define S second
#define make make_pair
#define pb push_back
#define sz(x) (ll)(x.size()) 
#define all(x) x.begin (), x.end ()

using namespace std;
                        
typedef unsigned long long ull;
typedef long double ld;

const int MOD = (int)1e9 + 7;
const int N = (int)2e6+ 222;
const ll INF = (ll)1e18;
const double eps = (double)1e-6;
    
int n, a[N], b[N], ans[N], dp[N], mx;
vector < pair <int, int> > g[N];

void dfs (int x = 1, int pr = 1) {
	int k = 1;
	for (auto to : g[x]) {
		if (to.F == pr) continue;
		ans[to.S] = (dp[x] + k) % mx;  
		dp[to.F] = (dp[x] + k) % mx;
		k ++;
	}
	for (auto to : g[x]) {
		if (to.F == pr) continue;
		dfs(to.F, x);
	}
}

void solve () {     
	cin >> n;
	for (int i = 1; i <= n - 1; ++i) {
		cin >> a[i] >> b[i];
		g[a[i]].pb({b[i], i});
		g[b[i]].pb({a[i], i});
	}                 
	for (int i = 1; i <= n; ++i) mx = max(mx, sz(g[i]));
	dfs();
	cout << mx << endl;
	for (int i = 1; i <= n - 1; ++i) {
	 	cout << ans[i] + 1 << endl; 
	}
	
}





signed main () {
    #ifdef Maga
        freopen("input", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);                                              
    int t = 1;
   // cin >> t;
    while (t --) {
    	solve ();
    }
    return 0;
}





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

int main(){
  long long A;
  cin>>A;
  long long N;
  cin>>N;
  if(A==1){
    cout<<N<<endl;
    return 0;
  }
  long long temp=N;
  map <long long,long long> mp;
  int i=2;
  while(temp>1){
    if(temp%i==0){
      mp[i]++;
      temp=temp/i;
      //cout<<i<<endl;
    }
    else i++;
    if(i>100000000){
      cout<<1<<endl;
      return 0;
    }
  }
  long long ans=1;
  long long mult=0;
  for(auto itr=mp.begin();itr !=mp.end();itr++){
    if((itr->second)>=A){
      mult=(itr->second)/A;
      ans=ans*pow((itr->first),mult);
      //cout<<itr->first<<endl;
    }
  }
  cout<<ans<<endl;
    
  return 0;
}

    

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  long a,b,c,ans;
  scanf("%ld %ld %ld",&a,&b,&c);
  if(a%2&&b%2&&c%2){
    ans=min(a*b,a*c);
    ans=min(ans,b*c);
  }
  else
    ans=0;
  printf("%ld\n",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n ,x) for (int i = x; i < (int)(n); ++i)
#define repBack(i, n) for (int i = n; i >= 0; --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int A,B,T;
    cin >> A >> B >> T;
    cout << ((int)(T/A))*B << endl;
    
    return 0;
}

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

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

  int n,m,x;
  cin >> n >> m >> x;

  int cnt = 0;

  for(int i = 0; i < m; i++){
    int tmp;
    cin >> tmp;
    if(tmp > x) break;
    cnt++;
  }

  cout << min(cnt, m - cnt) << endl;
}

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

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

using namespace std;


int main() {

    int n,m; cin >> n >> m;
    ll Min = 100000000000000000;
    int ans;
    pair<ll,ll> p[51];
    pair<ll,ll> s[51];
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        s[i] = make_pair(x,y);
    }

    rep(i,m){
        ll x,y;
        cin >> x >> y;
        p[i] = make_pair(x,y);
    }

    rep(i,n){
        Min = 100000000000000000;
        rep(j,m){
            ll tmp = abs(s[i].first-p[j].first)+abs(s[i].second-p[j].second);
            if(tmp < Min){
                Min = tmp;
                ans = j+1;
            }
        }
        cout << ans << endl;
    }

    return 0;
}











Measured memory_bytes: 3604
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))


int main() {
	int a,b,h,m;
	cin >> a >> b >> h >> m;
	//float PI = acos(-1);
	double t = 2*M_PI*(h * 60 + m);
	//int ch = 60*12;
	double theta = min(abs(t/720 - 2*M_PI*m/60), 2*M_PI - abs(t/720 - 2*M_PI*m/60));
	double ans = sqrt(a*a + b*b - 2*a*b*cos(theta));
	//cout << t << endl;
	//cout << t/720 <<endl;
	//cout << theta << endl;
	printf("%.20f", ans);
	return 0;
}


Measured memory_bytes: 4136
#include <stdio.h>
 
int main(){
    int x,a,b;
    scanf("%d",&x);
    if(x==1){
        printf("Hello World\n");
    }else if(x==2){
        scanf("%d %d",&a,&b);
        printf("%d\n",a+b);
    }
    return 0;
}

Measured memory_bytes: 128