akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>

using namespace std;

const string KEY = "keyence";

int main() {
    string S;
    cin >> S;

    bool ans = false;

    if (S.size() == KEY.size()) {
        for (int i = 0; i < S.size(); ++i) {
            if (S[i] != KEY[i]) goto fail0;
        }
        ans = true;
        fail0:;
    }
    else {
        for (int l = 0; l < S.size() - 1; ++l) {
            for (int r = l; r < S.size(); ++r) {
                if ((S.size() - (r - l + 1)) != KEY.size()) continue;

                for (int i = 0; i < S.size(); ++i) {
                    if (l <= i && i <= r) continue;

                    if (S[i] == KEY[0]) {
                        int buf = 0;
                        for (int j = 0; j < KEY.size(); ++j) {
                            if (l <= (i + j) && (i + j) <= r) buf = r - l + 1;
                            
                            if (S[i + j + buf] != KEY[j]) goto fail1;
                        }
                        ans = true;
                        break;
                        fail1:;
                    }
                }
            }
        }
    }

    cout << (ans ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ldb  double
bool Bar;
const ldb mi=1e-9;
int n,mk;
ldb q,w,a1,a2;
int sign(ldb a) {
	if(abs(a)<mi)return 0;
	return a>0?1:-1;
}
struct Point {
	ldb x,y;
	ldb len() {
		return x*x+y*y;
	}
	int operator ==(const Point& a)const {
		return abs(x-a.x)<=mi&&abs(y-a.y)<=mi;
	}
	Point operator +(const Point& a)const {
		return(Point)<%x+a.x,y+a.y%>;
	}
	Point operator -(const Point& a)const {
		return(Point)<%x-a.x,y-a.y%>;
	}
	Point operator /(const ldb& a)const {
		return(Point)<%x/a,y/a%>;
	}
	Point operator *(const ldb& a)const {
		return(Point)<%x*a,y*a%>;
	}
} a,b,c,d,l,r,mid;
bool Ka;
Point Base(Point a) {
	ldb l=sqrt(a.len());
	if(a.x<-mi)a.x=-a.x,a.y=-a.y;
	else if(abs(a.x)<=mi)a.y=abs(a.y);
	if(abs(l)<=mi)l=1;
	return a/l;
}
ldb dot(Point a,Point b) {
	return a.x*b.x+a.y*b.y;
}
ldb det(Point a,Point b) {
	return a.x*b.y-a.y*b.x;
}
int Check(ldb a,ldb b) {
	return sign(a-b)<1;
}
int Case;
int main() {
//	printf("%lf\n",(&Ka-&Bar)/1024.0/1024.0);
//	freopen("tmp.in","r",stdin);
//	freopen("tmp.out","w",stdout);
	scanf("%d",&n);
	for(int i=1; i<=n; ++i) {
		scanf("%lf%lf",&a.x,&a.y);
		scanf("%lf%lf",&b.x,&b.y);
		scanf("%lf%lf",&c.x,&c.y);
		scanf("%lf%lf",&d.x,&d.y);
		l=Base(b-a),r=Base(d-c);
//		l=b-a,r=d-c;
//		printf("%d ",++Case);
		mid=a+l*(det(r,(a-c))/det(l,r));
		if(a.x>b.x)swap(a.x,b.x);
		if(a.y>b.y)swap(a.y,b.y);
		if(c.x>d.x)swap(c.x,d.x);
		if(c.y>d.y)swap(c.y,d.y);
//		if(l==r) {
//			mk=Check(a.x,c.x)&&Check(c.x,b.x)&&Check(a.y,c.y)&&Check(c.y,b.y);
//			mk|=Check(a.x,d.x)&&Check(d.x,b.x)&&Check(a.y,d.y)&&Check(d.y,b.y);
//			mk|=Check(c.x,a.x)&&Check(a.x,d.x)&&Check(c.y,a.y)&&Check(a.y,d.y);
//			mk|=Check(c.x,b.x)&&Check(b.x,d.x)&&Check(c.y,b.y)&&Check(b.y,d.y);
//		} else {
		printf("%.10lf %.10lf\n",mid.x,mid.y);
//			mk=Check(a.x,mid.x)&&Check(mid.x,b.x)&&Check(c.x,mid.x)&&Check(mid.x,d.x)&&
//			   Check(a.y,mid.y)&&Check(mid.y,b.y)&&Check(c.y,mid.y)&&Check(mid.y,d.y);
//			mk&=(mid.x==mid.x)&&(mid.y==mid.t)
//
//		}
//		if(!mk)puts("0");
//		else puts("1");
	}
	return 0;
}


Measured memory_bytes: 3212
use proconio::input;
use std::collections::HashMap;
 
fn main() {
  input! {
    N: usize,
    A: [usize;N]
  }
  let mut map: HashMap<usize, usize> = HashMap::new();
  for v in A.iter() {
    let mut a = map.entry(*v).or_insert(0);
    *a += 1;
  }
  
  let mut total = 0;
  
  for key in map.keys() {
    let val = map.get(&key).unwrap();
    if val > &1 {
      total += val * (val - 1) / 2;
    }
  }
  
  for i in A {
    if let Some(v) = map.get(&i) {
      if v > &1 {
        let before = v * (v-1) /2;
        let after = (v-1) * (v-2) / 2;
        println!("{}", total - before + after);
      } else {
        println!("{}", total);
      }
    } else {
      println!("{}", 0);
    }
  }
}

Measured memory_bytes: 11440
#include <iostream>

using namespace std;

bool solve(int A[],int n,int idx,int m){
  if(m==0){
    return true;
  }else if(m<0){
    return false;
  }
  if(idx<n){
    return solve(A,n,idx+1,m-A[idx]) ||
           solve(A,n,idx+1,m);
  }else if(idx==n){
    return false;
  }
}

int main(){
  int n; cin>>n;
  int A[n]; for(int i=0;i<n;i++) cin>>A[i];
  int q; cin>>q;
  
  for(int i=0;i<q;i++){
    int m; cin>>m;
    if(solve(A,n,0,m)){
      cout<<"yes"<<endl;
    }else{
      cout<<"no"<<endl;
    }
  }
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int n, m, now, ans;
struct dd {
	int x, y;
}e[100005];
bool cmp(dd a, dd b) {
	if (a.y == b.y) {
		return a.x > b.x;
	}
	return a.y < b.y;
}
int main() {
	scanf ("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) {
		scanf ("%d%d", &e[i].x, &e[i].y);
	}
	sort(e + 1, e + m + 1, cmp);
	now = e[1].y - 1;
	ans++;
	for (int i = 1; i <= m; i++) {
		if (now < e[i].x) {
			ans++;
			now = e[i].y - 1;
		}
	}
	cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cmath>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(size_t i = (j); i < (n); ++i)
#define rrep(i, j, n) for(size_t i = (n) - 1; (j) <= i; --i)
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	
	int n; cin >> n;
	set<string> st;
	string s;
	rep(i, 0, n) {
		cin >> s;
		st.insert(s);
	}
	cout << st.size() << endl;
	return 0;

}


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

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		int[][] iyp = new int[M][3];
		String[] ans = new String[M];
		int[] count = new int[N+1];

		for(int i=0;i<M;i++) {
			int P = sc.nextInt();
			int Y = sc.nextInt();
			iyp[i] = new int[] {P,Y,i};
		}
		Arrays.sort(iyp,(a,b)->Integer.compare(a[1],b[1]));
		for(int i=0;i<M;i++) {
			String temp = String.format("%06d%06d", iyp[i][0],++count[iyp[i][0]]);
			ans[iyp[i][2]] = temp;
		}

		for(int i=0;i<ans.length;i++) {
			System.out.println(ans[i]);
		}
	}
}


Measured memory_bytes: 162216
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());

        int sum = 0;
        for (int i1 = 1; i1 <= N; i1++) {
            String iStr = Integer.toString(i1);
            int temp_sum = 0;
            for (int i2 = 0; i2 < iStr.length(); i2++) {
                int temp = Integer.parseInt(String.valueOf(iStr.charAt(i2)));
                temp_sum += temp;
            }
            if ((A <= temp_sum) && (temp_sum <= B)) {
                sum += i1;
            }
        }
        System.out.println(sum);
    }
}


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

int main(){
  int n,y,mkr;
  mkr=1;
  cin >> n >> y;
  for(int i=0;i<floor(y/10000)+1;i++){
    for(int j=0;j<floor((y-10000*i)/5000)+1;j++){
      if((y-10000*i-5000*j)%1000 == 0 && i+j+(y-10000*i-5000*j)/1000==n){
        cout << i << ' ' << j << ' ' << (y-10000*i-5000*j)/1000 << endl;
        mkr=0;
        break;
      }
    }
    if(mkr==0){
      break;
    }
  }
  if(mkr==1){
    cout << -1 << ' ' << -1 << ' ' << -1 << endl;
  }
}

Measured memory_bytes: 3592
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  cin >> A;
  sort(A.begin(), A.end());
  vector<int> v(340771, -1);
  for (int i = 0; i < N; i++) {
    v[A[i]]++;
  }
  int dlt_cnt = 0;
  int cnt = 0;
  // debug(v);
  for (int i = 0; i < 340711; i++) {
    if (v[i] < 1) continue;
    if (v[i] % 2 == 0) {
      cnt += 2;
      dlt_cnt += v[i] - 2;
    } else {
      cnt += 1;
      dlt_cnt += v[i] - 1;
    }
    debug(dlt_cnt, cnt);
  }
  debug(dlt_cnt);
  if (cnt % 2 == 0) {
    dlt_cnt += cnt;
  } else {
    dlt_cnt += cnt + 1;
  }
  cout << N - dlt_cnt << endl;
  return 0;
}


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

int main()
{
    int N, X, T;

    cin >> N >> X >> T;

    int a, b;

    a = N / X;
    b = N % X;
    if (b != 0)
    {
        cout << T * (a + 1) << endl;
    }
    else
    {
        cout << T * a << endl;
    }
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
 
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int x, n;
    cin >> x >> n;
    int arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    
    for (int i = 0; i < x + 1; i++) {
        if (find(arr, arr+n, x + (i * -1)) == arr + n) {
            cout << x + (i * -1);
            break;
        }
        else if (find(arr, arr+n, x + i) == arr + n) {
            cout << x + i;
            break;
        }
    }
}


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

int main()
{
ll n , x , t ;
cin >> n >> x >> t ;
ans=((n+x-1)/x)*t;
cout << ans << endl;
return 0;
}

Measured memory_bytes: 3620
a = input()
n = int(input())
rev = False
front = []
back = []
q = [input() for i in range(n)]
for i in q:
    if i == "1":
        rev = not rev
    else:
        i,f,c = i.split()
        if rev == False:
            if f == "1":
                front.append(c)
            else:
                back.append(c)
        else:
            if f == "1":
                back.append(c)
            else:
                front.append(c)
if rev == False:
    print("".join(list(reversed(front))+[a]+back))
else:
    print("".join(list(reversed(back))+[a[::-1]]+front))

Measured memory_bytes: 20336
#include <iostream>
#include <algorithm>
using namespace std;
struct edge { int u, v, cost; };
int V, E;
int par[100100];
int rank_[100100];
edge es[100100];

void init(int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        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 (rank_[x] < rank_[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (rank_[x] == rank_[y]) rank_[x]++; 
    }
}

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

bool comp(const edge& e1, const edge& e2) {
    return e1.cost < e2.cost;
}

int kruskal() {
    sort(es, es + E, comp);
    init(V);
    int res = 0;
    for (int i = 0; i < E; i++) {
        edge e = es[i];
        if (!same(e.u, e.v)) {
            unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

int main() {
    cin >> V >> E;
    for (int i = 0; i < E; i++) {
        int s, t, w; cin >> s >> t >> w;
        es[i] = {s, t, w};
    }
    cout << kruskal() << endl;
}


Measured memory_bytes: 4348
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

ll mod = 1e9 + 7;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}

map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

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

    vector<ll> A(N);
    map<ll, ll> lcm;
    vector<map<ll, ll> > A_factors(N);
    ll ans = 0;
    REP(i, N) {
        cin >> A[i];
        map<ll, ll> A_factor = prime_factor(A[i]);
        A_factors[i] = A_factor;
        for(auto p = A_factor.begin(); p!=A_factor.end(); ++p)
            lcm[p->first] = max(lcm[p->first], p->second);
    }

    ll lcm_value = 1;
    for(auto p = lcm.begin(); p != lcm.end(); ++p) {
        ll multiplier = mod_pow(p->first, p->second, mod);
        lcm_value *= multiplier;
        lcm_value %= mod;
    }

    REP(i, N) {
        map<ll, ll> B_factor;
        ll b = lcm_value;
        for(auto p = A_factors[i].begin(); p != A_factors[i].end(); ++p) {
            ll n = A_factors[i][p->first];
            b *= modinv(mod_pow(p->first, n, mod), mod);
            b %= mod;
        }

        ans += b;
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3968
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            Deque<int[]> stack = new ArrayDeque<int[]>();
            int n, s, time = 0;
            n = sc.nextInt();
            s = sc.nextInt();
            if (n == 0 && s == 0) break;
            else if (n > 10 || s > 45) time = 0;
            else if (n == 1) {
                if (0 <= s && s <= 9) time = 1;
                else time = 0;
            } else {
                int[] state = new int[n + 1];
                for (int j = 0; j <= s && j<= 9; j++) {
                    for (int i = 0; i < n + 1; i++) {
                        state[i] = 0;
                    }
                    state[0] = j;
                    state[n] = 1;
                    stack.add(state.clone());
                }

                while (stack.size() > 0) {
                    state = new int[n + 1];
                    state = stack.remove();

                    if (state[n] < n - 1) {
                        for (int i = state[state[n] - 1] + 1; i <= 9; i++) {
                            int[] temp = state.clone();
                            temp[temp[n]] = i;
                            temp[n]++;
                            int sum = sum(temp, n);
                            if (sum < s) stack.add(temp.clone());
                            else break;
                        }
                    } else {
                        for (int i = state[state[n] - 1] + 1; i <= 9; i++) {
                            int[] temp = state.clone();
                            temp[temp[n]] = i;
                            temp[n]++;
                            int sum = sum(temp, n);
                            if (sum == s) {
                                time += 1;
                                break;
                            }
                        }
                    }
                }
            }
            System.out.println(time);

        }

    }

    public static int sum(int[] state, int k) {
        int sum = 0;
        for (int i = 0; i < k; i++) {
            sum += state[i];
        }
        return sum;
    }
}


Measured memory_bytes: 26872
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

string s;
int main(){
    cin>>s;
    int n=s.size();
    bool flag=true;
    FOR(i,1,n-1)if(s[i-1]!=s[n-i-1]) flag=false;
    if(s[0]=='0'||s[n-1]=='1') flag=false;
    if(!flag){
        cout<<-1<<endl;
        return 0;
    }
    int cur=n-1;
    for(int i=n-2;i>=0;--i){
        cout<<cur+1<<" "<<i+1<<endl;
        if(s[i]=='1') cur=i;
    }
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> vll;
typedef pair<int, int> vii;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define asd cout << "ok" << endl;

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define trav(it, m) for(auto it = m.begin(); it!= m.end(); it++)

const char nl = '\n';
const int MX = 2e5 +5;
const int MOD = 1e9 +7;
const int inf = 1e9;
const ll INF = 1e18;
const ld PI = acos((ld)-1);

int fenwick[MX] = {};




int main(){
   ios_base::sync_with_stdio(0); cin.tie(0);
   int n; cin >> n;
   vi v(n);
   ll cnt =0;
   for(int i = 0; i < n; i++) cin >> v[i];

   for(int i = 0; i <n-2; i++){
    for(int j = i+1; j < n-1; j++){
      for(int k = j + 1; k < n; k++){
        int a[3];
        a[0] = v[i];
        a[1] = v[j];
        a[2] = v[k];
        sort(a, a+3);
        if(a[0] + a[1] > a[2] && a[0]!=a[1] && a[1] !=a[2] && a[0] != a[2])
          cnt++;
      }
    }
   }
   cout << cnt <<nl;


}


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

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

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}


const int MOD = 1E9 + 7;
void _main() {
        int n, m; cin >> n >> m;
        if (n > m) swap(n, m);
        vector<ll> fact(m + 1);
        fact[0] = 1;
        for (int i = 1; i <= m; i++) fact[i] = fact[i - 1] * i % MOD;

        if (m > n + 1) {
                cout << 0;
        } else if (m == n + 1) cout << (fact[n] * fact[m]) % MOD;
        else cout << (fact[n] * fact[m] % MOD * 2) % MOD;
}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
	ll n;
	cin >> n;
	vector<int> bits(100);
	int p = 0;
	while(n > 0){
		bits[p++] = (--n) % 26;
		n /= 26;
	}
	for(int i = p-1; i>=0; i--){
		cout << char(bits[i] + 'a');
	}
	return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<limits>
#include<stack>
#include<array>
#include<stdio.h>
#include<cstring>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<pair<int,int> > vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;

int INF = std::numeric_limits<int>::max();
ll LLINF = 1e15;
int NINF = std::numeric_limits<int>::min();
int MOD = 1e9+7;

int col[] = {0,-1,0,1,1,1,-1,-1};
int row[] = {-1,0,1,0,1,-1,1,-1};

//knight moves
int cc[] = {1,2,2,1,-1,-1,-2,-2};
int rr[] = {-2,-1,1,2,-2,2,1,-1};

vvi adjLst(1e5+5,vi());
vb vstd(1e5+5,0);
vi dp(1e5+5,1);


void dfs(int u)
{
    vstd[u] = 1;
    for(int i = 0 ; i < adjLst[u].size() ; ++i)
    {
        if(!vstd[adjLst[u][i]])
            dfs(adjLst[u][i]);

        dp[u] = max(dp[u], dp[adjLst[u][i]] +1);
    }
}


int main()
{
    //cout << LLINF ;
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, m, u, v;
    cin >> n >> m;
    for(int i = 0; i < m ; ++i)
    {
        cin >> u >> v;
        adjLst[u].push_back(v);
    }

    int mx = 0;
    for(int i = 1 ; i <= n ; ++i)
    {
        if(!vstd[i])
            dfs(i);
    }

    for(int i = 1; i <= n ; ++i)
        mx = max(mx,dp[i]);

    cout << mx-1;

    return 0;
}


Measured memory_bytes: 12296
#include <bits/stdc++.h>
using namespace std;
#define fastIO                        \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
// g++ -std=c++11 -O2 -Wall *.cpp -o *
#define eps 1e-9
#define MAX 10000001
#define MOD 998244353
#define Fi first
#define Se second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef pair<int, int> pr_int;

const int maxn = 2000 + 10;
char st[maxn];
int res[maxn];
int need[maxn];

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


Measured memory_bytes: 256
#include <stdio.h>

long lpow2(long num) {
  return
    num == 0 ? 1
    : num % 2 == 0 ? lpow2(num / 2) * lpow2(num / 2)
    : 2 * lpow2(num - 1);
}

int main() {
  long H;
  scanf("%ld", &H);
  int r;
  while (H > 0) {
    H /= 2;
    r++;
  }
  printf("%ld", lpow2(r) - 1);
  return 0;
}


Measured memory_bytes: 128
n = gets.to_i
arr = gets.split.map(&:to_i)
s = arr.inject(0){|sum,x| sum + x }
min = s
f = 0
b = s
arr.each do |i|
    f += i
    b -= i
    diff = (f-b).abs
    min = [min, diff].min
end
puts min

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

int main()
{
    int k;
    cin >> k;
    for (int i = 0; i < k; ++i)
    {
        cout << "ACL";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3636
#if !defined(MAX)
#define MAX(A,B)    ((A) > (B) ? (A) : (B))
#endif


#import <stdio.h>
int main(int argc, const char * argv[]) {
    @autoreleasepool {
        int a,b,c;
        scanf("%d %d %d", &a,&b,&c);
        printf("%d\n", MAX(10*a+b+c,MAX(a+10*b+c,a+b+10*c)));
    }
    return 0;
}


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

class Main{
	public static void main(String[] args) {
		int[] intList = new int[10];
		Scanner sc = new Scanner(System.in);
		for (int count = 0; count < 10; count++) {
			int temp = sc.nextInt();
			if (temp <= 10000) {
				intList[count] = temp;
			}
		}
		Arrays.sort(intList);
		for (int j = 9; j >= 7; j--) {
			System.out.println(intList[j]);
		}
		sc.close();
	}
}

Measured memory_bytes: 25996
class Node:
    def __init__(self, num, leftChild, rightChild):
        self.id = num
        self.parent = -1
        self.sibling = -1
        self.degree = 0
        self.depth = 0
        self.height = 0
        self.type = 'leaf'
        self.leftChild = leftChild
        self.rightChild = rightChild
        
    def show_info(self):
        print('node {}:'.format(self.id), 'parent = {},'.format(self.parent),
              'sibling = {},'.format(self.sibling),
              'degree = {},'.format(self.degree),
              'depth = {},'.format(self.depth),
              'height = {},'.format(self.height),
              '{}'.format(self.type))


def set_node(i_s):
    num, leftChild, rightChild = list(map(int, i_s.split()))
    node = Node(num, leftChild, rightChild)
    T[num] = node
    T[-1] -= (max(0, leftChild) + max(0, rightChild))


def set_attributes(n_i, parent, sibling, depth):
    node = T[n_i]
    node.parent = parent
    node.sibling = sibling
    node.depth = depth
    if node.leftChild != -1:
        node.degree += 1
        node.type = 'internal node'
        set_attributes(node.leftChild, node.id, node.rightChild, depth + 1)
    if node.rightChild != -1:
        node.degree += 1
        node.type = 'internal node'
        set_attributes(node.rightChild, node.id, node.leftChild, depth + 1)
    if node.leftChild != -1 and node.rightChild != -1:
        node.height = max(T[node.leftChild].height,
                          T[node.rightChild].height) + 1
    elif node.leftChild != -1:
        node.height = T[node.leftChild].height + 1
    elif node.rightChild != -1:
        node.height = T[node.rightChild].height + 1



import sys

n = int(sys.stdin.readline())

T = [None] * n

T.append(int(n * (n - 1) / 2))

for x in sys.stdin.readlines():
    set_node(x)

set_attributes(T[-1], -1, -1, 0)

T[T[-1]].type = 'root'

for n in T[:-1]:
    n.show_info()

Measured memory_bytes: 7844
#include <stdio.h>

int main(void){
  int time[5],i,timest[5],mintime=10,minum,sum=0;
  for(i=0;i<5;i++){
    scanf("%d",&time[i]);
    timest[i] = time[i]%10;
    if(timest[i] < mintime && timest[i] != 0){
      minum = i;
      mintime = timest[i];
    }
  }
  for(i=0;i<5;i++){
    if(i != minum && timest[i] != 0)
      time[i] = (time[i]/10+1)*10;
    sum += time[i];
  }
  printf("%d\n",sum);
  return 0;
}

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

int main() {
	int N;
	string S;
	cin >> N >> S;
	vector<vector<int>> Match(N, vector<int>(N, -1));
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			int ii = i, jj = j;
			if (Match[i][j] >= 0) continue;
			while (S[ii] == S[jj] && jj<N) {
				ii++;
				jj++;
			}
			int MAX = ii - i;
			Match[i][j] = min(MAX, j-i);
			ii = i, jj = j;
			while (MAX > 0 && ii + 1 < N && jj + 1 < N) {
				Match[ii + 1][jj + 1] = min(MAX - 1, jj - ii);
				MAX--;
				ii++;
				jj++;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < N; i++) for (int j = i + 1; j < N; j++) ans = max(ans, Match[i][j]);
	cout << ans << endl;
}


Measured memory_bytes: 101124
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<long long int>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vb vector<bool>
#define vvl vector<vector<ll> >
#define vvi vector<vector<int> >
#define pl pair<ll,ll>
#define pb push_back
#define PI 3.14159265
#define mod 998244353
#define pb push_back
#define mp make_pair
#define fri(s,n) for(int i=s;i<n;i++)
#define frj(s,n) for(int j=s;j<n;j++)
#define T(i) int i=1;cin>>i;while(i--)
#define vsi vector<set<int> >
#define pii pair<int,int>
#define inf 1e9
#define vpii vector<pair<int,int> >


ll power(ll a,ll b){
    if(b==0)
        return 1;
    if(b&1)
        return a*power(a,b-1);
    ll temp=power(a,b/2);
    return temp*temp;
    }
ll mycompare(ll a,ll b){
    return a>b;
    }
bool isvalid(int x,int y,int n){
    if(x>=0 && x<n && y>=0 && y<n)
        return true;
    return false;
    }
vector<vector<int> > dp(3001,vector<int>(3001,-1));
string ans="";
void printLCS(string &s,string &t){
    int len=dp[0][0];
    int k=0,i=0,j=0;
    while(k<len){
        if(s[i]==t[j]){
            ans.push_back(s[i]);
            i++;j++;
            k++;}
        else{
            if(dp[i+1][j]>dp[i][j+1]){
                i++;
            }
            else
                j++;
        }
    }
    return;
    }
int findLCS(string &s,string &t,int i,int j){
    if(i>=s.length() || j>=t.length())
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    if(s[i]==t[j])
        return dp[i][j]=1+findLCS(s,t,i+1,j+1);
    return dp[i][j]=max(findLCS(s,t,i+1,j),findLCS(s,t,i,j+1));
    }
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    string s,t;
    cin>>s>>t;
    int p=findLCS(s,t,0,0);
    printLCS(s,t);
    cout<<ans;
    }


Measured memory_bytes: 39260
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int h,i;
  int n;
  cin>>n;
  for(h=0;h<n;++h){
    char s[1001];
    cin>>s;
    int sg=0,ct=0;
    for(i=0;s[i];++i){
      sg+=s[i]-'0';
      ++ct;
      if(sg>9){
	sg=sg%10+1;
	++ct;
      }
    }
    if(ct%2)
      cout<<"Audrey wins."<<endl;
    else
      cout<<"Fabre wins."<<endl;
  }
  return 0;
}

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

int main(){
  int n,d,x,i;
  cin>>n;
  cin>>d>>x;
  int a[n];
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  for(i=0;i<n;i++){
    x+=(d-1)/a[i]+1;
  }
  cout<<x;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll gcd(ll a,ll b){
  ll r=a%b;
  while(r>0){
    a=b;b=r;r=a%b;
  }
  return b;
}
vector<bool> prime(1111111,true);
void make_prime(){
  prime[0]=prime[1]=false;
  for(ll i=0;i<1111111;i++){
    if(prime[i]==false)continue;
    for(ll j=2*i;j<1111111;j+=i){
      prime[j]=false;
    }
  }
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b;cin>>a>>b;
  ll num=gcd(a,b);
  
  ll ans=0;
  for(int i=2;i<1111111;i++){
    if(num%i==0){
      ans++;
      while(num%i==0)num/=i;
    }
  }
  if(num>1)ans++;
  cout<<ans+1<<endl;
  return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#include<assert.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int inf = 1e17;
const int mod = 1000000007;
typedef pair<int, int> P;
typedef pair<int, P> PP;

char ans[1001][1001];
char ans2[1001][1001];
void disp(int n, int m) {
	puts("YES");
	rep(i, n) {
		rep(j, m) {
			cout << ans[i][j];
		}
		cout << endl;
	}return;
}
void disp2(int n, int m) {
	puts("YES");
	rep(i, n) {
		rep(j, m) {
			cout << ans2[i][j];
		}
		cout << endl;
	}return;
}
signed main() {
	int n, m, a, b; cin >> n >> m >> a >> b;
	int a2 = a, b2 = b;
	rep(i, n)rep(j, m)ans[i][j] = '.';
	rep(i, n)rep(j, m)ans2[i][j] = '.';
	if (n & 1) {
		for (int i = 0; i < m - 1; i += 2) {
			if (a) {
				ans[n - 1][i] = '<';
				ans[n - 1][i + 1] = '>';
				a--;
			}
		}
	}
	if (m & 1) {
		for (int i = 0; i < n - 1; i += 2) {
			if (b) {
				ans[i][m - 1] = '^';
				ans[i + 1][m - 1] = 'v';
				b--;
			}
		}
	}

	for (int i = 0; i < n - 1; i += 2) {
		for (int j = 0; j < m - 1; j += 2) {
			if (a) {
				ans[i][j] = '<';
				ans[i][j + 1] = '>';
				a--;
				if (a) {
					ans[i + 1][j] = '<';
					ans[i + 1][j + 1] = '>';
					a--;
				}
			}
			else if (b) {
				ans[i][j] = '^';
				ans[i + 1][j] = 'v';
				b--;
				if (b) {
					ans[i][j + 1] = '^';
					ans[i + 1][j + 1] = 'v';
					b--;
				}
			}
		}
	}
	
	if (a + b) {
		if ((n & 1) && (m & 1)) {
			if (a2) {
				ans2[0][0] = '<'; ans2[0][1] = '>'; a2--;
				if (a2) {
					ans2[2][1] = '<'; ans2[2][2] = '>'; a2--;
				}
			}
			if (b2) {
				ans2[1][0] = '^'; ans2[2][0] = 'v'; b2--;
				if (b2) {
					ans2[0][2] = '^'; ans2[1][2] = 'v'; b2--;
				}
			}
			for (int i = 3; i<n; i += 2) {
				if (b2) {
					ans2[i][0] = '^';
					ans2[i + 1][0] = 'v';
					b2--;
				}
			}
			for (int i = 3; i<m; i += 2) {
				if (a2) {
					ans2[0][i] = '<';
					ans2[0][i + 1] = '>';
					a2--;
				}
			}
			for (int i = 1; i<n; i += 2) {
				for (int j = 1; j<m; j += 2) {
					if (i == 1 && j == 1)continue;
					if (a2) {
						ans2[i][j] = '<';
						ans2[i][j + 1] = '>';
						a2--;
						if (a2) {
							ans2[i + 1][j] = '<';
							ans2[i + 1][j + 1] = '>';
							a2--;
						}

					}
					else if (b2) {
						ans2[i][j] = '^';
						ans2[i + 1][j] = 'v';
						b2--;
						if (b2) {
							ans2[i][j + 1] = '^';
							ans2[i + 1][j + 1] = 'v';
							b2--;
						}

					}
				}

			}

			if (a2 || b2)
				puts("NO");
			else disp2(n, m);
		}
		else {
			puts("NO");
		}
	}
	else disp(n, m);
}

Measured memory_bytes: 3200
import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
M = sum(A)

s = 1 << M
for a in A:
  s |= s >> a
ans = bin(s)[2+(M+1)//2:].find("1") + (M+1)//2
print(ans)

Measured memory_bytes: 10576
/**Bismillahir Rahmanir Raheem
    Author:Refatul Fahad**/

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

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e5 + 5;
const ll M = (ll)1e9 + 7;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}

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

set<int>st;
int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);

    int test=1;
    ///cin>>test;
    for(int cs=1; cs<=test; ++cs) {
        int x,n,v;
        cin>>x>>n;bool ck=true;
        for(int i=1; i<=n; ++i) {
            cin>>v;
            st.insert(v);
            if(x==v)ck=false;
        }
        if(ck) {
            cout<<x<<endl;
        } else {
            for(int i=x-1,j=x+1;; i--,j++) {
                if(!st.count(i)) {
                    cout<<i<<endl;
                    break;
                } else if(!st.count(j)) {
                    cout<<j<<endl;
                    break;
                }
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3664
N = int(input())
Xs = [int(i) for i in input().split()]

mh = 1000000000
for x in range(1,101):
    sh = 0
    for n in range(N):
        sh += (Xs[n] - x)*(Xs[n] - x)
    mh = min(mh, sh)

print(mh)

Measured memory_bytes: 3060
#include <cstdio>
#include <cctype>
#define reg register
using namespace std;
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
signed main(void)
{
	int n,k;
	rd(n);rd(k);
	if(k==1)
		return puts("0"),0;
	printf("%d",n-k);
	return 0;
}


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

using namespace std;
using ll = long long;
using pint = pair<int, int>;

int main() {
	int a;
	string s;
	cin >> a >> s;

	if (a >= 3200) {
		cout << s << endl;
	}
	else {
		cout << "red" << endl;
	}

	return 0;
}



Measured memory_bytes: 3600
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define rep(i,n) for(LL i=0;i<n;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n,option) f(i,0,n)cout<<v[i]<<option;
#define all(a) a.begin(),a.end()
#define size(s) ((int)s.size())
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INT_INF 1<<29
#define LL_INF 1LL<<60
#define MOD 10000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<int>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using mll = map<LL, LL>;
using vpi = vector<pi>;

#pragma endregion


//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0) {
			return false;
		}
	}
	return true;
}

void y_n(bool p) {
	if (p)_y();
	else _n();
}

void Y_N(bool p) {
	if (p) _Y();
	else _N();
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b)*b);
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= 1000000007;
	}
	return ret;
}

#pragma endregion


/************************************************************************/
signed main(void) {
	cin.tie(0); ios::sync_with_stdio(false);

	while (1) {
		st s;
		cin >> s;
		if (s == "#")break;
		bool f;
		int ans = 0;
		rep(i, size(s)) {
			if (i == 0) {
				if (s[0] == 't' || s[0] == 'g' || s[0] == 'b' || s[0] == 'r' || s[0] == 'f' || s[0] == 'v' || s[0] == 'e' || s[0] == 'd' || s[0] == 'c' || s[0] == 'w' || s[0] == 's' || s[0] == 'x' || s[0] == 'q' || s[0] == 'a' || s[0] == 'z') {
					f = true;
				}
				else {
					f = false;
				}
			}
			else {
				if (f == false && (s[i] == 't' || s[i] == 'g' || s[i] == 'b' || s[i] == 'r' || s[i] == 'f' || s[i] == 'v' || s[i] == 'e' || s[i] == 'd' || s[i] == 'c' || s[i] == 'w' || s[i] == 's' || s[i] == 'x' || s[i] == 'q' || s[i] == 'a' || s[i] == 'z')) {
					ans++;
					f = true;
				}
				else if (f == true && (s[i] == 'y' || s[i] == 'h' || s[i] == 'n' || s[i] == 'u' || s[i] == 'j' || s[i] == 'm' || s[i] == 'i' || s[i] == 'k' || s[i] == 'm' || s[i] == 'o' || s[i] == 'l' || s[i] == 'p')) {
					ans++;
					f = false;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3180
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x_y = [abs(x[i]-y[i]) for i in range (n)]
p1 = sum(x_y)
p2 = sum(i ** 2 for i in x_y)**(1/2)
p3 = sum(i ** 3 for i in x_y)**(1/3)
p_infinity = max(x_y)
print(f"{p1:.6f}")
print(f"{p2:.6f}")
print(f"{p3:.6f}")
print(f"{p_infinity:.6f}")



Measured memory_bytes: 5664
#include<cstdio>
#include<cmath>
int main(){
    double x[4],y[4];
    while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf\n",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&x[3],&y[3])!=-1){
        bool is=true;
        double radsum=0;
        for(int i=0;i<4;i++){
            int a=i,b=(i+1)%4,c=(i+2)%4;
            radsum+=acos((pow(x[a]-x[b],2)+pow(y[a]-y[b],2)+pow(x[b]-x[c],2)+pow(y[b]-y[c],2)-pow(x[c]-x[a],2)-pow(y[c]-y[a],2))/(2*sqrt(pow(x[a]-x[b],2)+pow(y[a]-y[b],2))*sqrt(pow(x[b]-x[c],2)+pow(y[b]-y[c],2))));
        }
        if(radsum<M_PI*2)printf("NO\n");
        else printf("YES\n");
    }
}


Measured memory_bytes: 2692
#include<cstdio>
#include<algorithm>
using namespace std;

typedef long long ll;
const int Maxn=2000;
const ll Mod=1e9+7;

int N,A[Maxn+5];
ll K;

ll QuickPow(ll a,ll k) {
	ll ret=1;
	while(k) {
		if(k&1)ret=(ret*a)%Mod;
		a=(a*a)%Mod;
		k>>=1;
	}
	return ret;
}

int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	scanf("%d %lld",&N,&K);
	for(int i=1;i<=N;i++)
		scanf("%d",&A[i]);
	ll ans=0;
	for(int i=1;i<=N;i++)
		for(int j=i+1;j<=N;j++)
			if(A[i]>A[j])
				ans++;
	ll ans1=0;
	for(int i=1;i<=N;i++)
		for(int j=1;j<i;j++)
			if(A[i]>A[j])
				ans1++;
	ll inv2=QuickPow(2,Mod-2);
	printf("%lld\n",(ans*K%Mod*(K+1)%Mod*inv2%Mod+ans1*K%Mod*(K-1)%Mod*inv2%Mod)%Mod);
	return 0;
}

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

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	long long ans;
	if (A == B && B == C && A % 2 == 0)
		ans = -1;
	else if (A == B && B == C && A % 2 == 0)
		ans = 0;
	else {
		ans = 0;
		while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
			int a = A, b = B, c = C;
			A = (b + c) / 2;
			B = (c + a) / 2;
			C = (a + b) / 2;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int N,ans = 0,max = -1;
    cin >> N;
    vector<int> H(N);
    
    for(int i = 0;i < N;i++){
        cin >> H.at(i);
    }

    for(int i = 0;i < N;i++){
        if(max <= H.at(i)){
            max = H.at(i);
            ans++;
        }
    }

    cout << ans << endl;
}

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

int main() {
    int N, T;
    double A;
    cin >> N >> T >> A;

    int H;
    double div = 100000;
    int ans;

    for(int i=0; i<N; i++) {
        cin >> H;
        double avg_tmp = T - H * 0.006;
        if(abs(avg_tmp-A) < div) {
            ans = i+1;
            div = abs(avg_tmp-A);
        }
    }
    cout << ans << endl;
}

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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.ReadLine();
        }

        public void Solve(ConsoleInput cin)
        {
            int a = cin.ReadInt;
            int[] b = cin.ReadIntArray(a);

            int cnt = 0;

            while (IsOK(ref b))
                cnt++;

            Console.WriteLine(cnt);

        }

        bool IsOK(ref int[] a)
        {
            foreach (int i in a)
            {
                if (i % 2 != 0) return false;
            }

            for(int i = 0; i < a.Length; i++)
            {
                a[i] = a[i] / 2;
            }
            return true;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long num) { var ret = new string[num]; for (long i = 0; i < num; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long num) { var ret = new int[num]; for (long i = 0; i < num; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long num) { var ret = new long[num]; for (long i = 0; i < num; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()

map<char,int> m;
int32_t main(){
	int n;
	cin>>n;
	string s;
	for(char c='a';c<='z';c++){
		m[c]=1000000;
	}
	while(n--){
		cin>>s;
		for(char c='a';c<='z';c++){
			m[c]=min(m[c],(int)count(all(s),c));	
		}
	}
	for(char c='a';c<='z';c++){
		for(int i=1;i<=m[c];i++){
			cout<<c;
		}
	}
}


Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    if (n % 2 == 1) {
        cout << b[n / 2] - a[n / 2] + 1 << endl;
    } else {
        ll upper = (2 * b[n / 2] + 2 * b[n / 2 - 1]) / 2;
        ll lower = (2 * a[n / 2] + 2 * a[n / 2 - 1]) / 2;
        cout << upper - lower + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 6364
#include <iostream>
#include <vector>
using namespace std;
typedef int Weight;
struct Edge {
	int src, dst;
	Weight weight;
	Edge(int src, int dst, Weight weight = 0) :
		src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight :
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

bool augment(Graph& g, int u,
	vector<int>& matchTo, vector<bool>& visited) {
	if (u < 0) return true;
	for(Edge& e: g[u]) if (!visited[e.dst]) {
		visited[e.dst] = true;
		if (augment(g, matchTo[e.dst], matchTo, visited)) {
			matchTo[e.src] = e.dst;
			matchTo[e.dst] = e.src;
			return true;
		}
	}
	return false;
}
int bipartiteMatching(Graph& g, int L, Edges& matching) {
	const int n = g.size();
	vector<int> matchTo(n, -1);
	int match = 0;
	for (int u = 0; u < L;u++) {
		vector<bool> visited(n);
		if (augment(g, u, matchTo, visited)) ++match;
	}
	for (int u = 0; u < L;u++) if (matchTo[u] >= 0)
		matching.push_back(Edge(u, matchTo[u]));
	return match;
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int X, Y, E; cin >> X >> Y >> E;
	Graph g(X + Y);
	Edges match;
	for (int i = 0; i < E; i++) {
		int x, y; cin >> x >> y;
		g[x].emplace_back(Edge(x, X + y));
		g[X + y].emplace_back((Edge(X + y, x)));
	}
	cout << bipartiteMatching(g, X, match) << endl;
}

Measured memory_bytes: 3276