akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}

unsigned long lcm(unsigned long x, unsigned long y){
    unsigned long g = gcd(x, y);
    return x*y/g;

}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

int main(void){
    long long input[3];
    for (int i = 0; i < 3; i++){
        scanf("%lld", &input[i]);
    }
    long long S[3] = {input[1]*input[2], input[0]*input[2], input[0]*input[1]};
    long long min = 1000000000000000005;
    for (int i = 0; i < 3; i++){
        if (input[i] % 2 == 0){
            printf("0\n");
            return 0;
        }else{
            if (min > S[i]){
                min = S[i];
            }
        }
    }
    printf("%lld\n", min);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i = (a); i <= (b); ++i)
#define drep(i,a,b) for (int i = (a); i >= (b); --i)
#define grep(i,u) for (int i = head[u],v = e[i].v; i; v = e[i = e[i].nxt].v)
#define il inline
#define LL long long
#define ULL unsigned LL
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<LL,LL>
#define fi first
#define se second
using namespace std;
il LL read() {
	LL res = 0,f = 1; char ch = getchar(); while (!isdigit(ch)) {if (ch == '-') f = -f; ch = getchar();}
	while (isdigit(ch)) {res = res*10+ch-'0'; ch = getchar();} return res*f;
}
namespace qiqi {
	const int N = 10,C = 55,S = 1<<N; int n,c,l[N],f[N*C][S];
	void main() {
		int x,cnt = 0; LL ans = 0; n = read(); c = read(); rep(i,0,n-1) l[i] = read(); sort(l,l+n);
		while (1) {
			memset(f,0,sizeof(f)); f[l[n-1]*n][0] = 1;
			rep(i,1,c*n) if ((x = i%n-1) >= 0) rep(j,i,c*n) rep(s,0,(1<<(n-1))-1) if (!((s>>x)&1)) f[min(c*n,max(j,i+l[x]*n))][s|(1<<x)] += f[j][s];
			ans += f[c*n][(1<<(n-1))-1]; ++cnt; if (!next_permutation(l,l+n-1)) break;
		}
		printf("%.13lf\n",1.0*ans/cnt/pow(c,n-1));
	}
}
int main() {
	qiqi::main(); return 0;
}

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

struct point {
    double x, y;
    point(double a, double b) {
        x = a, y = b;
    }
    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 k) {
        return point(k * x, k * y) ;
    }
    point operator / (double k) {
        return point(x / k, y / k);
    }
    double norm() {
        return x * x + y * y;
    }
    double abs() {
        return sqrt(norm());
    }
};

double dot(point a, point b) {
    return a.x * b.x + a.y * b.y;
}

double cross(point a, point b) {
    return a.x * b.y - a.y * b.x;
}

point project(point a, point b) {
    return b * (dot(a, b) / b.norm());
}

int main() {
    int x1, y1, x2, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    point p1(x1, y1);
    point p2(x2, y2);
    point base = p2 - p1;
    // printf("base(%f, %f)\n", base.x, base.y);
    int n;
    scanf("%d", &n);
    rep(i, n) {
        int x, y;
        scanf("%d %d", &x, &y);
        point p(x, y);
        // printf("p(%f, %f)\n", p.x, p.y);
        point hypo = p - p1;
        // printf("hypo(%f, %f)\n", hypo.x, hypo.y);
        point X = p1 + project(hypo, base);
        printf("%.10lf %.10lf\n", X.x, X.y);
    }
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
#define long long ll
#define f(i,n) for(int i=0;i<n;i++)
const int maxn=305;
double dp[maxn][maxn][maxn];
double recur(int k, int b, int c,int n){
	if(dp[k][b][c]>=0)return dp[k][b][c];
	if(k==0&&b==0&&c==0)return 0.0;
	double res=0.0;
	// dp[k][b][c]=0.0;
	if(k>0)res+=(k)*recur(k-1,b,c,n);
	if(b>0)res+=(b)*recur(k+1,b-1,c,n);
	if(c>0)res+=(c)*recur(k,b+1,c-1,n);
	// dp[k][b][c]/=(n-k-c-b);
	res+=n;
	res*=1.0/(k+b+c);
	return dp[k][b][c]=res;
}
int main() {

	cout<<fixed<<setprecision(10);
	int n;
	cin>>n;
	vector<int>a(4,0);
	f(i,n){int x;
	cin>>x;
	a[x]++;
	}
	memset(dp, -1, sizeof(dp));
	cout<<fixed<<setprecision(9)<<recur(a[1],a[2],a[3],n)<<endl;

	return 0;
}


Measured memory_bytes: 225460
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        h: i64,
        w: i64,
        n: i64,
    }

    let t = std::cmp::max(h, w);
    let ans = (n + t - 1) / t;

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


Measured memory_bytes: 4352
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair  
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
 
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9+7;
const ll MAX = 1e2+7;
const ll inf = 1e9+7;
int main() {
	fastio;
	ll x,n;
    cin >> x >> n;
    map<ll,ll> mp;
    f(i,0,n){
        ll lec;
        cin>>lec;
        mp[lec] = 1;
    }
    ll i = 0;
    while(true){
        if(mp.find((x - i)) == mp.end()){
            cout << x - i << endl;
            break;
        }else if(mp.find((x + i)) == mp.end()){
            cout << x + i << endl;
            break;
        }
        i++;
    }
	return 0;
}

Measured memory_bytes: 3600
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10 ** 7)


def solve_(N: int, A: "List[int]"):
    m = 1e10
    s = 0
    n_plus, n_minus = 0, 0
    for x in A:
        m = min(m, abs(x))
        if x >= 0:
            n_plus += 1
        else:
            n_minus += 1
        s += abs(x)
    # print(n_plus, n_minus)
    if n_minus % 2 == 0:
        print(s)
    else:
        print(s - m * 2)

    return


def solve(N: int, A: "List[int]"):
    inf = 1e10
    dp = [[-inf, -inf] for i in range(N + 1)]
    dp[0] = 0, -inf
    for i in range(1, N + 1):
        dp[i][0] = max(dp[i - 1][0] + A[i - 1], dp[i - 1][1] - A[i - 1])
        dp[i][1] = max(dp[i - 1][0] - A[i - 1], dp[i - 1][1] + A[i - 1])

    print(dp[N][0])

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools
# (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74144
#include<bits/stdc++.h>
using namespace std;
long long int a=1,b,c,d,n,t[500000];

long long int gcd(long long int m,long long int n){
	if(0==n)return m;
	return gcd(n,m%n);
}

long long int lcm(long long int m,long long int n){
	return m/gcd(m,n)*n;
}

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>t[i];
    }
    sort(t,t+n);
    reverse(t,t+n);

    for(int i=0;i<n;i++){
        a=lcm(a,t[i]);
    }
    cout<<a<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string.h>
#include <vector>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <queue>
using namespace std;
typedef unsigned long long ui64;
typedef long long i64;
void AtCoderCrackers() {
	int N, K;
	cin >> N >> K;
	cout << (N % K != 0);
}
int main() {
	AtCoderCrackers();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
#define MAX_N (int)1e6

typedef long long ll;
const ll INF = 1LL << 60;
typedef pair<ll, ll> P;

int N, E;
vector<ll> x, y;

struct edge { ll u, v, cost; };
bool comp(const edge& e1, const edge& e2) {
    return e1.cost < e2.cost;
}
// edge es[(int)1e6];
vector<edge> es;

class UnionFind {
    int par[MAX_N];  // 親
    int my_rank[MAX_N]; // 木の深さ

public:
    void init(int n) {
        for (int i = 0; i < n; i++) {
            par[i] = i;
            my_rank[i] = 0;
        }
    }

    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        } } 
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) {
            return;
        }
        if (my_rank[x] < my_rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (my_rank[x] == my_rank[y]) my_rank[x]++;
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

ll kruskal() {
    // N 個
    UnionFind uf;
    uf.init(N);
    // sort(es, es + E, comp);
    sort(es.begin(), es.end(), comp);
    ll res = 0;
    for (ll i = 0; i < E; i++) {
        edge e = es[i];
        if (!uf.same(e.u, e.v)) {
            uf.unite(e.u, e.v);
            res += e.cost;
        }
    }

    return res;
}

int main() {
    cin >> N;
    x.resize(N);
    y.resize(N);
    rep(i, N) {
        cin >> x[i] >> y[i];
    }
    vector<P> x2;
    vector<P> y2;
    rep(i, N) {
        P px(x[i], i);
        x2.push_back(px);
        P py(y[i], i);
        y2.push_back(py);
    }
    sort(x2.begin(), x2.end());
    sort(y2.begin(), y2.end());

    // x の辺
    rep(i, N) {
        if (i - 1 >= 0) {
            edge ex = {x2[i].second, x2[i - 1].second, abs(x2[i].first - x2[i - 1].first)};
            es.push_back(ex);
        }
        if (i + 1 <= N - 1) {
            edge ex2 = {x2[i].second, x2[i + 1].second, abs(x2[i].first - x2[i + 1].first)};
            es.push_back(ex2);
        }
    }

    // y の辺
    rep(i, N) {
        if (i - 1 >= 0) {
            edge ey = {y2[i].second, y2[i - 1].second, abs(y2[i].first - y2[i - 1].first)};
            es.push_back(ey);
        }
        if (i + 1 <= N - 1) {
            edge ey2 = {y2[i].second, y2[i + 1].second, abs(y2[i].first - y2[i + 1].first)};
            es.push_back(ey2);
        }
    }
    E = es.size();
    ll ans = kruskal();
    cout << ans << endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

ll dp[5][202030] = {};

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

    ll L;
    cin >> L;
    vector<ll> A(L);
    REP(i, L) cin >> A[i];

    const ll INF = (1ll<<60);
    REP(i, 5)REP(j, 202020) dp[i][j] = INF;

    dp[0][0] = 0;

    REP(j, L){
    	REP(i, 5){
    		if(dp[i][j]==INF) continue;
    		REP(k, 5){
    			if(i>k) continue;
    			if(k==0||k==4){
    				chmin(dp[k][j+1], dp[i][j] + A[j]);
    			}
    			if(k==1||k==3){
    				ll add = (A[j]==0?2:A[j]%2);
    				chmin(dp[k][j+1], dp[i][j] + add);
    			}
    			if(k==2){
    				chmin(dp[k][j+1], dp[i][j] + (A[j]+1)%2);
    			}
    		}
    	}
    }

    ll res = INF;
    REP(i, 5) chmin(res, dp[i][L]);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 9728
#include <iostream>
#include <algorithm>

using namespace std;

int arr[100];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int N;
    while(cin >> N) {
        for(int i = 0; i < N; ++i) {
            cin >> arr[i];
        }
        sort(arr, arr+N);
        unsigned long long ans = 0;
        unsigned long long acc = 0;
        for(int i = 0; i < N; ++i) {
            acc += arr[i];
            ans += acc;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1204
#include <stdio.h>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int main() {

    int N;
    scanf("%d", &N);

    if (N <= 999) {
        printf("ABC\n");
    } else {
        printf("ABD\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

int main() {
    ll N;
    cin >> N;
    vector<ll> P(N);
    for(int i = 0; i < N; i++) {
        cin >> P[i];
        P[i]--;
    }
    
    vector<ll> A(N), B(N);
    vector<ll> dA(N + 1), dB(N + 1);
    vector<ll> accA(N + 2), accB(N + 2);
    
    
    for(int i = 0; i < N; i++) {
        dA[P[i]] += i;
        dB[P[i] + 1] -= i;
    }
    
    for(int i = 0; i < N + 1; i++) {
        accA[i + 1] = accA[i] + dA[i];
        accB[i + 1] = accB[i] + dB[i];
    }
    
    for(int i = 0; i < N; i++) {
        A[i] = 1 + i + accA[i + 1];
    }
    ll mi = B[0];
    for(int i = 0; i < N; i++) {
        B[i] = (N - i) + accB[i + 1];
        mi = min(mi, B[i]);
    }
    for(int i = 0; i < N; i++) {
        B[i] += abs(min(mi, 0LL)) + 1;
    }
    
    
    for(int i = 0; i < N; i++) cout << A[i] << " ";
    cout << endl;
    for(int i = 0; i < N; i++) cout << B[i] << " ";
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 1792
// https://atcoder.jp/contests/abc177/tasks/abc177_e
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)
const int MOD = 2019;

// 参考
// https://mirucacule.hatenablog.com/entry/2020/04/27/090908
void solve() {
    string S;
    cin >> S;
    reverse(ALL(S));
    int ans = 0, x = 1, total = 0;
    vector<int> cnt(MOD);
    cnt[0] = 1;
    REP(i, S.size()) {
        total += (S[i] - '0') * x;
        total %= MOD;
        ans += cnt[total];
        cnt[total]++;
        x = x * 10 % MOD;
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3696
N=int(input())
ans=0
s=[]
t=[]
for i in range(N):
    s.append(input())
M=int(input())
for j in range(M):
    t.append(input())

s.sort()
t.sort()
for i in range(N-1):
    if s[i]!=s[i+1]:
        sf=s.count(s[i+1])
        tf=t.count(s[i+1])
        if sf>tf:
            temp=sf-tf
            if temp>ans:
                ans=temp
sf=s.count(s[0])
tf=t.count(s[0])
if sf>tf:
    temp=sf-tf
    if ans<temp:
        ans=temp
print(ans)


Measured memory_bytes: 9072
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    rep(i, x) cin >> a[i];
    rep(i, y) cin >> b[i];
    rep(i, z) cin >> c[i];
    vector<ll> bc(y*z);
    rep(i, y) rep(j, z) bc[y*i+j] = b[i] + c[j];
    sort(all(a));
    sort(all(bc));
    auto check = [&](ll sum) {
                     int cnt = 0;
                     rrep(i, x) { 
                         int idx = lower_bound(all(bc), sum - a[i]) - bc.begin();
                         cnt += y*z - idx;
                         if (cnt >= k) return true;
                     }
                     return false;
                 };
    ll l = 0, r = 1e11;
    while (r - l > 1) {
        ll mid = (l + r) >> 1;
        if (check(mid)) l = mid;
        else r = mid;
    }
    multiset<ll> st;
    rrep(i, x) {
        int idx = upper_bound(all(bc), l - a[i]) - bc.begin();
        reps(j, idx, y*z) {
            st.insert(a[i] + bc[j]);
        }
    }
    int cnt = 0;
    for (auto it = st.rbegin(); cnt < k && it != st.rend(); ++it, ++cnt) cout << *it << endl;
    for (; cnt < k; ++cnt) cout << l << endl;
}


Measured memory_bytes: 11108
inp = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(inp[k-1])


Measured memory_bytes: 2940
import java.util.*;

public class Main {
	public static void main(String[] args) {
		for (int i = 1; i <= 9; i++) {
			for (int j = 1; j <= 9; j++) {
				System.out.println(i + "x" + j + "=" + (i * j));
			}
		}
	}
}

Measured memory_bytes: 24224
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll,ll>
#define PP pair<P,P>
using namespace std;

ll po(ll a,ll b){
    if(b==0) return 0;
    if(b==1) return a;
    if(b%2==0) return po(a,b/2)*po(a,b/2);
    else return po(a,b-1)*a;
}


vector<P> primes(ll n){
    vector<P> res;
    for(int i=2; i<=sqrt(n); i++){
        if(n%i==0){
            res.push_back(P(i,1));
            n/=i;
            while(n%i==0){
                res.back().second++;
                n/=i;
            }
        }
    }
    if(n!=1) res.push_back(P(n,1));
    return res;
}

int main(){
    ll n; cin >> n;
    ll n2=n;
    vector<P> pri=primes(n);
    /*
    int ans=0;
    
    for(ll i=2; i<=sqrt(n2); i++){
        if(n%i==0){
            n/=i;
            ans++;
        }
        int now=2;
        while(n%po(i,now)==0){
            n/=po(i,now);
            ans++;
            now++;
        }
    }
    if(n>sqrt(n2)) ans++;
    */
   int ans=0;
   rep(i,pri.size()){
       int t=pri[i].second;
       int now=1;
       while(t>=now){
           ans++;
           t-=now;
           now++;
       }
   }
    cout << ans << endl;
return 0;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
const int inf=0x7fffffff;
const int mod=1e9+7;
const int eps=1e-6;
typedef long long ll;
typedef unsigned long long ull;
#define ls p<<1
#define rs p<<1|1
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
int a[N];
signed main()
{
    IOS;
    int k,n;
    cin>>k>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    int ma=a[1]+k-a[n];
    for(int i=2;i<=n;i++)
    {
        ma=max(a[i]-a[i-1],ma);
    }
    cout<<k-ma<<endl;
}


Measured memory_bytes: 1792
#include <cstdint>
#include <iostream>
#include <vector>
#include <algorithm>

int main(void)
{
    uint32_t n;

    std::cin >> n;

    std::vector<int32_t> a_list(n+2);
    uint64_t total_cost = 0;

    for (uint32_t i=1; i <= n; ++i) {
        std::cin >> a_list.at(i);
    }

    for (uint32_t i=0; i < a_list.size()-1; ++i) {
        total_cost += std::abs(a_list.at(i) - a_list.at(i+1));
    }

    for (uint32_t i=1; i <= n; ++i) {
        uint64_t cost = total_cost;
        cost -= std::abs(a_list.at(i-1) - a_list.at(i));
        cost -= std::abs(a_list.at(i) - a_list.at(i+1));
        cost += std::abs(a_list.at(i-1) - a_list.at(i+1));
        std::cout << cost << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1664
//#define _CRT_SECURE_NO_WARNINGS
//#include <bits/stdc++.h>
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()

#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x; cin >> x;
	vector<int> v(2001);
	v[0] = 0;
	rep(i, 1000) {
		int k = pow((i + 1), 5);
		v[1 + i] = k;
		v[1001 + i] = -1*k;
	}
	int a = 0,b=0;
	rep(i, 2001)rep(j, 2001) {
		if (v[i] - v[j] == x) {
			a = i;
			b = j;
		}
	}
	if (a > 1000) a = -1*(a - 1000);
	if (b > 1000) b = -1*(b - 1000);
	cout << a<<" " << b;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
string m,n="CODEFESTIVAL2016";
int tot;
int main(){
    cin>>m;
    for(int i=0;i<16;i++){
    	if(m[i]!=n[i])
    		tot++;
	}
	cout<<tot<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <ctime>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <map>
using namespace std;
int a,b,ans;
string s;
int main()
{
cin>>a>>b;
ans=ceil((1.00*a+b)/2);
cout<<ans<<endl;
return 0;
}



Measured memory_bytes: 256
from itertools import groupby

s = input()

con = [sum(1 for _ in it) for k, it in groupby(s)]

idx = 0
cnt = 1
res = []
res.append(0) if s[0] == '<' else res.append(con[idx])
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        if s[i] == '<':
            res.append(cnt)
        else:
            res.append(con[idx]-cnt)
        cnt += 1
    else:
        idx += 1
        if s[i] == '<':
            res.append(max(cnt, con[idx]))
        else:
            res.append(0)
        cnt = 1
res.append(0) if s[-1] == '>' else res.append(con[-1])

print(sum(res))


Measured memory_bytes: 24200
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

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

struct edge{
    int to;
    int cost;

};

int main(){
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> rs(R, 0);
    rep(i, R){
        int r;
        cin >> r;
        r --;
        rs[i] = r;
    }
    sort(rs.begin(), rs.end());
    vector<vector<edge>> g(N);
    rep(i, M){
        int a, b, c;
        cin >> a >> b >> c;
        a --;
        b --;
        g[a].push_back(edge{b, c});
        g[b].push_back(edge{a, c});
    }
    ll inf = 1e18;

    vector<vector<ll>> dist(N, vector<ll>(N, inf));
    rep(i, N){
        dist[i][i] = 0;
        rep(j, g[i].size()){
            edge e = g[i][j];
            dist[i][e.to] = min(ll(e.cost), dist[i][e.to]);
        }
    }

    rep(k, N){
        rep(i, N){
            rep(j, N){
                dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]);
            }
        }
    }

    ll ans = inf;

    do{
        ll tmp = 0;
        rep(i, rs.size() - 1){
            tmp += dist[rs[i]][rs[i + 1]];
        }
        ans = min(tmp, ans);

    }while(next_permutation(rs.begin(), rs.end()));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner


object Main {


  case class GF(representative: Long) extends AnyVal {
    def +(that: GF): GF = GF((this.representative + that.representative) % GF.mod)

    def -(that: GF): GF = GF((this.representative - that.representative + GF.mod) % GF.mod)

    def *(that: GF): GF = GF((this.representative * that.representative) % GF.mod)

    def /(that: GF): GF = this * that.inv

    def unary_- : GF = GF((-this.representative + GF.mod) % GF.mod)

    def inv: GF = GF.powGF(this, GF.mod - 2)
  }


  object GF {
    val mod: Long = (1e9 + 7).toLong

    val _0: GF = GF(0)
    val _1: GF = GF(1)

    def powGF(x: GF, t: Long): GF = {
      if (t == 0) {
        return GF(1)
      }
      val y = powGF(x, t / 2)
      if (t % 2 == 0) {
        y * y
      } else {
        x * y * y
      }
    }
  }

  def read() = {
    val sc = new Scanner(System.in)
    val n, a, b, c = sc.nextInt()
    (n, a, b, c)
  }


  //def combGF(n: Int, r: Int): GF = fracGF(n) / (fracGF(r) * fracGF(n - r))

  def solve2(n: Int, a: Int, b: Int, c: Int): Long = {
    val p = GF(a) / GF(a + b)
    val q = GF(b) / GF(a + b)
    val fracGF = (1 to 2 * n).map(GF(_)).scanLeft(GF(1))(_ * _)

    def combGF(n: Int, r: Int): GF = fracGF(n) / (fracGF(r) * fracGF(n - r))

    //def fracGF(n: Int): GF = (1 to n).map(GF(_)).foldLeft(GF(1))(_ * _)
    val powQ = (0 to n).scanLeft(GF(1))((x, _) => x * q)
    val powP = (0 to n).scanLeft(GF(1))((x, _) => x * p)
    val powPN = GF.powGF(p, n)
    val powQN = GF.powGF(q, n)
    val result0 = (0 until n).map(i =>
      combGF(n + i - 1, i) * (powPN * powQ(i) + powQN * powP(i)) * GF(n + i)
    ).foldLeft(GF(0))(_ + _)
    val result1 = result0 * GF(100) / (GF(100) - GF(c))
    result1.representative
  }


  def solve3(n: Int, a: Int, b: Int, c: Int): Float = {
    val p = a.toFloat / (a + b)
    val q = b.toFloat / (a + b)
    val fracGF = (1 to 2 * n).map(_.toFloat).scanLeft(1F)(_ * _)

    def combGF(n: Int, r: Int): Float = fracGF(n) / (fracGF(r) * fracGF(n - r))

    //def fracGF(n: Int): GF = (1 to n).map(GF(_)).foldLeft(GF(1))(_ * _)
    val powQ = (0 to n).scanLeft(1F)((x, _) => x * q)
    val powP = (0 to n).scanLeft(1F)((x, _) => x * p)
    val powPN = math.pow(p, n).toFloat
    val powQN = math.pow(q, n).toFloat
    val result0 = (0 until n).map { i =>
      combGF(n + i - 1, i) * (powPN * powQ(i) + powQN * powP(i)) * (n + i)
    }.foldLeft(0F)(_ + _)
    val result1 = result0 * 100F / (100F - c)
    result1
  }

  def main(args: Array[String]): Unit = {
    val (n, a, b, c) = read()
    println(solve2(n, a, b, c))
  }
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for ((i) = 0; (i) < (n); (i)++)
#define rep2(i, s, e) for ((i) = (s); (i) < (e); (i)++)
#define repd(i, n) for ((i) = (n)-1; (i) >= 0; (i)--)
#define rep2d(i, s, e) for ((i) = (e)-1; (i) >= (s); (i)--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b)
{
    return b ? gcd(b, a % b) : a;
}
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void func(std::string S)
{
    if (S[1] == 'B')
    {
        cout << "ARC" << endl;
    }
    else
    {
        cout << "ABC"<<endl;
    }
}

int main()
{
    // cout << fixed << setprecision(5);

    std::string S;
    std::cin >> S;
    func(S);
    return 0;
}


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

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int ans = 0;
    int cnt = 0;
    for(auto c : s)
    {
        if(c == 'A' || c == 'C' || c == 'G' || c == 'T')
        {
            cnt++;
        }
        else
        {
            chmax(ans, cnt);
            cnt = 0;
        }
    }
    chmax(ans, cnt);
    cout << ans << endl;

    return 0;
}


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

int main() {
  int A, B, C, D;
	
	cin >> A >> B >> C >> D;
	if ((A + B) < (C + D)) cout << "Right" << endl;
	else if ((A + B) == (C + D)) cout << "Balanced" << endl;
	else cout << "Left" << endl; 

  return 0;
}

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

int A, B, K;

int main() {
	cin >> A >> B >> K;
	for (int i = A; i <= min(A + K - 1, B); i++) {
		cout << i << endl;
	}
	for (int i = max(B - K + 1, min(A + K - 1, B) + 1); i <= B; i++) {
		cout << i << endl;
	}
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define MAX 1e9+7
#define MIN -1e9-7
#define int long long
#define endl "\n"
#define max(x,y) (x>y)?x:y
#define min(x,y) (x<y)?x:y
#define s(n) scanf("%d",&n)
#define mem memset(a, 0, sizeof(a))
#define minimum(a)	*min_element(a.begin(), a.end())
#define maximum(a)	*max_element(a.begin(), a.end())
typedef vector<int> vi;
typedef vector<string> vs;


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
int n,k;
cin>>n>>k;
int arr[n];
for(int i=0;i<n;i++)
{
	cin>>arr[i];
}
for(int i=0;i<n-k;i++)
{
	if(arr[i+k]>arr[i])
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}



return 0;
}

Measured memory_bytes: 5204
n = int(input())
dic = []
dic3 = []
for i in range(n):
    a,b = input().split()
    b = int(b)
    dic3.append(b)
    for j in dic:
        if a in j:
            j.append(b)
            break
    else:
        dic.append([a,b])
#print(dic3)
dic.sort()
#print(dic)
dic2 = []
for re in dic:
    del re[0]
    re.sort()
    re.reverse()
    for j in re: dic2.append(j)
for res in dic2:
    print(dic3.index(res)+1)


Measured memory_bytes: 3064
from collections import Counter

N = int(input())

def prime(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = Counter(prime(N))

ans = 0
for i in c.values():
    if i > 0:
        a = 0
        b = 0
        for j in range(1, i+1):
            a += j
            if a > i:
                break
            b += 1    
        ans += b

print(ans)

Measured memory_bytes: 9468
#include <iostream>

using namespace std;

/* 配列の要素を順番に出力 */
void trace(int A[], int N){
    for ( int i = 0; i < N; i++){
        if ( i > 0 ) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

/* 挿入ソート */
void insertionSort(int A[], int N){
    int v;

    for ( int i = 1; i < N; i++ ){
        v = A[i];
        int j = i - 1;

        while ( j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }   
        A[j+1] = v;
        trace(A, N);
    }
}

int main(){
    int N;
    int A[100];

    cin >> N;

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

    trace(A, N);
    insertionSort(A, N);

    return 0;
}




Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long N,K;
    cin >> N >> K;
    vector<long long> a(N),b(N);
    for(long long i = 0; i < N; i++) cin >> a[i] >> b[i];
    long long S = 0;
    long long ans = 0;
    map<long long,long long> mp;
    for(long long i = 0; i < N; i++) mp[a[i]] += b[i];

    for(auto p : mp){
        long long a = p.first;
        long long b = p.second;
        S += b;
        ans = a;
        if(S >= K){
            cout << ans << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <algorithm>

#define rep(X, Y) for( int (X) = 0; (X) < (Y); ++(X) )

int main(){
	int i, cnt;
	std::vector<long long> vec;

	while( std::cin >> cnt, cnt ){
		vec.push_back(0);

		while(cnt--)
			std::cin >> i, vec.push_back(i);

		std::sort( vec.begin(), vec.end() );

		rep( i, 2 )
			rep( l, (int)vec.size() - 2 )	
				vec[l + 1] += vec[l];

		std::cout << vec[(int)vec.size() - 2] << std::endl;
		
		vec.clear();
	}
	return 0;
}

Measured memory_bytes: 1336
N, M = gets.split.map(&:to_i)
U = Array.new(N + 1, &:itself)

class << U
  def root(i)
    self[i] == i ? i : (self[i] = root(self[i]))
  end
  
  def union(i,j)
    pi = root(i)
    pj = root(j)
    self[pi] = self[pj] = (pi < pj ? pi : pj)
  end
  
end

F = M.times.map{ gets.split.map(&:to_i) }
F.each do |i,j,z|
  U.union(i, j)
end

puts (1 .. N).group_by{|i| U.root(i) }.size




Measured memory_bytes: 18428
N = int(input())
A = [int(input()) for a in range(N)]
maxnum = max(A)
maxcount = A.count(maxnum)
s = sorted(A,reverse=True)

if maxcount == 1:
  index = A.index(maxnum)
  ans = [maxnum] * N
  ans[index] = s[1]
else:
  ans = [maxnum] * N
for a in ans:
  print(a)

Measured memory_bytes: 92976
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
using ull = uint_fast64_t;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vull = vector<ull>;
#define rep(i, n) for (ull i = 0; i < n; ++i)
#define rep1(i, n) for (ull i = 1; i < n; ++i)
#define iter(it, v) for (auto it = v.begin(); it != v.end(); ++it)
#define pb push_back
#define fi first
#define se second
#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }
template <typename T> void vecout(const T &v) {
  for (auto it = v.begin(); it != v.end();
       ++it, cout << (it != v.end() ? " " : "\n")) {
    cout << *it;
  }
}
template <typename T> void arrout(const T arr, int n) {
  for (int i = 0; i < n; ++i, cout << (i != n ? " " : "\n")) {
    cout << arr[i];
  }
}

void solve() {
  // main coding
  string s; cin>>s;
  ll n=s.length();
  vector<char> stack;
  rep(i,n) {
    if(!stack.empty() && stack.back()!=s[i]) stack.pop_back();
    else stack.pb(s[i]);
  }
  cout<<n-stack.size()<<endl;
}

int main() {
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n[3];
    
    for (int i = 0; i < 3; i++) {
        cin >> n[i];
    }
    sort(n, n+3, greater<int>());

    cout << n[0] * 10 + n[1] + n[2] << endl;
}

Measured memory_bytes: 256
import Control.Monad
import qualified Data.ByteString.Char8 as C
import Data.List
import Data.Maybe
import qualified Data.Set as S
import Data.Vector.Generic ((!))
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM

main = C.interact $ put . sol . get

get = U.unfoldr (C.readInt . C.dropWhile (<'0'))

put = C.pack

sol v = if cnt>0 then "Fennec" else "Snuke"
  where
  n = U.head v
  u = U.tail v
  tree = build n $ U.unfoldrN (n-1) split2 u
  split2 u = Just ((U.head v,U.last v), w) where (v,w) = U.splitAt 2 u
  d1 = levels n tree 1
  dn = levels n tree n
  cnt = foldl' (\s i -> if d1!i <= dn!i then s+1 else s-1) 0 [1..n]

build :: Int -> U.Vector (Int, Int) -> V.Vector (U.Vector Int)
build n es = V.create $ do
  v <- VM.replicate (n+1) U.empty
  let add a b = VM.read v a >>= VM.write v a . (U.cons b) 
  U.forM_ es $ \(a,b) -> do
    add a b
    add b a
  return v

levels :: Int -> V.Vector (U.Vector Int) -> Int -> U.Vector Int
levels n tree v0 = U.create $ do
  d <- UM.replicate (n+1) maxBound
  UM.write d v0 0
  loop d $ S.singleton (0,v0)
  return d
  where
  loop d q = when (not $ S.null q) $ do
    let ((lvl,nd),q') = fromJust $ S.minView q
    U.foldM (f (lvl+1) d) q' (tree!nd) >>= loop d
  f l d q v = do
    l0 <- UM.read d v
    if l >= l0
      then return q
      else do
        UM.write d v l
        return . S.insert (l,v) $ S.delete (l0,v) q

Measured memory_bytes: 34956
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
#include <queue>
using namespace std;
#define INF 1 << 28

typedef tuple<double, int, pair<int, int>> State; //コスト, スピード, 前の場所, 今の場所
typedef tuple<int, int, int> Edge; // 接続先の都市, 道路の距離, 制限速度
typedef pair<int, int> Location;
int n, m, s, g;
vector<Edge> edge[30]; //都市の数だけ作成
double memo[31][31][31]; //速度, 前の都市, 現在の都市

double dijkstra(){
  priority_queue<State, vector<State>, greater<State>> que;
  que.push(make_tuple(0.0, 1, make_pair(s, s)));

  while(!que.empty()){
    double cost;
    int v;
    Location loc;
    State now = que.top(); que.pop();
    tie(cost, v, loc) = now;
    int prev = loc.first, current = loc.second;
    if(current == g && v == 1) return cost;
    for(int i = 0;i < (int)edge[current].size();i++){
      int to, dist, limitv;
      tie(to, dist, limitv) = edge[current][i];
      if(prev == to) continue;
      int nv, nprev = current, ncurrent = to;
      for(int i = -1; i <= 1 ; i++){
        nv = v + i;
        if(current == s && prev == s && i != 0) continue;
        if(nv > limitv || nv <= 0 || nv >= 31) continue;
        double ncost = cost + dist / (double)nv;
        if(memo[nv][nprev][ncurrent] <= ncost) continue;
        memo[nv][nprev][ncurrent] = ncost;
        que.push(make_tuple(ncost, nv, make_pair(nprev, ncurrent)));
      }
    }
  }
  return -1;
}

int main(void){
  while(true){
    cin >> n >> m;
    if(n == 0 && m == 0) break;
    for(int i = 0;i<30;i++) edge[i].clear();
    for(int i = 0;i<31;i++){
      for(int j = 0;j<31;j++){
        for(int k = 0;k<31;k++){
          memo[i][j][k] = INF;
        }
      }
    }
    cin >> s >> g;
    s--; g--;
    for(int i = 0;i<m;i++){
      int x,y,d,c;
      cin >> x >> y >> d >> c;
      x--; y--;
      edge[x].push_back(make_tuple(y, d, c));
      edge[y].push_back(make_tuple(x, d, c));
    }
    double ans = dijkstra();
    if(ans > -1) cout << ans << endl;
    else cout << "unreachable" << endl;
  }
  return 0;
}


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

int main(){
  int N, A, B, temp, digsum, Nsum=0;
  cin >> N >> A >> B;
  
  for(int i=1; i<=N; ++i) {
    temp = i;
    digsum = 0;
  	while(temp>0) {
    	digsum += temp % 10;
    	temp /= 10;
  	}
    if(digsum>=A && digsum<=B) Nsum += i;
  }
  
  cout << Nsum << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
vector<vector<int>> edge(100001);
vector<int> lpath(100001,-1);
int longPath(int st)
{
    if(edge[st].size()==0)
    {
        lpath[st]=0; 
    }
    else
    {
        int longest=0;
        for(int i=0;i<edge[st].size();i++)
        {
            if(lpath[edge[st][i]]==-1)
            {
                longest=max(longest,1+longPath(edge[st][i]));
            }
            else
            {
                longest=max(longest,1+lpath[edge[st][i]]);
            }
        }
        lpath[st]=longest;
    }
    return lpath[st];
}

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

    int n,m,i,j,x,y;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        edge[x].push_back(y);
    }
    int longest=0;
    for(i=1;i<=n;i++)
    {
        if(lpath[i]==-1)
        {
            longest=max(longest,longPath(i));
        }
        else
        {
            longest=max(longest,lpath[i]);
        }
        /*for(j=1;j<=n;j++)
            cout<<lpath[j]<<" ";
        cout<<endl;*/
    }

    cout<<longest<<endl;

}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

bool isprime(int x) {
    for(int i = 2; i*i <= x; i++) {
        if (x % i == 0)
            return false;
    }
    return true;
}
int main() {
    int x;
    cin >> x;
    while(1) {
        if (isprime(x) == true) {
            cout << x << endl;
            return 0;
        }
        x++;
    }

    return 0;
}




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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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 ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
set<ll> divisor2(ll n) {
  set<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.insert(i);
      if (i != n / i) res.insert(n / i);
    }
  }
  return res;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) ++res[i], n /= i;
  }
  if (n != 1) res[n] = 1;
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b; cin>>a>>b;
  auto s1=divisor2(a);
  auto s2=divisor2(b);
  vll c;
  for(auto e: s1){
    if(s2.count(e)) c.push_back(e);
  }
  vsort(c);
  // for(auto e: c) cout<<e<<" ";
  set<ll> check;
  ll ans=0;
  ll n=c.size();
  rep(i,n){
    if(check.count(c[i])) continue;
    ans++;
    if(c[i]==1) continue;
    irep(j,i+1,n){
      if(c[j]%c[i]==0) check.insert(c[j]);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1280