akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn to_code(c: char) -> u8 {
    c as u8 - 'a' as u8
}

fn from_code(code: u8) -> char {
    (code + 'a' as u8) as char
}


fn count_word(s: &Vec<char>) -> Vec<u32> {
    let mut arr = vec![0; 26];
    for c in s {
        arr[to_code(*c)  as usize] += 1;
    }
    arr
}


fn solve(ss: Vec<Vec<char>>) -> String {
    let mut arr = vec![std::u32::MAX; 26];
    for s in ss {
        let larr = count_word(&s);
        for i in 0..26 {
            if arr[i] > larr[i] {
                arr[i] = larr[i];
            }
        }
    }

    let mut res = String::new();
    for i in 0..26 {
        for _ in 0..arr[i] {
            res.push(from_code(i as u8));
        }
    }

    res

}



fn main() {
    input! {
        n: usize,
        ss: [chars; n],
    };
    println!("{}", solve(ss));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin>>N;
    FOR(w,1,4000)FOR(n,1,4000){
        ll x=N*n*w,y=4*n*w-N*w-N*n;
        if(y>0 && x%y==0){
            ll h=x/y;
            cout<<h<<' '<<w<<' '<<n<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3616
N, K = map(int, input().split())
v_list = list(map(int, input().split()))

ans = 0

for a in range(min(N, K) + 1):
    for b in range(min(N-a, K-a)+1):
        c = K - a - b
        tmp = v_list[:a:] + v_list[N-b:]
        tmp.sort()
        trash = 0
        for i in range(min(c, len(tmp))):
            t = tmp[i]
            if t < 0:
                trash += t
            else:
                break
        ans = max(sum(tmp) - trash, ans)
print(ans)


Measured memory_bytes: 3064
def examA():
    S = SI()
    if "W" in S and not "E" in S:
        print("No")
    elif "E" in S and not "W" in S:
        print("No")
    elif "N" in S and not "S" in S:
        print("No")
    elif "S" in S and not "N" in S:
        print("No")
    else:
        print("Yes")
    return

def examB():
    N = I()
    A = [I()for _ in range(N)]
    ans = 0
    for i in range(N-1):
        ans += A[i]//2
        if A[i]%2 and A[i+1]>=1:
            ans += 1
            A[i+1] -= 1
    ans += A[N-1]//2
    print(ans)
    return

def examC():
    N = I()
    A = [I()for _ in range(N)]
    if N==1:
        print(0)
        return
    odd = set()
    for i in range(N):
        if i&1==0:
            odd.add(A[i])
    A.sort()
    ans = 0
    for i in range((N+1)//2):
        if A[i*2] in odd:
            continue
        ans += 1
    print(ans)
    return

def examD():
    N = I()
    S = [I()for _ in range(N)]

    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examC()

"""

"""

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


int main(){
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> students;
    ll a, b, c, d;
    rep(i, 0, n){
        cin >> a >> b;
        students.push_back(make_pair(a, b)); 
    }
    // checkpoint
    vector<pair<ll, ll>> ckpt;
    rep(i, 0, m){
        cin >> c >> d;
        ckpt.push_back(make_pair(c, d)); 
    }

    for (auto stu:students){
        tie(a, b) = stu;
        ll dist = 1000000001;
        ll id;
        rep(i, 0, m){
            tie(c, d) = ckpt[i];
            ll dx = abs(a - c) + abs(b - d);
            if (dx < dist){
                dist = dx;
                id = i + 1;
            }
        }
        cout << id << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    for (int i = 1; i <= b; i++)
    {
        if ((a * i) % b == c)
        {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <map>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
using namespace std;
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;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    string A,B; cin >> A >> B;
    for(int i=0; i<min(A.length(),B.length()); ++i){
        cout << A[i] << B[i];
    }
    if(A.length()!=B.length()){
        cout << A[A.length()-1];
    }
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)

a = [a[len(a)-1]] + a[0:len(a)-1] + [-10000000000000]
li = []

for i in range(n-1):
    if a[i+2] >= 0:
        # 負にしたい
        if a[i+1] > a[i]:
            li.append([a[i], a[i+1]])
            ans = a[i] - a[i+1]
            a[i+1] = a[i] - a[i+1]
        else:
            li.append([a[i+1], a[i]])
            ans = a[i+1] - a[i]
            a[i+1] = a[i+1] - a[i]
    if a[i+2] < 0:
        # 正にしたい
        if a[i+1] > a[i]:
            li.append([a[i+1], a[i]])
            ans = a[i+1] - a[i]
            a[i+1] = a[i+1] - a[i]
        else:
            li.append([a[i], a[i+1]])
            ans = a[i] - a[i+1]
            a[i+1] = a[i] - a[i+1]

print(ans)
for i in li:
    print(' '.join(map(str, i)))

Measured memory_bytes: 67900
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> v;
	for (int i = 1; i <= 3500 && v.empty(); ++i) {
		for (int j = 1; j <= i && v.empty(); ++j) {
			long long p = 4 * i * j - N * i - N * j;
			long long q = 1LL * N * i * j;
			if (p > 0 && q % p == 0 && q / p <= 3500) {
				v = vector<int>({ i, j, int(q / p) });
			}
		}
	}
	cout << v[0] << ' ' << v[1] << ' ' << v[2] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int N, P, a, cnt[2];

int main(){
	scanf("%d%d", &N, &P);
	for(int i=0; i<N; i++) scanf("%d",&a), cnt[a%2]++;
	if(cnt[1]) printf("%lld\n", 1ll<<(N-1));
	else printf("%lld\n", P?0:(1ll<<N));
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

// typedef
typedef long long ll;
typedef unsigned long ul;
// #define int long long

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // 値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)  // 直後の要素をパディング
#define space_pad(num) setfill(' ') << std::right << setw(num)  // 直後の要素をパディング

// func declaration
template <class T> void print2DVec(vector< vector<T> >&);
template <class T> void calcVec(vector<T>&, int, char);
int char_to_int(const char);

// const
const int INF = 10000000;

/*MEMO
・辞書順
abc < abcd, atcoder < atlas
・イテレータ
std::vector<int>::iterator とタイプするのは面倒なので、
 通常は型推論の auto を使用する。
 auto iter = max_element(ALL(vec));
・2次元配列
vector<vector<int>> vec = {{1, 2, 3}, {4, 5, 6}}
・20×10の配列
vector<vector<int>> vec(20, vector<int>(10, 0));
・(n, m)の多次元配列
vector< vector<int> > vec(n, vector<int>(m, 0))  // 0で初期化
*/

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

    // input
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    
    // calculation
    int max_three = max(A, max(B, C));
    cout << A + B + C + max_three*pow(2, K) - max_three << "\n";
    
    return 0;
}


// function
template <class T> void print2DVec(vector< vector<T> >& vec) {
    REP(i, vec.size()) {
        REP(j, vec.front().size()) {
            cout << vec.at(i).at(j);
        }
        cout << endl;
    }
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    switch (ch) {
        case '+':
            REP(i, vec.size()) vec.at(i) += num; break;
        case '-':
            REP(i, vec.size()) vec.at(i) -= num; break;
        case '*':
            REP(i, vec.size()) vec.at(i) *= num; break;
        case '/':
            REP(i, vec.size()) vec.at(i) /= num; break;
        case '%':
            REP(i, vec.size()) vec.at(i) %= num; break;
        default:
            cout << "Incorrect Operator" << endl;
    }
}

int char_to_int(const char c) {
    if('0' <= c && c <= '9') return (c - '0');
    return -1;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    int N;cin>>N;
    LL A[N];REP(i,N)cin>>A[i];
    LL B[N];REP(i,N)B[i]=A[i];
    sort(B,B+N);
    LL sum[N];fill_n(sum,N,0);
    sum[0]=B[0];
    REP(i,N-1)sum[i+1]=sum[i]+B[i+1];

    LL min =0;
    REP(i,N-1)if(sum[i]*2<B[i+1])min=B[i];
    LL cnt=0;
    REP(i,N)if(B[i]>min)cnt++;
    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner
import scala.math._

object Main extends App {
  val sc = new Scanner(System.in)
  val a, b = sc.next

  val x = (a + b).toInt
  val y = floor(sqrt(x))
  val z = if (y * y == x) "Yes" else "No"
  println(z)
}


Measured memory_bytes: 25512
n = int(input())

t, x, y = 0, 0, 0
flg = True
for _ in range(n):
    tn, xn, yn = map(int, input().split())
    dt, dx, dy = abs(tn-t), abs(xn-x), abs(yn-y)

    if not (dx + dy <= dt and (dx + dy) % 2 == dt % 2):
        flg = False

    t, x, y = tn, xn, yn

print("Yes") if flg else print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0 ; i < (n) ; i++ )
using ll = long long;
using namespace std;
vector<long> A;
vector<long> ans;
bool hantei(long i,long n){
    vector<long> index;long sum=0;long base=i;
    for(long j = i+i; j <= n; j+= i){
        sum+=ans[j];
    }
    if(A[i] == 1){
        if(sum%2==0) return true;
        else return false;
    }else{
        if(sum%2==0) return false;
        else return true;
    }
}

int main(){
    long n;cin>>n;long Sum=0;
    A.resize(n+1);
    ans.resize(n+1);
    rep(i,n){
        cin >> A[i+1];
    }
    for(long i = n; i > 0;i--){
        if(hantei(i,n)){
            ans[i] = 1;
            Sum++;
        }
    }
    cout << Sum << endl;
    for(long i=1; i<n+1;i++){
        if( ans[i] == 1 ){
            cout << i << " ";
        }
    }
    return 0;
}

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


vector<int> g[300010];
bool used[300010];
int main(int argc, char const *argv[])
{
	int n, m; cin >> n >> m;
	vector<int> u(m), v(m); rep(i, m) cin >> u[i] >> v[i];
	rep(i, m) u[i]--, v[i]--;
	int s, t; cin >> s >> t;
	s--, t--;

	rep(i, m) {
		rep(j, 3)
			g[u[i] * 3 + j].push_back(v[i] * 3 + ((j + 1) % 3));
	}

	queue<pair<int, int>> q;
	q.push(make_pair(3 * s, 0));
	used[3 * s] = true;
	while (!q.empty()) {
		int d = q.front().first, cost = q.front().second;
		q.pop();

		if (d == 3 * t) {
			printf("%d\n", cost / 3);
			return 0;
		}
		for (auto nd : g[d]) {
			if (!used[nd]) {
				used[nd] = true;
				q.push(make_pair(nd, cost + 1));
			}
		}
	}
	printf("-1\n");
	return 0;
}


Measured memory_bytes: 17664
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,Q=map(int,input().split())
    S=list(input())+['X']
    A=[0]*N
    for i in range(N):
        if S[i]=='A' and S[i+1]=='C':
            A[i+1]+=1
    S_A=[0]*(N+1)
    for i in range(N):
        S_A[i+1]=S_A[i]+A[i]
    for i in range(Q):
        l,r=map(int,input().split())
        print(S_A[r]-S_A[l])

if __name__ == '__main__':
    main()


Measured memory_bytes: 57804
import math
a,b=list(map(int,input().split()))
ans=float("inf")
for i in range(2000,0,-1):
    if math.floor(i*0.1)==b and math.floor(i*0.08)==a:
        ans=min(ans,i)
if ans==float("inf"):
    ans=-1
print(ans)

Measured memory_bytes: 3060
def main():
    N, C = map(int, input().split())
    D = []
    for _ in range(C):
        d = list(map(int, input().split()))
        D.append(d)
    c = []
    for _ in range(N):
        cc = list(map(int, input().split()))
        c.append(cc)
    l = [[0] * (C+1) for _ in range(3)]
    for i in range(N):
        for j in range(N):
            l[(i + j) % 3][c[i][j]] += 1
    m = pow(10, 10000)
    for i in range(1, C+1):
        for j in range(1, C+1):
            for k in range(1, C+1):
                if i == j or i == k or j == k:
                    continue
                t = 0
                for ii in range(1, C+1):
                    t += l[0][ii] * D[ii-1][i-1]
                for jj in range(1, C+1):
                    t += l[1][jj] * D[jj-1][j-1]
                for kk in range(1, C+1):
                    t += l[2][kk] * D[kk-1][k-1]
                m = min(m, t)
    print(m)
main()


Measured memory_bytes: 45660
#include "cstdio"
#include "string"
using namespace std;

const int maxn = 1e5;

char s[maxn];

int main(int argc, char const *argv[])
{
	int a;
	scanf("%d%s", &a, s);
	printf("%s\n", (a>=3200)? s: "red");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
   ll N; cin >>N;
    vector<ll> A(N);
    vector<ll> B(N+1, 0);
    REP(i, N){
        cin >> A[i];
        B[A[i]]++;
    }
    ll res = 0;
    REP(i, N+1){
        res += B[i] * (B[i]-1) / 2;
    }
    REP(i, N){
        ll a = A[i];
        cout << res - (B[a]-1) << endl;
    }
    return 0;
}

Measured memory_bytes: 5760
#include<stdio.h>
#include<string.h>
void f(int a[][14][14],int d,int x,int y){
  int i;
  if(a[d][x][y]){
    a[d][x][y]=0;
    for(i=1;i<4;i++){
      f(a,d,x-i,y);
      f(a,d,x,y-i);
      f(a,d,x+i,y);
      f(a,d,x,y+i);
    }
  }
  return;
}
int main(){
  int i,j,k;
  int n;
  char s[9];
  scanf("%d",&n);
  int a[n][14][14],x[n],y[n];
  memset(a,0,sizeof(a));
  for(i=0;i<n;i++){
    for(j=0+3;j<8+3;j++){
      scanf("%s",s);
      for(k=0+3;k<8+3;k++)
	a[i][k][j]=s[k-3]-'0';
    }
    scanf("%d%d",&x[i],&y[i]);
    x[i]+=2;
    y[i]+=2;
  }
  for(i=0;i<n;i++){
    f(a,i,x[i],y[i]);
    printf("Data %d:\n",i+1);
    for(j=0+3;j<8+3;j++){
      for(k=0+3;k<8+3;k++)
	printf("%d",a[i][k][j]);
      puts("");
    }
  }
  return 0;
}

Measured memory_bytes: 0
n, k = map(int, input().split())

rate = 0

temp = 1
cnt = 0

while True:
  if temp >= k:
    break
  else:
    temp *= 2
    cnt += 1

for i in range(1, n + 1):
  if i * (2 **cnt) >= k > i * (2 ** (cnt - 1)):
    rate += 1 / n * 0.5 ** cnt
  else:
    cnt = max(0, cnt - 1)
    rate += 1 / n * 0.5 ** (cnt)

print(rate)


Measured memory_bytes: 40556
#include<stdio.h>
 
int main(){
	int A,B;
	scanf("%d %d",&A,&B);
	if(B%A==0) 
    {
      printf("%d\n",A+B);
    }
	else 
    {
      printf("%d\n",B-A);
    }
	return 0;
}

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

const long MOD = 998244353;
const int MAX = 300001;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit(int n) {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i <= n; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long combination(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int n, a, b;
    unsigned long long k;
    std::cin >> n >> a >> b >> k;

    COMinit(n);

    unsigned long long result = 0;
    int j = 0;

    for(int i = 0; i <= n ; i ++){
        if ( k < a * i ){
            break;
        }
        if ( ( k - a * i ) % b == 0 ){
            j = ( k - a * i ) / b;
            result += combination(n, i) * combination(n, j);
            result %= MOD;
        }
    }
    std::cout << result << std::endl;
    return 0;
}

Measured memory_bytes: 7296
h, w = map(int, input().split())
a = [[0]*w]*h
for i in range(h):
    a[i] = input()

c, l = [], []
for i in range(h):
    flag = True
    for j in range(w):
        if a[i][j] != '.':
            flag = False
            break
    if not flag:
        l.append(i)

for i in range(w):
    flag = True
    for j in range(h):
        if a[j][i] != '.':
            flag = False
            break
    if not flag:
        c.append(i)

for i in range(len(l)):
    s = ''
    for j in range(len(c)):
        s += a[l[i]][c[j]]
    print(s)

Measured memory_bytes: 9084
#include <bits/stdc++.h> 
#define N 100000
using namespace std;
bool flag=1;
int n,a[N|1],b[N|1],c[N|1];
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d%d%d",c+i,a+i,b+i);
		if(abs(a[i]-a[i-1])+abs(b[i]-b[i-1])>c[i]-c[i-1])
			flag=0;
		if(abs(abs(a[i]-a[i-1])+abs(b[i]-b[i-1])-(c[i]-c[i-1]))&1)
			flag=0;
	}
	if(flag)	puts("Yes");
	else		puts("No");
	return 0;
}


Measured memory_bytes: 1408
#define TEST_SNO	1
#define TEST_ENO	3
#define ll			long long

#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

typedef struct data {
	int a;
	int b;
} data;

FILE *in, *ans;
int tno;

int n, k;
char s[100010];
int ok[100010];
int ng[100010];
int okcnt, ngcnt;

int out(const char *s) {
#ifdef TEST
	char buf[8192];
	fgets(buf, sizeof(buf), ans);
	if (strcmp(buf, s)) {
		printf("err\n");
	}
#else
	printf(s);
#endif
	return 0;
}

int outi(int i) {
	char s[128];
	sprintf(s, "%d\n", i);
	out(s);
	return 0;
}

int outll(ll l) {
	char s[128];
	sprintf(s, "%lld\n", l);
	out(s);
	return 0;
}

int geti() {
	int i;
	fscanf(in, "%d", &i);
	return i;
}

ll getll() {
	ll l;
	fscanf(in, "%lld", &l);
	return l;
}

int getstr(char *s) {
	fscanf(in, "%s", s);
	return 0;
}

int fnc() {

	int i;

	okcnt = ngcnt = 0;

	n = geti();
	k = geti();
	getstr(s);

	if (s[0] == '0') {
		ok[0] = 0;
		okcnt = 1;
		ng[0] = 1;
		ngcnt = 1;
	}
	else {
		ok[0] = 1;
		okcnt = 1;
	}

	for (i = 1; ; i++) {
		if (s[i] == '0') {
			if (s[i - 1] == '0') {
				ng[ngcnt - 1]++;
			}
			else {
				ng[ngcnt] = 1;
				ngcnt++;
			}
		}
		else if (s[i] == '1') {
			if (s[i - 1] == '1') {
				ok[okcnt - 1]++;
			}
			else {
				ok[okcnt] = 1;
				okcnt++;
			}
		}
		else {
			break;
		}
	}
	okcnt++;

	if (k > ngcnt) {
		k = ngcnt;
	}

	int max = 0;
	for (i = 0; i < k; i++) {
		max += ok[i];
		max += ng[i];
	}
	max += ok[i];

	int cnt = ngcnt - k;
	int sum = max;
	for (i = 0; i < cnt; i++) {
		sum -= ok[i] + ng[i];
		sum += ok[i + 1 + k] + ng[i + k];
		if (max < sum) {
			max = sum;
		}
	}

	outi(max);

	return 0;
}

int main() {
#ifdef TEST
	for (tno = TEST_SNO; tno <= TEST_ENO; tno++) {
		char str[128];
		sprintf(str, "test%d.txt", tno);
		in = fopen(str, "r");
		sprintf(str, "ans%d.txt", tno);
		ans = fopen(str, "r");
		fnc();
		fclose(in);
		fclose(ans);
	}
	printf("end\n");
#else
	in = stdin;
	fnc();
#endif

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){

   while(1){
    int n,ans=1150,m;
    cin >> n;
    if(n==-1)break;
    if(n>10){
        m=n-10;
        if(m>=10)m=10;
        ans+=m*125;
        m=0;
    }
    if(n>20){
        m=n-20;
        if(m>=10)m=10;
        ans+=m*140;
        m=0;
    }
    if(n>30){
        m=n-30;
        ans+=m*160;
        m=0;
    }
    ans=4280-ans;
    cout << ans << endl;
   }

return 0;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;
const ll com_max = 510000;

ll fac[com_max], inv[com_max], finv[com_max];

void com_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;

    for (ll i = 2; i < com_max; i++) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

ll com(ll n, ll k) {
    if (n < k) {
        return 0;
    }
    if (n < 0 || k < 0) {
        return 0;
    }

    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main() {
source:
    ll h, w, a, b;
    cin >> h >> w >> a >> b;
    ll num = h - a;
    ll side_rem = w - b;
    com_init();
    ll on_the_way[num];
    ll combination[num];
    rep(i, num) {
        on_the_way[i] = com(b - 1 + i, i);
        combination[i] = com(h - i - 1 + side_rem - 1, side_rem - 1);
    }
    ll ans = 0;
    rep(i, num) { ans = (ans + on_the_way[i] * combination[i]) % mod; }
    cout << ans << endl;

    return 0;
}



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

void print(string s) {
    cout << s << endl;
}

int main() {
    string weather;
    cin >> weather;
    if (weather == "Sunny") print("Cloudy");
    else if (weather == "Cloudy") print("Rainy");
    else print("Sunny");
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int a[10],i,j,k,l,m,run;

for(i=0;i<5;i++){
    scanf("%d",&a[i]);
}
for(j=0;j<5;j++){
    for(k=0;k<4;k++){
        if(a[k]<a[k+1]){
            run=a[k];
            a[k]=a[k+1];
            a[k+1]=run;
        }
    }
}
for(l=0;l<5;l++){
    printf("%d",a[l]);
    if(l==4)printf("\n");
    else printf(" ");
    }
return 0;
}

Measured memory_bytes: 600
n,k,q = map(int,input().split())
A = []
for i in range (q):
  a = int(input())
  A.append(a)
point = [k - q]*n

for i in range(q):
  tmp = A[i] - 1
  point[tmp] += 1

for i in range(n):
    if point[i] > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 10428
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
sum = 0
attack = 0
mon = a[0]
for i in range(n):
    if mon >= b[i]:
        sum += b[i]
        mon = a[i+1]
    else:
        sum += mon
        attack = b[i] - mon
        mon = max(0, a[i+1] - attack)
        sum += (a[i+1] - mon)
print(sum)

Measured memory_bytes: 18624
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main(void){
	int n,m;
	while(cin>>n>>m,n||m){
		vector<set<int> > friends(n+1);
		for(int i=0,a,b;i<m;++i){
			cin>>a>>b;
			friends[a].insert(b);friends[b].insert(a);
		}
		set<int> myfriends;
		for(set<int>::iterator it=friends[1].begin();it!=friends[1].end();++it){
			for(set<int>::iterator it2=friends[*it].begin();it2!=friends[*it].end();++it2){
				myfriends.insert(*it2);
			}
			myfriends.insert(*it);
		}
		int ans=((myfriends.find(1)!=myfriends.end())?myfriends.size()-1:myfriends.size());
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int N = 200005;

int n, k, A[N];

bool step() {
    vector<int> cnt(n + 2, 0);
    for (int i = 1; i <= n; i++) {
        cnt[max(1, i - A[i])]++;
        cnt[min(n + 1, i + A[i] + 1)]--;
    }
    int sum = 0;
    bool ret = false;
    for (int i = 1; i <= n; i++) {
        sum += cnt[i];
        if (sum != A[i]) ret = true;
        A[i] = sum;
    }
    return ret;
}

int main() {
    scanf("%d %d", &n, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &A[i]);
    }
    
    for (int i = 1; i <= k; i++) {
        if (!step()) break;
    }
    for (int i = 1; i <= n; i++) {
        printf("%d ", A[i]);
    }
    printf("\n");
    return 0;
}


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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

void solve(long long N, std::vector<std::string> S) {
    set<string> s(S.begin(), S.end());
    cout << s.size() << endl;
}

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


Measured memory_bytes: 25100
#include "bits/stdc++.h"
using namespace std;
deque<int> fff;
int main(){
    bool push_b = true;
    int n; scanf("%d", &n);
    for(int e = 0; e < n; e++){
        int x; scanf("%d", &x);
        if(push_b) fff.push_back(x);
        else fff.push_front(x);
        push_b = !push_b;
    }
    vector<int> ans;
    if(push_b){
        while(!fff.empty()){
            ans.push_back(fff.front());
            fff.pop_front();
        }
    } else {
        while(!fff.empty()){
            ans.push_back(fff.back());
            fff.pop_back();
        }
    }
    for(int e = 0; e < n; e++)
        printf("%d ", ans[e]);
    printf("\n");
    return 0;
}


Measured memory_bytes: 3960
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define all(a)  a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define _for(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

using namespace std;

bool p[15];

bool check(int x){
   if(x == 0){
      if(p[x] == 0) return true;
      return false;
   }
   while(x){
      if(p[x % 10] == 1) return false;
      x /= 10;
   }
   return true;
}

int main(){
   int N, M;
   cin >> N >> M;
   int x;
   for(int n = 1; n <= M; ++n){
      scanf("%d", &x);
      p[x] = 1;
   }
   int st = N;
   while(true){
      if(check(N)) break;
      ++N;
   }
   cout << N << endl;
   return 0;
}

Measured memory_bytes: 256
from collections import deque

tmp = {}
saigen = []
N = int(input())
tree = [[] for _ in range(N)]  # N頂点
for _ in range(N-1):
    a, b = map(lambda x: int(x) - 1, input().split())
    tree[a].append(b)
    tmp[(a, b)] = -1
    saigen.append([a, b])
    # tree[b].append(a)

colors = [-1] * N

q = deque([0])

while len(q) != 0:
    v = q.popleft()  # 親のノードの番号
    color = 1
    for e in tree[v]:  # 子のノードの色を塗っていく
        if colors[e] != -1:
            continue
        if color == colors[v]:
            color += 1
        colors[e] = color
        tmp[v, e] = color
        color += 1
        q.append(e)
print(max(colors))
# 辺の順番を考慮する必要あり
# for c in colors[1:]:
#     print(c)
for a, b in saigen:
    print(tmp[a, b])


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

int main(){
  int a, b;
  cin >> a >> b;
  if (a > 9 || b > 9) cout << -1 << endl;
  else cout << a * b << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) a.begin(),a.end()
typedef long long ll;

using P = pair<ll,ll>;
#define v first
#define w second

// v高い順（vが同じならw軽い方優先）
bool comp(P a, P b){
    return a.v == b.v ? a.w < b.w : a.v > b.v;
}

int main(void){
    ll N,W;
    cin>>N>>W;
    vector<P> a(N);
    rep(i,N){
        ll v,w;
        cin>>v>>w;
        a[i] = {v,w};
    }
    vector<P> dp = {{0,0}};

    rep(i,N){
        vector<P> tmp;
        for(P s : dp){
            tmp.push_back(s);
            tmp.push_back({s.v + a[i].v, s.w + a[i].w});
        }

        sort(all(tmp),comp);
        dp.clear();
        ll w_border = W+1;
        for(P s : tmp){
            if( w_border > s.w){
                w_border = s.w;
                dp.push_back(s);
            }
        }
        assert((ll)dp.size() <= N*N+1);
    }
    cout<<dp[0].v<<endl;
    return 0;
}



Measured memory_bytes: 3200
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void solve() {
	int n; cin >> n; vector<bool> ans(n, true);
	set<LP> st;
	int x; cin >> x; ans[0] = true;
	st.insert({ 1, x });
	rep(i, n-1) {
		/*auto itr2 = st.begin();
		while (itr2 != st.end()) {
			LP p = *itr2;
			cout << p.first << " " << p.second << endl;
			itr2++;
		}*/
		int x; cin >> x;
		LP p = { x,INF };
		st.insert(p);
		auto itr = st.find(p);
		if (itr == st.begin()) {
			st.erase(p);
			ans[i + 1] = false;
			continue;
		}
		itr--; st.erase(p);
		p = *itr;
		if (p.first + p.second - 1 >= x) {
			ll dif = x - p.first;
			P nexle = { p.first,dif };
			P nexri = { x + 1,p.first + p.second - x - 1 };
			st.erase(itr);
			if (nexle.second > 0)st.insert(nexle);
			if (nexri.second > 0)st.insert(nexri);
		}
		else {
			P nexle = { p.first,p.second - 1 };
			P nexri = { p.first + p.second,x+1 - p.first - p.second };
			st.erase(itr);
			if (nexle.second > 0)st.insert(nexle);
			if (nexri.second > 0)st.insert(nexri);
		}
	}
	rep(i, n) {
		if (ans[i]) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 13240
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main() {
	i64 a, b, k; cin >> a >> b >> k;
	bool f = true;
	while(k--) {
		if(f) {
			a -= a % 2;
			b += a / 2;
			a /= 2;
		} else {
			b -= b % 2;
			a += b / 2;
			b /= 2;
		}
		f = !f;
	}
	
	cout << a << " " << b << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

class Dengen{
public:
    int A;
    int B;
    void keisan(int A, int B);
};

void Dengen::keisan(int A, int B){

    int first;
    first = 1;
    int ans = 0;

    while(first < B){
        first--;
        first = first + A;
        ans++;
    }

    cout << ans;
}

int main(){

    Dengen d;

    cin >> d.A;

    cin >> d.B;

    d.keisan(d.A, d.B);

    return 0;
}

Measured memory_bytes: 256
//K-OS WITH THE OCDE

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <iostream>
#include <numeric>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <climits>

using namespace std;

typedef long long int ll;
typedef long double db;


#define TEST ll t; cin>>t; while(t--)
#define vell vector<ll>
#define pl pair<ll,ll>
#define all(v) v.begin(),v.end()
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define dbg(x)  cerr << #x << ": "<< x <<endl
#define dbg2(x,y) cerr<< #x <<": "<< x <<" || "<< #y << ": " << y << endl

#define endl "\n"
#define MAX 1e18
#define MIN INT_MIN
#define mod 1000000007


const ll mxn = 1e5 + 5;
vector <ll> v[mxn];
bool vis[mxn] = {false};

void dfs(ll x)
{
    vis[x] = true;

    for (auto it : v[x])
        if (!vis[it])
            dfs(it);

}


void solve()
{
    ll n , m;
    cin >> n >> m;

    while (m--) {
        ll x, y;
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }

    ll f = 0;

    for (ll i = 1 ; i <= n ; ++i) {

        if (vis[i])
            continue;

        dfs(i);
        f++;
    }

    cout << f - 1;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0); cin.tie(0);
    //TEST
    solve();
}



Measured memory_bytes: 10384
#include<iostream>
#include<algorithm>
using namespace std;
int dp[1000001];
int odd[1000001];
const int n=1000000;

void update(int* dp,int x){
  for(int i=1;i<=n;i++){
    if(i<x)continue;
    dp[i]=min(dp[i],dp[i-x]+1);
  }
}

int main(){
  dp[0]=odd[0]=0;
  for(int i=1;i<=n;i++){
    dp[i]=99999999;
    odd[i]=99999999;
  }
  for(int i=1;i<=n;i++){
    int x=i*(i+1)*(i+2)/6;
    if(x>n)break;
    update(dp,x);
    if(x&1)update(odd,x);
  }
  int a;
  while(cin>>a,a){
    cout << dp[a] << " " << odd[a] << endl;
  }
  return 0;
}

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

const double eps = 1e-8;
int x1, y1, x2, y2, x3, y3, x4, y4, r;

double distDbl(double ax, double ay, double bx, double by) {
    return (bx - ax) * (bx - ax) + (by - ay) * (by - ay);
}

double getPerpDistDbl(double ax, double ay, double bx, double by, double cx, double cy) {
    double a, b, res;
    if (ax == bx) {
        res = (cx - ax) * (cx - ax);
    } else {
        a = (by - ay) / (bx - ax);
        b = ay - a * ax;
        res = (a * cx - cy + b) * (a * cx - cy + b) / (1 + a * a);
    }
    return res;
}

double getPerpDistSegDbl(double ax, double ay, double bx, double by, double cx, double cy) {
    double a, b, x, y, res;
    if (ax == bx) {
        y = cy;
        if (min(ay, by) <= y && y <= max(ay,by)) {
            res = (cx - ax) * (cx - ax);
        } else {
            res = min(distDbl(ax,ay,cx,cy), distDbl(bx,by,cx,cy));
        }
    } else {
        a = (by - ay) / (bx - ax);
        b = ay - a * ax;
        x = (cx + a * (cy - b)) / (1 + a * a);
        y = a * x + b;
        if (min(ax, bx) <= x && x <= max(ax,bx) &&
            min(ay, by) <= y && y <= max(ay,by)) {
            res = distDbl(x,y,cx,cy);
        } else {
            res = min(distDbl(ax,ay,cx,cy), distDbl(bx,by,cx,cy));
        }
    }
    return res;
}

bool isA() {
    int c = 0;
    if (0 <= (x2-x1)*(y4-y1)-(y2-y1)*(x4-x1)) ++c;
    if (0 <= (x3-x2)*(y4-y2)-(y3-y2)*(x4-x2)) ++c;
    if (0 <= (x1-x3)*(y4-y3)-(y1-y3)*(x4-x3)) ++c;
    if (c % 3 != 0) return false;
    if (getPerpDistDbl(x1, y1, x2, y2, x4, y4) + eps < r*r) return false;
    if (getPerpDistDbl(x2, y2, x3, y3, x4, y4) + eps < r*r) return false;
    if (getPerpDistDbl(x3, y3, x1, y1, x4, y4) + eps < r*r) return false;
    return true;
}

bool isB() {
    if (distDbl(x1,y1,x4,y4) <= r*r && distDbl(x2,y2,x4,y4) <= r*r && distDbl(x3,y3,x4,y4) <= r*r) {
        return true;
    }
    return false;
}

bool isC() {
    if (getPerpDistSegDbl(x1,y1,x2,y2,x4,y4) <= r*r + eps) return true;
    if (getPerpDistSegDbl(x2,y2,x3,y3,x4,y4) <= r*r + eps) return true;
    if (getPerpDistSegDbl(x3,y3,x1,y1,x4,y4) <= r*r + eps) return true;
    return false;
}

int main() {
    while (cin >> x1 >> y1, (x1 || y1)) {
        cin >> x2 >> y2 >> x3 >> y3 >> x4 >> y4 >> r;
        if (isB()) cout << "b" << endl;
        else if (isA()) cout << "a" << endl;
        else if (isC()) cout << "c" << endl;
        else cout << "d" << endl;
    }
    return 0;
}

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

int main(){
	int X, s, ans;
	scanf("%d", &X);
	for(s = X, ans = 1; s != 0; ans++){
		s = (s + X) % 360;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3824
'use strict';
(function(stdin) {
  var inputs = stdin.toString().trim().split('\n');
  var params = inputs[0].split(' ').map(Number);

  (function(a, b, c) {
    console.log(f(a,b,c));
    function f(a,b,c){
      if (a < b && b < c){return 'Yes';}
      return 'No'
    }

  }(params[0], params[1], params[2]));

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15528
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author teiwa
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int P = in.nextInt();
            int Q = in.nextInt();
            int R = in.nextInt();
            List<Integer> list = new ArrayList<>();
            list.add(P);
            list.add(Q);
            list.add(R);
            Collections.sort(list);
            out.println(list.get(0) + list.get(1));
        }

    }
}



Measured memory_bytes: 21844
use std::io;
use std::str::FromStr;
use std::collections::BinaryHeap;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (n, m) = input_tuple();
    let mut works: Vec<Vec<u64>> = vec![Vec::new(); 100001];   
    for _ in 0..n {
        let (a, b) = input_tuple();
        works[a as usize].push(b);
    }
    let mut sum = 0;
    let mut candidates: BinaryHeap<u64> = BinaryHeap::new();
    for day in 1..m+1 {
        // print!("{} ", day);
        for work in &works[day as usize] {
            candidates.push(*work);
        }
        // println!("{:?}", candidates);
        if candidates.len() == 0 {
            continue;
        }
        sum += candidates.pop().unwrap();
    }
    println!("{}", sum);
}


Measured memory_bytes: 10492
#include<algorithm> // sort,reverse,min,lower_bound
#include<iostream>
using namespace std;
#define df 0
typedef long int li;
int judge(int j,int* a,int k,int n);

int main(){
  if(df) printf("*debug mode*\n");
  int n,k; cin >>n >>k;
  int a[n];
  li sum=0;
  for(int& x: a){
    cin>> x;
    sum+=x;
  }
  if (df)printf("sum:%d\n",sum);
  if(sum<k){
    printf("%d\n",n);
    return 0;
  }
  sort(a,a+n);
  if(df){
    printf("sort:");
    for(int x:a)printf("%d ",x);
    printf("\n");
  }
  int noneed=-1,need=n;
  while(need-noneed>1){
    int temp=(noneed+need)/2;
    if(df)printf("judge:%d\n",temp);
    int flag=judge(temp,a,k,n);
    if(df)printf("%d\n",flag);
    if(flag)need=temp;else noneed=temp;
  }
  printf("%d\n",need);
}

int judge(int j,int* a,int k,int n){
  int dp[k+1];
  dp[0]=1;for(int i=1;i<=k;i++)dp[i]=0;
  if(df){
    for(int x:dp)printf("%d",x);
    printf("\n");
  }
  for(int i=0;i<n;i++){
    if(i==j)continue;
    for(int t=k-a[i];t>=0;t--){
      dp[t+a[i]]|=dp[t];
    }
    if(df){
      for(int x:dp)printf("%d",x);
      printf("\n");

    }
  }
  for(int i=max(0,k-a[j]);i<k;i++){
    if(dp[i])return 1;
  }
  return 0;
}

/// confirm df==0 ///


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        char[] ss = s.toCharArray();
        char[] ts = t.toCharArray();
        int ans = Integer.MAX_VALUE;
        int limit = ss.length - ts.length;
        for (int i = 0; i <= limit; i++) {
            int count  = 0;
            for (int j = 0; j < ts.length; j++) {
                if(ss[i + j] != ts[j]){
                    count++;
                }
            }
            ans = Math.min(ans,count);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35604