akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class I,class V=typename I::value_type>V sum_up(const I&l,const I&r){V v;for(I i=l;i!=r;i++)v=i==l?*i:v+*i;return v;}
template<class I,class T=iterator_traits<I>>I operator+(I it,int n){for(int i=0;i<n;i++)it++;return it;}
template<class I,class T=iterator_traits<I>>I operator-(I it,int n){for(int i=0;i<n;i++)it--;return it;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }

// O(N*2^M)
int main() {
    int N, M;
    cin >> N;
    vector<pair<int, int>> edge(N - 1);
    vector2d<pair<int, int>> connection(N);
    for(int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        connection[a].push_back({b, i});
        connection[b].push_back({a, i});
        edge[i] = {a, b};
    }
    vector<int> cond(N - 1);
    cin >> M;
    for(int j = 0; j < M; j++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        vector<bool> used(N, false);
        recursive([&](auto f, int p) -> bool {
            if(p == v) return true;
            if(used[p]) return false;
            used[p] = true;
            for(auto x : connection[p]) {
                int i, e;
                tie(i, e) = x;
                if(f(f, i)) {
                    cond[e] |= 1 << j;
                    return true;
                }
            }
            return false;
        })(u);
    }
    int pM = 1 << M;
    vector<i64> dp[2];
    dp[0] = vector<i64>(pM, 0);
    dp[0][0] = 1;
    for(int i = 0; i < N - 1; i++) {
        dp[1] = vector<i64>(pM, 0);
        for(int j = 0; j < pM; j++) {
            dp[1][j | cond[i]] += dp[0][j];
            dp[1][j] += dp[0][j];
        }
        swap(dp[0], dp[1]);
    }
    cout << dp[0][pM - 1] << endl;
}


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

int main(){
	unsigned short int N, i, iLongestSide, otherSideLengthSum;
	
	scanf("%hu", &N);
	unsigned short int L[N];
	
	i = 0;
	iLongestSide = i;
	scanf("%hu", &L[i]);
	otherSideLengthSum = 0;
	for(i = 1; i < N; i++){
		scanf("%hu", &L[i]);
		if(L[i] > L[iLongestSide]){
			otherSideLengthSum += L[iLongestSide];
			iLongestSide = i;
		}else{
			otherSideLengthSum += L[i];	
		}	
	}
	if(L[iLongestSide] < otherSideLengthSum){
		printf("Yes\n");
	} else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
s = input()
S = list(s)
re = 0
a = 0
for i in range(3):
    if S[i] == 'R':
        a += 1
if a > 0:
    if a == 2:
        if S[0] == S[1] or S[1] == S[2]:
            re = 2
        else:
            re = 1
    elif S[0] == S[1] and S[1] == S[2] and a == 3:
        re = 3
    else:
        re = 1
else:
    re = 0
print(re)

Measured memory_bytes: 9072
import collections
n = int(input())
c = list(input())
C = collections.Counter(c)
n_r = C['R']
n_w = C['W']
ans = [0,0]

for i in range(n_r):
    if c[i] == 'W':
        ans[0] += 1

c = c[::-1]

for i in range(n_w):
    if c[i] == 'R':
        ans[1] += 1

print(min(ans))

Measured memory_bytes: 12232
import math
N, K = map(int, input().split())

if N >= K:
    p = N - K + 1
else:
    p = 0

for n1 in range(1, min(N+1,K)):
    p += pow(1/2, math.ceil(math.log(K/n1)/math.log(2)))

print("{:>.20f}".format(p/N))


Measured memory_bytes: 2940
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 
#include <bits/stdc++.h>
using namespace std;

using namespace std;

int main(){
    int n,k=0;
    std::cin >> n;
    int v[n],c[n],a[n];
    rep(i,n){
        std::cin >>v[i] ;
    }
    rep(i,n){
        std::cin >>c[i] ;
    }
    rep(i,n){
        a[i]=v[i]-c[i];
        if(a[i]<0)a[i]=0;
        k+=a[i];
    }
    std::cout << k << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  int m,n,q,order,c,b,e;
  cin>>m;
  vector<int>v;
  for(int i=1;i<=m;i++){
    cin>>n;
    v.push_back(n);}
  cin>>q;
  while(q--){
    cin>>c>>b>>e;
      if(c) cout<<*max_element(v.begin()+b,v.begin()+e)<<endl;
        else cout<<*min_element(v.begin()+b,v.begin()+e)<<endl;


  }

  return 0;
}



Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,a,b;
	cin >> n;
	vector<int> v(n,0);
	vector<int> v2(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		v2[i] = v[i];
	}
	sort(v2.begin(), v2.end());
	a = v2[n / 2 - 1];
	b = v2[n / 2];
	for (int i = 0; i < n; i++) {
		if (v[i] <= a) {
			cout << b << endl;
		}
		else if (v[i] >= b) {
			cout << a << endl;
		}
	}
}

Measured memory_bytes: 3712
def main():
    s = input().rstrip()
    ans = -1
    for i in range(len(s)):
        for j in range(26):
            c = chr(ord("a") + j)
            f = True
            for k in range(len(s)-i):
                sf = True
                for l in range(i+1):
                    if s[k+l] == c:
                        sf = False
                        break
                if sf:
                    f = False
                    break
            if f:
                ans = i
                break
        if ans != -1:
            break
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define fi first
#define se second
#define Mp make_pair
#define pb push_back
#define rep(i, j, k) for (int i = (j); i <= (k); i++)
#define per(i, j, k) for (int i = (j); i >= (k); i--)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int, int> PII;
typedef vector<int> VI;

ll n,ans=0x3f3f3f3f3f3f3f;

int main(){
    cin>>n;
    for(ll i = 1;i*i<=n;i++){
        if(n%i==0) ans=min(ans,i+n/i-2);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int l,r,ans;
char s[1000000];
int main(){
	ios::sync_with_stdio(false);
	cin>>s;l=0;r=strlen(s)-1;
	while (l<r){
		if (s[l]==s[r]){l++;r--;continue;}
		if (s[l]=='x'){l++;ans++;continue;}
		if (s[r]=='x'){r--;ans++;continue;}
		cout<<-1<<endl;return 0;
	}cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <algorithm>
#define N 301000
template <typename T> inline void read(T &x) {
	x = 0; char c = getchar(); bool flag = false;
	while (!isdigit(c)) { if (c == '-')	flag = true; c = getchar(); }
	while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
	if (flag)	x = -x;
}
using namespace std;
const int up = 300000;
int n, m, t;
int X[N], Y[N];
int binx[N], biny[N];
int main() {
	read(n), read(m), read(t);
	for (int i = 1; i <= t; ++i) {
		read(X[i]), read(Y[i]);
		++binx[X[i]];
		++biny[Y[i]];
	}
	int mxx = 0, ctx = 0;
	for ( int i = 1; i <= up; ++i) {
		if (binx[i] > mxx)	mxx = binx[i], ctx = 1;
		else if (binx[i] == mxx)	++ctx;
	}
	int mxy = 0, cty = 0;
	for (int i = 1; i <= up; ++i) {
		if (biny[i] > mxy)	mxy = biny[i], cty = 1;
		else if (biny[i] == mxy)	++cty;
	}
	int cnt = 0;
	for (int i = 1; i <= t; ++i) {
		if (binx[X[i]] == mxx && biny[Y[i]] == mxy)	++cnt;
	}
	if (cnt == ctx * cty)	cout << mxx + mxy - 1 << endl;
	else cout << mxx + mxy << endl;
	return 0;
}



Measured memory_bytes: 7880
/*Saurav Paul*/
#include<bits/stdc++.h>
using namespace std;

#define ll 					  long long int
#define boost		          ios_base::sync_with_stdio(0);
#pragma GCC optimize("O3")
#define loop(i,a,b)           for(ll i=a;i<=b;++i)
#define eb                    emplace_back
#define itoc(c)               ((char)(((int)'0')+c))
#define ctoi(c)               ((int)(((int)c)-'0'))
#define all(p)                p.begin(),p.end()
#define bug()				  debug() <<

///////////////////////

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef PAUL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define dbg(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#ifdef ONLINE_JUDGE
#define cerr if (false) cerr
#endif
int main() ;
void file(){
	#ifdef PAUL
		freopen("in.txt","r",stdin);
		//freopen("out.txt","w",stdout);
	#endif
}
void time(){
	#ifdef PAUL
		cerr << "\nTime elapsed: " << (double)(1.0 * (double)clock() / CLOCKS_PER_SEC) << " s.\n";
	#endif
}
///////////////////////
const int INF = 1e9 + 90;
const ll LINF = 1e18 + 90 ;
using pii = pair<int,int >;
using vec = vector<int> ;

int main()
{
	boost ;
	int n ; cin >> n;
	vector<int> a(n) , b(n) , v , t;
	for(auto &x : a) cin >> x;
	for(auto &x : b) cin >> x;

	for(int i = 1; i<= n; i++){
		v.emplace_back(i);
	}
	t = v;
	int i  = 0 , j = 0 ;
	do{
		++i ;
		bug() dbg(v) dbg(i) ;
		if(v == a) break ;
	}while(next_permutation(all(v))) ;

	do{
		++j ;
		if(t == b) break ;
	}while(next_permutation(all(t))) ;
	bug() dbg(i) dbg(j) ;
	cout << abs(i-j) << endl ;

    return 0;
}


Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
using namespace std;
int main(){
  long long W, H, x, y;
  cin >> W >> H >> x >> y;
  cout << fixed << setprecision(12) << (double)W*H/2 << " " << (x*2 == W and y*2 == H) << endl;
}


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

using namespace std;

#define int long long
#define MP make_pair
#define F first
#define S second
#define pi pair<int,int> 
#define sz(s) ((int)s.size())
#define rep(i,a,b) for (int i = a; i <= (int)b; ++i)

const unsigned mod = 1e9 + 7;
const unsigned N = 5e5 + 4;

int dp[14][10][2][2];

int go(int id, const string &s, int last, bool f = 0, bool f2 = 0) {
	if (id == sz(s)) return f2;
	if (~dp[id][last][f][f2]) return dp[id][last][f][f2];
	// cout << id << ' ' << last << ' ' << f << ' ' <<f2 << '\n';
	int cur = s[id] - '0';
	int ans = 0;
	rep(i,0,9) {
		if (f == false && cur < i) break;
		if (!f2) ans += go(id + 1, s, i, f|(i<cur),f2|(i>0));
		else if (abs(i-last) <= 1) {
			ans += go(id + 1, s, i, f|(i<cur),f2|(i>0));
		}
	}
	return dp[id][last][f][f2] = ans;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  int lo = 1, hi = 1e12, mid;
  while (lo <= hi) {
  	mid = lo + hi >> 1LL;
  	memset(dp, -1, sizeof dp);
  	// const string 
  	if (go(0,to_string(mid),0) >= n)
  		hi = mid - 1;
  	else lo = mid + 1;
  }
  cout << hi+1 << '\n';
  memset(dp, -1, sizeof dp);
  // cout << go(0,to_string(21),0);
  assert(numeric_limits<int>::max() >= 1e18);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define eps 10e-9
using namespace std;
int main()
{
    int data[10],sum=0;
    int v1,v2;
    while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&data[0],&data[1],&data[2],&data[3],&data[4],&data[5],&data[6],&data[7],&data[8],&data[9],&v1,&v2)!=EOF)
    {
        sum=data[0];
        for(int i = 1; i < 10; ++i)
        {
            sum+=data[i];
            data[i]=sum;
        }
        //cout<<"sum="<<data[9]<<endl;
        double t=data[9]/(double)(v1+v2);
        //printf("t=%.9lf\n",t);
        for(int i = 0; i < 10; ++i)
        {
            if(v1*t<(double)data[i]+eps)
            {
                cout<<i+1<<endl;
                break;
            }
        }
    }
  return 0;
}

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

using namespace std;
typedef long long ll;

inline int at(ll x, int k){ return (x >> k) & 1; }
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)


int main() {
	ll n,m;
	cin >> n>>m;
	ll h[n];
	rep(i,0,n){
		cin >> h[i];
	}
	map<ll,ll> ab;

	rep(i,0,n){
		ab[i]=1;
	}

	rep(i,0,m){
		ll a,b;
		cin >> a >> b;
		a--;
		b--;
		if(h[a]>h[b]){
			ab.erase(b);
		}
		else if(h[a]<h[b]){
			ab.erase(a);
		}
		else{
			ab.erase(a);
			ab.erase(b);
		}
	}



	cout << ab.size() << endl;


}


Measured memory_bytes: 10660
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize,
        bv: [usize; n - 1]
    };

    let mut prev = std::usize::MAX;
    let mut res = 0;
    for &b in &bv {
        res += prev.min(b);
        prev = b;
    }
    res += bv[n - 2];
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2236
import sys
from decimal import Decimal
from fractions import Fraction

def main():

    input_strings = sys.stdin.readlines()
    for matrix_string in input_strings:
        matrix = list(map(Fraction, list(matrix_string.split())))
        if matrix[0] == 0:
            matrix = matrix[3:] + matrix[:3]
        matrix = list(map(lambda x: x / matrix[0], matrix[:3])) + matrix[3:]
        matrix = matrix[:3] + list(map(lambda x: x[1] - matrix[3] * x[0], zip(matrix[:3], matrix[3:])))
        matrix = matrix[:3] + list(map(lambda x: x / matrix[4], matrix[3:]))
        matrix = list(map(lambda x: x[0] - matrix[1] * x[1], zip(matrix[:3], matrix[3:]))) + matrix[3:]
        matrix = list(map(float, matrix))
        matrix = list(map(Decimal, matrix))
        matrix = list(map(lambda x: x.quantize(Decimal('.001'), rounding='ROUND_HALF_UP'), matrix))

        print('%.3f %.3f' % (matrix[2], matrix[5]))
main()

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

using ll = long long;

signed main(){
	ll n;
	cin >> n;

	if(n%2 == 1){
		cout << "0\n";
		return 0;
	}

	ll ans = 0;

	ll k = n/2;
	while(k>=5){
		ans = ans+(k/5);
		k = k/5;
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int x, y, z; cin >> x >> y >> z;
	swap(x, y);
	swap(x, z);
	cout << x << " " << y << " " << z;

	return 0;
}

Measured memory_bytes: 3196
import numpy as np
import math
import scipy
import itertools

def solve():
    n, a, b = map(int, input().split())
    if a > b:
        print(0)
    elif n == 1:
        if a == b:
            print(1)
        else:
            print(0)
    else:
        print((b*(n-1)+a)-(a*(n-1)+b)+1)
    return 0

if __name__ == "__main__":
    solve()



Measured memory_bytes: 13132
function Main(input) {
	var input = input.split(" ");
  	input = input.map(function (element) { return Number(element); });
  	var n=0;
	for(i=input[0];i<=input[1];i++){
      if(i>=input[2]&&i<=input[3]){        
        n++;
      }
    }
	if(n!==0){
	  n--;
  	}
      console.log(n);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

//const int M[6]= {};

const int maxn = 1e5+10;


int cnt[maxn];


const int mod = 1e9 + 7;

int C(int k, int n) {
	if (k > n) return 0;
	int res = 1;
	for(int i=1;i<=n;i++) res *= i;
	for(int i=1;i<=k;i++) res /= i;
	for(int i=1;i<=n-k;i++) res /= i;
	return res;
}
int main() {
	//freopen("inp.txt", "r", stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n = 0;
	cin >> n;
	
	int res = 1;
	for(int i=0;i<n;i++) {
		int x;
		cin >> x;
		if (x != 0) {
			cnt[x]++;
			if (cnt[x] > cnt[x-1]) {
				cout << 0;
//				assert(false);
				return 0;
			}
//			res = 1ll * res * cnt[x - 1] % mod;
			res = 1ll * res * (cnt[x-1] - cnt[x] + 1) % mod;
		} else {
			cnt[x] ++;
			if (cnt[x] > 3) {
				cout << "0";
//				assert(false);
				return 0;
			}
		}
	}
	
	int cof = 1;
	if (cnt[0] == 1) {
		cof = 3;
	} else if (cnt[0] == 2) cof = 6;
	else cof = 6;
	
	res = 1ll * res * cof % mod;
	cout << res;
	return 0;
}


Measured memory_bytes: 640
program ABC065B
    implicit none
    integer(8)::N,i,cn
    integer(8)::flg=0
    integer(8),allocatable,dimension(:)::A

    read(5,*)N
    allocate(A(N))
    read(5,*)(A(i),i=1,N)

    cn=1
    do i=1,N+1
        if(cn==2)then
            flg=1
            print'(i0)',i-1
            exit
        end if
        cn=A(cn)
    end do

    if(flg==0)then
        print'(i0)',-1
    end if
end program ABC065B

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001; // > 10^9
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

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

    cout << lcm(a, b) << endl;
    
    return 0;
}




Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)

// cout<<fixed<<setprecision(15)

//点またはベクトル
class Point{
  public:
  double x,y;
  
  Point(double x=0, double y=0): x(x),y(y) {}
  
  Point operator+(Point p){return Point(x+p.x,y+p.y);}
  Point operator-(Point &p){return Point(x-p.x,y-p.y);}
  Point operator*(double a){return Point(a*x,a*y);}
  Point operator/(double a){return Point(x/a,y/a);}
  
  //絶対値とその二乗
  double abs(){return sqrt(norm());}
  double norm(){return x*x+y*y;}
  
  bool operator<(const Point &p) const{
    return x != p.x ? x<p.x : y<p.y;
  }
  
  bool operator==(const Point &p) const{
    return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
  }
};
typedef Point Vector;

//直線
struct Segment{Point p1,p2;};
typedef Segment Line;

//円
class Circle{
public:
  Point c;
  double r;
  Circle(Point c=Point(), double r=0.0): c(c), r(r) {}
};

//多角形
typedef vector<Point> Polygon;

//内積
double dot(Vector a,Vector b){
  return a.x*b.x+a.y*b.y;
}

//外積
double cross(Vector a,Vector b){
  return a.x*b.y-a.y*b.x;
}

//直交判定
bool isOrthgonal(Vector a,Vector b){
  return equals(dot(a,b), 0.0);
}

//平行判定
bool isParallel(Vector a,Vector b){
  return equals(cross(a,b), 0.0);
}

//射影
Point project(Segment s,Point p){
  Vector base=s.p2-s.p1;
  double r=dot(p-s.p1,base)/base.norm();
  return s.p1+base*r;
}

int main(){
  Point p1,p2;
  cin>>p1.x>>p1.y>>p2.x>>p2.y;
  Segment s;
  s.p1=p1,s.p2=p2;
  
  int q;
  cin>>q;
  
  Point p,r;
  rep(i,q){
    cin>>p.x>>p.y;
    r=project(s,p);
    cout<<fixed<<setprecision(15)<<r.x<<" "<<r.y<<endl;
  } 
      
  return 0;
}


Measured memory_bytes: 3280
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, X] = [int(input_raw[0]), int(input_raw[1])]
    input_raw = read_func().strip().split()
    L = [int(input_raw[i]) for i in range(N)]
    D = 0
    ans = 1
    for i in range(N):
        D = D + L[i]
        if D <= X:
            ans += 1
    print ans
if __name__ == '__main__':
    main()


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

int main()
{
	int X;
	scanf("%d", &X);
	for (int t = 1;; t++)
	{
		if (t * (t + 1ll) / 2 >= X)
		{
			printf("%d\n", t);
			return 0;
		}
	}
}

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

int main() {
  int N; cin >> N;
  vector<long long int> A(N); for (int i = 0; i < N; i++) cin >> A[i];
  long long int ans = 0LL;
  long long int MOD = int(pow(10,9)+7);
  long long int asum = accumulate(A.begin(), A.end(), 0LL);
  for (int i = 0; i < N-1; i++) {
      asum -= A[i];
      ans += A[i]*(asum%MOD) % MOD;
      ans = ans % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4736
N=int(input())

if N==100000:
  print(90909)
elif N>=10000:
  print(1+N-10000+909)
elif N>=1000:
  print(909)
elif N>=100:
  print(1+N-100+9)
elif N>=10:
  print(9)
elif N>=0:
  print(N)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
vector<int> v;
int f(int n){
  int r;
  if(v[n]!=-1){
    return v[n];
  }else if(n==0){
    r=0;
  }else if(n<=5){
    r=n;
  }else{
    r=1e9;
    for(int i=1;i<7;i++){ if(n-pow(6,i)>=0) r=min(r,f(n-pow(6,i))+1); }
    for(int i=1;i<6;i++){ if(n-pow(9,i)>=0) r=min(r,f(n-pow(9,i))+1); }
                          if(n-1>=0)        r=min(r,f(n-1)+1);
  }
  return v[n]=r;
}
int main(){
  int n; cin>>n;
  v.resize(n+1);
  fill(v.begin(),v.end(),-1);
  cout<<f(n)<<endl;
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int n,k,q;
priority_queue<int,std::vector<int> ,greater<int> > heap;
std::vector<int> v;
int a[maxn];
void update()
{
    while(heap.size()>=k)
    {
        v.push_back(heap.top());
        heap.pop();
    }
    while(!heap.empty())
    {
        heap.pop();
    }
}
int main()
{
//    freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
    //freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);

    gbtb;
    cin>>n>>k>>q;
    repd(i,1,n)
    {
        cin>>a[i];
    }
    int mn;
    int ans=inf;
    repd(i,1,n)
    {
        mn=a[i];
        repd(j,1,n)
        {
            if(a[j]>=mn)
            {
                heap.push(a[j]);
            }else{
                update();
            }
        }
        // db(mn);
        update();
        sort(ALL(v));
        if(sz(v)>=q)
        {
//            for(auto x:v)
//            {
//                cout<<x<<" ";
//            }
//            cout<<endl;
            ans=min(ans,v[q-1]-mn);
//            cout<<i<<" "<<mn<<" "<<v[q-1]<<endl;
            // db(ans);
        }
        v.clear();
    }
    cout<<ans<<endl;

    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 256
#include <stdio.h>
int partition(int,int);
int A[100000];

int main(){
    int n,i,result;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    result = partition(0,n-1);

    for(i=0;i<n;i++){
        if(i==result){
            printf("[%d]",A[i]);
            if(i==n-1) printf("\n");
            else printf(" "); 
            continue;
        }
        if(i<n-1) printf("%d ",A[i]);
        else printf("%d\n",A[i]);
    }
    return 0;
}

int partition(int p,int r){
    int x,i,j,tmp;

    x = A[r];
    i = p-1;
    for(j=p;j<r;j++){
        if(A[j]<=x){
            i = i+1;
            tmp = A[i];
            A[i] = A[j];
            A[j] = tmp;
        }
    }
        tmp = A[i+1];
        A[i+1] = A[r];
        A[r] = tmp;
    return i+1;
}


Measured memory_bytes: 2064
#include <stdio.h>
#include <math.h>
#define TRUE 1
#define FALSE 0

int CheckPrime(int a);

int main(){
    int n,i;
    int cnt=0;
    scanf("%d",&n);

    for(i=0; i<n; i++){
        int a;
        scanf("%d",&a);
        if(CheckPrime(a)==TRUE){
            cnt++;
        }
    }

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

    return 0;
}

int CheckPrime(int a){
    if(a == 2) return TRUE;
    else if(a%2 == 0 && a > 2) return FALSE;

    int i;
    for(i=3; i<=sqrt(a); i += 2){
        if(a%i ==0) return FALSE;
    }

    return TRUE;
}


Measured memory_bytes: 2144
// AOJ 2550: Independent Research
// 2018.1.20 bal4u

#include <stdio.h>

int main()
{
	int r, c;
	
	puts("40");
	for(r = 0; r < 40; r++) {
		for(c = 0; c < 40; c++)	putchar(r - c && (r < 5 || c < 5)? 'Y': 'N');
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 2040
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const long long MOD = 1e9 + 7LL;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * POW(n, m - 1)) % MOD;
  }
}

ll factorial(ll n) {
  ll ans = 1;
  for (ll i = 2; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}

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

ll N = 0;
ll f[100002] = {};
ll A[100002] = {};
ll DICT[100002] = {};

// fはfactrial
ll nCr(ll n, ll r) {
  if (n < r) {
    return 0LL;
  }
  if (r > n / 2LL) {
    r = n - r;
  }
  ll res = (f[n] * POW(f[n - r], MOD - 2LL)) % MOD;
  res = (res * POW(f[r], MOD - 2LL)) % MOD;

  return res;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N;
  ll D1 = -1, D2 = -1;
  REP(i, 100002) DICT[i] = -1;
  REP(i, N + 1) {
    cin >> A[i];
    if (DICT[A[i]] > -1) {
      D1 = DICT[A[i]];
      D2 = i;
      // cout << D1 << "," << D2 << endl;
    }
    DICT[A[i]] = i;
  }
  // B[N + 1] = POW(factorial(N + 1), MOD - 2) % MOD;
  // RREP(i, N + 1) { B[i] = (B[i + 1] * (i + 1)) % MOD; }
  f[0] = 1LL;
  FOR(i, 1, 100002) f[i] = (f[i - 1] * i) % MOD;
  // cout << D1 + D2 << endl;

  FOR(i, 1, N + 2) {
    ll ans = nCr(N + 1, i);
    ans = (ans + MOD - nCr(D1 + N - D2, i - 1LL)) % MOD;
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3584
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

// 桁数を先に割り出してから計算するパターン
// 一つズレるのがポイント

func main() {
	N := nextInt()
	var digits int
	N--
	for i := 1; i <= 12; i++ {
		num := pow(26, i)
		if N < num {
			digits = i
			break
		}
		N -= num
	}
	an := make([]string, digits)
	for i := 0; i < digits; i++ {
		// fmt.Println(N)
		an[len(an)-1-i] = string(N%26 + 'a')
		N /= 26
	}
	// fmt.Println(N, digits, an)
	fmt.Println(strings.Join(an, ""))
}

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

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

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

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}

func Reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


Measured memory_bytes: 1820
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
using namespace std;
//
int N,W;
VE w1,w2,w3,w4;
int main(){
  cin>>N>>W;
  int num,val;
  cin>>num>>val;
  w1.PB(val);
  FOR(i,1,N){
    int w,v;
    cin>>w>>v;
    if(num==w){
      w1.PB(v);
    }else if(num+1==w){
      w2.PB(v);
    }else if(num+2==w){
      w3.PB(v);
    }else if(num+3==w){
      w4.PB(v);
    }
  }
  sort(w1.rbegin(),w1.rend());
  sort(w2.rbegin(),w2.rend());
  sort(w3.rbegin(),w3.rend());
  sort(w4.rbegin(),w4.rend());
  int MAX=-1;
  int h1=min(W/num,(int)w1.size());
  int h2=min(W/(num+1),(int)w2.size());
  int h3=min(W/(num+2),(int)w3.size());
  int h4=min(W/(num+3),(int)w4.size());
  FOR(i,0,h1+1){
    int sum1=0;
    if(W<i*num){
      continue;
    }else{
      FOR(a,0,i){
        sum1+=w1[a];
      }
    }
    FOR(j,0,h2+1){
      int sum2=0;
      if(W<(i+j)*num+j){
        continue;
      }else{
        FOR(b,0,j){
          sum2+=w2[b];
        }
      }
      FOR(k,0,h3+1){
        int sum3=0;
        if(W<(i+j+k)*num+j+2*k){
          continue;
        }else{
          FOR(c,0,k){
            sum3+=w3[c];
          }
        }
        FOR(l,0,h4+1){
          int sum4=0;
          if(W<(i+j+k+l)*num+j+2*k+3*l){
            continue;
          }else{
            FOR(d,0,l){
              sum4+=w4[d];
            }
          }
          MAX=max(MAX,sum1+sum2+sum3+sum4);
        }
      }
    }
  }
  cout<<MAX<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=1e9+7;
const ll MAX=300000;
using vi=vector<int>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}


//////////////////////////////////////


int main(){
    int n;
    cin>>n;
    vvi a(n,vi(n));
    rep(i,n)rep(j,n)cin>>a[i][j];
    vvb nd(n,vb(n,true));
    rep(i,n){
        rep(j,n){
            rep(k,n){
                if(i==j||j==k||i==k)continue;
                if(a[i][j]>a[i][k]+a[j][k]){
                    cout<<-1<<endl;
                    return 0;
                }
                if(a[i][j]==a[i][k]+a[j][k])nd[i][j]=false;
            }
        }
    }
    ll ans=0;
    rep(i,n){
        rep(j,i){
            if(nd[i][j])ans+=a[i][j];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pi M_PI
#define inf 1<<30
#define eps (1e-11)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;

class Point{
public:
  double x,y,z;
  Point(double x=0,double y=0,double z=0):x(x),y(y),z(z){}

  Point operator+(Point p){ return Point(x+p.x,y+p.y,z+p.z);}
  Point operator-(Point p){ return Point(x-p.x,y-p.y,z-p.z);}
  Point operator*(double k){ return Point(x*k,y*k,z*k);}
  Point operator/(double k){ return Point(x/k,y/k,z/k);}
  bool operator<(Point p)const{ return (x!=p.x ? x<p.x : (y!=p.y ? y<p.y : z<p.z));}
  bool operator==(Point p)const{ 
    return (fabs(x-p.x)<eps && fabs(y-p.y)<eps &&  fabs(z-p.z)<eps);}
  
  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y+z*z);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

class Segment{
public:
  Point p1,p2;
  Segment(Point p1,Point p2):p1(p1),p2(p2){}
};
typedef Segment Line;

class sphere{
public:
  Point c;
  double r;
  sphere(Point c=Point(),double r=0.0):c(c),r(r){}
};

double norm(Vector a){ return (a.x*a.x+a.y*a.y+a.z*a.z);}
double abs(Vector a){ return sqrt(norm(a));}
double dot(Vector a,Vector b){ return (a.x*b.x+a.y*b.y+a.z*b.z);}
Vector cross(Vector a,Vector b){ 
  Vector res;
  res.x=(a.y*b.z)-(a.z*b.y);
  res.y=(a.z*b.x)-(a.x*b.z);
  res.z=(a.x*b.y)-(a.y*b.x);
  return res;
}

double getDistanceLP(Line l,Point p){
  return abs(cross(l.p2-l.p1,p-l.p1))/abs(l.p2-l.p1);
}

double getDistanceSP(Segment s,Point p){
  if(dot(s.p2-s.p1,p-s.p1)<0.0)return abs(p-s.p1);
  if(dot(s.p1-s.p2,p-s.p2)<0.0)return abs(p-s.p2);
  return getDistanceLP(s,p);
}

bool isCross(sphere a,Segment b)
{
  if((abs(b.p1-a.c)-a.r)<-eps && (abs(b.p2-a.c)-a.r)<-eps)return false;
  if((abs(b.p1-a.c)-a.r)<-eps && (a.r-abs(b.p2-a.c))<eps)return true;
  if((a.r-abs(b.p1-a.c))<eps && (abs(b.p2-a.c)-a.r)<-eps)return true;
  if((getDistanceSP(b,a.c)-a.r)<eps)return true;
  return false;
}

int main()
{
  int n,m,r,a,b,c,d;
  vector<sphere> vs;
  vector<int> v[16];
  vector<pair<Point,int> > vp;

  while(1){
    cin>>n>>m>>r;
    if(n+m+r==0)break;

    for(int i=0;i<16;i++)v[i].clear();
    vs.clear();vp.clear();

    for(int i=0;i<n;i++){
      cin>>a>>b>>c>>d;
      vs.push_back(sphere(Point(a,b,c),d));
    }
    for(int i=0;i<m;i++){
      cin>>a>>b>>c>>d;
      vp.push_back(mp(Point(a,b,c),d));
    }
    cin>>a>>b>>c;
    Point origin=Point(a,b,c);

    for(int i=0;i<m;i++){
      for(int j=0;j<n;j++){
	if(isCross(vs[j],Segment(origin,vp[i].f)))v[i].push_back(j);
      }
    }

    double ans=0.0;
    for(int k=0;k<(1<<m);k++){
      bool bo[2001]={};
      double sum=0;
      int count=0;
      for(int i=0;i<m;i++){
	if((1<<i)&k){
	  for(int j=0;j<v[i].size();j++){
	    if(!bo[v[i][j]]){
	      bo[v[i][j]]=true;
	      count++;
	    }
	  }
	  sum+=vp[i].s/norm(origin-vp[i].f);
	}
      }
      if(count<=r)ans=max(ans,sum);
    }	

    printf("%.10f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,int> pi;
typedef tuple<int,int,int> piii;
const int INF=10000000;
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define all(x) (x).begin(), (x).end()
const int M=100001;
const int N=200001;
bool visited[2*(M+N)];
int dist[2*(M+N)];
vector<pair<int,int> > adj[2*(M+N)];
map<pair<int,int>,int> ptr;
int curr = N; 
int n, m;
void construct(int v, int c)
{

  int pointer = ++curr;
 
  adj[v].push_back({pointer,1}); 
  adj[pointer].push_back({v,0}); 
 
  ptr[{v,c}] = pointer;
}


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n >> m;
  curr=n;
  while(m--){
    int v1,v2,c;
    cin >> v1 >> v2 >> c;

    if (ptr.find({v1,c})==ptr.end()){
      construct(v1,c);
    }
    if (ptr.find({v2,c})==ptr.end()){
      construct(v2,c);
    }

    int ptr1=ptr[{v1,c}];
    int ptr2=ptr[{v2,c}];

    // cout<<ptr1<<" "<<v1<<" "<<c<<endl;
    // cout<<ptr2<<" "<<v2<<" "<<c<<endl;

    adj[ptr1].push_back({ptr2,0});
    adj[ptr2].push_back({ptr1,0});


  }

  // for (int i=1; i<2*(n+m+100); i++){
  //   cerr<<"node = "<<i<<" | ";
  //   for (int j=0; j<adj[i].size(); j++){
  //     cerr<<adj[i][j].first<<" "<<adj[i][j].second<<"    ";
  //   }
  //   cerr<<endl;
  // }


  priority_queue <pii,vector<pii>,greater<pii>> pq;
  //set<pii> check;
  memset(visited,false,sizeof visited);
  memset(dist,-1,sizeof dist);
  dist[1]=0;
  pii temp={0,1};
  pq.push(temp);
  //visited.insert(temp);

  while(!pq.empty()){
    int curr_node=pq.top().second;
    int curr_cost=pq.top().first;
    pq.pop();

    if (!visited[curr_node]){
      visited[curr_node]=true;
      for (const auto& e: adj[curr_node]){
      int next_node=e.first;
      int cost=e.second;
      if (dist[next_node]>curr_cost+cost or dist[next_node]==-1){
        dist[next_node]=curr_cost+cost;
        pq.push({curr_cost+cost,next_node});
      }
    }
    }


  }

  //if (distance[n]==INF) distance[n]=-1;
  cout<<dist[n]<<endl;







} 


Measured memory_bytes: 62584
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

class BIT
	def initialize(n)
		# holding cells of 1..n
		@cells = Array.new(n+1){0}
		@i_max = n
	end
	def add(i,n)
		if(i <= 0)
			return
		end
		while(i<=@i_max)
			@cells[i] += n
			i += i & -i
		end
	end
	def sum(i)
		if(i > @i_max)
			return
		end
		sum = 0
		while(i>0)
			sum += @cells[i]
			i -= i & -i
		end
		return sum
	end
	# arr : n size array holding values from 1 to n
	def inversion_num(arr)
		sum = 0
		arr.each_with_index{|n,j|
			sum += j-self.sum(arr[j])
			self.add(arr[j],1)
		}
		return sum
	end
end

S=gets.chomp
size = S.size
h = {}
arr = Array.new(S.size)
0.upto(S.size-1){|i|
	h[S[i]].nil? ? h[S[i]]=[i] : h[S[i]] << i
}

dpp h

odds = h.select{|k,v| v.size % 2 != 0}
dpp odds
if(size%2==0 && odds.size > 0 || size%2!=0 && odds.size != 1)
	puts -1
	exit(0)
end
oddkey = odds.keys

rearr = []
ih = {}
h.each{|k,v| if(v.size > 1) then v[0..((v.size)/2-1)].each{|v| rearr << [k,v]} end}

dpp "rearr #{rearr}"

rearrmap = Array.new(size)
rearr = rearr.sort{|kv1,kv2| kv1[1] <=> kv2[1]}

dpp "sorted rearr #{rearr}"

rearr.each_with_index{|kv,i|
	k = kv[0]
	v = kv[1]
	ih[k].nil? ? ih[k]=0 : ih[k]+=1
	dputs "kv and i is #{kv} #{i}"
	dputs "ih[k] #{ih[k]} ih[k][-v-1] #{ih[k][-v-1]}"
	rearrmap[v] = i+1
	rearrmap[h[k][-ih[k]-1]] = size-i
}
if(!oddkey.empty?)
	oddkey = oddkey[0]
	tmp = odds[oddkey]
	tmpsize = tmp.size
	rearrmap[tmp[tmpsize/2]]=size/2+1
end

dpp rearrmap

bit = BIT.new(size)
puts bit.inversion_num(rearrmap)


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

int main() {
    string s;
    string ans;
    cin >> s;
    rep(i, s.size()) {
        if (s[i] == 'B') {
            if (ans.size()>0) ans = ans.substr(0, ans.size()-1);
        } else {
            ans += s[i];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 998244353;
int O = 332748118;
int dp[300000][3];
signed main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s;
    cin >> s;
    int sz = s.size();
    dp[0][0] = 1, dp[0][1] = 1, dp[0][2] = 1;
    for (int i=1; i < sz; i++){
        dp[i][0] = (dp[i-1][1] + dp[i-1][2]) % MOD;
        dp[i][1] = (dp[i-1][0] + dp[i-1][2]) % MOD;
        dp[i][2] = (dp[i-1][1] + dp[i-1][0]) % MOD;
    }
    int x = (dp[sz-1][0] + dp[sz-1][1] + dp[sz-1][2]) % MOD;
    int S = 1;
    for (int i=0; i < sz; i++){
        S *= 3;
        S %= MOD;
    }
    S -= x;
    S %= MOD;
    if (S < 0) S += MOD;
    S *= O;
    S %= MOD;
    bool df = true;
    for (int i=0; i < s.size() - 1; i++){
        if (s[i] != s[i+1]) df = false;
    }
    if (df){
        cout << 1 << endl;
        return 0;
    }
    bool eq = false;
    for (int i=0; i < s.size() - 1; i++){
        if (s[i] == s[i+1]) eq = true;
    }
    if (sz % 3 != 0){
        cout << (S+!eq) % MOD << endl;
        return 0;
    }
    else{
        int A = sz/3 - 1, num = 1;
        while (A > 0){
            A--;
            num *= 2;
            num %= MOD;
        }
        int aa = 0, bb = 0, cc=0;
        for (int i=0; i < s.size(); i++){
            if (s[i] == 'a') aa++;
            if (s[i] == 'b') bb++;
            if (s[i] == 'c') cc++;
        }
        bool good = true;
        if (aa%3==0 && bb % 3==0 && cc%3==0) good = false;
        if (aa%3!=0 && bb % 3!=0 && cc%3!=0) good = false;
        if (good){
            cout << (S+!eq+num) % MOD << endl;
        }
        else{
            if (sz == 3){
                cout << 3 << endl;
                return 0;
            }
            S -= 2*num;
            S %= MOD;
            if (S<0) S += MOD;
            cout << (S+!eq) % MOD << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 6660
def main():
  from collections import deque
  n,k,*t=map(int,open(0).read().split())
  e=tuple(set()for _ in[0]*n)
  for a,b in zip(t[::2],t[1::2]):
    e[a-1].add(b-1)
    e[b-1].add(a-1)
  c,q=k,deque([0])
  while q:
    v,i=q.pop(),1
    for w in e[v]:
      c=c*(k-i-(v>0))%(10**9+7)
      e[w].remove(v)
      q+=w,
      i+=1
  print(c)
main()

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

using namespace std;
string ans;
int n;


string ask(int i) {
  cout << i << endl;
  fflush(stdout);
  string res;
  cin >> res;
  return res;
}

void func(int l, int r) {
  int mid = (l + r) / 2;
  string tmp = ask(mid);
  if(tmp == "Vacant") exit(0);

  if((mid % 2 == 0 && ans == tmp) || (mid % 2 == 1 && ans != tmp))
    func(mid + 1, r);
  else func(l,mid);
}

int main() {
  cin >> n;
  ans = ask(0);  
  if(ans == "Vacant") return 0;

  func(1,n);
}


Measured memory_bytes: 884
#include <bits/stdc++.h>
#define int long long int
#define gif(a,b) (a/b +(a%b?1:0))
#define pi 3.14159265358
#define watch(x) cout<<(#x)<<" is "<<(x)<<"\n";
#define float long double
using namespace std;

int32_t main()
{   
    cin.tie(NULL);
    std::ios::sync_with_stdio(false);
  	
  	string s;
  	cin >> s;
  	int n = s.length();
  	int flag = 0 , flag2 = 0;
  	if(s[0] == 'A')
  		flag++;
  	for(int i = 1; i < n ; ++i)
  	{
  		if(!(s[i] == 67 || s[i] >= 97))
  		{
  			cout << "WA";
  			return 0;
  		}
	}
	if(s[n -1] == 67)
  		{
  			cout << "WA";
  			return 0;
  		}
	for(int i = 2; i < n - 1; ++i)
	if(s[i] == 67)
		flag2++; 	
	if(flag == 1 && flag2 == 1)
  	cout << "AC";
  	else 
  	cout << "WA";
    return 0;
}


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

int main()
{
	int ans=1000,temp,i;
	string str;
	cin >>str;
	for(i=0;i<str.size()-2;i++){
		temp=abs((str.at(i)-48)*100+(str.at(i+1)-48)*10+(str.at(i+2)-48)-753);
		if(temp<ans){
			ans=temp;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256