akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define place 31
using namespace std;

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int>a(n);
	for(auto&i:a)cin>>i;
	vector<int>cnt1(place,0),cnt0(place,0);
	for(auto&i:a){
		int j=0,p=1;
		while(j<place){
			if(p&i)++cnt1.at(j);
			else ++cnt0.at(j);
			++j;
			p=p<<1;
		}
	}
	/*for(auto&i:cnt1)cout<<i<<"\t"s;
	cout<<"\n"s;
	for(auto&i:cnt0)cout<<i<<"\t"s;
	cout<<"\n"s;*/
	bool yes=true;
	for(int i=0;i<place;++i){
		if(cnt1.at(i)%2!=0||(cnt1.at(i)!=0&&cnt1.at(i)%2==0&&cnt0.at(i)==0)){
			yes=false;
		}
	}
	cout<<(yes?"Yes"s:"No"s)<<"\n"s;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	int t, st = 0, i;
	
	for (i = 0; i < 4; i++){
		scanf("%d", &t);
		st += t;
	}
	
	printf("%d\n%d\n", st / 60, st % 60);
	
	return (0);
}

Measured memory_bytes: 596
N,X,Y=map(int,input().split())
xdex=X-1
ydex=Y-1
l=[0]*(N)
#print(l)
le=0
#print(xdex,ydex)
for i in range(N):
    for j in range(i+1,N):
        le=(j-i)
        if (i<=xdex)and(ydex<=j):
            le = min(j - i, (j - i) - (Y - X - 1))
        elif ((i<=xdex)and(j<=ydex)and(xdex<=j)):
            le=min(j - i, (xdex-i)+(ydex- j)+1)
        elif ((xdex<i)and(j<=ydex)and(xdex<=j)):
            le=min(j-i,(i-xdex)+(ydex-j)+1)
        elif ((xdex<i)and(ydex<j)):
            le=min(j-i,(i-xdex)+(j-ydex)+1)
        #print(i+1,j+1,le)
        l[le]=l[le]+1
#print(l)
for i in range(N-1):
    print(l[i+1])

Measured memory_bytes: 48028
import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main()
{
auto x = readln.chomp.to!int;
writeln(x^^3);
}


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

int main()
{
    vector<long> limit(7,0);
    long n,a,b,c,d,e;
    cin >> n >> limit[1] >> limit[2] >> limit[3] >> limit[4] >> limit[5];
    long ans = 0;
    vector<long> town(7,0);
    town[1] = n;

    for(int i = 1; i <= 5; i++){
        if(town[i]%limit[i] > 0){
            ans += town[i]/limit[i]+1;
        }else{
            ans += town[i]/limit[i];
        }
        town[i+1] = n - (ans-i)*limit[i+1];
        if(town[i+1] <= 0){
            town[i+1] = min(town[i],limit[i]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
const int maxn=300005;

int main(){
    int a,b,k;
    cin >> a >> b >> k;
    int aa=a;
    while(aa<a+k&&aa<=b){
        printf("%d\n",aa++);
    }
    int bb=b-k+1;
    if(bb<aa) bb=aa;
    while(bb<=b){
        printf("%d\n",bb++);
    }
    return 0;
}


Measured memory_bytes: 256
/*input
8
2 2 3 3 3 3 3 3
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define int long long
#define N

int n;
vector<int> a;
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef UncleGrandpa
	freopen("1test.inp", "r", stdin);
#endif
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int x; cin >> x;
		a.push_back(x);
	}
	sort(a.begin(), a.end());
	if (a.back() - a.front() >= 2) {
		cout << "No" << endl;
		return 0;
	} else if (a.back() - a.front() == 1) {
		int cntx = 0, cnty = 0;
		for (int i = 0; i < a.size(); i++) {
			if (a[i] == a[0]) cntx++;
			else cnty++;
		}
		if (cntx + 1 <= a.back() && a.back() <= cntx + cnty / 2) {
			cout << "Yes" << endl;
			return 0;
		}
		cout << "No" << endl;
		return 0;
	}
	else {
		if (a.back() + 1 != n && n < a.back() * 2) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <set>

using namespace std;

#define ALL(co) co.begin(), co.end()
#define tpl(...) make_tuple(__VA_ARGS__)

typedef long long LL;
typedef pair<int, int> P; typedef pair<int, P> IP; typedef pair<P, P> PP;
typedef vector<int> Array; typedef vector<vector<int> > Array2;
typedef vector<LL> LArray; typedef vector<P> PArray; typedef vector<string> SArray;

const int INF = 1 << 29;
const LL LINF = 1LL << 60;

inline int getInt() { int itiv; return (cin >> itiv, itiv); }
template <typename T> void readAll(vector<T>& vec) { for (int i = 0, size = vec.size(); i < size; i++) cin >> vec[i]; }
template <typename T, typename U> void readAll(vector<pair<T, U> >& vec) { for (int i = 0, size = vec.size(); i < size; i++) cin >> vec[i].first >> vec[i].second; }
template < typename T > inline string toString( const T &a ){ ostringstream oss; oss << a; return oss.str(); };
inline bool between(int min, int max, int n) { return min <= n && n <= max; }
inline bool inRange(int begin, int end, int n) { return begin <= n && n < end; }
inline bool inRange(int size, int n) { return 0 <= n && n < size; }

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

int m, n;

int main(void)
{
	while(cin >> n >> m && n)
	{
		vector<vector<double> > table(n, vector<double>(n));
		for (int i = 0; i < n; i++)
		{
			readAll(table[i]);
		}
		
		vector<double> next(n);
		vector<double> now(n, 1);

		for (int i = 1; i < m; i++)
		{
			for (int j = 0; j < n; j++)
			{
				next[j] = now[0] * table[j][0];
				for (int k = 0; k < n; k++)
				{
					next[j] = max(next[j], now[k] * table[j][k]);
				}
			}
			now = next;
		}
		printf("%.2f\n", *max_element(ALL(now)));
	}
	return 0;
}

Measured memory_bytes: 1348
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.HashMap;

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

    static class AZeroSumRanges {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int n = in.nextInt();
            HashMap<Long, Integer> hm = new HashMap<>();
            long ad = 0;
            long res = 0;
            hm.put(ad, 1);
            for (int i = 0; i < n; i++) {
                ad += in.nextLong();
                hm.merge(ad, 1, Integer::sum);
            }


            for (int i : hm.values()) {
                long j = i;
                res += (j * j - j) / 2;
            }
            out.println(res);

        }

    }
}



Measured memory_bytes: 102588
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
int main() {
  int A,B;
  cin >> A >> B;
  if (A == 1) A = 14;
  if (B == 1) B = 14;
  if (A > B) cout << "Alice" << endl;
  if (A < B) cout << "Bob" << endl;
  if (A == B) cout << "Draw" << endl;
}

Measured memory_bytes: 256
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)


def read_values():
    return map(int, input().split())


def read_index():
    return map(lambda x: x - 1, map(int, input().split()))


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def functional(N, mod):
    F = [1] * (N + 1)
    for i in range(N):
        F[i + 1] = (i + 1) * F[i] % mod
    return F


INV = dict()
def inv(a, mod):
    if a in INV:
        return INV[a]
    i = pow(a, mod - 2, mod)
    INV[a] = i
    return i 


def C(F, a, b, mod):
    return F[a] * inv(F[a - b], mod) * inv(F[b], mod) % mod 


def main():
    N, K = read_values()
    mod = 10 ** 9 + 7
    F = functional(5 * 10 ** 5, mod)
    res = 0
    if N <= K:
        res = C(F, 2 * N - 1, N - 1, mod)
    else:
        c = C(F, N - 1, 0, mod)
        for k in range(K + 1):
            res += pow(c, 2, mod) * N * inv(N - k, mod) % mod
            c *= ((N - k - 1) * inv(k + 1, mod)) % mod
            c %= mod
    
    print(res % mod)

if __name__ == "__main__":
    main()

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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

#define int long long


signed main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; ++i) cin >> v[i];

    int ans = 1;
    int x = v[0];
    int f = -1;
    for(int i=1; i<v.size(); ++i) {
        int y = v[i];
        if(f==-1) {
            if(y>x) f = 1;
            else if(y<x) f = 0;
        }
        else if(f==1) {
            if(y<x) {
                ans++;
                f = -1;
            }
        }
        else if(f==0) {
            if(x<y) {
                ans++;
                f = -1;
            }
        }
        x = y;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
import sys


def solve(inp):
    A = list(map(int, inp.readline().strip().split(' ')))

    A = sorted(A)
    if A[0] == 5 and A[1] == 5 and A[2] == 7:
        return "YES"
    else:
        return "NO"


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
s = raw_input()
s = list(s)
K = int(raw_input())
# _s, _K = s[:], K
a = "abcdefghijklmnopqrstuvwxyz"
# ai = a.index("a")
zi = a.index("z") 
si = [zi - a.index(c) + 1 if c != "a" else 0  for c in s]

for i, (c, ci) in enumerate(zip(s, si)):
    if K == 0:
        break
    if c == "a":
        continue
    if ci <= K:
        s[i] = 'a'
        K = K - ci

K = K % len(a)
if K > 0:
    s[-1] = a[a.index(s[-1]) + K]

print("".join(s))

Measured memory_bytes: 12164
N, K = map(int, input().split())
A = list(map(int, input().split()))

import collections
from itertools import accumulate

c = collections.Counter(A)
_, counts = zip(*c.most_common()[::-1])
counts = list(accumulate(counts))
cnt = 0
inf = 10 ** 18

target = len(counts) - K 
 
if target <= 0:
  print(0)
else:
  print(counts[target-1])

Measured memory_bytes: 53556
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <cassert>
using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    priority_queue<int> pq;
    for(int i=0; i<N; i++){
        int A;
        cin >> A;
        pq.push(A);
    }
    for(int i=0; i<M; i++){
        int tp = pq.top();
        pq.pop();
        tp /= 2;
        pq.push(tp);
    }
    long long ans = 0;
    while(!pq.empty()){
        int x = pq.top();
        pq.pop();
        ans += x;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    ll ans, x = 0, y = 0;
    Rep(i, N) {
        cin >> A[i];
        if (i) x += A[i];
        else y += A[i];
    }
    ans = abs(x - y);
    for (int i = 1; i < N - 1; i++) {
        x -= A[i];
        y += A[i];
        ans = min(ans, abs(x - y));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4824
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
template<class T> inline bool chmax(T &a,T b){
  if (a<b){
    a=b;
    return 1;
  }
  return 0;
}
ll dp[100][2];

int main(){
  int n; ll k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  
  rep(i,100) dp[i][0] = dp[i][1] = -1; //初期化
  dp[45][0] = 0;
  for(int d = 44; d >= 0; d--){
    ll mask = 1LL << d;
    int num = 0;
    rep(i,n) if(a[i] & mask) num++;
    if(dp[d+1][1] >= 0) chmax(dp[d][1], dp[d+1][1] + mask * max(num,n-num));
    if(dp[d+1][0] >= 0) {
      if(k & (1LL << d)){
        chmax(dp[d][1],dp[d+1][0] + mask * num);
        chmax(dp[d][0],dp[d+1][0] + mask * (n-num));
      }else{
        chmax(dp[d][0],dp[d+1][0] + mask * num);
      }
    }
  }
  cout << max(dp[0][0],dp[0][1]) << endl;
  return 0;
}

Measured memory_bytes: 1024
// 2010/12/22 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		int kosu[10];
		for(int i=0; i<10; i++)
			kosu[i] = 0;

		for(int i=0; i<n; i++){
			int ice;
			cin >> ice;
			kosu[ice]++;
		}

		for(int i=0; i<10; i++)
			if(kosu[i]!=0){
				for(int j=0; j<kosu[i]; j++)
					cout << '*';
				cout << endl;
			}
			else{
				cout << '-' << endl;
			}
	}

	return 0;
}

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

namespace AtCoder.Heuristics
{
    class Introduction
    {
        private static int GeneN = 50;

        private static int DayN;

        private static int ContestN = 26;

        private static int[] c;

        private static int[][] s;

        private static int sumC;

        class Gene
        {
            public int[] Contest;
            public int[] Score;
            public Gene()
            {
                Contest = new int[DayN + 1];
                Score = new int[DayN + 1];
            }
        }

        public static void Score(int[] t, int[] v)
        {
            var last = new int[DayN + 1];
            var sum = c.Sum();
            var dec = 0;
            v[0] = 0;
            for (int i = 1; i <= DayN; i++)
            {
                dec += sum - (c[t[i]] * (i - last[t[i]]));
                last[t[i]] = i;
                v[i] = v[i-1] - dec + s[i][t[i]];
            }
        }

        public static void Main()
        {
            DayN = int.Parse(Console.ReadLine());
            c = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            c.Select((index, x) => (index: index, c: x)).OrderByDescending(x => x.c);

            sumC = c.Sum();

            s = new int[DayN + 1][];

            List<int[]> gene = new List<int[]>();

            var random = new Random();

            var seed = Enumerable.Range(0, 26);

            
            seed.OrderBy(x => random.Next());


            var t = new int[DayN + 1];
            for (int i = 1; i <= DayN; i++)
                s[i] = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            t = InitByGreedy();
            for (int i = 1; i <= DayN; i++)
                Console.WriteLine(t[i] + 1);
        }


        private static int[] InitByGreedy()
        {
            var gene = new int[DayN + 1];
            var last = new int[DayN + 1];
            var sum = c.Sum();
            for (int i = 1; i <= DayN; i++)
            {
                int max = int.MinValue;
                int maxIndex = 0;
                for (int j = 0; j < ContestN; j++)
                {
                    var temp = c[j] * last[j] * (DayN - i + 1) + s[i][j];
                    if (max < temp)
                    {
                        max = temp;
                        maxIndex = j;
                    }
                }
                last[maxIndex] = i;
                gene[i] = maxIndex;
            }
            return gene;
        }
    }
}


Measured memory_bytes: 28800
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<stack>
using namespace std;
int main(){
    string str;
    while(getline(cin,str)){
        stack<double> S;
        double now=0;
        for(int i=0;i<str.size();i++){
            if('0'<=str[i]&&str[i]<='9'&&now<0){
                now=now*10-(str[i]-'0');
            }
            else if('0'<=str[i]&&str[i]<='9'){
                now=now*10+(str[i]-'0');
                if(i){
                    if(str[i-1]=='-')now*=-1;
                }
            }
            else if(str[i]==' '&&'0'<=str[i-1]&&str[i-1]<='9'){
                S.push(now),now=0;
            }
            else if(str[i]!=' '&&(str[i+1]==' '||i==str.size()-1)){
                double a,b;
                b=S.top();S.pop();
                a=S.top();S.pop();
                if(str[i]=='+')S.push(a+b);
                if(str[i]=='-')S.push(a-b);
                if(str[i]=='*')S.push(a*b);
                if(str[i]=='/')S.push(a/b);
            }
        }

        if(!S.size()){
            cout<<str<<endl;
        }
        else printf("%.12f\n",S.top());

        //printf("%.12f\n",S.top());
    }
    return 0;
}

Measured memory_bytes: 1244
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto abc = readints;
    int a = abc[0], b = abc[1], c = abc[2];

    if (a <= c && c <= b)
        writeln("Yes");
    else
        writeln("No");
}


Measured memory_bytes: 256
def resolve():
    a, b, c, d = map(int, input().split())
    if a<b<=c<d:
        print(0)
    elif c<=a<b<=d:
        print(b - a)
    elif a<c<b<d:
        print(b - c)
    elif a <= c < b < d:
        print(b - c)
    elif c < a < d < b:
        print(d - a)
    elif c<d<=a<b:
        print(0)
    elif c<a<d<b:
        print(b-c)
    elif a<=c<d<=b:
        print(d-c)
    elif a<c<b<d:
        print(b-c)

resolve()

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define vi vector<int>

#define ll long long
#define vl vector<ll>
#define vll vector<vl>

const int INF = 1e9;
int n;
ll k;
ll a[1000010];
ll f[1000010];

bool han(ll x)
{
	ll sum=0;
	rep(i, n)
	{
		ll b=f[n-1-i];
		ll tm=a[i]*b-x;
		if(tm<0) tm=0;
		sum+=(tm+b-1)/b;
	}
	if(sum<=k) return true;
	else return false;
}

int main() {
	cin >> n >> k;
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> f[i];
	sort(a, a+n);
	sort(f, f+n);
	if(han(0))
	{
		cout << '0' << endl;
		return 0;
	}
	ll l=0, r=1000000000000;
	while(r-l>1)
	{
		ll m=(l+r)/2;
		if(han(m)) r=m;
		else l=m;
	}
	if(han(l)) cout << l << endl;
	else cout << r << endl;
	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> n(N, vector<int>(2));
  vector<vector<int>> m(M, vector<int>(2));
  for (int i = 0; i < N; i++) cin >> n[i][0] >> n[i][1];
  for (int i = 0; i < M; i++) cin >> m[i][0] >> m[i][1];

  for (int i = 0; i < N; i++) {
    int ans = 0;
    int min_d = pow(10, 9);
    for (int j = 0; j < M; j++) {
      int d = abs(n[i][0] - m[j][0]) + abs(n[i][1] - m[j][1]);
      if (d < min_d) {
        ans = j + 1;
        min_d = d;
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
using namespace std;
int n,a[102];
long long ans=LONG_LONG_MAX;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=a[1];i<=a[n];i++)
    {
        long long num=0;
        for(int j=1;j<=n;j++)
            num+=(long long)(a[j]-i)*(long long)(a[j]-i);
        if(num<ans) ans=num;
    }
    cout<<ans;
}


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


int main() {
	int n;
	cin >> n;
	long long a[201010];
	for (int i=0; i<n; i++) cin >> a[i+1];

	long long max_ch[201010], ht[201010];
	max_ch[1] = a[1];
	ht[1] = a[1];
	max_ch[2] = max(a[2], a[1]);
	max_ch[3] = max(max_ch[2], a[3]);
	ht[3] = a[1] + a[3];
	for (int i=4; i<=n; i++) {
		long long r1 = max_ch[i-2] + a[i];
		long long r2;
		if (i%2) r2 = max_ch[i-3] + a[i-1];
		else {
			r2 = ht[i-3] + a[i-1];
			ht[i-1] = r2;
		}
		max_ch[i] = max(r1, r2);
		//cout << i << ": " << max_ch[i] << " " << a[i] << endl;
	}

	cout << max_ch[n] << endl;
}


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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  int a, b;
  cin >> a >> b;

  cout << (a + b + 1) / 2 << endl;
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;

int dp[1000];

int main()
{
    int n;
    while(scanf(" %d", &n),n)
    {
        vector<pi> p(n);
        rep(i,n) scanf(" %d %d", &p[i].fi, &p[i].se);
        sort(all(p));

        if(n==1)
        {
            printf("%d\n", p[0].fi*2+p[0].se);
            continue;
        }

        int sum_r=0;
        rep(i,n) sum_r+=p[i].fi;

        if(sum_r - p[n-1].fi >= p[n-1].fi)
        {
            // 2?????¨???sum_r??§???????????????
            int ans=sum_r;
            rep(i,n) ans+=p[i].se;
            printf("%d\n", ans);
        }
        else
        {
            // 2*p[n-1].fi???????????????
            memset(dp,0,sizeof(dp));

            // 0~n-2?????????????????¨??????????????????????????????
            int rem = p[n-1].fi - (sum_r-p[n-1].fi);

            // n-1?????????????????????????????????????????¢???
            dp[0]=1;
            rep(i,n-1)
            {
                for(int j=rem; j>=0; --j)if(dp[j]) dp[j+p[i].se]=1;
            }

            int ok=0;
            rep(i,rem+1)if(dp[i]) ok=i;

            int sum_w=0;
            rep(i,n) sum_w+=p[i].se;

            printf("%d\n", 2*p[n-1].fi+sum_w-ok);
        }
    }
    return 0;
}

Measured memory_bytes: 3212
import java.util.*;

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;
	
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		Card[] A1 = new Card[n], A2 = new Card[n];
		for(int i = 0; i < n; ++i){
			String s = sc.next();
			A1[i] = new Card();
			A1[i].suit = s.charAt(0);
			A1[i].num = (s.charAt(1) - '0');
			A2[i] = new Card();
			A2[i].suit = A1[i].suit;
			A2[i].num = A1[i].num;
			}
		sc.close();
		bubbleSort(A1);
		selectionSort(A2);
		printCards(A1);
		System.out.println("Stable");
		printCards(A2);
		System.out.println((isStable(A1, A2) ?"Stable" : "Not stable"));
	}
	
	public static void printCards(Card[] a){
		int n = a.length;
		for(int i = 0; i < n; ++i){
			if(i != 0) System.out.print(" ");
			System.out.printf("%c%d", a[i].suit, a[i].num);
		}
		System.out.println();
	}
	
	public static void bubbleSort(Card[] a){
		int n = a.length;
		boolean flag = true;
		for(int i = 0; flag && (i < n); ++i){
			flag = false;
			for(int j = n-1; j > i; --j){
				if(a[j-1].num > a[j].num){
					{//swap(a[j-1], a[j]の代わり
						Card temp = a[j-1];
						a[j-1] = a[j];
						a[j] = temp;
					}
					flag = true;
				}
			}
		}
	}
	
	public static void selectionSort(Card[] a){
		int n = a.length;
		for(int i = 0; i < n; ++i){
			int minidx = i;
			for(int j = i; j < n; ++j){
				if(a[j].num < a[minidx].num) minidx = j;
			}
			if(i != minidx){
				{//swap(a[i], a[minidx])
					Card temp = a[i];
					a[i] = a[minidx];
					a[minidx] = temp;
				}
			}
		}
	}
	
	public static boolean isStable(Card[] a, Card[] b){
		//a.bはソート済み。aは安定、bを調べる。個数は同じ
		int n = a.length;
		for(int i = 0; i < n; ++i){
	        if(a[i].suit != b[i].suit) return false;
	    }
	    return true;
	}
	
	static class Card{
		char suit; int num;
	}
}


Measured memory_bytes: 26344
// Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector <ll> vec;
typedef pair <ll, ll> pr;
typedef pair <ll, pr> pr2;
typedef map <ll, vector<ll> > mv;

const int MX = 2e6+10;
const int mod = 1e9 + 7;
const ll inf = 1LL << 62;

int dx4[] = { 0, 0, -1, 1 };
int dy4[] = { 1, -1, 0, 0 };

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

// TOOLS
#define LCM(a,b)        (a / __gcd(a,b) ) *b
#define gcd(a,b)        __gcd(a,b)
#define all(x)          (x).begin(), (x).end()
#define mem(a, n)       memset(a, n, sizeof(a))
#define for1(i, n)      for(int i=1; i<=n; i++)
#define for0(i, n)      for(int i=0; i<n; i++)
#define rof0(i, n)      for(int i=n-1; i>=0; i--)
#define rof1(i, n)      for(int i=n; i>=1; i--)
#define forab(i, a, b)  for(int i=a; i<=b; i++)
#define rofab(i, a, b)  for(int i=b; i>=a; i--)
#define pb              push_back
#define pbb             pop_back

// CIN/COUT
#define sin(s)          getline(cin, s)
#define case(a)              cout << "Case "<<(a)<<": "

// SCANF/PRINTF
#define fYES            printf("YES\n")
#define fNO             printf("NO\n")
#define Scf(a)          scanf("%lld", &a)
#define Scf2(a, b)      scanf("%lld %lld", &a, &b)
#define Scf3(a, b, c)   scanf("%lld %lld %lld", &a, &b, &c)
#define Scf4(a,b,c,d)   scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define Pnf(a)          printf("%lld\n", a)
#define Pnf2(a, b)      printf("%lld %lld\n", a, b)
#define Pnf3(a, b, c)   printf("%lld %lld %lld\n", a, b, c)
#define Bug(n)          printf(">> %lld <<\n", n)

// OTHERS
#define sz(n)          n.size()
#define clr(v)          v.clear()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in              freopen("input.txt", "r", stdin)
#define out             freopen("output.txt", "w", stdout)
#define FastIO          { ios_base::sync_with_stdio(false); cin.tie(0); }
#define F               first
#define S               second
#define mpp             make_pair
//End
vector<int> v;
map<ll,vector<ll> > mp;
priority_queue<ll> PQ;
//priority_queue<pair<ll,ll> >PQ;
int main()
{

    ll n, m, k, q, t, cnt = 0, sum = 0,ans=0, mx = -inf, mn = inf, a, b, c,d,e,f,g,h,i,j ,x, y, z,temp, temp1;
    string s, s1, s2, s3;
    cin>>n>>m;
    cout<<(n*m)-(n+m-1)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
int gcd(ll a, ll b){
    if(b == 0) return a;
    gcd(b,a%b);
}


int main() {
  int N;
  cin >> N;
  double ans = 0;
  if(N%2 == 0){
    ans = 0.5;
  }
  else{

    ans = ((N/2) + 1.0)/N;
  }
  cout << fixed << setprecision(10);
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
string s,ss;cin>>s>>ss;
  ll ans = 0;
  for(int i=0;i<s.size();i++)
	ans += s[i]!=ss[i];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3772
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n=I()
Ts=LI()
m=I()
for i in range(m):
    a,b=MI()
    ans=sum(Ts)-Ts[a-1]+b
    print(ans)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

struct Unionfind {
	vector< int > par;
	Unionfind(int N) : par(N,-1){
	}
	bool unite(int x, int y) {
		x = root(x), y = root(y);
		if(x == y) return 0;
		if(par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return 1;
	}
	int root(int k) {
		if(par[k] < 0) return (k);
		return (par[k] = root(par[k]));
	}
	bool same(int x, int y){
		x = root(x);
		y = root(y);
		return x==y;
	}
	int size(int k) {
		return (-par[root(k)]);
	}
};

int main(){
  
  int n,m; cin>>n>>m;
  Unionfind uf(n);
  for(int i=0; i<m; i++){
    int a,b; cin>>a>>b;
    --a; --b;
    uf.unite(a,b);
  }
  int ans{};
  for(int i=0; i<n; i++){
    ans = max(ans,uf.size(i));
  }
  cout << ans << endl;
}


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

int main() {
    int n; cin>>n;
    while(n != 0){
        int s[n], sum=0;
        for(int i=0; i<n; i++) cin>>s[i], sum+=s[i];
        sort(s, s+n);
        cout << (sum-s[0]-s[n-1])/(n-2) << endl;
        cin >> n;
    }
}



Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
const int inf = 0x3f3f3f3f;
const ll linf = 123456789012345678;
const ll mod = 1000000007;
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << x << endl
#define sz(x) ((int)(x).size())

int n, u, v;
vvi adj;
vi p, d;

void root(int node, int par, int depth){
    p[node] = par;
    d[node] = depth;
    for(int x : adj[node]){
        if(x == par) continue;
        root(x, node, depth+1);
    }
}

int solve(int node, int steps){
    int r = steps;
    for(int x : adj[node]){
        if(x == p[node]) continue;
        r = max(r, solve(x, steps+1));
    }
    return r;
}

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

    cin >> n >> u >> v;
    u--,v--;
    adj = vvi(n);
    for(int i = 0; i < n-1; i++){
        int a, b;
        cin >> a >> b;
        a--,b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    p = vi(n);
    d = vi(n);
    root(v, -1, 0);
    int m = u;
    for(int i = 0; i < (d[u]-1)/2; i++){
        m = p[m];
    }
    int ans = solve(m, d[m])-1;
    cout << ans << endl;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int a,b;
signed main()
{
    a=read(), b=read();
    if(a==1) a+=13;
    if(b==1) b+=13;
    if(a<b) puts("Bob");
    else if(a==b) puts("Draw");
    else puts("Alice");
    return 0;
}

Measured memory_bytes: 3544
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,n) for(int i=0;i<n;++i)
#define rep(j,n) for(int j=0;j<n;++j)
#define REP(i,n) for(int i=1;i<=n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define len(s)   ((int)s.size())
#define F first
#define S second
#define pb push_back
#define pf push_front
#define m_p make_pair
typedef long long ll;
typedef double db;
typedef vector<ll> ve;
typedef vector<pair<int, int> > vepa;
typedef set<string>se;
typedef map<int,int> mpp;
const ll N=1024,OO=1e14,MOD=1e9+7;
const int di[]={1,-1,0,0};
const int dj[]={0,0,1,-1};
ll TC,n,m,k,a,b,cnt,sum,mx,mn,arr[N];
bool f,vis[N];
int main(){
   IOS;
   string s;
   cin>>s;
    rep(i,len(s))
   {
       if(s[i]=='S'){
        mx=max(mx,cnt);
        cnt=0;
       }else cnt++;
   }
   mx=max(mx,cnt);
   cout<<mx;
go;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	lint ans = 0;
	if (A + B > 2 * C) {
		if (X > Y) { 
			ans += 2 * Y * C;
			X -= Y;
			Y = 0;
		}
		else {
			ans += 2 * X * C;
			Y -= X;
			X = 0;
		}
	}

	if (X > 0) {
		if (A > 2 * C) ans += 2 * C * X;
		else ans += A * X;
	}
	if (Y > 0) {
		if (B > 2 * C) ans += 2 * C * Y;
		else ans += B * Y;
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n)    for (ll (i) = 0;   (i) < (n); ++(i))
#define FOR(i, a, b) for (ll (i) = (a); (i) < (b); ++(i))

signed main() {

    int N, M;   cin >> N >> M;

    vector<int> sw(N, 0);
    REP(i, M) {
        int K;  cin >> K;
        REP(j, K) {
            int S;  cin >> S;   --S;
            sw[S] |= 1 << i;
        }
    }

    int P = 0;
    REP(i, M) {
        int p;  cin >> p;
        P |= p << i;
    }

    int res = 0;
    REP(i, 1 << N) {
        int b = 0;
        REP(j, N) if (i & (1 << j)) b ^= sw[j];
        res += P == b;
    }
    cout << res << endl;

}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S, T = input().split()

print(T+S)


Measured memory_bytes: 3884
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


int main() {
    int n,m;
    cin >> n >> m;
    vector<ll> x,y;
    rep(i,0,n){
        ll tmp;
        cin >> tmp;
        x.push_back(tmp);
    }
    rep(i,0,m){
        ll tmp;
        cin >> tmp;
        y.push_back(tmp);
    }
    sort(all(x));
    sort(all(y));
    vector<ll> dx,dy;
    rep(i,1,x.size()){
        dx.push_back(x[i]-x[i-1]);
    }
    rep(i,1,y.size()){
        dy.push_back(y[i]-y[i-1]);
    }
    vector<ll> hx(n-1),hy(m-1);
    hx[0] = n-1;
    hy[0] = m-1;
    for(int i = 0; i < n-2; i++){
        hx[i+1] += hx[i] + ((n-1) - (i+1) * 2);
    }
    for(int i = 0; i < m-2; i++){
        hy[i+1] += hy[i] + ((m-1) - (i+1) * 2);
    }
    for(int i = 0; i < n; i++){
        hx[i] %= MOD;
    }
    for(int i = 0; i < m; i++){
        hy[i] %= MOD;
    }
    ll xx = 0;
    rep(i,0,dx.size()){
        xx += dx[i] * hx[i];
        xx %= MOD;
    }
    ll yy = 0;
    rep(i,0,dy.size()){
        yy += dy[i] * hy[i];
        yy %= MOD;
    }
    ll ans = xx * yy % MOD;

    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 5108
import java.util.*;

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

        String s = sc.next();

        char[] c = s.toCharArray();

        int t = 0;

        for (int i=0; i<s.length(); i++){
            if (i%2==0){
                if (c[i]=='R' || c[i]=='U' || c[i]=='D'){
                    t++;
                }
            }else {
                if (c[i]=='L' || c[i]=='U' || c[i]=='D'){
                    t++;
                }
            }
        }
        if (t==s.length()){
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }

    }
}

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

int main() {
    int h, w;
    cin >> h >> w;
    string bar(w + 2, '#'), temp;
    cout << bar << endl;
    rep(i, h) {
        cin >> temp;
        cout << '#' << temp << '#' << endl;
    }
    cout << bar << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << -1; return;}

void solve() {
    int n, k;
    cin >> n >> k;
    double ans = 0;
    for (int i = 1; i <= n; ++i) {
        int j = i;
        double p = 1;
        while (j < k) {
            j <<= 1; p /= 2;
        }
        ans += p;
    }
    cout << fixed << setprecision(10) << ans / n;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 3816
//https://atcoder.jp/contests/abc128/tasks/abc128_c
//C - Switches
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in");
    //std::ifstream in("./input.txt");
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N,M; cin>>N>>M;    
    vector<ll> masks(M);
    FOR(i,0,M){
        ll k; cin>>k;
        ll mask=0;
        FOR(j,0,k){
            ll s; cin>>s;
            mask |= (1LL<<(s-1LL));
        }
        masks.at(i)=mask;
    }
    vector<ll> pm(M);
    for(auto&& p:pm){
        cin>>p;
    }

    ll ans=0;
    ll max=1LL<<N;
    FOR(i,0,max){
        bool flag=true;
        FOR(j,0,M){
            const auto& m = masks.at(j);
            auto tmp=i&m;
            auto num=__builtin_popcountll(tmp);
            if(num%2!=pm.at(j)){
                flag=false;
                break;
            }
        }
        if(flag)++ans;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n, m, c = nm()
    B = np.array(nl())
    ans = 0
    for i in range(n):
        A = np.array(nl())
        if np.sum(A * B) + c > 0:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 27188
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
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; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s1, s2; cin >> s1 >> s2;
	vector<vector<int>>dp(s1.size() + 1, vector<int>(s2.size() + 1));
	rep(i, 0, s1.size() + 1)dp[i][0] = i;
	rep(i, 0, s2.size() + 1)dp[0][i] = i;
	rep(i, 1, s1.size() + 1)rep(j, 1, s2.size() + 1)
		dp[i][j] = min(dp[i - 1][j] + 1, min(dp[i][j - 1] + 1, dp[i - 1][j - 1] + (s1[i - 1] != s2[j - 1])));
	cout << dp[s1.size()][s2.size()] << endl;
	return 0;
}

Measured memory_bytes: 6736
#include "bits/stdc++.h"

using namespace std;

#define ll long long int

void solve()
{
	ll n, cnt=0;
	scanf("%lld", &n);
	for(ll i=1;i<n;i++)
	{
		for(ll j=1;j<n;j++)
		{
			ll x=n-(i*j);
			if(x>0&&x<n)
				cnt++;
			else
				break;
		}
	}
	printf("%lld",cnt);
}

int main()
{
	ll t=1;
	// scanf("%lld",&t);
	while(t--)solve();
	return 0;
}

Measured memory_bytes: 3864
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(void)
{
	int i,len;
	char str[1200];
	gets(str);
	len = strlen(str);
	for (i=0; i<len; i++) {
		if(isupper(str[i])) {
			str[i] += 32;
		} else if(islower(str[i])) {
			str[i] -= 32;
		}
	}
	puts(str);
	return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef long double ld;
#define mkp make_pair
int main()
{
	long long k,n;
	cin>>k>>n;
	vector<int> vi;
	for(int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		vi.push_back(a);
	}
	int ans = vi[n-1]-vi[0];
	for(int i=0;i<n-1;i++)
	{
		int cha = vi[i+1]-vi[i];
		int chano = k-cha;
		ans = min(chano,ans);
	}
	for(int i=n-1;i>0;i--)
	{
		int cha = vi[i]-vi[i-1];
		int chano = k-cha;
		ans = min(chano,ans);
	}
	cout<<ans<<endl;
	return 0;
 } 

Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    string A, B, C;
    cin >> A >> B >> C;

    int ans = 0;

    for (int i = 0; i < N; ++i) {
        unordered_set<char> s;
        s.insert(A[i]);
        s.insert(B[i]);
        s.insert(C[i]);

        if (s.size() == 3) {
            ans += 2;
        } else if (s.size() == 2) {
            ans += 1;
        }
    }

    cout << ans << endl;

    return 0;
}

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

const int N = 200005;

int n, r;

int solve() {
  scanf("%d", &n);

  string s;
  map<string, int> cnt;
  for (int i = 0; i < n; ++i) {
    cin >> s;
    ++cnt[s];
  }

  cout << "AC x " << cnt["AC"] << endl;
  cout << "WA x " << cnt["WA"] << endl;
  cout << "TLE x " << cnt["TLE"] << endl;
  cout << "RE x " << cnt["RE"] << endl;
  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  while (t--) solve();
  return 0;
}


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

struct city
{
  // 誕生年, 入力された順番
  int year ,in_order;
};

int main()
{
  int n, m;
  cin >> n >> m;
  vector<city> prefecture[101010];
  for (int i = 0; i < m; ++i)
  {
    int p, y;
    cin >> p >> y;
    prefecture[p].push_back({y, i+1});
  }

  // 県ごとに誕生年でソート
  for (int i = 1; i <= n; ++i)
  {
    if (prefecture[i].empty()) continue;
    sort(prefecture[i].begin(), prefecture[i].end(), [](const city &x, const city &y) {
      return x.year < y.year;
    });
  }

  vector<int> id_upper(m + 1), id_bottom(m + 1);
  for (int i = 1; i <= n; ++i)
  {
    for (int j = 0, s = (int)prefecture[i].size(); j < s; ++j)
    {
      id_upper[prefecture[i][j].in_order] = i;
      id_bottom[prefecture[i][j].in_order] = j + 1;
    }
  }

  for (int i = 1; i <= m; ++i)
    cout << setfill('0') << right << setw(6) << id_upper[i] << setfill('0') << right << setw(6) << id_bottom[i] << "\n";
}

Measured memory_bytes: 7808