akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);

    vl a(N);
    vl t(N+1);
    Rep(i,N){
        Scll(a[i]);
        t[i+1] = t[i]+a[i];
    }

    ll p=a[0],q=a[1];
    ll r=a[2],s=t[N]-t[3];

    ll pqsa = abs(p-q);
    ll rssa = abs(r-s);

    ll pqi = 1;
    ll rsi = 3;


    Repe(i,N,3){
        r += a[i];
        s -= a[i];
        if( abs(r-s) < rssa ){
            rsi = i+1;
            rssa = abs(r-s);
        }else{
            r -= a[i];
            s += a[i];
            break;
        }
    }

    ll ans = INF*INF;
    // printf ("%lld,%lld,%lld,%lld\n", p,q,r,s );
    ans = min( ans, max(max(p,q),max(r,s))-min(min(p,q),min(r,s)) );

    Repe(i,N-1,2){
        q += a[i];
        pqsa = abs(p-q);
        while( abs((p+a[pqi])-(q-a[pqi])) < pqsa ){
            p += a[pqi]; q -= a[pqi]; pqi++; pqsa = abs(p-q);
        }
        r -= a[i];
        rssa = abs(r-s);
        while( abs((r+a[rsi])-(s-a[rsi])) < rssa ){
            r += a[rsi]; s -= a[rsi]; rsi++; rssa = abs(r-s);
        }
        // printf ("%lld,%lld,%lld,%lld\n", p,q,r,s );
        ans = min( ans, max(max(p,q),max(r,s))-min(min(p,q),min(r,s)) );
    }

    printf ("%lld\n", ans );
    return 0;
}



Measured memory_bytes: 3328
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<cstring>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<algorithm>
// #include<bits/stdc++.h>
#define INF 0x7f7f7f7f //2139062143
#define INF1 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.141592653589793//23846264338327950254
#define ft first
#define sd second
#define pb push_back
#define ll long long
#define vec vector<ll>
#define mat vector<vector<ll>>
//cout<<fixed<<setprecision(6)<<
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//ifstream f1("/Users/wangzichao/Documents/wzc.in");
//ofstream f2("/Users/wangzichao/Documents/wzc.out");
//ios::sync_with_stdio(false);
//cin.tie(0);cout.tie(0);
using namespace std;
#define local
#ifdef local
#endif
const ll maxn=6e5+7;
const double eps=1e-10;
const ll mod=1e9+7;
#define STDIN freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);//************************************
#define Quick ios::sync_with_stdio(false);cin.tie(NULL);

// int main()
// {
//     STDIN
//     Quick
//     string s;
//     cin >> s;
//     string ans = "No";
//     for (int i = 0; i < 3; i++)
//     {
//         if (s[i] == '7')
//             {
//                 ans = "Yes";break;
//             }
//     }
//     cout << ans << endl;
//     return 0;
// }

int main()
{
    //STDIN
    Quick
    int n; cin >> n;
    ll sum = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i%3 == 0 || i%5 == 0) continue;
        sum += i;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3652
S = [v for v in input()]
N = len(S)
M = [0] * N
for i in range(N):
    if S[i] == 'L':
        M[i] = i - 1
    else:
        M[i] = i + 1

binary = format(10 ** 100, 'b')
Bin = []
for v in binary:
    a = int(v)
    Bin.append(a)

ans = [1] * N
while Bin:
    a = Bin.pop()
    if a == 0:
        L = [0] * N
        for j in range(N):
            L[j] = M[M[j]]
        M = L
    else:
        new_ans = [0] * N
        for j in range(N):
            new_ans[M[j]] += ans[j]
        ans = new_ans

        L = [0] * N
        for j in range(N):
            L[j] = M[M[j]]
        M = L

print(' '.join(map(str, ans)))

Measured memory_bytes: 119092
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int x,y,z;
    cin >> x >> y >> z;
    int i=0;
    int ans;
    while(true){
        ans = x;
        ans=ans-y*i;
        if(i>=1){
            ans = ans-z*(i+1);
        }
        if(ans<0){
            i=i-1;
            break;
        }
        i++;
    }
    cout << i << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int find_root(string s){
  int len = s.length();
  //cout << s << " " << len << endl;
  if(len <= 1){
    return -1;
  }
  if(s == "(,)"){
    return -1;
  }
  
  REP(i,len-2){
    if(s[i] == ')' && s[i+1] == ',' && s[i+2] =='('){
      int idx = i+1;
      int l = 0, r = 0;
      for(int j = 0; j < idx; ++j){
        if(s[j] == '(') l++;
        if(s[j] == ')') r++;
      }
      if(l != r+1){
        continue;
      }
      l = 0; r = 0;
      for(int j = idx+1; j < len; ++j){
        if(s[j] == '(') l++;
        if(s[j] ==')') r++;
      }
      if(l+1 == r){
        return idx;
      }
      
    }
  }
  if(s[0] == '(' && s[1] == ',' && s[2] == '('){
    return 1;
  }
  if(s[len-3] == ')' && s[len-2] == ',' && s[len-1] == ')'){
    return len-2;
  }
  return -1;
}

string solve(int ope, string s1, string s2){
  int root1 = find_root(s1), root2 = find_root(s2);
  //cout << "start " << s1 << " " << s2 << endl;
  string res = ",";
  //左
  string sub1 = "", sub2 = "";
  if(root1 != -1)
    sub1 = s1.substr(1,root1-1);
  if(root2 != -1)
    sub2 = s2.substr(1,root2-1);

  //cout << "l " << s1 << ":" << sub1 << " v " << s2 <<":" << sub2 << endl;
  //0 is insertion
  if(ope == 0){
    if(sub1 != "" && sub2 != ""){
      res = solve(ope, sub1, sub2) + res;
    }  
  }else{
    if(sub1 != "" || sub2 != ""){
      res = solve(ope, sub1, sub2) + res;
    }
  }
  sub1 = ""; sub2 = "";
  if(root1 != -1)
    sub1 = s1.substr(root1+1,s1.length()-root1-2);
  if(root2 != -1)
    sub2 = s2.substr(root2+1,s2.length()-root2-2);

  //cout << "r " << s1 << ":" << sub1 << " v "  << s2 << ":" << sub2 << endl;
  if(ope == 0){
    if(sub1 != "" && sub2 != ""){
      res = res + solve(ope, sub1, sub2);
    }
  }else{
    if(sub1 != "" || sub2 != ""){
      res = res + solve(ope, sub1, sub2);
    }
  }
  return "(" + res + ")";
}


int main(){

  char ope;
  while(cin >> ope){
    string s1, s2;
    cin >> s1 >> s2;

    if(ope == 'i'){
      cout << solve(0, s1, s2) << endl;;
    }else{
      cout << solve(1, s1, s2) << endl;;
    }
  }
  return 0;
}




Measured memory_bytes: 3220
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextLong()
    println(problem057c(n))
}

fun problem057c(n: Long): Int {

    var ans = n.toString().length
    var a = 0L
    while (a * a <= n) {
        a++
        if (n % a != 0L) continue
        val b = n / a
        val cur = Math.max(a.toString().length, b.toString().length)
        if (ans > cur) {
            ans = cur
        }
    }
    return ans
}

Measured memory_bytes: 31140
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] arr = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
            sum += arr[i];
        }
        PriorityQueue<Integer> queue = new PriorityQueue<>();
        queue.add(-1);
        queue.add(-sum);
        for (int i = 2; i <= Math.sqrt(sum); i++) {
            if (sum % i == 0) {
                queue.add(-i);
                if (i * i != sum) {
                    queue.add(-sum / i);
                }
            }
        }
        while (queue.size() > 0) {
            int x = - queue.poll();
            int[] mods = new int[n];
            for (int i = 0; i < n; i++) {
                mods[i] = arr[i] % x;
            }
            Arrays.sort(mods);
            if (mods[n - 1] == 0) {
                System.out.println(x);
                return;
            }
            long[] sums = new long[n + 1];
            for (int i = 1; i <= n; i++) {
                sums[i] = sums[i - 1] + mods[i - 1];
            }
            int tmp = 0;
            for (int i = n; i > 0; i--) {
                tmp += x - mods[i - 1];
                if (tmp > k) {
                    break;
                }
                if (tmp == sums[i - 1]) {
                    System.out.println(x);
                    return;
                } 
            }
        }
    }
}

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

using namespace std;
typedef long long ll;
const int MAXN = 300100;
const int MAXM = 1100;
const ll MOD = 998244353;

ll pp[MAXN];
ll dp[MAXM];
ll nk[MAXM];
ll ndp[MAXM];

int N, M;
vector <int> edge[MAXN];
int mex[MAXN];

void go_tree()
{
    cin >> M;
    for (int i = 0; i < N; i++)
        edge[i].clear();

    for (int i = 0; i < M; i++)
    {
        int x, y;
        cin >> x >> y;
        x--, y--;
        if (x > y) swap (x, y);
        edge[x].push_back(y);
    }

    for (int i = N - 1; i >= 0; i--)
    {
        set <int> s;
        for (int neigh : edge[i])
            s.insert(mex[neigh]);
        int res = 0;
        while (s.find(res) != s.end()) res++;

        mex[i] = res;
    }

    for (int i = 0; i < MAXM; i++)
        nk[i] = ndp[i] = 0;
    for (int i = 0; i < N; i++)
    {
        nk[mex[i]] = (nk[mex[i]] + pp[i+1]) % MOD;
    }

    for (int i = 0; i < MAXM; i++)
        for (int j = 0; j < MAXM; j++)
        {
            ndp[i^j] = (ndp[i^j] + dp[i] * nk[j]) % MOD;
        }
    for (int i = 0; i < MAXM; i++)
        dp[i] = ndp[i];
}

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N;
    pp[0] = 1;
    pp[1] = ((ll) 1e18) % MOD;
    for (int i = 2; i < MAXN; i++)
    {
        pp[i] = (pp[i-1] * pp[1]) % MOD;
    }

    dp[0] = 1;

    for (int i = 0; i < 3; i++)
    {
        go_tree();
    }
    cout << dp[0] << "\n";
}

Measured memory_bytes: 12672
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li      int32_t
#define lli     long long
#define ulli unsigned long long

#define pn           printf("\n")
#define nl           cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))

#define pb      push_back
#define pob     pop_back
#define itr     iterator
#define sz()    size()
#define szof    sizeof
#define lb      lower_bound
#define ub      upper_bound
#define mp      make_pair
#define vlli    vector<lli>
#define plli    pair<lli,lli>
#define vplli   vector<plli >
#define F       first
#define S       second
#define Dup     erase(unique(V.begin(),V.end()),V.end())

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

#define ALL(V)  V.begin(),V.end()

#define MX1     100000
#define MX2     1000000
#define MX3     10000
#define mod     1000003
#define Inf     1000000000000000
#define MAX 999999999


using namespace std;




int main(){
	int n;
	scanf("%d",&n);
	
	int num[n];
	int maximum = -1;
	
	map<int,int> m;
	map<int,int>::iterator k;
	for(int i=0;i<n;i++){
		scanf("%d",&num[i]);
		m[num[i]]++;
		m[num[i]-1]++;
		m[num[i]+1]++;
	}
	
	for(k=m.begin();k!=m.end();k++){
		if(k->second > maximum){
			maximum = k->second;
		}
	}   
	printf("%d",maximum);    
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
  ll num=0;
  ll N;
  ll a,b;
  cin>>N;
  for(ll i=0;i<N;i++){cin>>a>>b;num+=(b-a)+1;}
  cout<<num<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e2 + 10;
const int  INF = 0x3f3f3f3f;
struct EDGE{ int v, w, nxt; }Edge[maxn * maxn];
int Head[maxn], cnt, id, N;
int ID[3][maxn];
int Weight[3][maxn];

inline void init()
{
    memset(Head, -1, sizeof(Head));
    cnt = id = 0;
}

inline void AddEdge(int From, int To, int Weight)
{
    Edge[cnt].v = To;
    Edge[cnt].w = Weight;
    Edge[cnt].nxt = Head[From];
    Head[From] = cnt++;
}

struct Node{
    int first, second;
    Node(){};
    Node(int f, int s):first(f), second(s){};
    bool operator < (const Node & rhs) const{
        return this->first < rhs.first;
    };
};
int Dis[maxn];
int Dij()
{
    int st = ID[1][1];
    int des = ID[2][N];
    for(int i=0; i<=id; i++) Dis[i] = -INF;
    Dis[st] = Weight[1][1];
    priority_queue<Node> que;
    que.push(Node(Dis[st], st));
    while(!que.empty()){
        Node T = que.top();
        que.pop();
        if(T.first != Dis[T.second]) continue;
        for(int i=Head[T.second]; i != -1; i=Edge[i].nxt){
            int Eiv = Edge[i].v;
            if(Dis[Eiv] < Dis[T.second] + Edge[i].w){
                Dis[Eiv] = Dis[T.second] + Edge[i].w;
                que.push(Node(Dis[Eiv], Eiv));
            }
        }
    }
    return Dis[des];
}

#define Debug 0
int main(void)
{
#if Debug
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif
    while(~scanf("%d", &N)){
        init();
        for(int i=1; i<=2; i++)
            for(int j=1; j<=N; j++){
                ID[i][j] = id++;
                scanf("%d", &Weight[i][j]);
                if(j != 1) AddEdge(ID[i][j-1], ID[i][j], Weight[i][j]);
                if(i != 1) AddEdge(ID[i-1][j], ID[i][j], Weight[i][j]);
            }
//        for(int i=1; i<=2; i++){
//            for(int j=1; j<=N; j++){
//                printf("%d ", ID[i][j]);
//            }puts("");
//        }puts("");
        printf("%d\n", Dij());
    }
    return 0;
}


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

namespace ABC142_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var list = new List<Tuple<int, int>>();
            for (int i = 1; i <= n; i++)
            {
                list.Add(new Tuple<int, int>(i, a[i - 1]));
            }

            list = list.OrderBy(x => x.Item2).ToList();

            Console.WriteLine(string.Join(" ", list.Select(x => x.Item1)));
        }
    }
}


Measured memory_bytes: 33756
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>

#define INF 1000000000
using namespace::std;



long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int x) {
	if (x < 0) {
		return -x;
	}
	return x;
}



int  H,W,c[11][11],ans,N,A,B;
string S,s;


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

	cout << min(N*A,B) << endl;
	return 0;
}




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

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    if(k>(n-1)*(n-2)/2){
        cout << -1 << endl;
    }else{
        int ret = n - 1;
        vector<pair<int, int>> v;
        for(int i = 2; i <= n;i++){
            v.push_back(make_pair(1, i));
        }
        int now = (n - 1) * (n - 2) / 2;
        int x = 2, y = 3;
        while(now > k) {
            v.push_back(make_pair(x, y));
            now--;
            ret++;
            y++;
            if(y==n+1){
                x++;
                y = x + 1;
            }
        }
        cout << ret << endl;
        for(pair<int,int> p:v){
            cout << p.first << " " << p.second << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 384
// Justice will be served
// شهید حاج قاسم سلیمانی

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

#define all(x) x.begin() , x.end()

#define PB push_back
#define F first
#define S second
#define _sz(x) (int)x.size()

#define debug(x) cerr << #x << " = " << x << endl

typedef long long ll ;
typedef pair<int , int> pii ;

const int MAX_N = -1 ;
const int inf = 2e9 + 19 ;

int main() {
        ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;
        int a , b ;
        cin >> a >> b ;
        if (a > 9 || b > 9)
                cout << -1 ;
        else
                cout << a * b ;
        return (0) ;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}



int main() {
	int x; cin >> x;
	
	int sq = sqrt(x);
	Int maxx = 0;

	for (int i = sq + 1; i > sq - 3; i--) {
		if (i * i <= x && maxx < i * i) maxx = i * i;
	}
	cout << maxx;

	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())

import sys
sys.setrecursionlimit(10**9) #再帰の上限をあげる

root=[i for i in range(n+1)] #自分が親なら自身の番号を、そうでないなら（元）親の番号を示す

def r(x):   #親は誰？
    if root[x]==x:
        return x
    else:
        root[x]=r(root[x])
        return root[x]

def unite(x,y):
    x=r(x)
    y=r(y)
    if x==y:
        return
    if x>y:
        x,y=y,x
    root[y]=x

for i in range(m):
    a,b=map(int,input().split())
    unite(a,b)

ans=0
for i in range(1,n+1):
    if root[i]==i:
        ans+=1
print(ans-1)


Measured memory_bytes: 80788
#include <stdio.h>
#define N 10000
typedef struct {
        char name;
        int value;

}Card;
void Bubble(Card c[],int n){
        Card swap;
        int i,j;
        for(i=0; i<=n-1; i++) {
                for(j=n-1; j>=i+1; j--) {
                        if(c[j].value<c[j-1].value) {
                                swap=c[j];
                                c[j]=c[j-1];
                                c[j-1] =swap;
                        }
                }
        }
        for(i=0; i<n-1; i++) {
                printf("%c%d ",c[i].name,c[i].value);
        }
        printf("%c%d",c[i].name,c[i].value);
        printf("\n");
}
void Selection(Card c[],int n){
        Card swap;
        int i,j;
        int minj;
        for(i=0; i<n; i++) {
                minj=i;
                for(j=i+1; j<n; j++) {
                        if(c[j].value<c[minj].value) {
                                minj=j;

                        }

                }
                swap=c[i];
                c[i]=c[minj];
                c[minj] =swap;
        }
        for(i=0; i<n-1; i++) {
                printf("%c%d ",c[i].name,c[i].value);
        }
          printf("%c%d",c[i].name,c[i].value);
        printf("\n");
}
int isStable(Card A[],Card B[],int n){
        int flug=0,i;
        for(i=0; i<n; i++) {
                if(A[i].name!=B[i].name) {
                        flug++;
                }

        }
        if(flug==0) return 1;
        else return 0;
}
int main(){
        int i,n;

        Card A[N],B[N];
        scanf("%d",&n);
        for(i=0; i<n; i++) {
                scanf("%c%c%d",&A[i].name,&A[i].name,&A[i].value);
                B[i]=A[i];
        }

        Bubble(A, n);
        printf("Stable\n");
        Selection(B, n);
        if(isStable(A,B,n)) {
                printf("Stable\n");
        }
        else  {

                printf("Not stable\n");
        }
        return 0;
}



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

int main() {
  int A, B;
  int i;
  
  cin >> A;
  cin >> B;
  if (A >= B) {
    for(i = 0; i < A; i++) {
      cout << B;
    }
  }
  else {
    for(i = 0; i < B; i++) {
      cout << A;
    }
  }
}

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

int main(){
	int A,B,R;
	char op;
	cin >>A >>op >>B;
	
	if(op=='+'){
		R = A+B;
	}
	else if(op=='-'){
		R = A-B;
	}
	else
		R = -1;
	
	cout << R <<endl;
}

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

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

  int ans = 0;
  for(int i = 0; i < S.size(); i++){
    if(S[i] == '+'){
      ans++;
    }
    else
    {
      ans--;
    }
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N;
  int i,kei;
  cin >>N;
  char S[N];
  cin >>S;
  
  for(i=0;i<N;i++){
    if(S[i]!=S[i+1]){
      kei ++;
    }
  }
    cout << kei << endl;
}
    
    
  

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

int main(){
    ll a[3][3] = {};
    ll cnt[8] = {};
    ll n;
    rep(i,0,3) rep(j,0,3) cin >> a[i][j];

    cin >> n;
    ll b[n];
    rep(i,0,n){
        cin >> b[i];
        rep(j,0,3){
            rep(k,0,3){ 
                if(a[j][k] == b[i]){
                    cnt[j]++;
                    cnt[3+k]++;
                    if(j == k) cnt[6]++;
                    if(j + k == 2) cnt[7]++;
                }
            }
        }
    }

    rep(i,0,8) {
        if(cnt[i] >= 3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string abc = Console.ReadLine();

            if (abc.Equals("ABC"))
            {
                Console.WriteLine("ARC");
            }
            else
            {
                Console.WriteLine("ABC");
            }

        }
    }
}


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


int main(){
    int n;
    cin >> n;
    vector<pair<string,int> > v;

    string x;

    for(int i = 0; i < n; ++i){
        string s;
        int a;

        cin >> s >> a;

        v.push_back(make_pair(s,a));
    }

    cin >> x;

    bool f = false;

    int ans = 0;

    for(int i = 0; i < n; ++i){
        if(f) ans += v[i].second;
        if(v[i].first == x) f = true;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
s = []
d = []
l = []
for i in 0..2
  s[i] = gets.chomp.to_i
end
for j in 0..1
  d[j] = gets.chomp.to_i
end
k = 0
for i in 0..2
  for j in 0..1
    l[k] = s[i]+d[j]
    k += 1
  end
end

p l.min-50



Measured memory_bytes: 6856
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        string s = Console.ReadLine();
        bool a = s[0] == 'H';
        bool b = s[2] == 'H';
        if ((a && b) || (!a && !b))
        {
            Console.WriteLine("H");
        }
        else
        {
            Console.WriteLine("D");
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define N 26

int main(){
  string str;
  cin >> str;
  int Array[N]={0};
  
  for(int i=0 ; i<str.size() ; i++)
    Array[(int)str[i]-97]++;
  
  for(int i=1 ; i<N ; i++)
    Array[0]|=Array[i];
  
  if(Array[0]%2)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define riterator reverse_iterator
#define y1 Lorem_ipsum_dolor
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int mxN = 1<<17;
const int P = 998244353;
const llong Inv2 = 499122177ll;
const llong W = 716070898ll;
int sg[mxN+3];
llong pwW[mxN+3];
llong f[3][mxN+3],g[mxN+3];
vector<int> adj[mxN+3]; vector<int> vec;
int n,m,dgr;

int get_mex()
{
	int ret = 0; sort(vec.begin(),vec.end());
	for(int i=0; i<vec.size(); i++)
	{
		if(vec[i]==ret) {ret++;}
		else if(vec[i]>ret) {break;}
	}
	vec.clear(); return ret;
}

void fwt(int dgr,int coe,llong poly[],llong ret[])
{
	for(int i=0; i<(1<<dgr); i++) ret[i] = poly[i];
	for(int i=1; i<(1<<dgr); i<<=1)
	{
		for(int j=0; j<(1<<dgr); j+=(i<<1))
		{
			for(int k=0; k<i; k++)
			{
				llong x = ret[j+k],y = ret[j+i+k];
				ret[j+k] = (x+y)%P,ret[j+i+k] = (x-y+P)%P;
				if(coe==-1) {ret[j+k] = ret[j+k]*Inv2%P,ret[j+i+k] = ret[j+i+k]*Inv2%P;}
			}
		}
	}
}

int main()
{
	scanf("%d",&n); while((1<<dgr)<=n) dgr++;
	pwW[0] = 1ll; for(int i=1; i<=n; i++) pwW[i] = pwW[i-1]*W%P;
	for(int T=0; T<3; T++)
	{
		scanf("%d",&m);
		for(int i=1; i<=m; i++)
		{
			int u,v; scanf("%d%d",&u,&v);
			if(u>v) {swap(u,v);} adj[u].push_back(v);
		}
		for(int i=n; i>=1; i--)
		{
			for(int o=0; o<adj[i].size(); o++)
			{
				vec.push_back(sg[adj[i][o]]);
			}
			sg[i] = get_mex();
//			printf("sg[%d]=%d\n",i,sg[i]);
			f[T][sg[i]] = (f[T][sg[i]]+pwW[i])%P;
		}
		for(int i=1; i<=n; i++) adj[i].clear(),sg[i] = 0;
		fwt(dgr,1,f[T],f[T]);
	}
	for(int i=0; i<(1<<dgr); i++) {g[i] = f[0][i]*f[1][i]%P*f[2][i]%P;}
	fwt(dgr,-1,g,g);
	printf("%lld\n",g[0]);
	return 0;
}

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

int main(){
	int X,Y;
	cin >> X >> Y;
	
	int ans=0;
	for(int i=1;i<=3;i++){
		if(X<=i)ans+=100000;
		if(Y<=i)ans+=100000;
	}
	if(X*Y==1)ans+=400000;
	
	cout << ans << endl;
	return 0;
}

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

int main() {
    ll n; cin >> n;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    ll num = 0;
    for(auto v : a) num = num ^ v;
    if(!num) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n;
  cin>>n;
  vector<ll> vec(n);
  set<ll> st;
  for(int i=0;i<n;i++){
    cin>>vec[i];
    st.insert(vec[i]);
  }
  vector<ll> tmp;
  for(auto &e:st){
    tmp.push_back(e);
  }
  bool flag=false;
  if(tmp.size()==1&&tmp[0]==0) flag=true;
  if(n%3==0&&tmp.size()==3){
    ll a=tmp[0],b=tmp[1],c=tmp[2];
    ll d=a^b;
    if(c==d){
      sort(vec.begin(),vec.end());
      ll cnt_a=upper_bound(vec.begin(),vec.end(),a)-lower_bound(vec.begin(),vec.end(),a);
      ll cnt_b=upper_bound(vec.begin(),vec.end(),b)-lower_bound(vec.begin(),vec.end(),b);
      ll cnt_c=upper_bound(vec.begin(),vec.end(),c)-lower_bound(vec.begin(),vec.end(),c);
      if(cnt_a==(n/3)&&cnt_b==(n/3)&&cnt_c==(n/3)) flag=true;
    }
  }
  if(n%3==0&&tmp.size()==2){
    ll a=tmp[0],b=tmp[1];
    if(a==0){
      sort(vec.begin(),vec.end());
      ll cnt_a=upper_bound(vec.begin(),vec.end(),a)-lower_bound(vec.begin(),vec.end(),a);
      ll cnt_b=upper_bound(vec.begin(),vec.end(),b)-lower_bound(vec.begin(),vec.end(),b);
      if(cnt_a==n/3&&cnt_b==2*n/3) flag=true;
    }
  }
  cout<<(flag? "Yes":"No");
}

Measured memory_bytes: 5628
import math
K = int(input())
ans = 0


# all of them are different
for i in range(1, K+1):
    ans += i
    for j in range(1, K+1):
        if i != j:
            ans += 3 * math.gcd(i, j)
    for j in range(i+1, K+1):
        for k in range(j+1, K+1):
            ans += 6 * math.gcd(math.gcd(i, j), k)
print(ans)

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

int main() {
  int k;
  string s;
  cin >> k >> s;
  
  if (s.size() <= k)
    cout << s << endl;
  else
    cout << s.substr(0,k) << "..." << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(void){
    int n;
    cin >> n;
    int ans;
    if(n%111==0)
        ans = n;
    else if(n%111!=0 && n >= 112)
        ans = n+111-(n%111);
    else if(n%111!=0 && n < 111)
        ans = 111;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools
N = int(input())
ans = 0

for i in range(3, len(str(N)) + 1):
  for ptn in itertools.product((3, 5, 7), repeat=i):
    if (3 not in ptn) or (5 not in ptn) or (7 not in ptn):
        continue
    a = int("".join(list(map(str, ptn))))
    if a <= N:
      ans +=1

print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    long double A, B, N;
    cin >> A >> B >> N;

    if (N < B) {
        cout << ll(floor(A * N / B)) << endl;
    } else {
        cout << ll(floor(A * (B - 1) / B)) << endl;
    }
    
}


Measured memory_bytes: 3800
#include<iostream>
#include<stdio.h>
#include<vector>
using namespace std;

long long H, W;
int count = 0;
    // vector<vector<int>> A(20, vector<int>(20));
int main(){
    cin >> H >> W;
    // vector<vector<int> > banmen(H, vector<int>(W));

    if(H == 1 or W == 1){
        cout << 1 << endl;
    }
    else if(H % 2 == 1 && W % 2 == 1){
        cout << (H * W + 1) / 2 << endl;
    }
    else{
        cout << H * W / 2 << endl;
    }
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main() {
    int A;
    int B;
    int C;
    int tmp;
    cin>>A>>B>>C;
    
    tmp = A;
    A = B;
    B = tmp;
    
    tmp = A;
    A = C;
    C = tmp;
    cout<<A<<" "<<B<<" "<<C<<" "<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k[4];
string s;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n;
	while(n--){
		cin>>s;
		switch(s[0]){
			case'A':k[0]++;break;
			case'W':k[1]++;break;
			case'T':k[2]++;break;
			case'R':k[3]++;break;
		}
	}
	cout<<"AC x "<<k[0]<<"\nWA x "<<k[1]<<"\nTLE x "<<k[2]<<"\nRE x "<<k[3];
}


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

using namespace std;
#define l unsigned long long int 


int main(){
    l n;
    cin>>n;
    l ar[n+1]={0};
    for(l i = 1;i<=n;i++){
        for(l j = i;j<=n;j+=i){
            ar[j]++;
        }
    }
    l sum = 0;
    for(l i = 1;i<=n;i++){
        sum +=(i*ar[i]);
    }    
    cout<<sum;
    return 0;
}

Measured memory_bytes: 81748
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    string s;
    cin>>n;
    cin>>s;
    long long l=s.length();
    if(l>n)
    {
    for(int i=0;i<n;i++)
    {
        cout<<s[i];
    }
    cout<<"..."<<endl;
    }
    if(l==n)
    {
        cout<<s;
    }
    if(l<n)
    {
        cout<<s;
    }
}

Measured memory_bytes: 3580
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <tuple>

static size_t di[] = {size_t(-1), 0, 1, 0};
static size_t dj[] = {0, size_t(-1), 0, 1};

std::vector<std::vector<int>> paint(std::vector<std::vector<int>> p, int c) {
  size_t h = p.size();
  size_t w = p[0].size();
  std::queue<std::pair<size_t, size_t>> q;
  int c0 = p[0][0];
  if (c0 == c) return p;
  q.emplace(0, 0);
  while (!q.empty()) {
    size_t i, j;
    std::tie(i, j) = q.front();
    q.pop();
    if (p[i][j] == c) continue;
    p[i][j] = c;
    for (size_t k = 0; k < 4; ++k) {
      size_t ni = i + di[k];
      size_t nj = j + dj[k];
      if (!(ni < h && nj < w)) continue;
      if (p[ni][nj] != c0) continue;
      q.emplace(ni, nj);
    }
  }
  return p;
}

int count(std::vector<std::vector<int>> p) {
  size_t h = p.size();
  size_t w = p[0].size();
  std::queue<std::pair<size_t, size_t>> q;
  int c0 = p[0][0];
  q.emplace(0, 0);
  int res = 0;
  while (!q.empty()) {
    size_t i, j;
    std::tie(i, j) = q.front();
    q.pop();
    if (p[i][j] == 0) continue;
    p[i][j] = 0;
    ++res;
    for (size_t k = 0; k < 4; ++k) {
      size_t ni = i + di[k];
      size_t nj = j + dj[k];
      if (!(ni < h && nj < w)) continue;
      if (p[ni][nj] != c0) continue;
      q.emplace(ni, nj);
    }
  }
  return res;
}

int paint(std::vector<std::vector<int>> p, int r, int c) {
  if (r == 0) {
    return count(paint(p, c));
  }

  int res = 1;
  for (int i = 1; i <= 6; ++i)
    res = std::max(res, paint(paint(p, i), r-1, c));
  return res;
}

int testcase_ends() {
  size_t h, w;
  int c;
  scanf("%zu %zu %d", &h, &w, &c);
  if (h == 0 && w == 0 && c == 0) return 1;

  std::vector<std::vector<int>> p(h, std::vector<int>(w));
  for (size_t i = 0; i < h; ++i)
    for (size_t j = 0; j < w; ++j)
      scanf("%d", &p[i][j]);

  printf("%d\n", paint(p, 4, c));
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 2788
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define in(v) v; cin >> v;
#define rep(i,n) for(ll i=0,_i=(n);i<_i;++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif

int main() {
  int in(X);

  set<ll> s;
  map<ll, int> m;
  rep(i, 1e5) {
    ll A = i * i * i * i * i;
    s.insert(A);
    s.insert(-A);
    m[A] = i;
    m[-A] = -i;
    if (s.find(A - X) != s.end()) {
      cout << m[A] << " " << m[A-X] << endl;
      return 0;
    }
    if (s.find(A + X) != s.end()) {
      cout << m[A] << " " << m[A+X] << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3648
package main

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

func main() {
	io := newIo()
	defer io.flush()

	n := io.nextInt()
	b := make([]int, n)

	for i := range b {
		a := io.nextInt()
		b[n/2-((i+1)/2)*[]int{-1, 1}[(n+i)%2]] = a
	}

	for i := range b {
		if i != 0 {
			io.print(" ")
		}
		io.print(b[i])
	}
	io.println()
}

type io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func newIo() *io {
	return &io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *io) flush() {
	_ = io.writer.Flush()
}

func (io *io) nextLine() string {
	var buffer []byte
	for {
		line, isPrefix, _ := io.reader.ReadLine()
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *io) nextString() string {
	for io.nextToken >= len(io.tokens) {
		line := io.nextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *io) nextInt() int {
	i, _ := strconv.Atoi(io.nextString())
	return i
}

func (io *io) print(a ...interface{}) {
	fmt.Fprint(io.writer, a...)
}

func (io *io) println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *io) printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}


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

int n;
string s;
string u[4] = {"SS", "SW", "WS", "WW"};
char func(char a, char b, char c){
	bool f = (a == 'S');
	f = (f == (b == 'S'));
	f = (f == (c == 'o'));
	return f ? 'S' : 'W';
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> s;
	for(int i=0; i<4; ++i){
		string t;
		t += u[i];
		for(int j=1; j<n-1; ++j)
			t += func(t[j-1], t[j], s[j]);
		if(func(t[n-1], t[0], s[0]) == t[1] && func(t[n-2], t[n-1], s[n-1]) == t[0]){
			cout << t << "\n";
			return 0;
		}
	}
	cout << -1 << "\n";
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

void primeNumber(int N, vector<bool>& prime)
{
    prime.assign(N+1, true);
    prime [0] = prime[1] = false;
    for(int i=2; i*i<=N; i++){
        if(prime[i]){
            for(int j=i; i*j<=N; j++){
                prime[i*j] = false;
            }
        }
    }
}

int main()
{
    vector<bool> prime;
    primeNumber(30000, prime);

    for(;;){
        int t;
        cin >> t;
        if(t == 0)
            return 0;

        int ret = 0;
        for(int a=1; a<=t; ++a){
            if(!prime[a])
                continue;

            int b = a;
            int c = t - a - b;
            while(b <= c){
                if(a + b > c && prime[b] && prime[c])
                    ++ ret;
                ++ b;
                -- c;
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 1200
import math
n, k = map(int, input().split())
r=0
if n < k:
    for i in range(1, n+1):
        r=r+(1/n)*0.5**math.ceil(math.log2(k/i))
    print(r)
else:
    r=1-(k/n)
    for i in range(1, k+1):
        r=r+(1/n)*0.5**math.ceil(math.log2(k/i))
    print(r)

Measured memory_bytes: 3060
import java.io.*;
import java.util.*;
import java.lang.*;
public class Main {
	
	public static void main(String[] args) {
	
		MyScanner sc = new MyScanner();
		int n=sc.nextInt();
		int v[]=new int[n+1];
		int num0[]=new int[100001];
		int num1[]=new int[100001];
		for (int i = 1; i <= n; i++) {
			v[i]=sc.nextInt();
			if(i%2==0) {
				num0[v[i]]++;
				
			}else {
				num1[v[i]]++;
			}
		}
		
		int x[]=new int[100001];
		int y[]=new int[100001];
		System.arraycopy(num0,0,x,0,100000);
		System.arraycopy(num1,0,y,0,100000);
		Arrays.sort(num0);
		Arrays.sort(num1);
		
		int ev1=num0[100000];
		int od1=num1[100000];
		int ev2=num0[99999];
		int od2=num1[99999];
		int ans=0;
		int eve_most=0;
		int odd_most=0;
		for (int i = 1; i <=100000; i++) {
			if(x[i]==ev1) {
				eve_most=i;
			}
			if(y[i]==od1) {
				odd_most=i;
			}
		}
		if(eve_most==odd_most) {
			
			if(ev1+od2>=ev2+od1) {
				ans=n-ev1-od2;
			}else {
				ans=n-ev2-od1;
			}
			
			
		}else {
			ans=n-ev1-od1;
			
		}
		System.out.println(ans);
		
			
	}
	
	
	
//----------------------------------------------------------
	static int l_min(int[] a) {
		Arrays.sort(a);
		return a[0];
	}
	static int l_max(int[] a) {
		int l=a.length;
		Arrays.sort(a);
		return a[l-1];
	}
	
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	

}


Measured memory_bytes: 37420
a=list(map(int,input().split()))
a.sort()
ans=a[2]-a[1]
a[0]+=a[2]-a[1]
a[1]+=ans
ans+=(a[1]-a[0])//2
a[0]+=((a[1]-a[0])//2)*2
if (a[0]==a[1])and(a[1]==a[2]):
    print(ans)
else:
    print(ans+2)    

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

p = 10**9+7
h, w, k = map(int, input().split())

if w == 1:
    print(1)
    exit()

d = [[0]*(w+1) for _ in range(h+1)]

d[0][0] = 1
# [i,j]を(i*0.5)行 (j+1)列 の地点とする
# dp[i][j]: [0][0]をスタートとした時の[i][j]に到達しうるあみだくじの総数

case = [1, 2, 3, 5, 8, 13, 21]

ans = 0
for i in range(1,h+1):
    for j in range(w):
        if i+1 <= j: continue
        # center to center
        d[i][j] += d[i-1][j]*case[max(0,w-j-2)] * case[max(0,j-1)]%p
        # left to right
        if j-1>=0:
            d[i][j] += d[i-1][j-1]* case[max(0,w-j-2)] * case[max(0,j-2)]%p
        # right to left
        if j+1<=w:
            d[i][j] += d[i-1][j+1]* case[max(0,w-j-3)] * case[max(0,j-1)]%p

print(d[h][k-1]%p)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace::std;
#define all(n) (n).begin(),(n).end()
#define MOD 1000000007LL

struct rolling_hash{
    using u64=uint64_t;
    constexpr static u64 mod=(1ULL<<61)-1;
    constexpr static u64 base=10007;
    int sz;
    u64 hash;
    constexpr rolling_hash():sz(0),hash(0){}
    constexpr rolling_hash(char c):sz(1),hash(c){}
    rolling_hash(string s):sz(0),hash(0){
        for(auto c:s)(*this)+=c;
    }
    constexpr u64 pow(u64 s,int t){
        u64 ret=1;
        while(t){
            if(t&1)ret=mul(ret,s);
            s=mul(s,s);
            t/=2;
        }
        return ret;
    }
    constexpr u64 add(u64 s,u64 t)noexcept{
        s+=t;
        return s>=mod?s-mod:s;
    }
    constexpr u64 sub(u64 s,u64 t)noexcept{
        if(s<t)s+=mod;
        return s-t;
    }
    constexpr u64 mul(u64 a,u64 b)noexcept{
        return __int128_t(a)*b%mod;
    }
    constexpr rolling_hash operator+(rolling_hash s)const noexcept{return rolling_hash(*this)+=s;}
    constexpr bool operator==(rolling_hash s)noexcept{return hash==s.hash&&sz==s.sz;}
    constexpr bool operator<(rolling_hash s)const noexcept{return make_pair(hash,sz)<make_pair(s.hash,s.sz);}
    constexpr bool operator>(rolling_hash s)const noexcept{return make_pair(hash,sz)>make_pair(s.hash,s.sz);}
    constexpr bool operator<=(rolling_hash s)const noexcept{return make_pair(hash,sz)<=make_pair(s.hash,s.sz);}
    constexpr bool operator>=(rolling_hash s)const noexcept{return make_pair(hash,sz)>=make_pair(s.hash,s.sz);}
    constexpr rolling_hash operator+=(rolling_hash s)noexcept{
        (*this).hash=add((*this).hash*pow(base,s.sz),s.hash);
        (*this).sz+=s.sz;
        return *this;
    }
    constexpr int size(){return sz;}
};

int main(){
	vector<rolling_hash>m;
	int n;
	cin>>n;
	vector<rolling_hash>v(n);
	for(int i=0;i<n;++i){
		string s;
		cin>>s;
		reverse(all(s));
		vector<int>cnt(26,0);
		for(int j=0;j<(int)s.size();++j)cnt[s[j]-'a']++;
		bitset<26>b;
		for(int j=0;j<26;++j)if(cnt[j])b[j]=1;
		for(int j=0;j<(int)s.size();++j){
			for(int k=b._Find_first();k<26;k=b._Find_next(k)){
				m.push_back(v[i]+(k+'a'));
			}
			v[i]+=s[j];
			cnt[s[j]-'a']--;
			if(!cnt[s[j]-'a'])b[s[j]-'a']=0;
		}
	}
    sort(all(m));
	int64_t ans=0;
	for(int i=0;i<n;++i){
		ans+=upper_bound(all(m),v[i])-lower_bound(all(m),v[i])-1;
	}
	cout<<ans<<endl;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmin(T & ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T & ref, const T value) {
    if (ref < value) ref = value;
}

const ll mod = 1000000007;

struct UnionFind {
public:
	vector <ll> par; // 
	vector <ll> siz; // 

	UnionFind() {}

	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}

	ll root(ll x) {
		while (par[x] != x) {
			x = par[x] = par[par[x]];
		}
		return x;
	}

	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}

	bool issame(ll x, ll y) {
		return root(x) == root(y);
	}

	ll size(ll x) {
		return siz[root(x)];
	}
};

int main() {
	ll n, m;
	cin >> n >> m;
	vector<P> edges(m);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		edges[i] = { a,b };
	}
	ll sum = 0;
	rep(i, m) {
		UnionFind uf(n);
		rep(j, m) {
			if (i == j) continue;
			uf.merge(edges[j].first, edges[j].second);
		}
		set<int> ids;
		rep(i, n) {
			ids.insert(uf.root(i));
		}
		if (ids.size() > 1) {
			sum++;
		}
	}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 3652
def main():
    N, K = map(int, input().split())
    *h, = map(int, input().split())

    ans = f(N, K, h)
    print(ans)


def f(N, K, h):
    dp = [None] * (N + 1)
    dp[0] = 0
    dp[1] = 0

    for i in range(2, N + 1):
        hi = i - 1
        cost = float("inf")
        for k in range(1, K + 1):
            if i - k < 1:
                continue

            tmp = dp[i-k] + abs(h[hi] - h[hi-k])
            cost = min(cost, tmp)

        dp[i] = cost

    ans = dp[N]
    return ans


if __name__ == "__main__":
    main()


Measured memory_bytes: 56800