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

int main(){
    int n, m;
    std::cin >> n >> m;
    std::vector<int> x(m);
    for(int i = 0; i < m; i++){
        std::cin >> x[i];
    }

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

    // 例外処理
    if(n >= m){
        std::cout << 0 << std::endl;
        return 0;
    }
    if(n == 1){
        std::cout << x[m - 1] - x[0] << std::endl;
        return 0;
    }

    // 区間を求める
    int ans = 0;
    std::vector<int> interval(m - 1);
    for(int i = 1; i < m; i++){
        interval.push_back(x[i] - x[i - 1]);
        ans += x[i] - x[i - 1];
    }

    
    std::sort(interval.begin(), interval.end(), std::greater<int>());
    for(int i = 0; i < n - 1; i ++){
        // 区間が大きいところから順に潰す
        ans -= interval[i];
    }

    std::cout << ans << std::endl;
            
    return 0;
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RREP(i,n) RFOR(i,0,n)
#define RREPS(i,n) RFOR(i,1,n+1)
#define ALL(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define debug(x) cout << #x << ": " << x << endl

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF (1L << 30)
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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; }
using ll = long long;
#define int ll

bool Fcomp(const pair<int,int>& firstElof, const pair<int,int>& secondElof)
{return firstElof.F < secondElof.F;}
bool Scomp(const pair<int,int>& firstElof, const pair<int,int>& secondElof)
{return firstElof.S < secondElof.S;}

//**********

signed main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    int a[200010];
    int b[200010];
    vector<int> amod;
    vector<int> bmod;
    REP(i,n) {cin >> a[i];}
    REP(i,n) {cin >> b[i];}
    
    int ans = 0;
    
    REP(k,29) { // k bit
        
        int m = 2<<k;
        int knum = 0;
        
        //printf("m=%lld\n",m);
        
        REP(i,n){
            amod.pb(a[i]%m);
            bmod.pb(b[i]%m);
        }
        sort(ALL(amod));
        sort(ALL(bmod));
        
        //printf("%lld %lld %lld %lld %lld\n%lld %lld %lld %lld %lld\n",amod[0],amod[1],amod[2],amod[3],amod[4],bmod[0],bmod[1],bmod[2],bmod[3],bmod[4]);
        
        REP(i,n){
            if(amod[i]<=m/2){
                knum += lower_bound(ALL(bmod),m-amod[i]) - lower_bound(ALL(bmod),m/2-amod[i]);
                //printf("a:knum = %lld\n",knum);
                
            } else {
                knum += bmod.size() - (lower_bound(ALL(bmod),m/2-amod[i]+m) - lower_bound(ALL(bmod),m-amod[i]));
                //printf("b:knum = %lld\n",knum);
            }
        }
        if(knum&1) ans += m/2;
        amod.clear();
        bmod.clear();
    }
    
    
    
    printf("%lld\n",ans);
    //    else printf("No\n");
    
    return 0;
    
}








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

int main(){
    int N,M,C;
    cin >>N>>M>>C;
    int A[N][M],B[M];
    for(int i = 0; i < M; i++){
        cin >> B[i];
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            cin >> A[i][j];
        }
    }

    int sum = 0;
    int ans = 0;
    for(int i = 0; i < N; i++){
        //ここで初期化しとかないと前のやつも足されていってしまう
        sum = 0;
        for(int j = 0; j < M; j++){
            sum += A[i][j]*B[j];
        }
        if(sum + C > 0){
            ans++;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
multiset<int> s; int a[1000000];
int main()
{	int n; ll ans=0; cin>>n;
	for(rint i=1;i<=n;i++) scanf("%d",&a[i]),s.insert(a[i]);
	sort(a+1,a+n+1,greater<int>());
	for(rint i=1;i<=n;i++)
	if(s.count(a[i]))
	{	s.erase(s.find(a[i]));
		for(rint j=(1<<30);j;j>>=1)
		{	auto it=s.lower_bound(j-a[i]);
			if(it!=s.end()&&*it==j-a[i]){ans++,s.erase(it);break;}
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
	map<int,int> m;
	vector<int> v;
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		if(m[x]==0)
		v.push_back(x);
		m[x]++;
	}
	int ans=0;
	for(int i=0;i<v.size();i++)
	if(v[i]>m[v[i]])
	ans+=m[v[i]];
	else
	if(v[i]<m[v[i]])
	ans+=m[v[i]]-v[i];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 7160
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define ll long long
#define int ll
#define eps 1e-7
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
using pii = pair<int, int>;

int n;
vector <int> v;
vector <int> pdivs[1010101];
int decomp[1010101];
bool set_check()
{
    int g = v[0];
    for (int it : v)
    {
        g = __gcd(g, it);
    }
    return (g == 1);
}

bool pair_check()
{
    for (int i = 2; i<=1000000; i++)
    {
        if (pdivs[i].empty())
        {
            for (int j = 1; i*j <= 1000000; j++)
            {
                pdivs[i*j].push_back(i);
            }
        }
        else continue;
    }
    for (int i = 0; i<n; i++)
    {
        for (auto it:pdivs[v[i]])
            decomp[it]++;
    }
    for (int i = 2; i<=1000000; i++)
    {
        if (decomp[i] > 1)
        {
            return false;
        }
    }
    return true;
}

int32_t main()
{
    usecppio
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int x; cin >> x;
        v.push_back(x);
    }
    if (!set_check())
    {
        cout << "not coprime\n";
        return 0;
    }
    if (!pair_check())
        cout << "setwise coprime\n";
    else cout << "pairwise coprime\n";
}


Measured memory_bytes: 89072
#include <bits/stdc++.h>
typedef long long ll;

int main(int argc, char const *argv[]) {
    ll N;
    std::string S;
    std::cin >> N >> S;
    ll max = 0;
    ll x = 0;
    for (size_t i = 0; i < S.length(); i++) {
        if (S[i] == 'I') {
            x++;
            max = std::max(max, x);
        } else {
            x--;
        }
    }
    std::cout << max << '\n';
    return 0;
}


Measured memory_bytes: 256
#c
n=int(input())
N=100100
happy=[[0]*3 for i in range(N)]
dp=[[0]*3 for i in range(N)]
for i in range(1,n+1):
    x,y,z=map(int,input().split())
    happy[i][0]=x
    happy[i][1]=y
    happy[i][2]=z
ans=0
for i in range(1,n+1):
    for place in range(3):
        for place_y in range(3):
            if place==place_y:
                continue
            else:
                dp[i][place]=max(dp[i][place],dp[i-1][place_y]+happy[i][place])

for place in range(3):
    ans=max(ans,dp[n][place])
print(ans)


Measured memory_bytes: 68204
x1, y1, x2, y2 = list(map(int, input().split()))

vec_12_x = x2 -x1
vec_12_y = y2 -y1

vec_23_x = -vec_12_y
vec_23_y = vec_12_x

vec_34_x = -vec_12_x
vec_34_y = -vec_12_y

print(x2+vec_23_x, y2+ vec_23_y, x2+vec_23_x+vec_34_x, y2+vec_23_y+vec_34_y)


Measured memory_bytes: 2940
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	k := intScanner()
	a := intScanner()
	b := intScanner()
	if k < a || b <= a+2 {
		fmt.Println(k + 1)
	} else {
		c := a
		k -= a - 1
		c += k / 2 * (b - a)
		c += k % 2
		fmt.Println(c)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N, Q;
    cin>>N>>Q;

    vec_int a(N-1), b(N-1);
    rep(i,N-1)cin>>a.at(i)>>b.at(i);
    vec_int p(Q), x(Q);
    rep(i,Q)cin>>p.at(i)>>x.at(i);

    vec_int scores(N+1,0);
    rep(i,Q){
        scores.at(p.at(i)) += x.at(i);
    }

    vector<vector<int>> tree_str(N+1);
    for(int i=0;i<N-1;i++){
        tree_str.at(a.at(i)).push_back(b.at(i));
        tree_str.at(b.at(i)).push_back(a.at(i));
    }


    //深さ優先探索をする 幅優先探索でもOK
    // stackを使おう
    queue<P> next_nodes;
    vec_int visited(N+1,0);
    for(auto pos: tree_str.at(1)){
        next_nodes.push(make_pair(pos, scores.at(1)));
    }
    visited.at(1) = 1;

    while(next_nodes.size()>0){
        int pos, score; tie(pos,score) = next_nodes.front(); next_nodes.pop();
        visited.at(pos) = 1;
        scores.at(pos) = scores.at(pos) + score;

        for(auto next_pos: tree_str.at(pos)){
            if(visited.at(next_pos)==1)continue;
            next_nodes.push(make_pair(next_pos, scores.at(pos)));
        }
    }
    for(int i=1;i<N;i++){
        cout<<scores.at(i)<<" ";
    }
        cout<<scores.at(N)<<endl;

















    return 0;
}

Measured memory_bytes: 28436
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> v(3);
  cin>>v.at(0)>>v.at(1)>>v.at(2);
  sort(v.begin(),v.end());
  cout << 10*v.at(2)+v.at(1)+v.at(0) << endl;
}
  

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, m) = readPair().toList().map(String::toLong)
    val sList = mutableListOf<MutableList<Long>>()
    m.rep(0) {
        val list = readLongList()
        val memC = list.subList(1, list.size).toMutableList()
        sList.add(memC)
    }
    val p = readLongList()

    val _mem = mutableListOf<Boolean>()
    n.rep {
        _mem.add(false)
    }

    var ans = 0

    fun checkDfs(mem: List<Boolean>, index: Int) {
        if (index == n.toInt()) {
            if (sList.filterIndexed { index, mutableList ->
                    mutableList.filter { mem[it.toInt() - 1] }.size % 2 == p[index].toInt()
                }.size == sList.size) {
                ans++
            }
        } else {
            checkDfs(mem, index + 1)
            val copy = mem.copy().toMutableList()
            copy[index] = true
            checkDfs(copy, index + 1)
        }
    }

    checkDfs(_mem, 0)



    println(ans)

}


fun readList() = readLine()!!.split(' ')
fun readLongList() = readList().map(String::toLong)

fun readLong() = readLine()!!.toLong()
fun readString() = readLine()!!

fun readPair(): Pair<String, String> {
    val splite = readLine()!!.split(' ')
    return Pair(splite[0], splite[1])
}

fun <T> List<T>.copy() = this.map { it }

// 速度のためforEachは避ける
fun Int.rep(start: Int = 0, body: (Int) -> Unit) {
    for (i in start until this) {
        body(i)
    }
}

fun Long.rep(start: Long = 0, body: (Long) -> Unit) {
    for (i in start until this) {
        body(i)
    }
}

Measured memory_bytes: 42732
from fractions import gcd
from functools import reduce
def gcds(*numbers):
  return reduce(gcd, numbers)
n = int(input())
for i in range(n):
  a,b,c,d = map(int,input().split())
  x = gcds(a,b,c,d)
  if x != 1:
    a = a//x
    b = b//x
    c = c//x
    d = d//x
  if b>d or a<b:
    print("No")
  elif c>=b-1:
    print("Yes")
  elif gcd(b,d) != 1:
    y = gcd(b,d)
    if b-c<y and c%y >= a%y:
        print("Yes")
    else:
      print("No")
  else:
    print("No")


Measured memory_bytes: 5076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N=1e6+5,inf=1e18,mod=1e9+7;
#define test ll testcases;cin>>testcases; while(testcases--)
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define sz(x) ((ll)((x).size()))
const ld pi=3.141592653589793238;

bool check_prime(ll n)
{
	ll flag=0,i;
	for(i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			flag=1;
			break;
		}
	}
	if(n==1)
	{
		return false;
	}
	else if(flag==0 || n==2 || n==3)
	{
		return true;
	}
	else
	{
		return false;
	}
}

ll fastexpo(ll a,ll b,ll MOD) 
{
	ll result=1;
	while(b>0)
	{
		if(b%2==1)
		{
			result=(result*a)%MOD;
		}
		a=(a*a)%MOD;
		b=b/2;
	}
	return result;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,i,j,l;
    string s1,s2;
    cin>>s1>>s2;
    n=sz(s1);
    m=sz(s2);
    ll dp[n+1][m+1];
    for(i=0;i<=n;i++)
    {
    	for(j=0;j<=m;j++)
    	{
    		if(i==0 || j==0)
    		{
    			dp[i][j]=0;
    		}
    		else if(s1[i-1]==s2[j-1])
    		{
    			dp[i][j]=dp[i-1][j-1]+1;
    		}
    		else
    		{
    			dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
    		}
    	}
    }
    vector<char> v;
    i=n;
    j=m;
    while(i>0 && j>0)
    {
    	if(s1[i-1]==s2[j-1])
    	{
    		v.pb(s1[i-1]);
    		i--;
    		j--;
    	}
    	else if(dp[i-1][j]>dp[i][j-1])
    	{
    		i--;
    	}
    	else
    	{
    		j--;
    	}
    }
    reverse(all(v));
    for(i=0;i<sz(v);i++)
    {
    	cout<<v[i];
    }
    cout<<"\n";
	return 0;
}

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

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)

const int inf = 1e9 + 5;

signed main()
{
	int N; cin >> N;
	vector<int> A(N), B(N);
	int sum = 0;
	int mn = inf;
	rep(i, N) {
		cin >> A[i] >> B[i];
		if (A[i] > B[i]) {
			if (mn > B[i]) mn = B[i];
		}
		sum += A[i];
	}

	bool flag = true;

	rep(i, N) flag &= (A[i] == B[i]);

	if (flag) {
		cout << 0 << endl;
		return 0;
	}

	if (mn == inf) {
		cout << sum << endl;
	} else {
		cout << sum - mn << endl;
	}
}



Measured memory_bytes: 3596
#include <iostream>
#include <stdio.h>

int main() {
    int a, b;

    while (true) {
        std::cin >> a >> b;

        if (a == 0 && b == 0) {
            break;
        }
        
        if (a > b) {
            std::cout << b << ' ' << a << std::endl;
        } else {
            std::cout << a << ' ' << b << std::endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long x, ans;
	cin >> x;
	x -= x % 5;
	ans = 1000 * (x / 500) + 5 * ((x % 500) / 5);
	cout << ans << "\n";
		

	return 0;
}



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

using namespace std;

//aとbを比較して、aに小さいほうを入れる。bのほうが小さければtrueを戻す
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;}return false;}

//aとbを比較して、aに大きいほうを入れる。bのほうが大きければtrueを戻す
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;}return false;}

int main(void){
  while(true){
  int n; cin >> n;
  if(n == 0)break;
  vector<long long> dp(n+1, 0);
  dp[0] = 1;
  for(int now = 0; now < n; now++){
    for(int next = now+1; next <= min(n, now+3); next++){
      dp[next] += dp[now];
    }
  }
  cout << ceil((double)dp[n] / 10 / 365) << endl; 
  }
  return 0;
}


Measured memory_bytes: 3148
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[100100];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int cnt=0;
    for(int i=0;i<n;){
        if(i==n-1||(a[i]!=a[i+1])){
            cnt++;
            i++;
        }
        else
            i+=2;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n,m,count=0;
    cin >> n;
    ll d[n];
    for (ll i=0;i<n;i++)cin >> d[i];
    cin >> m;
    ll t[m];
    for (ll i=0;i<m;i++)cin >> t[i];
    sort(d,d+n);
    sort(t,t+m);
    for (ll i=0;i<n;i++){
        if (d[i]==t[count])count++;
    }
    if (count==m){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 3328
program name

    implicit none
    integer A,B,C,D
    integer AB,CD
    read *, A,B,C,D
    AB = A*B
    CD = C*D
    if ( AB>CD ) then
        print*, AB
    elseif ( CD>AB ) then
        print*, CD
    else
        print*, AB
    end if

end program


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define vi vector<ll>
using namespace std;
const int N=1e5+5;
ll x[N][3],n,m,ans;
int main()
{
	cin>>n>>m;
	for(ll i=0;i<n;i++)cin>>x[i][0]>>x[i][1]>>x[i][2];
	for(ll mask=0;mask<(1<<3);mask++)
	{
		vi v;
		for(ll i=0;i<n;i++)
		{
			ll t=mask;
			ll sum=0;
			for(ll j=0;j<3;j++)
			{
				if(t&1)sum+=x[i][j];
				else sum-=x[i][j];
				t/=2;
			}
			v.push_back(sum);
		}
		sort(v.begin(),v.end());
		reverse(v.begin(),v.end());
		ll sum=0;
		for(ll i=0;i<m;i++)sum+=v[i];
		ans=max(ans,sum);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		boolean[][] cardHasFlag =new boolean[4][13];
		int cardNum=sc.nextInt();
		for(int i=0;i<cardNum;i++) {
			String sign =sc.next();
			int card=sc.nextInt();

			switch(sign) {
			case "S":
				cardHasFlag[0][card-1]=true;
				break;
			case "H":
				cardHasFlag[1][card-1]=true;
				break;
			case "C":
				cardHasFlag[2][card-1]=true;
				break;
			case "D":
				cardHasFlag[3][card-1]=true;
				break;
			}
		}
		for(int i=0;i<4;i++) {
			for(int j=0;j<13;j++) {
				if(cardHasFlag[i][j]==false) {
					switch(i) {
					case 0:
						System.out.printf("S %d\n",j+1);
						break;
					case 1:
						System.out.printf("H %d\n",j+1);
						break;
					case 2:
						System.out.printf("C %d\n",j+1);
						break;
					case 3:
						System.out.printf("D %d\n",j+1);
						break;
					}
				}
			}
		}

	}

}



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

int main() {
    int n;
    cin >> n;
    int a[n];
    int d = 0;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        if(a[i] != (i+1))
        d++;
    }
    if(d==0 || d==2)
    cout << "YES" << endl;
    else 
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

int main() {
	int c1 = 0, c2 = 0;
	int a, b, c; char ch;
	while (cin >> a >> ch >> b >> ch >> c) {
		c1 += a * a + b * b == c * c;
		c2 += a + b >= c && a == b;
	}
	Cout(c1);
	Cout(c2);
}


Measured memory_bytes: 3016
sub main {
    chomp(my $S = <STDIN>);
    chomp(my $K = <STDIN>);
    print solver($S,$K);
}
main() unless caller;

sub solver {
    my ($S,$K) = @_;
    my @ar = split //, $S;
    my $fst = $ar[0];
    my $end = $ar[-1];
    my $idx = 0;
    my @ans;
    my $anser = 0;
    my $len = scalar @ar;
    if($len == 1){
        return 0 if $K == 1;
        return int($K/2);
    }
    if($S =~ /^(.)\1*$/){
        if($len%2 != 0 && $K > 1){
            return int($len * $K /2);
        }
        $anser = int($len/2);
        return $anser * $K;
    }
    for my $i(0 .. $len-1) {
        if(!defined $ans[$idx]) {
            $ans[$idx] = 1;
        }
        if($i < $len-1 && $ar[$i] eq $ar[$i+1]){
            $ans[$idx]++;
            next;
        } elsif($len > $i+1) {
            $idx++;
        }
    }
    for my $n(@ans) {
        next if $n == 1;
        $anser += int($n/2);
    }
    $anser *= $K;
    if($fst eq $end){
        if($ans[0]%2!=0 && $ans[-1]%2!=0 ){
            $anser += $K-1;
        }
    }
    return $anser;
}

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

int main() {
    int n; cin >> n;
    string s, t; cin >> s >> t;

    string st;
    rep(i, n){
        st += s.at(i);
        st += t.at(i);
    }

    cout << st << endl;
}


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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;
const ll MAXN = 1e5 + 5;

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

  ll n, k;
  cin >> n >> k;
  vector < ll > a(n + 1);
  for(int i = 1; i <= n; i++) cin >> a[i];

  if(k == 0){
    cout << 1 << '\n';
    return 0;
  }

  vector < vector < ll > > dp(MAXN, vector < ll > (105));
  vector < vector < ll > > p(MAXN, vector < ll > (105, 0));

  for(int i = 0; i <= k; i++){
    p[i][0] = 1;
    if(i < 105){
      p[0][i] = 1;
    }
  }
  for(int i = 1; i <= k; i++){
    for(int j = 1; j <= n; j++){
      if(i - a[j] >= 1) dp[i][j] = p[i][j - 1] - p[i - a[j] - 1][j - 1] + mod;
      else dp[i][j] = p[i][j - 1];
      dp[i][j] %= mod;

      p[i][j] = (p[i - 1][j] + dp[i][j]) % mod;
    }
  }

  cout << dp[k][n] << '\n';
}


Measured memory_bytes: 170624
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

int main() {
    string s;
    cin >> s;
    string t[] = {"Sunny", "Cloudy", "Rainy"};

    for (int i = 0; i < 3; ++i) {
        if (s == t[i]) {
            cout << t[(i+1)%3] << endl;
            return 0;
        }
    }


    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
char str[100100];
int main(){
//	freopen("A.in","r",stdin);
	scanf("%s",str+1);
	int n=strlen(str+1);
	if(n<4){
		printf("No\n");
		return 0;
	}
	if(str[1]=='Y'&&str[2]=='A'&&str[3]=='K'&&str[4]=='I')
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map
#include<cmath>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 10000007

typedef  long long ll;

using namespace std;

ll gcd(ll a,ll b){
    if (b==0)return a;
    return gcd(b,a%b);
}

void solve(){
    ll n,m;
    cin >> n >> m;
    ll p[m];
    string s[m];
    ll af[n+1],wf[n+1];
    for(int i = 0;i <= n;i++){
        af[i] = wf[i] = 0;
    }
    for(int i = 0; i< m;i++){
        cin >> p[i] >> s[i];
    }
    ll ac = 0,wa = 0;
    for(int i = 0;i < m;i++){
        if(s[i] == "AC"){
            af[p[i]]++;
        }else{
            if(af[p[i]] == 0)
            wf[p[i]]++;
        }
    }
    for(int i = 0;i <= n;i++){
        if(af[i] != 0){
            ac++;
            wa+=wf[i];
        }
    }
    cout << ac << " " << wa << endl;
}

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


Measured memory_bytes: 8064
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n,m;
	std::cin >> n >> m;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	std::sort(all(a));
	std::vector<int> ac(n+1,0);
	rep(i,n) ac[i+1] = ac[i]+a[i];

	// binary search
	int max = 0;
	int l=-1,r=2e5+1;
	while(r-l>1) {
		int mid = (l+r)/2;
		debug(r,l,mid);
		int sum = 0;
		int count = 0;
		rep(i,n) {
			auto lb = std::lower_bound(all(a),mid-a[i]);
			int cnt = i-(lb-a.begin())+1;
			if(cnt<=0) continue;
			cnt = (cnt-1)*2+1;
			debug(a[i],cnt);
			sum+=cnt*a[i];
			sum+=(ac[i]-ac[(lb-a.begin())])*2+a[i];
			count+= cnt;
		}
		debug(sum,sum-mid*(count-m),count,m);
		if(count>=m) {
			l=mid;
			max = sum-mid*(count-m);
		}
		else {
			r=mid;
		}
	}
	print(max);

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'e' || c == 'i'|| c == 'o' || c == 'u') {
      cout << "vowel" << endl;
  } else {
      cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int h,w;
    cin >> h >> w;
    char c[h+2][w+2];
    rep(i,h){
        rep(j,w){
            cin >> c[i+1][j+1];
        }
    }
    rep(i,h+2){
        rep(j,w+2){
            if(i==0 || i==h+1 || j==0 || j==w+1) c[i][j]='#';
        }
    }
    rep(i,h+2){
        rep(j,w+2){
            cout << c[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug1(x) cout << #x << " " << x << endl;
#define debug2(x,y) cout << #x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout << #x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;

typedef long long ll;
using namespace std;

void readFile() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

ll binpow(ll a,ll b) {    // a^b
    if(b==0) return 1;
    long long res = binpow(a,b/2);
    if(b%2)
        return res*res*a;
    else
        return res*res;
}

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

    int n;
    cin >> n;
    if(n%1000==0)
        cout << "0\n";
    else {
        cout << (n/1000+1)*1000-n << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<string>
#include<cfloat>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<map>
#include<functional>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
const int mod = 1e9+7;
const int INFINT = INT_MAX/2;
typedef long long ll;
typedef unsigned long long ull;
int dp[40][100000];

void makeDoubling(vector<ull> &xs, ull L){
    int N = xs.size();
    for (int i=0;i<N;i++){
        dp[0][i] = lower_bound(xs.begin(), xs.end(), xs[i]+L+1) - xs.begin() - 1;
    }
    for (int i=1;i<40;i++){
        for (int j=0;j<N;j++){
            dp[i][j] = dp[i-1][dp[i-1][j]];
        }
    }
    return;
}

int MinimumDays(int a, int b){
    if(a > b) swap(a, b);
    int now = a;
    int res = 0;
    for (int i=39;i>=0;i--){
        if(dp[i][now] < b){
            now = dp[i][now];
            res += 1<<i;
        }
    }
    res++;
    return res;
}

int main(){
    int N, x;
    cin >> N;
    vector<ull> xs(N);
    for(int i=0;i<N;i++){
        cin >> x;
        xs[i] = x;
    }
    ull L;
    int Q, a, b;
    cin >> L >> Q;
    makeDoubling(xs, L);

    for (int i=0;i<Q;i++){
        cin >> a >> b;
        cout << MinimumDays(a-1, b-1) << endl;
    }

    return 0;
}

Measured memory_bytes: 17280
from itertools import chain

N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()

m = N // 2
L, R = A[:m], A[m:]

def sumOfDiff(A):
    """隣の要素との差の合計"""
    return sum(abs(a - b) for a, b in zip(A, A[1:]))

def merge(L, R):
    """[L[0], R[0], L[1], R[1], ...]"""
    return list(chain.from_iterable(zip(L, R)))

if N % 2 == 0:
    # Rの最小値とLの最大値を端に
    s = sumOfDiff(merge(R, L))
else:
    L.reverse()
    B1 = merge(L, R[1:]) + [R[0]]  # Lの最大値が端
    B2 = merge(R[1:], L) + [R[0]]  # Rの最小値が端
    s = max(sumOfDiff(B1), sumOfDiff(B2))

print(s)


Measured memory_bytes: 10456
N=int(input())
S=[input() for i in range(N)]
M,A,R,C,H=0,0,0,0,0
for i in S:
  if i[0]=='M':
    M+=1
  elif i[0]=='A':
    A+=1
  elif i[0]=='R':
    R+=1
  elif i[0]=='C':
    C+=1
  elif i[0]=='H':
    H+=1
ans=M*A*R+M*A*C+M*A*H+M*R*C+M*R*H+M*C*H+A*R*C+A*R*H+A*C*H+R*C*H
print(ans)

Measured memory_bytes: 9776
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include <map>

#define ll long long int
#define ull unsigned long long int

#define INF 100000000000L

using namespace std;

ll N,M;
vector<pair<ll,ll>> S;

int main(){
    cin >> N >> M;
    S.resize(N);
    for(int i=0;i<N;i++){
        ll a,b;
        cin >> a >> b;
        S[i] = make_pair(a,b);
    }
    sort(S.begin(),S.end());
    ll count =0;
    ll sum = 0;
    for(int i=0;i<N;i++){
        ll a,b;
        a = S[i].first;
        b = S[i].second;
        if(count + b < M){
            sum += a*b;
            count += b;
            continue;
        }
        sum += a*(M-count);
        break;
    }
    cout << sum << endl;
    return 0;
}

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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;

ll n;
int perm[15];

void brute(){
	for(int i = 0; i < n; i++){
		perm[i] = i + 1;
	}
	
	ll mx = 0;
	do {
		ll ans = 0;
		for(int i = 0; i < n; i++){
			int ii = i + 1;
			ans += ii % perm[i];
		}

		mx = max(mx, ans);
	}	while(next_permutation(perm, perm + n));

	cout << mx << '\n';
}

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

	ll ans = n * (n - 1) / 2;

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
using namespace std;
#define N 200012
typedef long long ll;
const int p=1e9+7;
int n,m;
int a[N],dp[18][N];
int f[N],inv[N],finv[N],siz[N];
inline int C(int nn,int mm)
{
	if(nn==mm||mm==0)return 1;
	else if(nn<mm)return 0;
	else return 1ll*f[nn]*finv[mm]%p*finv[nn-mm]%p;
}
int main()
{
	scanf("%d%d",&n,&m);
	f[1]=inv[1]=finv[1]=1;
	for(int i=2;i<=200000;i++)
	{
		inv[i]=1ll*(p-p/i)*inv[p%i]%p;
		f[i]=1ll*f[i-1]*i%p;
		finv[i]=1ll*finv[i-1]*inv[i]%p;
	}
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	sort(a+1,a+1+m);reverse(a+1,a+1+m);
	dp[0][0]=1;if(a[m]==2){puts("0");return 0;}
	for(int i=1;i<=m;i++)
	{
		for(int j=0;j<(1<<n);j++)
		{
			(dp[i][j]+=dp[i-1][j])%=p;
			for(int k=1;k<=n;k++)
			{
				if(j&(1<<(k-1)))continue;
				dp[i][j|(1<<(k-1))]+=1ll*dp[i-1][j]*f[1<<(k-1)]%p*C((1<<n)-a[i]-j,(1<<(k-1))-1)%p;
				dp[i][j|(1<<(k-1))]%=p;
			}
		}
	}
	int ans=0;
	for(int s=0;s<(1<<n);s++)
	{siz[s]=siz[s>>1]+(s&1);
		int te=1ll*dp[m][s]*f[(1<<n)-s-1]%p;
		if(siz[s]&1)ans=(ans-te+p)%p;
		else ans=(ans+te)%p;
	}
	ans=1ll*ans*(1<<n)%p;
	printf("%d\n",ans);
}
/*
4 4
2 8 11 13 

*/

Measured memory_bytes: 16128
package main

import "fmt"

var N, T int
var t []int
var values []int

func getValues(i int) int {
	if t[i-1] < t[i]-T {
		return values[i-1] + T
	} else {
		return values[i-1] + T - (t[i-1] + T - t[i])
	}
}

func main() {
	fmt.Scan(&N, &T)
	tmp := 0
	t = make([]int, N)
	values = make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&tmp)
		t[i] = tmp
	}
	values[0] = T

	for i := 1; i < N; i++ {
		values[i] = getValues(i)
	}
	fmt.Println(values[N-1])
}


Measured memory_bytes: 7808
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  string s;cin>>s;
  rep(i, 0, 3){
    if (s[i]==s[i+1]){
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int W = scan.nextInt();
        int a = scan.nextInt();
        int b = scan.nextInt();
        if (b < a) {
            int t = a;
            a = b;
            b = t;
        }
        int answer = 0;
        if (b <= a + W) {
            answer = 0;
        } else {
            answer = b - a - W;
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <math.h>
#include <stdio.h>

using namespace std;

int main() {
  int N, T, A;
  cin >> N >> T >> A;
  double t = 1'000'000;
  int res = 0;
  for (int i = 0; i < N; ++i) {
    int h;
    cin >> h;
    double _t = abs(A - (T - h * 0.006));
    if (_t < t) {
      res = i;
      t = _t;
    }
  }
  printf("%d\n", res + 1);
}

Measured memory_bytes: 3168
#include <map>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

#define x first
#define y second

#define INF 0x3f3f3f3f

using namespace std;

const int maxn = 1e5 + 10;

typedef long long LL;
typedef pair<int,int>PII;

int main(void) {
	string str;
	cin >> str;
	int a = 0,b = 0;
	for(int i = 0; i < str.length(); i ++) {
		if(str[i] == 'A') a ++;
		else b ++;
	}
	if(a == 3 || b == 3) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;

int main() {
	string s;
	cin >> s;
	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])cout << "Bad" << endl;
	else cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    int n, K;
    scanf("%d%d", &n, &K);
    double ans = 0;
    For(i, 1, n+1){
        int j = i;
        double tmp = (double)1/n;
        while(j < K){
            j *= 2;
            tmp /= 2;
        }
        ans += tmp;
    }
    printf("%.20lf\n", ans);
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static int Solve(int N, int[][] A)
        {
            int max = 0;
            for (int i = 0; i < N; ++i)
            {
                max = Math.Max(A[0].Take(i + 1).Sum() + A[1].Skip(i).Sum(), max);
            }
            return max;
        }

        static void Main(string[] args)
        {
            int N = ReadInt();
            int[][] A = new int[2][];
            for (int i = 0; i < 2; ++i) { A[i] = ReadInts(); }
            Console.WriteLine(Solve(N, A));
        }
    }
}


Measured memory_bytes: 13396
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int x = m % 10;
        if(x == 2 || x == 4 || x == 5 || x == 7 || x == 9){
            System.out.println("hon");
        }else if(x == 0 || x == 1 || x == 6 || x == 8){
            System.out.println("pon");
        }else{
            System.out.println("bon");
        }
    }
}


Measured memory_bytes: 35844
package main

import "fmt"

func main() {
	var n, m, c int
	fmt.Scan(&n)
	fmt.Scan(&m)
	fmt.Scan(&c)

	b := ScanNums(m)
	var re int
	for index := 0; index < n; index++ {
		a := ScanNums(m)
		var rs int
		for j := 0; j < m; j++ {
			rs += a[j] * b[j]
		}
		if rs+c > 0 {
			re++
		}
	}
	fmt.Printf("%#v\n", re)
}

func ScanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back

#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

signed main()
{
    speed
    int n,k;cin>>n>>k;
    std::vector<int> inp(n);
    int sum=0;
    for(int i=0;i<n;++i)
    {
        cin>>inp[i];
        sum+=inp[i];
    }
    vector<int> factors;
    int i;
    for(i=1;i*i<sum;++i)
    {
        if(sum%i==0)
        {
            factors.pb(i);
            factors.pb(sum/i);
        }
    }
    if(i*i==sum)
    {
        factors.pb(i);
    }
    sort(factors.begin(),factors.end(),greater<int>());
    for(auto ans:factors)
    {
        std::vector<int> vec;
        for(auto it:inp)
        {
            vec.pb(it%ans);
        }
        sort(vec.begin(),vec.end());
        int s=0,e=n-1,tot=0;
        while(s<e)
        {
            int a=vec[s];
            int b=ans-vec[e];
            if(a==b)
            {
                tot+=a;
                ++s;--e;
            }
            else
            {
                if(a>b)
                {
                    tot+=b;
                    --e;
                    vec[s]-=b;
                }
                else
                {
                    tot+=a;
                    ++s;
                    vec[e]+=a;
                }
            }
        }
        if(tot<=k)
        {
            cout<<ans<<"\n";return 0;
        }
    }
}

Measured memory_bytes: 256
//Atcoder series  of  7 contest 
//learning concepts through this 7 contest series
#include<bits/stdc++.h> 
#define int long long 
using namespace std; 
void solve(); 

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

#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin); 
	freopen("error.txt", "w", stderr); 
	freopen("output.txt", "w", stdout); 
#endif 
	int t=1; 
	/*is Single Test case?*/
	while(t--) 
	{ 
		solve(); 
		cout<<"\n"; 
	} 

	cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl; 
	return 0; 
} 
void solve() { 
	int x ;
	cin>>x;
	if(x>=30) cout<<"Yes";
	else cout<<"No";
} 


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll x, y;
    scanf("%lld%lld", &x, &y);

    // Ai+1はAiの倍数であり、かつAi+1はAiより真に大きい
    // Ai+1はAiの2倍のとき、配列の要素数を一番多くできる
    ll ans = 0;
    while(x <= y) {
        ans++;
        x *= 2;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3752
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args ) {
    Scanner sc = new Scanner(System.in);
    
    String a = sc.next();
    String b = sc.next();
    
    char[] A = new char[a.length()];
    for(int i =0; i< a.length(); i++){
      A[i]=a.charAt(i);
    }
    char[] B = new char[a.length()];
    for(int i =0; i< a.length(); i++){
      B[i]=b.charAt(i);
    }
    
    int num=0;
    for (int i =0; i< a.length(); i++){
      if (A[i]!=B[i]) {
        num = num + 1;
      }
    }
    System.out.println(num);
  }
}

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

long long dpres(int i, int w, vector<vector<long long>> &dp,vector<vector<long long>> l){
  if(dp.at(i).at(w) == -1){
    if(w < l.at(i-1).at(0)){
      dp.at(i).at(w) = dpres(i-1,w,dp,l);
    }else{
      dp.at(i).at(w) = max(dpres(i-1,w-l.at(i-1).at(0),dp,l) + l.at(i-1).at(1),dpres(i-1,w,dp,l));
    }
  }
  return dp.at(i).at(w);
}

int main() {
  int n,w;
  cin >> n >> w;
  vector<vector<long long>> l(n, vector<long long>(2));
  
  for (int i = 0; i < n; i++){
    for(int j = 0; j < 2; j++){
      cin >> l.at(i).at(j);
    }
  }
  vector<vector<long long>> dp(n+1, vector<long long>(w+1,0));
  for(int i = 1; i < n+1; i++){
    for(int j = 0; j < w+1; j++){
      if(j < l.at(i-1).at(0)){
        dp.at(i).at(j) = dp[i-1][j];
      }else{
        dp.at(i).at(j) = max(dp[i-1][j-l.at(i-1).at(0)] + l.at(i-1).at(1),dp[i-1][j]);

      }
    } 
  }
  
  cout << dp[n][w];
}

Measured memory_bytes: 80256
def main():
    n, k = map(int, input().split())
    a, b = [0 for i in range(n)], [0 for i in range(n)]
    for i in range(n):
        a[i], b[i] = [int(x) for x in input().split()]
    ans = solve(n, k, a, b)
    print(ans)


def solve(n, k, a, b):
    ab = [[a[i], b[i]] for i in range(n)]
    ab.sort(key = lambda x:x[0])
    back = 0
    for i in range(n):
        back += ab[i][1]
        if back >= k:
            return ab[i][0]
    return 


if __name__ == '__main__':
    main()

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

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

int main() {
    int d, t, s;
    cin >> d >> t >> s;

    if((float)d / s <= t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3564
// TOPSIC001_1

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

unsigned gcd(unsigned a, unsigned b) {
    if(a < b) return gcd(b, a);
    unsigned r;
    while ((r = a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int main(){
    int N; cin >> N;
    vi A(N);
    REP(i, N) cin >> A.at(i);

//    DEBUG_VEC(A);

    int ans = MOD;
    FOR(i, 0, N - 1){
        ans = min(ans, (int)gcd(A.at(i), A.at(i + 1)));
    }

    cout << ans;
}

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

int main()
{
  string s;
  cin >> s;
  if(s.at(0) == s.at(1) && s.at(1) == s.at(2)){
    cout << "No" << endl;
  } else { 
    cout << "Yes" << endl;
  }
  //cout << s << endl;
  return 0;
}


Measured memory_bytes: 256