akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int K;
string S;
int A[1000010],B[1000010];

void mul(int &a,int b){
	a*=b;
	a%=MOD;
}

void add(int &a,int b){
	a+=b;
	a%=MOD;
}

int extgcd(int a,int b,int &x,int &y){
	int g=a;
	x=1,y=0;
	if(b!=0){
		g=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}
	return g;
}
 
// 逆元
int mod_inverse(int a,int m){
	int x, y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}
 
// 階乗
std::vector<int>fact;
void mod_fact(int n, int m){
	fact.resize(n+1);
	fact[0]=1;
	for(int i=1;i<=n;i++){
		fact[i]=fact[i-1]*i%m;
	}
}
 
// nCk mod p
int mod_nCr(int n, int k, int m){
	if(n<k)return 0;
	return fact[n]*mod_inverse(fact[k]*fact[n-k]%m,m)%m;
}

signed main(){
	cin>>K>>S;
	int N=S.size();
	mod_fact(5000010,MOD);
	for(int i=0;i<=1000000;i++){
		A[i]=1,B[i]=1;
	}
	for(int i=1;i<=1000000;i++){
		A[i]=A[i-1]*26%MOD;
		B[i]=B[i-1]*25%MOD;
	}
	int ans=0;
	for(int i=0;i<=K;i++){
		int res=mod_nCr(N-1+K-i,K-i,MOD);
		mul(res,A[i]);
		mul(res,B[K-i]);
		add(ans,res);
	}
	cout<<ans<<endl;
	return 0;
}


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

const ll mod = 1e9 + 7;

const ll N = 2005;
ll fact[N];

void fact_precompute() {
	fact[0] = fact[1] = 1;
	ll i;
	for (i = 2; i<N; ++i) {
		fact[i] = (i* fact[i-1]) % mod;
	}
}

ll modExpo(ll a, ll b, ll m) {
	ll ans = 1;
	a = a % m;
	while (b > 0) {
		if (b & 1) ans = (ans * a) % m;
		b >>= 1;
		a = (a * a) % m;
	}
	return ans;
}

ll modInv(ll a, ll m) {
	return modExpo(a, m-2, m);
}

ll ncr(ll n, ll r, ll  m) {
	return (((fact[n]*modInv(fact[r], m)) % m) * modInv(fact[n-r], m)) %m;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	fact_precompute();
	ll i, s, ans = 0;
	cin >> s;
	for (i=1; i*3 <= s; ++i) {
		ans = (ans + ncr(i+s-3*i-1, s-3*i, mod)) % mod;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3656
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {

            int[] input = Console.ReadLine().Split().Select(i => Convert.ToInt32(i)).ToArray();
            if (input[1] == 100)
            {
                switch (input[0])
                {
                    case 0:
                        Console.WriteLine(1 * 101);
                        break;
                    case 1:
                        Console.WriteLine(100 * 101);
                        break;
                    case 2:
                        Console.WriteLine(10000 * 101);
                        break;
                }
                return;
            }
            if (input[0] == 0)
            {
                Console.WriteLine(input[1]);
                return;
            }
            long step = (int)Math.Pow(100, input[0]);
            long res = step * input[1];
            Console.WriteLine(res);
        }
    }
}


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

#define pb push_back
#define all(a) (a).begin(), (a).end()

using ll = long long;
using pii = pair<int, int>;

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int n; cin >> n;
    string s, t; cin >> s >> t;
    string ans;
    for (int i = 0; i < n; ++i) {
        ans += s[i];
        ans += t[i];
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
using lint=int64_t;
using namespace std;

int main()
{
	int N;

	map<int,int> m;

	cin >> N;
	for(int i=1;i<=N;i++)
	{
		int A;
		cin >> A;
		m[A]=i;
	}

	for(int i=1;i<=N;i++)
	{
		cout << m[i];
		if(i==N)cout << endl;
		else cout << " ";
	}
	
	return 0;
}



Measured memory_bytes: 5504
from itertools import accumulate
n = int(input())
As = list(map(int, input().split()))

if n == 0:
    if As[0] == 1:print(1)
    else:print(-1)
    exit()


if As[0] != 0:
    print(-1)
    exit()

b = 1
ans = 1
acc = list(accumulate(As))
s = acc[-1]
for ac,a in zip(acc[1:], As[1:]):
    # print(s-ac,2*b-a)
    b = min(2*b-a, s-ac)
    if b < 0:
        print(-1)
        exit()
    ans += b+a
print(ans)
    

Measured memory_bytes: 85964
import Data.Bool (bool)
import Data.List (sort, sortBy)

main :: IO ()
main = do
    [s,t] <- getParams
    putStrLn $ solve s t

getParams :: IO [String]
getParams = lines <$> getContents

solve :: String -> String -> String
solve s = toAnswer . lessable s

toAnswer :: Bool -> String
toAnswer = bool "No" "Yes"

lessable :: String -> String -> Bool
lessable s t = minS < maxT
  where
    minS = sort s
    maxT = sortBy (flip compare) t


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

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

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

    long int r;
    cin>>r;

    cout<<3*r*r;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

const ll inf = 1LL<<60;

int N, M, L;
vector<vector<ll>> dist(330, vector<ll>(330, inf)), dist2(330, vector<ll>(330, inf));

void floyd(){
    rep(k, N){
        rep(i, N){
            if(dist[i][k]==inf) continue;
            rep(j, N){
                if(dist[k][j]==inf) continue;
                chmin(dist[i][j], dist[i][k]+dist[k][j]);
            }
        }
    }
}

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

    cin >> N >> M >> L;
    rep(i, M){
        int a, b, c; cin >> a >> b >> c;
        if(c > L) continue;
        --a; --b;
        dist[a][b] = dist[b][a] = c;
    }

    rep(i, N) dist[i][i] = dist2[i][i] = 0;
    floyd();
    rep(i, N) rep(j, N){
        if(dist[i][j]<=L) chmin(dist2[i][j], 1LL);
    }

    rep(k, N){
        rep(i, N){
            if(dist2[i][k]==inf) continue;
            rep(j, N){
                if(dist2[k][j]==inf) continue;
                chmin(dist2[i][j], dist2[i][k]+dist2[k][j]);
            }
        }
    }

    int Q; cin >> Q;
    while(Q--){
        int s, t; cin >> s >> t;
        --s; --t;
        ll ans = dist2[s][t];
        if(ans==inf) cout << -1 << endl;
        else cout << ans-1 << endl;
    }

    return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int64_t gcd(int64_t a, int64_t b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int64_t a, b; cin >> a >> b;
	cout << a * b / gcd(a, b) << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
 
const int N=1e5+5,M=1e9+7;
int s[N],a[N],b[N];
int32_t main(){
    int n,A,B;
    cin>>n>>A>>B;
    s[0]=-M;
    for(int i=1;i<=n;++i)cin>>s[i];
    a[0]=1;b[0]=1;
    int ka=0,kb=0;
    for(int i=1;i<=n;++i){
        while(ka+1!=i-1&&s[i]-s[ka+1]>=A)ka++;
        while(kb+1!=i-1&&s[i]-s[kb+1]>=B)kb++;
        int nowa=b[ka],nowb=a[kb];
        if(s[i]-s[i-1]<A)memset(a,0,i*(sizeof(int)));
        if(s[i]-s[i-1]<B)memset(b,0,i*(sizeof(int)));
        a[i-1]=(i>1?a[i-2]:0)+nowa;
        b[i-1]=(i>1?b[i-2]:0)+nowb;
        if(a[i-1]>=M)a[i-1]-=M;
        if(b[i-1]>=M)b[i-1]-=M;
    }
    cout<<(a[n-1]+b[n-1])%M<<'\n';
    return 0;
}

Measured memory_bytes: 5980
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderExamCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string tmp = Console.ReadLine();
            string[] tmpSplit = tmp.Split();
            int[] tmpInt = new int[2];
            for (int i = 0; i < tmpSplit.Length; i++)
            {
                tmpInt[i] = int.Parse(tmpSplit[i]);
            }
            if (tmpInt[1] % 2 != 0 || tmpInt[0] > 50 || tmpInt[0] * 2 > tmpInt[1] || tmpInt[0] * 4 < tmpInt[1])
            {
                Console.WriteLine("No");
            }
            else
            {
                bool flag = false;
                for (int i = 0; i <= tmpInt[0]; i++)
                {
                    if ((tmpInt[0] - i) * 2 + i * 4 == tmpInt[1])
                    {
                        flag = true;
                    }
                }
                if (flag)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
        }
    }
}


Measured memory_bytes: 27348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    int ary[n];
    rep(i,n) cin >> ary[i];

    sort(ary, ary+n);
    cout << ary[n-1] - ary[0] << endl;
}


Measured memory_bytes: 256
import math

class Dice():
    top   = 0 #上
    left  = 0 #左
    right = 0 #右
    front = 0 #前面
    back  = 0 #後面
    below = 0 #真下

    DEBUG_MODE = False
    def __init__(self,lst,dbg = False):
        if len(lst) == 6:
            self.top   = lst[0]
            self.front = lst[1]
            self.right = lst[2]
            self.left  = lst[3]
            self.back  = lst[4]
            self.below = lst[5]

        if dbg == True:
            self.DEBUG_MODE = True
        else:
            self.DEBUG_MODE = False
    
    def rotate(self,string):
        
        for ch in string:
            if   ch == 'W':
                self.left,self.top,self.right,self.below = self.top,self.right,self.below,self.left

            elif ch == 'E':
                self.left,self.top,self.right,self.below = self.below,self.left,self.top,self.right

            elif ch == 'S':
                self.top,self.back,self.below,self.front = self.back,self.below,self.front,self.top

            elif ch == 'N':
                self.top,self.back,self.below,self.front = self.front,self.top,self.back,self.below
            
            # デバッグモードなら全部の値をモニタする
            if self.DEBUG_MODE:
                self.dbg_PRINT_ALL_VALUE()

        
    def get_topvalue(self):
        return self.top
    
    def dbg_PRINT_ALL_VALUE(self):
        print(f"        bk:{self.back:04} ")
        print(f"le:{self.left:04} tp:{self.top:04} ri:{self.right:04} be:{self.below:04}")
        print(f"        fr:{self.front:04} ")

lst = list(map(int,input().split()))
#lst = [1,2,3,4,5,6]
dice = Dice(lst)
dice.rotate(input())
print(dice.get_topvalue())


Measured memory_bytes: 5684
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i=0;i<n;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			System.out.println(isRightTriangle(a, b, c) ? "YES" : "NO");
		}
	}
	
	public static boolean isRightTriangle(int a,int b,int c) {
		int[] x = new int[3];
		x[0] = a; x[1] = b; x[2] = c;
		Arrays.sort(x);
		return x[0] * x[0] + x[1] * x[1] == x[2] * x[2];
	}

}

Measured memory_bytes: 23564
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin>>N;
  vector<int> a(N);
  
  int cnt_odd=0,cnt_four=0,cnt_two=0;
  for(int i=0;i<N;++i){
    cin>>a.at(i);
    if(a.at(i)%2!=0){
      ++cnt_odd;
    }
    else if(a.at(i)%4==0){
      ++cnt_four;
    }
    else{
      ++cnt_two;
    }
  }
 
  if(cnt_four>=cnt_odd){
    cout<<"Yes"<<endl;
  }
  else if(cnt_four-cnt_odd==-1 && cnt_two==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
 
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

#define pi 3.141592653589793
#define mod 1000000007

int main() {
	int n, y;
	cin >> n >> y;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			int k = n - i - j;
			if (10000 * i + 5000 * j + 1000 * k == y&& k >= 0) {
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>

int main() {
  intmax_t h, a;
  scanf("%jd %jd", &h, &a);

  printf("%jd\n", (h+a-1)/a);
}


Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  int a,b,c;
  C3(a,b,c);
  if(a+c == 2*b)
    YES;
  else
    NO;
  ret 0;
}

Measured memory_bytes: 256
#include<iostream>
int main() {
	int last, last2;
	int day;
	int a, b;
	int max1, max2;
	std::cin >> day >> max1>> max2 >> a>> b;
	if (max1%a > 0)last = (max1 / a) +1;
	else last = max1 / a;
	if (max2%b > 0)last2 = (max2 / b) + 1;
	else last2 = max2 / b;
	if (last >= last2)std::cout << day - last<<std::endl;
	else std::cout << day - last2 << std::endl;
	return 0;
}

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


int main()
{
	int n; cin >> n;
	map<string, int> dict;
	for (int i = 0; i < n; ++i)
	{
		string s; cin >> s;
		dict[s]++;
	}
	int m; cin >> m;
	for (int i = 0; i < m; ++i)
	{
		string t; cin >> t;
		dict[t]--;
	}
	int ans = 0;
	for (auto &x : dict)
		ans = max(ans, x.second);
	cout << ans << endl;
}



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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

typedef std::complex<double> P2;
P2 projection(P2 p1, P2 p2, P2 p) {
   using namespace std;
   P2 t = p2 - p1;
   return p1+(t)/norm(t)*real((p-p1)*conj(t));
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long x1, y1, x2, y2; scan(x1, y1, x2, y2);
      long q; scan(q);
      for(long i = 0; i < q; ++i) {
         long x, y; scan(x, y);
         auto res = projection(P2(x1,y1), P2(x2, y2), P2(x,y));
         printf("%.20lf %.20lf\n", res.real(), res.imag());
      }
   }
};

int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
}

Measured memory_bytes: 3260
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 

int ds(int x){
    int ans = 0;
    while(x>=10){
        ans+=x%10;
        x/=10;
    }
    return ans+x;
}

int main(void){
    int n,l;
    cin>>n>>l;
    vector<string>ans;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        ans.push_back(s);
    }
    sort(ans.begin(),ans.end());
    for(int i=0;i<n;i++)cout<<ans[i];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
  ll N,M; cin >> N >> M;
  
  ll ans = 0;
  if (2*N > M) ans = M / 2;
  else ans = N + (M - 2*N) / 4;

  cout << ans << endl; 
}

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

namespace ITP1_10_D
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            int[] a = ReadIntAr();
            int[] b = ReadIntAr();
            int[] d = a.Select((x,index) => Math.Abs(x - b[index])).ToArray();

            double L1 = d.Sum();
            double L2 = Math.Sqrt(d.Sum(x => Math.Pow(x,2)));
            double L3 = Math.Pow(d.Sum(x => Math.Pow(x, 3)), 1/3D);
            double LINF = d.Max();

            Console.WriteLine("{0}", L1);
            Console.WriteLine("{0}", L2);
            Console.WriteLine("{0}", L3);
            Console.WriteLine("{0}", LINF);
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



Measured memory_bytes: 18584
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=3e5+10,mod=998244353,inf=1e9+10;
int fact[M],rev[M];
int pw(int x,int y)
{
	if(y==0)return 1;
	int tmp=pw(x,y/2);
	if(y%2==0)return (tmp*tmp)%mod;
	return ((tmp*tmp)%mod*x)%mod;
}
int C(int n,int r)
{
	int tmp=rev[r]*rev[n-r];
	tmp%=mod;
	tmp*=fact[n];
	tmp%=mod;
	return tmp;
}
int32_t main()
{
	int n,a,b,k;
	cin>>n>>a>>b>>k;
	fact[0]=1;
	rev[0]=pw(1,mod-2);
	for(int i=1;i<=3e5+2;i++)fact[i]=fact[i-1]*i,fact[i]%=mod,rev[i]=pw(fact[i],mod-2);
	int ans=0;
	//cout<<C(5,0)<<endl;
	for(int i=0;i<=n;i++)
	{
		int tmp=k-a*i;
		if(tmp<0)continue;
		if(tmp%b!=0)continue;
		tmp/=b;
		if(tmp>n)continue;
		int hlp=C(n,i)*C(n,tmp);
		hlp%=mod;
		ans+=hlp;
		ans%=mod;
	}
	cout<<ans;
}



Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){

    vector<int> a(3);
    vector<int> b(3);

    for(int i = 0; i < 3; i++) cin >> a[i];
    for(int i = 0; i < 3; i++) cin >> b[i];

    vector<int> cnt(4);
    for(int i = 0; i < 3; i++){
        cnt[ a[i]-1 ] ++;
        cnt[ b[i]-1 ] ++;
    }

    sort(all(cnt));
    if(cnt[3] > 2){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
    }


}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	ll N, K; cin >> N >> K;
	ll x[100];
	ll sum = 0;
	rep(i, 0, N) {
		cin >> x[i];
		sum += ((x[i] > K - x[i]) ? K - x[i] : x[i]);
	}
	cout << sum * 2 << endl;
	return 0;
}

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

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

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

    while (1)
    {
        string s = to_string(n);
        if (s[0] == s[1] && s[1] == s[2])
        {
            cout << s << endl;
            break;
        }
        n++;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> hoge(n);
  for (int i = 0; i < n; i++){
    cin >> hoge.at(i);
  }
  vector<int> hoge_copy(hoge.size());
  copy(hoge.begin(), hoge.end(), hoge_copy.begin());
  sort(hoge_copy.begin(), hoge_copy.end(), greater<int>());
  // cout << "@" << endl;
  // for (int i = 0; i < hoge_copy.size(); i++){
  //   cout << hoge_copy[i] << endl;
  // }
  int max = hoge_copy[0];
  int max2 = hoge_copy[1];
  for (int i = 0; i < hoge.size(); i++){
    if(hoge[i] == max){
      cout << max2 << endl;
    }else{
      cout << max << endl;
    }
  }
  
  

// cout << "#" << endl;
// cout << *(hoge.begin() + 4) << endl;
// int maxa = *max_element(hoge.begin(), hoge.end());
//   for (int i = 0; i < hoge.size(); i++){
//     if (hoge[i] < maxa){
//       cout << maxa << endl;
//     }else{
//       if(i == 0){
//         int maxx = *max_element(&hoge.at(1), &hoge.at(n-1) + 1);
//         cout << maxx << endl;
//       }else if(i == n - 1){
//         int maxx = *max_element(&hoge.at(0), &hoge.at(n - 1));
//         cout << maxx << endl;
//       }else{
//         int maxx = *max_element(&hoge.at(0), &hoge.at(i-1)+1);
//         int maxx2 = *max_element(&hoge.at(i+1), &hoge.at(n-1)+1);
//         cout << max(maxx, maxx2) << endl;
//       }
//     }
//   }
}

Measured memory_bytes: 3200
a, b, c = map(int, input().split())
dc = {}
dc[a] = dc.get(a, 0)+1
dc[b] = dc.get(b, 0)+1
dc[c] = dc.get(c, 0)+1
if dc[5] is 2 and dc[7] is 1:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int MODULO=1e9+7;
string str;
int D;
long long dp[100005][105][2];

long long solve(int idx, int sum, bool flag){
    if(idx==str.length()) return sum==0;
    int dig = str[idx]-'0';
    if(flag) dig=9;
    long long &ret=dp[idx][sum][flag];
    if(~ret) return ret;
    ret=0;
    for (int i = 0; i <= dig; ++i)
    {
        bool ok=flag;
        if(i<dig) ok=1;
        ret +=solve(idx+1, (sum+i)%D, ok)%MODULO;
    }
    return ret%MODULO;
}

int main(){
    // freopen("out.txt","wt",stdout);
    // scanf("%s", &str);
    // scanf("%d", &D);
    cin>>str>>D;
    memset(dp, -1, sizeof dp);
    cout<<(solve(0,0,0)-1+MODULO)%MODULO<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;

int main(){
  ll N, M;
  cin >> N >> M;
  map<ll, ll> mp;
  mp[0] = 1;
  ll ans = 0;
  ll sum = 0;
  for(int i=0;i<N;i++){
    ll a;
    cin >> a;
    sum += a;
    sum %= M;
    if(mp.find(sum) != mp.end()){
      ans += mp[sum];
      mp[sum]++;
    }else
      mp[sum] = 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6016
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    private static final BufferedReader READER = new BufferedReader(new InputStreamReader(System.in));

    private static int getInt() {
        try {
            return Integer.parseInt(READER.readLine());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private static int[] getIntArr(int n) {
        int[] ans = new int[n];

        StringTokenizer stringTokenizer = null;
        try {
            stringTokenizer = new StringTokenizer(READER.readLine(), " ");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        for (int i = 0; i < n && stringTokenizer.hasMoreTokens(); i++) {
            ans[i] = Integer.parseInt(stringTokenizer.nextToken());
        }

        return ans;
    }

    private static long solve() {
        int[] nw = getIntArr(2);
        int n = nw[0];
        int w = nw[1];

        Item[] items = new Item[n];
        for (int i = 0; i < n; i++) {
            items[i] = Item.of(getIntArr(2));
        }
        return solveInternal(n, w, items);
    }

    private static long solveInternal(int n, int W, Item[] items) {
        long[][] dp = new long[n + 1][W + 1];

        for (int i = 1; i <= n; i++) {
            for (int w = 1; w <= W; w++) {
                Item item = items[i - 1];
                if (item.w > w) {
                    dp[i][w] = dp[i - 1][w];
                } else {
                    dp[i][w] = Math.max(dp[i - 1][w], dp[i - 1][w - item.w] + item.v);
                }
            }
        }

//        for (int i = 0; i <= n; i++) {
//            for (int w = 0; w <= W; w++) {
//                System.out.println(String.format("dp[%s,%s]=%s", i, w, dp[i][w]));
//            }
//        }

        return dp[n][W];
    }


    public static final class Item {
        public final int v;
        public final int w;

        private Item(int w, int v) {
            this.v = v;
            this.w = w;
        }

        public static Item of(int[] arr) {
            return new Item(arr[0], arr[1]);
        }
    }

    public static void main(String... args) {
        System.out.println(solve());
//        System.out.println(
//                solveInternal(6, 5, new Item[]{
//                        new Item(1, 1000000000),
//                        new Item(1, 1000000000),
//                        new Item(1, 1000000000),
//                        new Item(1, 1000000000),
//                        new Item(1, 1000000000)
//                })
//        );
    }
}

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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); \
				cin.tie(0); \
				cout.tie(0)
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(_v)             _v.begin(), _v.end()
#define sz(_v)              (int) _v.size()
#define first(_obj)         (*_obj.begin())
#define last(_obj)          (*prev(_obj.end()))
#define FIND(_obj, _val)    (_obj.find(_val) != _obj.end())
#define RESET(_a, _v)       fill_n(_a,sizeof(_a)/sizeof(_a[0]),_v)
#define REP(_i, _n)         for (int _i = 0; _i < (int) _n; _i++)
#define FOR(_i, _a, _b)     for (int _i = (int) _a; _i <= (int) _b; _i++)
#define FORD(_i, _a, _b)    for (int _i = (int) _a; _i >= (int) _b; _i--)
#define FORIT(_it, _obj)    for (auto _it = _obj.begin(); _it != _obj.end(); _it++)

// DEBUG UTIL
template<typename TF>
void debug(ostream &out, TF const &f) {
    out << f << std::endl;
}
 
template<typename TF, typename ... TR>
void debug(ostream &out, TF const &f, TR const& ... rest) {
    out << f << " ";
    debug( out, rest... );
}
 
#define DEBUG(...) debug(cerr, "[", #__VA_ARGS__, "]:", __VA_ARGS__)

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pdd = pair<double,double>;
using vi = vector<int>;
using vii = vector<pii>;
using vll = vector<ll>;
using vs = vector<string>;

const int DR[] = {-1, 0, 1, 0, -1, 1, 1, -1}; // ccw
const int DC[] = {0, -1, 0, 1, -1, -1, 1, 1};
const double PI = acos(-1.0);
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = 1073741823;
const ll INFLL = 4e18;
const int MAX = 1e5;

int K, dist[MAX+5];

void read() {
	cin >> K;
}

void solve() {
	REP(i, MAX) dist[i] = INF;

	deque<int> dq;
	dist[1] = 1;
	dq.pb(1);

	while (!dq.empty()) {
		int now = dq.front();
		dq.pop_front();

		int nex = 10 * now % K;
		if (dist[now] < dist[nex]) {
			dist[nex] = dist[now];
			dq.push_front(nex);
		}

		nex = (now + 1) % K;
		if (dist[now] + 1 < dist[nex]) {
			dist[nex] = dist[now] + 1;
			dq.pb(nex);
		}
	}

	assert(dist[0] < INF);
	cout << dist[0] << "\n";
}

int main() {
	FAST_IO;
	int TC = 1;
	FOR(tc, 1, TC) {
		read();
		solve();
	}
}

Measured memory_bytes: 896
N, A, cou   = int(input()), [int(temp) for temp in input().split()], 0

for i in range(N) :
    minj = i
    for j in range(i, N) :
        if A[j] < A[minj] :
            minj = int(j)
    if A[i] != A[minj] :
        A[i], A[minj] = int(A[minj]), int(A[i])
        cou = cou + 1
print(*A)
print(cou)

Measured memory_bytes: 7748
package main

import "fmt"

func main() {
	arr := make([]int, 4)
	for i := 0; i < 4; i++ {
		var tmp int
		fmt.Scan(&tmp)
		arr[i] = tmp
	}
	sum := 0
	if arr[0] < arr[1] {
		sum += arr[0]
	} else {
		sum += arr[1]
	}
	if arr[2] < arr[3] {
		sum += arr[2]
	} else {
		sum += arr[3]
	}
	fmt.Println(sum)
}

Measured memory_bytes: 512
from itertools import accumulate
from operator import xor


def solve(acc):
    MOD = 10 ** 9 + 7
    cnt0 = 0
    dp0 = {}
    dp1 = {}
    last_0 = {}
    for a in acc:
        if a == 0:
            cnt0 += 1
        else:
            if a not in dp1:
                dp0[a] = 1
                dp1[a] = 1
                last_0[a] = cnt0
            else:
                bw0 = cnt0 - last_0[a]
                if bw0 > 0:
                    dp0[a] = (dp0[a] + dp1[a] * bw0) % MOD
                    last_0[a] = cnt0
                dp1[a] = (dp1[a] + dp0[a]) % MOD

    if acc[-1] == 0:
        return (pow(2, cnt0 - 1, MOD) + sum(dp1.values())) % MOD
    else:
        return dp0[acc[-1]]


n = int(input())
aaa = list(map(int, input().split()))
acc = list(accumulate(aaa, func=xor))
print(solve(acc))


Measured memory_bytes: 91544
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define fe(vec,lambda) std::for_each(vec.begin(), vec.end(), lambda );
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}
inline bool operator<(const pii &lhs,const pii &rhs){return(lhs.second<rhs.second);}
template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){vector<pair<T,T>> out(input.size()-1);rep(i,input.size()-1){out[i].first =input[i  ];out[i].second=input[i+1];}return(out);}
vector<char> String_to_vector_char(const string& input){vector<char> out(input.size());rep(i,input.size()){out[i]=input[i];}return out;}


ll a,b,c,d;
vector<ll>v;
map<ll,ll>m;
string s,s2;
void input(){
    cin>>a>>b;
}
void src(){
    if(a==b){cout<<"Draw";return ;}
    if((a>b or a==1) and b!=1){cout<<"Alice";return ;}
    if(a<b or b==1){cout<<"Bob";return ;}
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
    //ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N, Q; cin >> N >> Q;
        vector<ll> A(N); cin >> A;
        vector<ll> X(Q); cin >> X;
        sort(all(A)); reverse(all(A));
        vector<ll> sum(N + 1);
        rep(i, N) sum[i + 1] = sum[i] + A[i];
        vector<ll> rsum1(N + 1), rsum2(N + 1);
        rep(i, N) {
            rsum1[N - i - 1] = rsum1[N - i] + (i % 2 == 0 ? A[N - i - 1] : 0);
            rsum2[N - i - 1] = rsum2[N - i] + (i % 2 == 1 ? A[N - i - 1] : 0);
        }
        rep(q, Q) {
            auto check = [&] (int m) {
                if(m == 0) return true;
                if(m >= N / 2 + N % 2) return false;
                ll a = abs(A[m] - X[q]);
                ll b = abs(A[m + m] - X[q]);
                return a >= b;
            };


            int l = 0, r = N;
            while(l + 1 < r) {
                int m = (l + r) / 2;
                (check(m) ? l : r) = m;
            }
            cerr << l << endl;
            ll ans = sum[r] + ((N - r * 2) % 2  == 0 ? rsum2 : rsum1)[r * 2];
            cout << ans << endl;
        }
        return 0;
    }
};

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


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

int main(){
    int n, x, y;
    cin >> n >> x >> y;
    vector<int> to[n];
    vector<int> ans(n+1);
    rep(i,n-1){
        to[i].push_back(i+1);
        to[i+1].push_back(i);
        if (i==x-1) {
            to[i].push_back(y-1);
            to[y-1].push_back(i);
        }
    }

    rep(i,n){
        vector<int> dist(n, -1);
        dist[i] = 0;
        queue<int> q;
        q.push(i);
        while (!q.empty()){
            int v = q.front(); q.pop();
            for (int u : to[v]){
                if (dist[u] != -1) continue;
                dist[u] = dist[v] + 1;
                ans[dist[u]] += 1;
                q.push(u);
            } 
        }
    }
    
    rep(i,n){
        if (i==0) continue;
        cout << ans[i] / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 384
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

s = rr()
if s in 'ABCDEFGHIJKLMOPQRSTUVWXYZ':
  print('A')
else:
  print('a')



Measured memory_bytes: 27172
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int N,x[21];
set<vector<int> >res;

int vm(int *d)
{
	int mx;
	for(mx=400;mx;mx--)
		if(d[mx])break;
	return mx;
}

void dfs(int j,int *d)
{
	if(j==N)
	{
		int r[20];
		memcpy(r,x,sizeof(r));
		sort(r,r+N);
		vector<int>v;
		for(int i=0;i<N-1;i++)v.push_back(r[i+1]-r[i]);
		res.insert(v);
		return;
	}

	int tm[401];
	int l=vm(d);
	for(int i=0;i<2;i++)
	{
		int a;
		memcpy(tm,d,sizeof(tm));
		x[j]=(i?l:(x[1]-l));
		for(a=0;a<j;a++)
		{
			int dd=abs(x[j]-x[a]);
			if(!tm[dd])
				break;
			tm[dd]--;
		}
		if(a==j)
			dfs(j+1,tm);
	}
}

int main()
{
	for(;scanf("%d",&N),N;)
	{
		int d[401]={0};
		for(int i=0;i<N*(N-1)/2;i++)
		{
			int t;
			scanf("%d",&t);
			d[t]++;
		}
		res.clear();
		int l=vm(d);
		x[0]=0;x[1]=l;d[l]--;
		dfs(2,d);
		for(set<vector<int> >::iterator it=res.begin();it!=res.end();it++)
			for(int i=0;i<N-1;i++)
				printf("%d%s",(*it)[i],i==N-2?"\n":" ");
		puts("-----");
	}
}

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

string in;

void reverse(int a, int b){
	for(int i = a; i <= b && i < b-(i-a); i++){
		int temp = in[i];
		in[i] = in[b-(i-a)];
		in[b-(i-a)] = temp;
	}
}

void print(int a, int b){
	for(int i = a; i <= b; i++)
		cout << in[i];
	cout << endl;
}

void replace(int a, int b){
	string rep;
	cin >> rep;
	for(int i = a; i <= b; i++){
		in[i] = rep[i-a];
	}
}

int main(){
	string c;
	cin >> in;
	int a, b;
	int t;
	cin >> t;
	for(int i = 0 ; i < t; i++){
		cin >> c >> a >> b;
		if(!c.compare("reverse"))
			reverse(a, b);
		else if(!c.compare("replace"))
			replace(a, b);
		else if(!c.compare("print"))
			print(a, b);
	}
}



Measured memory_bytes: 3200
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]


n = int(input())

if (n == 1):
    print(1)
else:
    l1 = 1
    l2 = 3
    ans = 3
    for i in range(n-2):
        ans = l2 + l1
        l1 = l2
        l2 = ans
    print(ans)




Measured memory_bytes: 9112
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main()
{
	string a, b, c;
	cin >> a >> b >> c;
	if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#define MAX 10000
#define NIL -1

struct Node { int parent, left, right; };

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
  if ( u == NIL ) return;
  D[u] = d;
  setDepth(T[u].left, d + 1);
  setDepth(T[u].right, d + 1);
}

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if ( T[u].left != NIL )
    h1 = setHeight(T[u].left) + 1;
   if ( T[u].right != NIL )
    h2 = setHeight(T[u].right) + 1;
   return H[u] = ( h1 > h2 ? h1 : h2 );
}


int getSibling(int u) {
  if ( T[u].parent == NIL ) return NIL;
  if ( T[T[u].parent].left != u && T[T[u].parent].left != NIL )
    return T[T[u].parent].left;
  if ( T[T[u].parent].right != u && T[T[u].parent].right != NIL )
    return T[T[u].parent].right;
  return NIL;
}

void print(int u) {
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
  int deg = 0;
  if ( T[u].left != NIL ) deg++;
  if ( T[u].right != NIL ) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if ( T[u].parent == NIL ) {
    printf("root\n");
  } else if ( T[u].left == NIL && T[u].right == NIL ) {
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}

int main() {
  int v, l, r, root = 0;
  scanf("%d", &n);

  for ( int i = 0; i < n; i++) T[i].parent = NIL;

  for ( int i = 0; i < n; i++) {
    scanf("%d %d %d", &v, &l, &r);
    T[v].left = l;
    T[v].right = r;
    if ( l != NIL ) T[l].parent = v;
    if ( r != NIL ) T[r].parent = v;
  }

  for ( int i = 0; i < n; i++) if ( T[i].parent == NIL ) root =i;

  setDepth(root,0);
  setHeight(root);

  for ( int i = 0; i < n; i++ ) print(i);

  return 0;
}



Measured memory_bytes: 2688
a,b,c,x,y=map(int,input().split())
check=2*c-a-b
ans=0
if x>=y:
    if check>=0:
        ans+=(a+b)*y+a*(x-y)
    else:
        ans+=2*c*y+min(a,2*c)*(x-y)
else:
    if check>=0:
        ans+=(a+b)*x+b*(y-x)
    else:
        ans+=2*c*x+min(b,2*c)*(y-x)
print(ans)



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

int main()
{
    int h, w;
    while (cin >> h >> w, h || w)
    {
        for (int i = 0; i < h; ++i)
        {
            for (int j = 0; j < w; ++j)
            {
                if (i == 0 || i == h -1 || j == 0 || j == w -1)
                    cout << '#';
                else
                    cout << '.';
            }
            cout << endl;
        }
        cout << endl;
    }
}



Measured memory_bytes: 3072
#include <cmath>
#include <iostream>
#include <utility>
using namespace std;

int main() {
  long A, B;
  cin >> A >> B;
  
  if (A < B) swap(A, B);
  while (true) {
    long mod = A % B;
    if (mod == 0) break;
    else {
      A = B;
      B = mod;
    }
  }
  long gcd = B;
  
  long ans = 1, n = 2, cnt = 0;
  while (gcd >= n * n) {
    if (gcd % n == 0 && cnt == 0) {
      gcd /= n;
      ans++;
      cnt++;
    } else if (gcd % n == 0 && cnt != 0) {
      gcd /= n;
    } else {
      n++;
      cnt = 0;
    }
  }
  if (gcd > n) ans++;
  
  cout << ans  << endl;
  return 0;
}

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

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

    double prob;

    for (int i = 1; i <= N; i++)
    {
        double thisProb;

        thisProb = (1.0 / N);

        int score = i;

        while (score < K)
        {
            score *= 2;

            thisProb *= 0.5;
        }

        prob += thisProb;
    }

    std::cout << std::fixed << std::setprecision(10) << prob << endl;
}


Measured memory_bytes: 256