akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF 1000000009
typedef long long ll;
using namespace std;
ll ans;
ll N;
ll A[200001];
ll sum[200001];
ll L[200001];//左端を保存
ll R[200001];
int main() {
	ans = INF;
	cin >> N>>A[0];
	rep(i, 1, N) {
		cin >> A[i];
		A[i] += A[i - 1];
	}
	ll num = 0;//leftの右端
	ll left;
	ll right;
	ll sub;
	ll left2;
	ll right2;
	ll sub2;
	rep(i, 1, N-2) {
		do{
			left = A[num];
			right = A[i]-A[num];
			sub = abs(left - right);
			left2 = A[num + 1];
			right2 = A[i] - A[num+1];
			sub2 = abs(left2 - right2);
			if (sub > sub2) {
				num++;
			}
		} while (sub>sub2 && num!=i-1);
		L[i] = num;
	}
	num = 2;
	rep(i, 1, N-2) {
		do {
			left = A[num] - A[i];
			right = A[N-1]-A[num];
			sub = abs(left - right);
			left2 = A[num + 1]-A[i];
			right2 = A[N-1] - A[num + 1];
			sub2 = abs(left2 - right2);
			if (sub > sub2) {
				num++;
			}
		} while (sub>sub2  && num != N - 1);
		R[i] = num;
	}
	rep(i, 1, N-2) {
		ll p = A[L[i]];
		ll q = A[i]-p;
		ll r = A[R[i]]-A[i];
		ll s = A[N-1]-A[R[i]];
		ll sortnum[] = { p,q,r,s };
		sort(sortnum, sortnum + 4);
		ans = min(sortnum[3] - sortnum[0],ans);
		cerr << p <<endl<< q <<endl<< r <<endl<< s << endl << endl;
	}
	cout << ans << endl;
	cin >> ans;
	return 0;
}

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

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

   if(2*b<a)
   {
       cout<<a-(2*b)<<endl;
   }
   else if(2*b>=a)
   {
       cout<<"0"<<endl;
   }
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    long long a,b;cin >> a >>b;

    if((a<0 && b>0)||a==0 || b==0) {
        cout << "Zero" << endl;
        return 0;
    }

    if(a>0&&b>0) 
    {
        cout<<"Positive"<<endl;
        return 0;
    }
    long long m = b - a;
    if((a<0 && b<0)&& m % 2 ==0)
    {
        cout <<"Negative"<<endl;
        return 0;
    }
    cout <<"Positive"<<endl;



}

Measured memory_bytes: 256
# input
n = int(input())
A = list(map(int, input().split()))

# 偶数番目が＋
A_even = A[:]
S_even = 0
ans_even = 0
for i in range(n):
    if (S_even + A_even[i]) * ((-1) ** (i - 1)) > 0:
        S_even += A_even[i]
        continue
    A_even[i] = (-1) ** (i - 1) - S_even
    ans_even += abs(A[i] - A_even[i])
    S_even = (-1) ** (i - 1)

# 奇数番目が＋
A_odd = A[:]
S_odd = 0
ans_odd = 0
for i in range(n):
    if (S_odd + A_odd[i]) * ((-1) ** i) > 0:
        S_odd += A_odd[i]
        continue
    A_odd[i] = (-1) ** i - S_odd
    ans_odd += abs(A[i] - A_odd[i])
    S_odd = (-1) ** i

ans = int(min(ans_even, ans_odd))

print(ans)

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

int min_cost(int f,int dp[],int h[],int k)
{
    if(f<=0){return 0;}
    if(dp[f]!=-1){return dp[f];}
    int i=INT_MAX;
    for(int x=1;x<=k;x++)
    {
        if(f-x>0)
        {i=min(i,min_cost(f-x,dp,h,k)+abs(h[f]-h[f-x]));}
        else
        {i=min(i,min_cost(f-x,dp,h,k)+abs(h[f]-h[1]));}
    }
    dp[f]=i;
    return dp[f];
}

int main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);cout.tie(0);
   int n,k;
   cin>>n>>k;
   int h[n+1],dp[n+1]={-1};
   for(int x=1;x<=n;x++)
   {
       cin>>h[x];
       dp[x]=-1;
   }
   cout<<min_cost(n,dp,h,k)<<endl;
}








Measured memory_bytes: 13652
N, A, B, C = map(int, raw_input().split())
target = [A, B, C]
memo = [[[0, 0, 0], 0]]
for i in range(0, N):
	t = int(raw_input())
	m = len(memo)
	for j in range(0, m):
		now = memo[j]
		trees = now[0]
		mp = now[1]
		for k in range(0, 3):
			addmp = 0
			if trees[k] != 0: addmp = 10
			newmemo = [[trees[0], trees[1], trees[2]], mp+addmp]
			newmemo[0][k] += t
			memo.append(newmemo)
min = 1000000007
for i in range(0, len(memo)):
	if 0 not in memo[i][0]:
		sum = memo[i][1]
		for j in range(0, 3):
			sum += abs(target[j]-memo[i][0][j])
		if sum < min: min = sum
print min

Measured memory_bytes: 45596
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
using namespace std;
typedef int64_t ll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll N;
        in >> N;
        map<ll, bool> m;
        rep(i, N) {
            ll a;
            in >> a;
            m[a] = !m[a];
        }
        ll ans = 0;
        for (auto &b : m) {
            b.second && ans++;
        }
        out << ans << '\n';
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 6528
using System;

public class Sum
{
    private static void Main()
    {
        string[] abc = Console.ReadLine().Split(' ');
        int a = int.Parse(abc[0]);
        int b = int.Parse(abc[1]);
        int c = int.Parse(abc[2]);

        if (a < b && b < c)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}

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

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

  long nFact = 1;
  for (int n = 1; n <= nNum; n++)
  {
    nFact *= n;
    nFact %= 1000000007;
  }

  cout << nFact << endl;
  return 0;
}

Measured memory_bytes: 256
//median min 25mins
//time
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)

int main()
{
    ll N, K, m, M, ans = INF;
    cin >> N >> K;
    vector<ll> H(N);
    repi(i, N, 0)
    {
        cin >> H[i];
    }
    sort(all(H));
    for (ll i = 0; i < N - K + 1; i ++)
    {
        ans = min(ans, H.at(i + K - 1) - H.at(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 100 + 5;
int n, w, a[N], f[4], *****dp, v[N];
int calc(int i, int w0, int w1, int w2, int w3) {
	if (ll(w0)*(a[0]) + ll(w1)*(a[0] + 1) + ll(w2)*(a[0] + 2) + ll(w3)*(a[0] + 3) > w) return -1e9;
	if (i == n) return 0;
	int &ret = dp[i][w0][w1][w2][w3];
	if (ret != -1) return ret;
	ret = calc(i + 1, w0, w1, w2, w3);
	if (a[i] == a[0]) {
		ret = max(ret, v[i] + calc(i + 1, w0 + 1, w1, w2, w3));
	}
	else if (a[i] == a[0] + 1) {
		ret = max(ret, v[i] + calc(i + 1, w0, w1 + 1, w2, w3));
	}
	else if (a[i] == a[0] + 2) {
		ret = max(ret, v[i] + calc(i + 1, w0, w1, w2 + 1, w3));
	}
	else {
		ret = max(ret, v[i] + calc(i + 1, w0, w1, w2, w3 + 1));
	}
	return ret;
}


int main() {
	scanf("%d%d", &n, &w);
	for (int i = 0; i < n; ++i)
		scanf("%d%d", a + i, v + i);
	for (int i = 0; i < n; ++i)
		++f[a[i] - a[0]];
	dp = new int ****[n];
	for (int i = 0; i < n; ++i) {
		dp[i] = new int ***[f[0] + 3];
		for (int j = 0; j <= f[0]; ++j) {
			dp[i][j] = new int **[f[1] + 3];
			for (int k = 0; k <= f[1]; ++k) {
				dp[i][j][k] = new int *[f[2] + 3];
				for (int l = 0; l <= f[2]; ++l) {
					dp[i][j][k][l] = new int[f[3] + 3];
					for (int m = 0; m <= f[3]; ++m)
						dp[i][j][k][l][m] = -1;
				}
			}
		}
	}
	printf("%d\n", calc(0, 0, 0, 0, 0));
	return 0;
}



Measured memory_bytes: 236416
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

void solve(){

    string st;
    cin >> st;
    if(st[0]==st[1]&&st[1]==st[2]) cout << "No" << endl;
    else cout << "Yes" << endl;

}

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


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_132
{
    class F
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            long[] nk = ReadLongs();
            long n = nk[0];
            long k = nk[1];

            List<long> cnts = new List<long>();
            List<long> topCnts = new List<long>();
            long bottom = 1;
            long top = n;
            for (; bottom * bottom <= n; bottom++)
            {
                cnts.Add(1);

                long topNext = n / bottom;
                if (bottom > 1) topCnts.Add(top - topNext);
                top = topNext;
            }
            if (top - bottom + 1 > 0) topCnts.Add(top - bottom + 1);
            topCnts.Reverse();
            cnts.AddRange(topCnts);
            for (int i = 1; i < cnts.Count; i++) cnts[i] += cnts[i - 1];

            long mask = 1000000000 + 7;
            long[] dp = new long[cnts.Count];
            for(int i = 0; i < cnts.Count; i++)
            {
                long val = i == 0 ? cnts[i] : cnts[i] - cnts[i - 1];
                dp[i] = cnts[cnts.Count - i - 1] * val;
                if (i > 0) dp[i] += dp[i - 1];
                dp[i] %= mask;
            }
            for(int i = 0; i < k - 2; i++)
            {
                long[] next = new long[cnts.Count];
                for(int j = 0; j < cnts.Count; j++)
                {
                    long val = j == 0 ? cnts[j] : cnts[j] - cnts[j - 1];
                    next[j] = dp[cnts.Count - j - 1] * val;
                    if (j > 0) next[j] += next[j - 1];
                    next[j] %= mask;
                }
                dp = next;
            }

            WriteLine(dp[cnts.Count - 1]);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 29236
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

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

	int ans = 0;
	rep(i, n - 1) {
		if (s[i] != s[i + 1]) ans++;
	}
	cout << ans + 1 << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define int long long
#define pb push_back
#define endl "\n";
#define deb1(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << " | " << #y << ": " << y << endl
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define printclock cerr << "Time : " << 1000 * (ld)clock() / (ld)CLOCKS_PER_SEC << "ms\n";
#define vii vector<int>
#define pii pair<int, int>
#define prec(n) fixed << setprecision(n)
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define MOD LLONG_MAX
inline void get(vector<int> &arr, int n)
{
    int a;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        arr.push_back(a);
    }
}
inline void print(vector<int> &arr, int n)
{
    for (int i = 0; i < n; i++)
        cout << arr[i] << " ";
    cout << endl;
}
int dp[100005][3];
void solve(vector<vii> &act, int n)
{
    rep(i, 1, n + 1)
    {
        dp[i][0] = max(act[i][0] + dp[i - 1][1], act[i][0] + dp[i - 1][2]);
        dp[i][1] = max(act[i][1] + dp[i - 1][2], act[i][1] + dp[i - 1][0]);
        dp[i][2] = max(act[i][2] + dp[i - 1][0], act[i][2] + dp[i - 1][1]);
    }
}
int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    fast;
    int t;
    t = 1;
    while (t--)
    {
        int n;
        cin >> n;
        vector<vii> act(n + 1, vector<int>(3));
        rep(i, 1, n + 1)
        {
            cin >> act[i][0] >> act[i][1] >> act[i][2];
        }
        memset(dp, 0, sizeof(dp));
        solve(act, n);
        cout << max({dp[n][0],dp[n][1],dp[n][2]}) << endl;
    }
    return 0;
}

Measured memory_bytes: 11124
#include <algorithm>
#include <iostream>
#include <string.h>

using namespace std;

#define int_ int64_t
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define lb long double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

ll n,a[15];
vector<ll> v1,v2;
bool ans=false;

void dfs(ll idx) {
    if (idx>10) {
        ans=true;
        return;
    }
    if (v1.empty()||a[idx]>v1.back()) {
        v1.pb(a[idx]);
        dfs(idx+1);
        v1.pop_back();
    }
    if (v2.empty()||a[idx]>v2.back()) {
        v2.pb(a[idx]);
        dfs(idx+1);
        v2.pop_back();
    }
}

int main()
{
    scanf("%lld",&n);
    for (ll i=1;i<=n;i++) {
        for (ll j=1;j<=10;j++) scanf("%lld",a+j);
        ans=false;
        dfs(1);
        if (ans) printf("YES\n");
        else printf("NO\n");
    }
}


Measured memory_bytes: 3196
N = int(input())
XYH = [[int(x) for x in input().split()] for _ in range(N)]

def get_cands(x, y, h):
    for xc in range(100 + 1):
        for yc in range(100 + 1):
            hc = h + abs(xc - x) + abs(yc - y)
            yield (xc, yc, hc)

def is_valid(top, view):
    xt, yt, ht = top
    xv, yv, hv = view
    return hv == max(0, ht - abs(xt - xv) - abs(yt - yv))

cand = set(get_cands(*next(filter(lambda x: x[2] > 0, XYH))))
ans = filter(lambda x: all(is_valid(x, v) for v in XYH), cand)

print(*next(ans))

Measured memory_bytes: 4592
use std::io::Read;
use std::cmp::min;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    const INF: usize = 100_001;
    let mut dp: Vec<usize> = vec![INF; n + 1];
    dp[0] = 0;
    for i in 0..n {
        dp[i + 1] = min(dp[i + 1], dp[i] + 1);
        let mut x: usize = 6;
        while i + x <= n {
            dp[i + x] = min(dp[i + x], dp[i] + 1);
            x *= 6;
        }
        let mut y: usize = 9;
        while i + y <= n {
            dp[i + y] = min(dp[i + y], dp[i] + 1);
            y *= 9;
        }
    }
    return dp[n].to_string();
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
#include <chrono> 
 
using namespace std;
using namespace std::chrono; 
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
#define gcd(a,b) __gcd(a,b)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vc vector<char>
#define pb(n) push_back(n)
#define pp pop_back()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define type(a) typeid(a).name();
#define print(arr) cout << "[" ;for(unsigned int i=0;i<(unsigned int) arr.size();i++){ (i==arr.size()-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define Arr(arr,l) cout << "[" ;for(unsigned int i=0;i<(unsigned int) l;i++){ (i==l-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define console(arr) cout << "["<<endl; for(ll i=0;i<(ll)arr.size();++i){cout << " [";for(ll j=0;j<(ll)arr[i].size();++j){(j==(int)arr[i].size()-1)?cout << arr[i][j]:cout << arr[i][j] << ",";}cout << "]"<<endl;} cout << "]"<<endl
#define starting() auto start = high_resolution_clock::now()
#define ending() auto stop = high_resolution_clock::now();auto duration = duration_cast<microseconds>(stop - start);cout << endl << endl << "Execution Time : "<<duration.count()/1000 << " ms" << endl
 
template <typename T1,typename T2>
void mapped(map<T1,T2>m){for(auto ite=m.begin();ite!=m.end();++ite){cout << "'" << ite->first << "'"<<" : "<<ite->second <<endl;}}
 
template <typename T1 , typename T2>
void mappedArr(map<T1,vector<T2>>m){for(auto ity=m.begin();ity!=m.end();++ity){cout << "'"<< ity->first <<"'"<<" : "<<"[";
for(int i=0;i<(int)ity->second.size();++i){(i==(int)ity->second.size()-1)?cout << ity->second[i]:cout << ity->second[i] << ",";}cout << "]"<<endl;}}
 
string int_to_string(int x){ stringstream ss; ss << x; string ni = ss.str(); return ni;}
int char_to_int(char c){ int n = (int)c - 48; return n; }
int string_to_int(string x){ int n; stringstream s(x); s >> n; return n; }
 
template <typename T1,typename T2>
void ArrPair(vector<pair<T1,T2>>vp){for(int i=0;i<(int)vp.size();++i){
cout << "(" << vp[i].first << "," << vp[i].second << ")"<<endl ;}}
 
const int MOD = 1e9 + 7;
const ll INF = 1e18L + 5;
 
unordered_map<int,int> um;
unordered_set<int> us;
set<int> s;
// v.front() gives the first element of vector 
// v.back()  gives the last element of vector
// insert erase substr
 
int main(){
   int l;
   cin >> l;
   int last = (l/2)-1;
   if(l%2==1){
	   last = l/2;
   }  
   int counting = 0;
   for(int i=1;i<=last;++i){
	   if(i != l-i){
		   counting++;
	   }
   }
   cout << counting;
}   
 















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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

const ll INF = 1LL << 60;

ll mod=1000000007;

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

int main() {
  int x,y;cin>>x>>y;
  rep(a,x+1){
    int b=x-a;
    if(2*a+4*b==y){cout<<"Yes";return 0;}
  }
  cout<<"No";
}

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

int count(int A, int B, int C)
{
    int i = 0;
    int c = 0;
    while (c < C)
    {
        i++;
        c += A;
        if (i % 7 == 0)
        {
            c += B;
        }
    }
    return i;
}
int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    cout << count(A, B, C) << endl;
    return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;


int main() {
    ll a, b; cin >> a >> b;

    if(a == 0){
        if(b < 0) cout << abs(b) + 1 << endl;
        else cout << abs(b) << endl;
    }else if(b == 0){
        if(a < 0) cout << abs(a) << endl;
        else cout << abs(a) + 1 << endl;
    }else if(0 < a && 0 < b){
        if(a < b){
            cout << b - a << endl;
        }else{
            cout << abs(b - a) + 2 << endl;
        }
    }else if(a < 0 && b < 0){
        if(abs(a) < abs(b)){
            cout << abs(b) - abs(a) + 2 << endl;
        }else{
            cout << abs(a) - abs(b) << endl;
        }
    }else if(a < 0 && 0 < b){
        if(abs(a) < b){
            cout << b - abs(a) + 1 << endl;
        }else{
            cout << abs(a) - b + 1 << endl;
        }
    }else if(0 < a && b < 0){
        if(a < abs(b)){
            cout << abs(b) - a + 1 << endl;
        }else{
            cout << a - abs(b) + 1 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
vector<ull>hash,power;
void Roliha(string &s){
  ull B=1000000007;
  int sz=s.size();
  hash.assign(sz+1,0);
  power.assign(sz+1,0);
  power[0]=1;
  for(int i=1;i<=sz;i++)power[i]=power[i-1]*B;
  for(int i=1;i<=sz;i++)hash[i]=(hash[i-1]+s[i-1])*B;
}
ull get_hash(int l,int r){return hash[r]-hash[l]*power[r-l];}
int main(){
  int n,m,l=0,r=1;
  string s,t;
  cin>>n>>m>>s;
  set<ull>p;
  Roliha(s);
  while(m--&&cin>>t){
    if(t[0]=='R')t[1]=='+'?r++:r--;
    else t[1]=='+'?l++:l--;
    p.insert(get_hash(l,r));
  }
  cout<<p.size()<<endl;
}

Measured memory_bytes: 21696
n = int(input())
if n == 0:
    print(0)
    exit()
i = 0
#for i in range(10):
ans = []
while abs(n) > 0:
    #print(n, n // (2 * (-1)**i), n % (2 * (-1)**i))
    #print(n, n % (2 * (-1)**i), n % 2)
    ans.append(n%2)
    #n = n // (2 * (-1)**i)
    n = (n - n % (2 * (-1)**i)) // 2
    i += 1
#print(n, n % (2 * (-1)**i))
#print(ans[::-1])
print(''.join(map(str, ans[::-1])))


Measured memory_bytes: 2940
fun main(args: Array<String>) {
    val x = readLine()!!.toInt()
    val l = mutableSetOf<Int>()
    l.add(1)
    for (i in 2..32) {
        var p = 2
        while (Math.pow(i.toDouble(), p.toDouble()) <= 1000) {
            l.add(Math.pow(i.toDouble(), p.toDouble()).toInt())
            p++
        }
    }
    println(l.filter { it <= x }.max())
}


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

vector<P>E[200000];
ll d[200000];
int par[20][200000];

struct LCA{
	vector<vector<int> > g;
	const int MAX_LOG = 22;
	vector<vector<int> > lcc;
	vector<int> dep;
	vector<int> myr;  //its root
private:
	void init2(){
		int n = g.size();
		for (int i = 0; i + 1 < MAX_LOG; i++){
			for (int j = 0; j < n; j++){
				if (lcc[i][j] == -1){
					lcc[i + 1][j] = -1;
					continue;
				}
				lcc[i + 1][j] = lcc[i][lcc[i][j]];
			}
		}
	}
public:
	int lca(int a, int b){
		if (myr[a] != myr[b]){
			return -1;
		}
		if (dep[a] < dep[b]){
			swap(a, b);
		}
		for (int i = 0; i < MAX_LOG; i++){
			if (((dep[a] - dep[b]) >> i) & 1){
				a = lcc[i][a];
			}
		}
		if (a == b){
			return a;
		}
		for (int i = MAX_LOG - 1; i >= 0; i--){
			if (lcc[i][a] != lcc[i][b]){
				a = lcc[i][a];
				b = lcc[i][b];
			}
		}
		return lcc[0][a];
	}
private:
	int flag_r;
	inline void dfs(int b, int pr = -1, int d = 0){
		for (auto &i : g[b]){
			if (i == pr)continue;
			dfs(i, b, d + 1);
		}
		dep[b] = d;
		lcc[0][b] = pr;
		myr[b] = flag_r;
	}
public:

	void init(vector<vector<int> > &tree, int root = 0){
		g = tree;
		myr.resize(tree.size(), -1);
		flag_r = root;
		lcc.resize(MAX_LOG, vector<int>(g.size(), 0));
		dep.resize(g.size());
		dfs(root);
		init2();
	}
	void init(vector<vector<int> > &tree, vector<int> &root){  //not varified
		g = tree;
		myr.resize(tree.size(), -1);
		lcc.resize(MAX_LOG, vector<int>(g.size(), 0));
		dep.resize(g.size());
		for (int &i : root){
			if (myr[i] == -1){
				flag_r = i;
				dfs(i);
			}
		}
		init2();
	}
	int dist(int a, int b){
		if (myr[a] != myr[b]){
			return -1;
		}
		int lc = lca(a, b);
		return dep[a] + dep[b] - 2 * dep[lc];
	}
	int go(int a, int b){
		for (int i = 0; i < MAX_LOG; i++){
			if ((b >> i) & 1){
				a = lcc[i][a];
			}
		}
		return a;
	}
};
void dfs(int v,int p,ll d1){
	d[v]=d1;par[0][v]=p;
	for(P u:E[v]){
		if(u.second!=p)dfs(u.second,v,d1+u.first);
	}
}
LCA G;
ll dist(int x,int y){
	return d[x]+d[y]-d[G.lca(x,y)]*2;
}
int main(){
	int n;scanf("%d",&n);
	vector<vector<int>>F(n);
	rep(i,n-1){
		int a,b,c;scanf("%d%d%d",&a,&b,&c);a--;b--;
		E[a].push_back(P(c,b));E[b].push_back(P(c,a));
		F[a].push_back(b);F[b].push_back(a);
	}
	G.init(F);
	dfs(0,-1,0);
	int q,k;scanf("%d%d",&q,&k);k--;
	rep(i,q){
		int x,y;scanf("%d%d",&x,&y);x--;y--;
		printf("%lld\n",dist(x,k)+dist(k,y));
	}
}

Measured memory_bytes: 37880
a,b,c = STDIN.gets.split(' ').map{|s| s.to_i}

if c - a - b > 0
  if ((c-a-b)**2 - 4*a*b ) > 0
    puts 'Yes'
  else
    puts 'No'
  end
elsif c - a - b < 0
  puts 'No'
else
  puts 'No'
end


Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<unordered_map>
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0;i < 3;i++){
        if(s[i] == '1')ans++;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int s[100005];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&s[i]);
    }
    int sum=0;
    for(int i=1;i<=n;i++){
        if(s[i]==i)
        {
            if(i+1<=n)swap(s[i],s[i+1]),sum++;
            else if(i-1>=1)swap(s[i],s[i-1]),sum++;
        }
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 768
#include <iostream>

using namespace std;

int main()
{
  int N,max = 0;
  char S[110] = {0};

  cin >> N;

  for(int i = 0;i < N;i++)
    cin >> S[i];

  
  for(int i = 0;i < N;i++){
    int c = 0;
    int check[30] = {0};
    for(int j = 0;j < i;j++){
      for(int l = i;l < N;l++){
	if(S[j] - 'a' == S[l] - 'a'){
	  if(check[S[j] - 'a'] == 0){
	    check[S[j] - 'a']++;
	  }
	}
      }
    }
    for(int k = 0;k < 30;k++){
      if(check[k])
	c++;
    }
    if(c > max)
      max = c;
  }

  cout << max << endl;

  return 0;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
using namespace std;
int main(){
     string ab,bc,cd=" ";
     int k,t=0,h=0;
     cin>>k;
     for(int n=0;n<k;n++){
     cin>>ab>>bc;
     if(ab==bc){
        t=t+1;
        h=h+1;
     }else if(ab>bc){
         t=t+3;
     }else{
         h=h+3;
     }
     }
     cout<< t << cd << h <<endl;
return 0;
}

Measured memory_bytes: 1212
n = int(input())
arr = [0]*(n+1)

for i in range(2, n+1):
  tmp = i
  div = 2
  while(div <= i):
    if(tmp%div == 0):
      arr[div] += 1
      tmp //= div
    else:
      div += 1
    
def count(n):
  return len([i for i in arr if i >= n])

ans = count(74) + count(24)*(count(2)-1) + count(14)*(count(4)-1) + count(4)*(count(4)-1)*(count(2)-2)//2
print(ans)

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String t = br.readLine();
        String p = br.readLine();
        for (int i = 0; i < t.length() - p.length() + 1; i++){
            if (t.substring(i, i + p.length()).equals(p)){
                System.out.println(i);
            }
        }
    }
}

Measured memory_bytes: 24488
#include <bits/stdc++.h>
using namespace std;
using vv=vector<int>;

int main(){
  long i,N=1,M,A,B;
  cin>>A>>B;
  M=min(A,B);
  for(i=2;i<M+1;i++){
    if(A%i==0&&B%i==0)N=i;
  }
  cout<<A*B/N<<endl;
}


Measured memory_bytes: 3608
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll MOD=(ll)1e9+7;
//}}}

void f(string s, string t)
{
  rep(i, s.size()){
    if(s[i] != t[i]){
      char si = s[i];
      char ti = t[i];
      rep(j, s.size()){
        if(s[j] == si) s[j] = ti;
        else if(s[j] == ti) s[j] = si;
      }
    }
  }
  bool ans = s == t;
  puts(ans ? "Yes" : "No");
}

int main(){
  string s, t;
  cin >> s >> t;
  char ch[26];
  rep(i, 26){
    ch[i] = '.';
  }
  vector<pair<char, char>> v;
  rep(i, s.size()){
    v.emplace_back(t[i], s[i]);
  }
  sort(v.begin(), v.end());

  string newS;
  string newT;

  bool flag = true;
  foreach(x, v){
    char ct = x.first;
    char cs = x.second;
    char last_cs;
    char last_ct;
    if(flag){
      flag = false;
      newS = cs;
      newT = ct;
      last_cs = cs;
      last_ct = ct;
      continue;
    }
    if(last_cs != cs || last_ct != ct){
      newS += cs;
      newT += ct;
    }
  }

  f(newS, newT);
  return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<string>
using namespace std;
struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
  }
  int top() {
    return s[0];
  }
};

int main(){
  Dice d;
  for(int i=0;i<6;i++) cin >> d.s[i];
  string s;
  cin >> s;
  for(int i=0;i<s.size();i++) d.roll(s[i]);
  cout << d.top() << endl;
  return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

typedef long long ll;
#define READ(a) int a; cin >> a;
#define READARR(a, n) int a[(n) + 1]; FOR(i, 1, (n)) {cin >> a[i];}
#define READMAT(a, n, m) int a[n + 1][m + 1]; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define pb(x) push_back(x)
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string str;
	cin >> str;
	int n = str.length();
	str = " " + str;
	
	int dp[n + 1][13] = {};
	if (str[1] == '?')
	    FOR (i, 0, 9) dp[1][i] = 1;
	
	else dp[1][str[1] - 48] = 1;
	
	FOR (i, 2, n)
	{
	    if (str[i] == '?')
	    {
	        FOR (j, 0, 9)
	           FOR (k, 0, 12)
	               dp[i][(10*k + j) % 13] = (dp[i][(10*k + j) % 13] + dp[i - 1][k]) % mod;
	    }
	    
	    else
	    {
	        int j = str[i] - 48;
	        FOR (k, 0, 12)
	               dp[i][(10*k + j) % 13] = (dp[i][(10*k + j) % 13] + dp[i - 1][k]) % mod;
	    }
	}
	
	cout << dp[n][5];
}

Measured memory_bytes: 10604
#include <stdio.h>

int main( void ) {
	int i, a, b, first = 1, exist;

	while ( scanf( "%d %d", &a, &b ), a ) {
		if ( !first )
			putchar( '\n' );

		exist = 0;
		for ( i = ( a - 1 ) / 4 * 4 + 4; i <= b; i += 4 )
			if ( i % 25 || !( i % 400 ) ) {
				printf( "%d\n", i );

				exist = 1;
			}
		if ( !exist )
			puts( "NA" );

		first = 0;
	}

	return 0;
}

Measured memory_bytes: 616
program abc121b
  integer n, m, c, i, ans
  integer, allocatable :: a(:), b(:)
  read *, n, m, c
  allocate(a(m), b(m))
  read *, b
  ans = 0
  do i = 1, n
     read *, a
     if (sum(a * b) + c > 0) ans = ans + 1
  end do
  print *, ans
end program abc121b


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
	int i, j;
	char a[30];
	int la;
	int ans = 0;
	scanf("%s", &a);
	la = strlen(a);
	for(i = 0; i < la - 1; i++)
		for(j = i + 1; j < la; j++)
			if(a[i] == a[j])
			ans++;
			
			if(ans == 0)
				printf("yes\n");
				else
					printf("no\n");
}

Measured memory_bytes: 256
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())

num0 = 0
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                A[i][j] = 0
                num0 += 1
                if num0 >= 3:
                    if max(A[0]) == 0 or max(A[1]) == 0 or max(A[2]) == 0:
                        print("Yes")
                        exit()
                    elif A[0][0] == A[1][0] == A[2][0] == 0:
                        print("Yes")
                        exit()
                    elif A[0][1] == A[1][1] == A[2][1] == 0:
                        print("Yes")
                        exit()
                    elif A[0][2] == A[1][2] == A[2][2] == 0:
                        print("Yes")
                        exit()
                    elif A[0][0] == A[1][1] == A[2][2] == 0:
                        print("Yes")
                        exit()
                    elif A[0][2] == A[1][1] == A[2][0] == 0:
                        print("Yes")
                        exit()

print("No")

Measured memory_bytes: 38384
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision) << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 110;
ll W, H, x, y;

int main(int argc, const char * argv[]) {
    cin >> W >> H >> x >> y;

    double ans = W * H / 2.0;

    int ans2 = 0;
    if (x == W / 2.0 && y == H / 2.0) {
        ans2 = 1;
    }

    output(ans, 12);
    output(ans2);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>

using std::string;
using std::vector;
using std::unordered_map;
using std::map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ui N{}, Q{}; cin >> N >> Q;
  unordered_map<ui, pair<ull, vector<ui>>> tree{};
  for(size_t temporary = 0; temporary < N - 1; ++temporary)
  {
    ui a{}, b{}; cin >> a >> b;
    --a; --b;
    tree[a].second.push_back(b);
    // tree[b].second.emplace(a);
  }

  // typedef pair<ui, ui> Pair0;
  // std::queue<pair<ui, ui>> queue0;
  // for(const auto& v : tree[0].second)
  // {
  //   queue0.push({v, 0});
  // }
  // while (!queue0.empty())
  // {
  //   Pair0 p = queue0.front();
  //   queue0.pop();
  //   tree[p.first].second.erase(p.second);
  //   for(const auto& v : tree[p.first].second)
  //   {
  //     queue0.push({v, p.first});
  //   }
  // }

  typedef pair<ui, ull> Pair;
  std::queue<pair<ui, ull>> queue{};
  for(size_t temporary = 0; temporary < Q; ++temporary)
  {
    ui p{}, x{}; cin >> p >> x;
    --p;
    tree[p].first += x;
  }
  for(const auto& v : tree[0].second)
  {
    queue.push({v, tree[0].first});
  }
  while(!queue.empty())
  {
    Pair p = queue.front();
    queue.pop();
    tree[p.first].first += p.second;
    for(const auto& v : tree[p.first].second)
    {
      queue.push({v, tree[p.first].first});
    }
  }

  cout << tree[0].first;
  for(ui i = 1; i < N; ++i)
  {
    cout << SPACE << tree[i].first;
  }
  cout << CRLF;

  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 23112
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int main() {
	int N;
	cin >> N;
	
	int nx = 0, ny = 0, nt = 0;
	bool ans = true;
	
	REP(i, N) {
		int t, x, y;
		scanf("%d %d %d", &t, &x, &y);
		int d = abs(nx - x) + abs(ny - y);
		if (d > t - nt) ans = false;
		else if ((t - nt - d) & 1) ans = false;
		nx = x; ny = y; nt = t;
	}
	
	puts(ans ? "Yes" : "No");
	
	return 0;
}

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

int main (int argc, char* argv[]){
    int n;
    cin >> n;
	vector<int> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    int q;
    cin >> q;
    vector<int> t(q);
    for (int i = 0; i < q; i++) {
        cin >> t[i];
    }

    int count = 0;
    for (int x : t){
        if (binary_search(s.begin(), s.end(), x)) {
            count++;
        }
    }

    cout << count << endl;

	return 0;
}

Measured memory_bytes: 3364
// 2009ツアツジツアツ地ツ凝ヲツ予ツ選 G : Malfatti Circles
#include <iostream>
#include <complex>
#include <stdio.h>

using namespace std;

const double EPS = 1e-12;

typedef complex<double> P;
struct L{ P p, q; L(P p, P q) : p(p), q(q) {} };

double cross(P a, P b) { return imag(conj(a)*b); }

double lpDist(L l, P p){
	return abs(cross(l.q-l.p,p-l.p))/abs(l.q-l.p);
}

P crossPoint(L l, L m){
	double A = cross(l.q-l.p, m.q-m.p);
	double B = cross(l.q-l.p, l.q-m.p);
	return m.p + B/A*(m.q-m.p);
}

int main(){
	int x1, y1, x2, y2, x3, y3;
	while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3){
		if(!(x1||y1||x2||y2||x3||y3)) break;
		P p1 = P(x1,y1), p2 = P(x2,y2), p3 = P(x3,y3);
		P dirA = (p2-p1)/abs(p2-p1)+(p3-p1)/abs(p3-p1);
		P dirB = (p1-p2)/abs(p1-p2)+(p3-p2)/abs(p3-p2);
		P c = crossPoint(L(p1,p1+dirA),L(p2,p2+dirB));
		double rA, rB, rC;
		double leftA = 0.0, rightA = 1.0, leftB, rightB, leftC, rightC;
		while(true){
			double midA = (leftA+rightA)/2;
			P cA = p1 + (c-p1)*midA, cB, cC;
			rA = lpDist(L(p1,p2), cA);
			leftB = 0.0, rightB = 1.0, leftC = 0.0, rightC = 1.0;
			while(rightB-leftB>EPS){
				double midB = (leftB+rightB)/2;
				cB = p2 + (c-p2)*midB;
				rB = lpDist(L(p2,p3), cB);
				if(rA+rB < abs(cB-cA)) leftB  = midB;
				else                   rightB = midB;
			}
			while(rightC-leftC>EPS){
				double midC = (leftC+rightC)/2;
				cC = p3 + (c-p3)*midC;
				rC = lpDist(L(p3,p1), cC);
				if(rA+rC < abs(cC-cA)) leftC  = midC;
				else                   rightC = midC;
			}
			if(rB+rC > abs(cB-cC)) leftA  = midA;
			else                   rightA = midA;
			if(rightA-leftA < EPS){
				printf("%.5lf %.5lf %.5lf\n", rA, rB, rC);
				break;
			}
		}
	}
}

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

double m, n;
double a[105];

int main()
{
	cin >> n >> m;
	int s = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		s += a[i];
	} 
	double std = 1.0 / (4 * m) * s;
//	cout << s << " " << std << endl;
	int cnt = 0;
	for (int i = 1; i <= n; i++) 
		if (a[i] >= std) cnt++;
	if (cnt >= m) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
using namespace std;
typedef int64_t ll;
typedef vector<ll> vll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll N;
        in >> N;
        vll x(N), y(N);
        rep(i, N) {
            in >> x[i] >> y[i];
        }
        ll ans = 0;
        ll mod = 998244353;
        reu(i, 0, N) {
            reu(j, i + 1, N) {
                ll cnt1 = 0;
                ll cnt2 = 0;
                reu(k, j + 1, N) {
                    cnt1 = (cnt1 * 2 + 1) % mod;
                    if (triangle(x[i] - x[k], y[i] - y[k], x[j] - x[k], y[j] - y[k]) == 0) {
                        cnt2 = (cnt2 * 2 + 1) % mod;
                    }
                }
                ans += cnt1;
                ans -= cnt2;
                ans %= mod;
                ans %= mod;
            }
        }
        out << ans << '\n';
    }
    ll triangle(ll ax, ll ay, ll bx, ll by) {
        return (ax*by) - (bx*ay);
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
h = [int(i) for i in input().split()]
for i in range(n):
    print('node %d: key = %d, ' %(i+1, h[i]), end='')
    if i != 0:
        print('parent key = %d, ' %(h[(i+1) // 2 - 1]), end='')
    li = 2 * i + 1
    if li < n:
        print('left key = %d, ' %(h[li]), end='')
    ri = 2 * i + 2
    if ri < n:
        print('right key = %d, ' %(h[ri]), end='')
    print('')
    

Measured memory_bytes: 7792
n,m=list(map(int,input().split()))
#隣接リスト表現
es=[[0 for i in range(n)] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  es[a-1][b-1]=1
  es[b-1][a-1]=1

# 再帰の深さが1000を超えそうなときはこれをやっておく
import sys
sys.setrecursionlimit(10**7)


#深さ優先探索
#n個の頂点が未探索であるとしておく
visited=[0 for i in range(n)]
check=[1 for i in range(n)]

def dfs(v,visited):
  #ansは頂点vから始まるパスの数
  ans=0
  #自分がいることろを探索済にしておく
  visited[v-1]=1

  if visited==check:
    visited[v-1]=0
    return 1
  #そこから行けるところに対して深さ優先探索
  for i in range(n):
    #つながっていて未探索
    if es[v-1][i]==1 and visited[i]==0:
        ans+=dfs(i+1,visited)
  #全部探索し終わったら今自分がいるところは未探索に戻しておく
  visited[v-1]=0
  return ans

print(dfs(1,visited))


Measured memory_bytes: 9144
n, a, b = map(int, input().split())

sum = 0
for i in range(n + 1):
    sum2 = 0
    j = i
    while True:
        if j == 0:
            break
        sum2 += j % 10
        j = j // 10
    if sum2 >= a and sum2 <= b:
        sum += i

print(sum)


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int main()
{
	int n, k;
	cin >> n >> k;
	if (n%k) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static const int INF = 1e9+7;

int main(){
    int h,n; cin>>h>>n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin>>a[i];
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());

    int i;

    for(i=0; i<n; i++){
        h -= a[i];
        if(h <= 0) break;
    }

    if(i != n) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

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

int main(){
    int N, A, B;
    cin >> N;
    if(N == 1){
        cout << "Hello World" << endl;
    }
    else if(N == 2) {
        cin >> A >> B;
        cout << A + B << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <cstdio>
#include <cmath>
#include <utility>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
using namespace std;

template<class T>inline string toString(T x){
        ostringstream sout; sout<<x; return sout.str();
}
const ll MOD=1e9+7;
const int inf=(ll)1e9;
const double PI=acos(-1.0);

struct UF
{
	int par[100001];
	bool mark[100001];
	void init(int n){
		for(int i=0;i<n;i++){
			par[i]=0;
			mark[i]=0;
		}
		mark[0]=1;
	}
	void parent(int p,int c){
		par[c]=p;
	}
	void Mark(int a){
		mark[a]=1;
	}
	int find(int a){
		if(mark[a])return a;
		else return find(par[a]);
	}
	void test(int n){
		for(int i=0;i<n;i++){
			cerr<<par[i]<<" ";
		}
		cerr<<endl;
		for(int i=0;i<n;i++){
			cerr<<mark[i]<<" ";
		}
		cerr<<endl;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
    cout<<fixed;
    int n,m;
    while(cin>>n>>m){
    	if(n==0 && m==0)return 0;
    	UF uf;
    	uf.init(n);
    	for(int i=1;i<n;i++){
    		int a;cin>>a;a--;
    		uf.parent(a,i);
    	}
    	ll ans=0;
    	for(int i=0;i<m;i++){
    		char a;
    		int b;
    		cin>>a>>b;b--;
    		if(a=='M'){
    			uf.Mark(b);
    			//uf.test(n);
    		}else{
    			ans+=uf.find(b)+1;
    		}
    	}
    	cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3696
#include <stdio.h>
#include <math.h>
#include <string.h>

int gcd(int a,int b){
    if(a<b){
        int now=a;
        a=b;
        b=a;
    }

    int r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }

    return b;
}



/* 値を入れ替える関数 */
void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}



int main(void){
    long int n;
    scanf("%ld",&n);
    int count=0;
    char ans[100];


    while(n>0){
        char now='a';
        int add=n%26;
        if(add==0){
            add=26;
            n-=26;
        }
        add--;
        now+=add;
        ans[count]=now;

        count++;
        n/=26;
    }

    int i;
    for(i=count-1;i>=0;i--){
        printf("%c",ans[i]);
    }
    printf("\n");
}

Measured memory_bytes: 1644