akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int a = scanner.nextInt();
		int b = scanner.nextInt();

		int plus		= a+b;
		int minus		= a-b;
		int multiplied	= a*b;

		int result		= 0;

		if(plus > minus){
			if(plus > multiplied){
				result = plus;
			}else{
				result = multiplied;
			}
		}else if(minus > multiplied){
			result = minus;
		}else{
			result = multiplied;
		}

		System.out.println(result);
	}
}

Measured memory_bytes: 21588
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <queue>
#include <set>

using namespace std;

typedef unsigned long long int ULL;
typedef long long LL;
typedef long double LD;


int main()
{
	
	LL n, k;
	cin >> n >> k;

	vector<LL> h(n);

	for (auto &e : h) {
		cin >> e;
	}

	vector<LL> dp(n, 1000000000000000);
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	for (int i = 2; i < n; ++i) {
		for (int j = 1; j <= k; ++j) {
			if (i-j >= 0) {
				dp[i] = min(dp[i-j] + abs(h[i]-h[i-j]), dp[i]);
			}
		}
		
	}

	cout << dp[n-1] << "\n";
	 
}

Measured memory_bytes: 1792
A, B, C, X, Y = map(int, input().split())
ans = 0
if A+B > 2*C:
    hoge = min(X, Y)
    ans += hoge * 2*C
    if X > Y:
        ans += (X-hoge)*A
    else:
        ans += (Y-hoge)*B
    ans = min(ans, max(X, Y) * 2*C)
else:
    ans = A*X + B*Y
print(ans)


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

int main(){
    int H,W;
    cin>>H>>W;
    vector<string> a(H);
    
    for(int i=0;i<H;++i){
        cin>>a.at(i);
    }
    
    vector<bool> row(H,false),col(W,false);
    
    for(int i=0;i<H;i++){
        for(int j=0;j<W;++j){
            if(a[i][j]=='#'){
                row.at(i)=true;
                col.at(j)=true;
            }
        }
    }
    
    for(int i=0;i<H;i++){
        if(row.at(i)){
            for(int j=0;j<W;++j){
                if(col.at(j)){
                    cout<<a.at(i).at(j);
                }
            }
            cout<<endl;
        }
    }
    
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int N=1000;

int LCS(string x,string y){
	int c[N+1][N+1],LCSlen=0;
	int m=x.size();
	int n=y.size();
	x=' '+x;
	y=' '+y;
	for(int i=1;i<=m;i++) c[i][0]=0;
	for(int j=1;j<=n;j++) c[0][j]=0;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			if(x[i]==y[j])
			c[i][j]=c[i-1][j-1]+1;
			else
			c[i][j]=c[i-1][j]>c[i][j-1] ? c[i-1][j]:c[i][j-1];
			LCSlen=LCSlen>c[i][j] ? LCSlen:c[i][j];
		}
	}
	return LCSlen;
}

int main(){
	string x,y;
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		cin>>x;
		cin>>y;
		printf("%d\n",LCS(x,y));
	}
}

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

int main()
{
    ll n,t,a,b,c,d,e,p,q,cnt=0;
    map<ll,ll>mp;
    vector<ll>vec;
    string s,s1,s2;
    ll ac=0,tle=0,wa=0,re=0;
    cin>>s;
    ll len=s.length();
    //ll cnt=0;
    ll maxx=0;
    for(ll i=0;i<len;i++){
        if(s[i]=='R'){
            cnt++;
            maxx=max(maxx,cnt);
        }
        else{
            maxx=max(maxx,cnt);
            cnt=0;
        }
    }

    cout<<maxx<<endl;

}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
    
int func(int N){
  int sum=0;
  for(int i=1;i<101;i++){
    for(int j=i;j<101;j++){
      for(int k=j;k<101;k++){
        if(N==i*i+j*j+k*k+i*j+j*k+k*i){
          if(i==j && j==k){
            sum+=1;
          }
          else if(i!=j && j!=k && k!=i){
            sum+=6;
          }
          else{
            sum+=3;
          }
        }
      }
    }
  }
  return sum;
}
           
int main(){
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
    cout << func(i+1) << endl;
  }
}

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

int main(){
    int n;
    cin >> n;
    int sum = 0;
    int T[n];
    for(int i=0;i<n;i++){
        cin >> T[i];
        sum += T[i];
    }
    int m;
    cin >> m;
    for(int i=0;i<m;i++){
        int p,x;
        cin >> p >> x;
        p--;
        cout << sum - T[p] + x << endl;
    }
}

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

typedef unsigned long long ull;
typedef long long ll;

double pi = 3.14159265358979323846;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	
	int r;
	cin >> r;
	
	cout << 2 * pi * r << endl;
	
	
	return 0;
}


Measured memory_bytes: 3768
cookies = map(int, raw_input().split())
count = 0
while cookies[0]%2 == 0 and cookies[1]%2 == 0 and cookies[2]%2 == 0:
  if cookies[0] == cookies[1] and cookies[0] == cookies[2]:
    count = -1
    break
  count += 1
  a = cookies[1]/2 + cookies[2]/2
  b = cookies[0]/2 + cookies[2]/2
  c = cookies[0]/2 + cookies[1]/2
  cookies = [a,b,c]
  #print cookies
print count

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

d1 = dict()

for i in range(n):
	s, p = [x for x in input().split()]
	if (s not in d1.keys()):
		d1[s] = []
		d1[s].append((int(p), i + 1))
	else:
		d1[s].append((int(p), i + 1))

for v in d1.values():
	v.sort(reverse = True)

l1 = list()

for k, v in d1.items():
		l1.append((k, v))

l1.sort()

for i in range(len(l1)):
	for j in l1[i][1]:
		print(j[1])

Measured memory_bytes: 3064
N, K, *A = map(int, open(0).read().split())

cntr = [0]*N
cntl = [0]*N


for i, a in enumerate(A):
    l = r = 0
    for b in A[:i]:
        if a > b:
            l += 1
    for b in A[i+1:]:
        if a > b:
            r += 1
    cntr[i] = r
    cntl[i] = l+r

mod = 10**9 + 7
ans = 0
for r in cntr:
    x = r * K % mod
    ans = (ans + x) % mod

c2 = K*(K-1)//2
for l in cntl:
    x = l*c2%mod
    ans = (ans + x) % mod

print(ans)

Measured memory_bytes: 9292
# -*- coding: utf-8 -*-
### 0 を入力されるまで数値入力を繰り返す。
### 入力が終わったら
### 入力された数値を Case i: '入力値' の形で１行ずつ表示する。

int_in =1
int_list = []
while int_in != 0:
	int_in = input()
	int_list = int_list + [int_in]

i = 1
for value in int_list:
	if value ==0:
		break
	print('Case ' + repr(i) +': '+ repr(value))
	i=i+1



Measured memory_bytes: 5108
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

constexpr ll inf = 1e+14;

class DAnticube {
public:

    ll find_pair(ll p, vector<ll>& primes) {
      map<ll, int> mp;
      int idx = 0;
      while(idx < primes.size() && primes[idx]*primes[idx] <= p) {
        while(p%primes[idx] == 0) {
          mp[primes[idx]]++;
          p /= primes[idx];
        }
        idx++;
      }
      if (p > 1) mp[p]++;

      ll ret = 1;
      for(auto e: mp) {
        if (e.second==1) {
          if (ret < inf/(e.first*e.first)) {
            ret *= e.first;
            ret *= e.first;
          } else {
            return inf;
          }
        } else {
          assert(e.second==2);
          if (ret < inf/e.first) {
            ret *= e.first;
          } else {
            return inf;
          }
        }
      }
      return ret;
    }

    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;

      vector<bool> check(100001, true);
      check[0] = false;
      check[1] = false;
      for(int i=2; i<=100000; i++) {
        if (check[i]) {
          for(int j=i+i; j<=100000; j+=i) {
            check[j] = false;
          }
        }
      }
      vector<ll> primes;
      for(int i=2; i<=100000; i++) {
        if (check[i]) primes.push_back(i);
      }

      vector<ll> s(n);
      rep(i, n) {
        cin >> s[i];
      }
      map<ll, int> mp;
      rep(i, n) {
        for(ll j=2; j*j*j<=s[i]; j++) {
          while (s[i]%(j*j*j)==0) {
            s[i] /= j*j*j;
          }
        }
        mp[s[i]]++;
      }

      int ans = 0;
      for(auto& e: mp) {
        if (e.first == 1) {
          ans++;
          continue;
        }
        ll p = find_pair(e.first, primes);
        int now = e.second;
        if (mp.find(p) != mp.end()) {
          chmax(now, mp[p]);
          mp[p] = 0;
          e.second = 0;
        }
        ans += now;
      }

      cout << ans << endl;



    }
};

signed main() {
  DAnticube solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int a, b;
	cin >> a >> b;
	if ((a + b) & 1)
	{
		cout << "IMPOSSIBLE";
	}
	else
	{
		cout << (a + b) / 2;
	}
	
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

/**
 * Created by enpingkuang on 2020/9/13 8:01 下午
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long[] a = new long[4];
        long sum = Long.MIN_VALUE;
        for(int i = 0;i<4;i++){
            a[i] = scanner.nextLong();
        }
        sum = Math.max(sum,a[0]*a[2]);
        sum = Math.max(sum,a[0]*a[3]);
        sum = Math.max(sum,a[1]*a[2]);
        sum = Math.max(sum,a[1]*a[3]);
        System.out.println(sum);
    }
}

Measured memory_bytes: 35784
import sys
from bisect import bisect_left, bisect_right


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, q = nm()
    S = input()
    ans = []
    A_pos = []
    C_pos = []
    for i in range(n - 1):
        if S[i] == 'A' and S[i + 1] == 'C':
            A_pos += [i + 1]
            C_pos += [i + 2]
    for i in range(q):
        l, r = nm()
        ans += [bisect_right(C_pos, r) - bisect_left(A_pos, l)]
    print(*ans, sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 18636
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

long long func(long long b, long long n) {
    if (n < b) { return n; }

    return n % b + func(b, n/b);
}

int main(int argc, char **argv) {
    long long n, s;
    std::cin >> n;
    std::cin >> s;

    const long long cond = 1000000;

    for (long long i = 2; i <= cond * 2; i++) {
        if (func(i, n) == s) {
            std::cout << i << std::endl;
            return 0;
        }
    }

    std::vector<long long> cand;
    if (n - s > 0) {
        for (long long i = 1; i <= cond + 50 && i <= s; i++) {
            if ((n - s) % i == 0) {
                long long bm1 = (n - s) / i;
                long long b = bm1 + 1;
                if (func(b, n) == s) {
                    cand.push_back(b);
                }
            }
        }
        if (0 < cand.size()) {
            std::cout << cand[cand.size() - 1] << std::endl;
            return 0;
        }
    }

    if (n == s) {
        std::cout << n + 1 << std::endl;
        return 0;
    }

    std::cout << -1 << std::endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0; i<n; i++)

using namespace std;

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

	int N;
    cin >> N;
	map<string, int> m;
  	int64_t ans = 0;
  	for (int i = 0; i < N; i++)
	  {
		  string s;
		  cin >> s;
		  sort(s.begin(), s.end());
		  if(m.count(s)==0)m[s]=1;
		  else {
            ans+=m[s];
            m[s]++;
          }
	  }
	cout << ans << endl;
}

Measured memory_bytes: 11264
#include<iostream>
#include<cstdio>
using namespace std;
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	while(n>=500)
	{
		n-=500;
	}
	if(n!=0&&n>m)
	{
		printf("No");
		return 0;
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
ll sr[4001],sg[4001],sb[4001];
int main(){
	ios::sync_with_stdio(0);
	int n;
	string s;
	cin>>n>>s;
	if(s[0]=='R')
	sr[0]++;
	if(s[0]=='G')
	sg[0]++;
	if(s[0]=='B')
	sb[0]++;
	forn(i,1,n){
		sr[i]=sr[i-1];
		sg[i]=sg[i-1];
		sb[i]=sb[i-1];
		if(s[i]=='R')
		sr[i]++;
		if(s[i]=='G')
		sg[i]++;
		if(s[i]=='B')
		sb[i]++;
	} 
	ll ans=0;
	rep(i,n){
		forn(j,i+1,n){
			if(s[j]==s[i])
			continue;
			bool r,g,b;
			r=g=b=false;
			if(s[i]=='R')
			r=true;
			if(s[i]=='G')
			g=true;
			if(s[i]=='B')
			b=true;
			if(s[j]=='R')
			r=true;
			if(s[j]=='G')
			g=true;
			if(s[j]=='B')
			b=true;
			int ans1=ans; 
			if(!r){
				ans+=sr[n-1]-sr[j];
				if(j+j-i<n&&s[j+j-i]=='R')
				ans--;
			}
			if(!g){
				ans+=sg[n-1]-sg[j];
				if(j+j-i<n&&s[j+j-i]=='G')
				ans--;
			}
			if(!b){
				ans+=sb[n-1]-sb[j];
				if(j+j-i<n&&s[j+j-i]=='B')
				ans--;
			}
		}
	}
	cout<<ans;
	re 0;
}

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

int main() {
 	int n;
  	cin >> n;
  	string s[n];
	int ac=0; 	int wa=0;  int tle=0; int re=0;  
  
    for(int i=0; i<n; i++) 
 	 {cin >> s[i];
     if(s[i] == "AC"){ac ++;}
     else if(s[i] == "WA"){wa ++;}
     else if(s[i] == "TLE"){tle ++;}
     else {re ++;}
     }


	cout <<"AC x "<< ac<< endl;
 	cout <<"WA x "<< wa<< endl;
  	cout <<"TLE x "<< tle<< endl;
 	cout <<"RE x "<< re<< endl;

}

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

ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
    w = input()
    if(w == 'AC'):
        ac += 1
    elif(w == 'WA'):
        wa += 1
    elif(w == 'TLE'):
        tle += 1
    elif(w == 'RE'):
        re += 1

print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))

Measured memory_bytes: 9216
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;

//aのp乗を求めるアルゴリズム。計算量はO(logp)
ll modpow(ll a, int p) {
    if(p == 0) {
        return 1;
    }
    if(p%2 == 0) {
        //pが偶数の時
        int halfP = p/2;
        ll half = modpow(a, halfP);
        //a^(p/2)をhalfとして、half*halfを計算
        return half * half % mod;
    }
    else {
        //pが奇数の時は、pを偶数にするために1減らす
        return a * modpow(a, p-1) % mod;
    }
}

ll Comb(int a, int b) {
    if(b > a-b) {
        return Comb(a, a-b);
    }

    ll ansMul = 1;
    ll ansDiv = 1;
    rep(i, b) {
        ansMul *= (a-i);
        ansDiv *= (i+1);
        ansMul %= mod;
        ansDiv %= mod;
    }
    // ansMul/ansDivをやりたい
    // ansDivの逆元を使って求めよう
    ll ans = ansMul * modpow(ansDiv, mod-2) % mod;

    return ans; 
}

int main() {
    int n, m;
    cin >> n >> m;

    int mNokori = m;
    ll ans = 1;
    for(int i = 2; i*i <= mNokori; i++) {
        if(mNokori%i == 0) {

            int cnt = 0;
            while(mNokori%i == 0) {
                cnt++;
                mNokori /= i;
            }

            ans *= Comb(cnt+n-1, cnt);
            ans %= mod;
        }
    }
    if(mNokori != 1) {
        //最後に素数が残ってる分を処理する
        ans *= n;
        ans %= mod;
    }

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

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

using namespace std;

using ll = long long;
using ld = long double;

using pll = pair<ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using gr = vector<vll>;
using wgr = vector<vpll>;

#define pb push_back
#define FOR(i, m, n) for (ll i(m); i < n; i++)
#define REP(i, n) FOR(i, 0, n)
#define F(n) REP(i, n)
#define FF(n) REP(j, n)
struct d_ {
    template<typename T> d_ & operator ,(const T & x) { cerr << ' ' <<  x; return *this;}
    template<typename T> d_ & operator ,(const vector<T> & x) { for(auto x: x) cerr << ' ' <<  x; return *this;}
} d_t;
#define dbg(args ...) { d_t,"|",__LINE__,"|",":",args,"\n"; }
#define EPS (1e-10)
#define INF (1LL<<61)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define all(x) begin(x),end(x)
#define IN(n) ll n;cin >> n;
#define x first
#define y second

int main(void) {
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    string s; cin >> s;
    vll sm(n);
    sm[0]=s[0]=='W';
    for(ll i=1;i<n;i++) sm[i]=sm[i-1]+(s[i]=='W');
    ll ret=INF;
    F(n) {
        ll cur = (i ? sm[i-1] : 0) + (n-i-1)-(sm[n-1]-sm[i]);
        ret=min(ret, cur);
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 2964
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AizuOnline
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var s = new List<List<int>>();

            while (true)
            {
                var a = Console.ReadLine().Split(' ');
                if (int.Parse(a[0]) == -1 && int.Parse(a[1]) == -1 && int.Parse(a[2]) == -1)
                {
                    break;
                }

                s.Add(new List<int>() { int.Parse(a[0]), int.Parse(a[1]), int.Parse(a[2]) });
            }

            foreach (var S in s)
            {
                var g = "";
                if (S[0] == -1 || S[1] == -1)
                {
                    g = "F";
                }
                else
                {
                    if (S[0] + S[1] >= 80)
                    {
                        g = "A";
                    }
                    else if (S[0] + S[1] >= 65 && S[0] + S[1] < 80)
                    {
                        g = "B";
                    }
                    else if (S[0] + S[1] >= 50 && S[0] + S[1] < 65)
                    {
                        g = "C";
                    }
                    else if (S[0] + S[1] >= 30 && S[0] + S[1] < 50)
                    {
                        g = "D";
                        if (S[2] >= 50)
                        {
                            g = "C";
                        }
                    }
                    else
                    {
                        g = "F";
                    }
                }
                Console.WriteLine(g);
            }

            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 8980
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 28 18:15:06 2019

@author: yuta
"""

N = int(input())
place = [list(map(int,input().split())) for _ in range(N)]

def main(p):
    count = 0
    for i in range(len(p)):
        t = p[i][0]
        sum_xy = p[i][1] + p[i][2]
        if t % 2 == 0:
            if sum_xy <= t and sum_xy % 2 == 0:
                count += 1
        else:
            if sum_xy <= t and sum_xy % 2 != 0:
                count += 1
    if count == len(p):
        print("Yes")
    else:
        print("No")

main(place)

Measured memory_bytes: 27300
using System;
using System.Collections.Generic;
namespace 令和{
    class ABC{
        static void Main(){
            
            int n = int.Parse(Console.ReadLine());
            List<int[]>[] tonari = new List<int[]>[n+1];
            for(int i=0;i<n+1;i++){
                tonari[i] = new List<int[]>();
            }
            for(int i=1;i<n;i++){
          	    int u;int v;int w;
                string[] uvw = Console.ReadLine().Split();
                u = int.Parse(uvw[0]);
                v = int.Parse(uvw[1]);
                w = int.Parse(uvw[2]);
                tonari[u].Add(new int[2]{v,w});
                tonari[v].Add(new int[2]{u,w});
            }
{
            int[] ans = new int[n+1];
            Queue<int> q = new Queue<int>();
            q.Enqueue(1);
            for(int i=0;i<n+1;i++){
                ans[i] = -1;
            }
            ans[1] = 0; 
            while(q.Count>0){
                int p = q.Dequeue();
                foreach(int[] tnr in tonari[p]){
                    if(ans[tnr[0]]==-1){
                        if(tnr[1]%2==0){
                            ans[tnr[0]] = ans[p];
                        }else{
                            ans[tnr[0]] = 1-ans[p];
                        }
                        q.Enqueue(tnr[0]);
                    }
                }
            }
}
{
            int[] ans = new int[n+1];
            Queue<int> q = new Queue<int>();
            q.Enqueue(1);
            for(int i=0;i<n+1;i++){
                ans[i] = -1;
            }
            ans[1] = 0; 
            while(q.Count>0){
                int p = q.Dequeue();
                foreach(int[] tnr in tonari[p]){
                    if(ans[tnr[0]]==-1){
                        if(tnr[1]%2==0){
                            ans[tnr[0]] = ans[p];
                        }else{
                            ans[tnr[0]] = 1-ans[p];
                        }
                        q.Enqueue(tnr[0]);
                    }
                }
            }

            for(int i=0;i<n;i++){
                Console.WriteLine(ans[i+1]);
            }

}
 
 
        }
    }
}

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

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

long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b;
}

int main() {
    int N;
    cin >> N;
    vector<long long> T(N);
    for (int i = 0; i < N; i++)
        cin >> T[i];

    long long res = 1;
    for (int i = 0; i < N; i++)
        res = lcm(res, T[i]);

    cout << res << endl;
    return 0;
}

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

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

    for(int i = 0; i < q; i++){
        int p, t, x;
        cin >> p;
        if(p == 0){
            cin >> t >> x;
            v[t].push_back(x);
        }
        else if(p == 1){
            cin >> t;
            //vector<int>::iterator itr;
            //itr = v[t].begin();
            int count = 0;
            for(int out : v[t]){
                cout << out;
                count++;
                if(count != v[t].size()){
                    cout << " ";
                }
            }
            cout << endl;
        }
        else {
            cin >> t;
            if(v[t].size() == 0){
                continue;
            }
            else {
                v[t].clear();
            }
        }

        
    }
    return 0;
}


Measured memory_bytes: 5832
def prime?(x)
  return true if x == 2
  return false if x < 2 || x.even?
  3.step(Math.sqrt(x), 2).each do |i|
    return false if x % i == 0
  end
  return true
end
n = gets.to_i
numbers = n.times.map { gets.to_i }
puts numbers.count {|x| prime?(x) }

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

using namespace std;

constexpr int MOD = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int N;
  cin >> N;

  int64_t p = 1;

  for (int i = 2; i <= N; i++) {
    p = (p * i) % MOD;
  }

  cout << p << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <string>
#include <map>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n - h + 1) * (n - w + 1) << endl;
}


Measured memory_bytes: 256
void main() {
	auto ip = readAs!(int[]), N = ip[0], M = ip[1];
	auto uf = new UnionFind!int(N);
	foreach(i; 0..M) {
		auto ip2 = readAs!(int[]), A = ip2[0], B = ip2[1];
		uf.unite(A-1, B-1);
	}
	ulong res;
	foreach(i; 0..N) {
		res = max(res, uf.size(i));
	}
	res.writeln;
}

class UnionFind(T) {
	T[] arr;
	this(ulong n) {
		arr.length = n;
		arr[] = -1;
	}
	T root(T x) {
		return arr[x] < 0 ? x : root(arr[x]);
	}
	bool same(T x, T y) {
		return root(x) == root(y);
	}
	bool unite(T x, T y) {
		x = root(x);
		y = root(y);
		if(x == y) return false;
		if(arr[x] > arr[y]) swap(x, y);
		arr[x] += arr[y];
		arr[y] = x;
		return true;
	}
	T size(T a) {
		return -arr[root(a)];
	}
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

long rl() {
	return readAs!long;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

using namespace std;

int main()
{
    int n,a,b,c,f=0;
    cin >> n >> a >> b;
    c=abs(a-b);
    if(c%2==1) f=1;
    if(f==0) cout << "Alice" << endl;
    else cout << "Borys" << endl;
    return 0;
}

Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int r , c , n;
int id(int x,int y){
    if(y == 0) return x;
    if(x == r) return r + y;
    if(y == c) return r + c + r - x;
    if(x == 0) return r + c + r + c - y;
    return -1;
}
vector<pii> pts;

int main(){
    scanf("%d%d%d",&r,&c,&n);
    rep(i,0,n) {
        int x , y , a[2];
        rep(j,0,2) {
            scanf("%d%d",&x,&y);
            a[j] = id(x , y);
        }
        if(a[0] != -1 && a[1] != -1){
            pts.pb(mp(a[0] , i));
            pts.pb(mp(a[1] , i));
        }
    }
    sort(all(pts));
    vi v;
    rep(i,0,sz(pts)) {
        if(sz(v) && v[sz(v)-1] == pts[i].se) v.pop_back();
        else v.pb(pts[i].se);
    }
    puts(sz(v) ? "NO" : "YES");
    return 0;
}


Measured memory_bytes: 2672
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
#define INF 100000

int main() {
	ll h, w;
	ll ans, case1, case2, case3, case4;
	ll buf, buf1, buf2, buf3;
	scanf("%lld %lld", &h, &w);

	//横
	if (h % 3 == 0) {
		case1 = 0;
	} else {
		case1 = (h / 3 + 1) * w - (h / 3) * w;
	}
	
	//縦
	if (w % 3 == 0) {
		case2 = 0;
	} else {
		case2 = (w / 3 + 1) * h - (w / 3) * h;
	}

	//横⇒縦
	case3 = INF;
	for (ll i = 1; i < h; i++) {
		if (w % 2 == 0) {
			buf = abs(i * w - (h - i) * (w / 2));
		} else {
			buf1 = abs(i * w - (h - i) * (w / 2));
			buf2 = abs(i * w - (h - i) * (w / 2 + 1));
			buf3 = abs(i * (w / 2 + 1) - (h - i) * (w / 2));
			buf = max(max(buf1, buf2), buf3);
		}
		if (case3 > buf) case3 = buf;
	}

	//縦⇒横
	case4 = INF;
	for (ll i = 1; i < w; i++) {
		if (h % 2 == 0) {
			buf = abs(i * h - (w - i) * (h / 2));
		} else {
			buf1 = abs(i * h - (w - i) * (h / 2));
			buf2 = abs(i * h - (w - i) * (h / 2 + 1));
			buf3 = abs(i * (h / 2 + 1) - (w - i) * (h / 2));
			buf = max(max(buf1, buf2), buf3);
		}
		if (case4 > buf) case4 = buf;
	}

	ans = min(min(case1, case2), min(case3, case4));
	printf("%lld\n", ans);
	return 0;
}


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

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s = br.readLine();
		String[] array = s.split(" ");
		char a = (array[0]).charAt(array[0].length() - 1);
		char b = (array[1]).charAt(0);
		char c = (array[1]).charAt(array[1].length() - 1);
		char d = (array[2]).charAt(0);

		if (a == b && c == d) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 23124
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    ll N;
    cin >> N;
    vector<ll> xs(N);
    rep(i,0,N) {
        cin >> xs[i];
    }
    ll ans = numeric_limits<ll>::max();
    rep(p,1,101) {
        ll ans_loc = 0;
        rep(i,0,N) {
            ans_loc += (xs[i] - p) * (xs[i] - p);
        }
        ans = min(ans, ans_loc);
    }
    cout << ans << endl;
}


Measured memory_bytes: 888
#include<iostream>
using namespace std;
 
int main()
{
    // get a integer
    int a;
    cin >> a;
    // get two integers separated with half-width break
    int b,c;
    cin >> b >> c;
    // get a string
   if (a + b + c == 17) {
        int m = min (a, min(b, c));
        int mx = max(a, max(b,c));
       if (m == 5 && mx == 7) {
          puts("YES");
          return 0;
      }
   }
   puts("NO");
    return 0;
}

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

int main(){
	int n,m,max,tmp,a[1000];
	while(1){
		cin >> n >> m;
		if(n==0&&m==0)break;
		max = 0;

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

		for(int i=0;i<n-1;i++){
			for(int j=i+1;j<n;j++){
				if(max<a[i]+a[j]&&m>=a[i]+a[j]){
					max = a[i]+a[j];
				}
			}
		}
		if(max==0){
			cout << "NONE" << endl;
			continue;
		}
		cout << max << endl;
	}
}

Measured memory_bytes: 3076
import java.util.*;

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

        if (a==b && b==c) {
            System.out.println("No");
        }

        else if (a==b||b==c||a==c) {
            System.out.println("Yes");
        }

        else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 21460
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<climits>
#include<stack>
#include<queue>
#include<set>
#include<cctype>
#include<bitset> 
using namespace std;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;
typedef long long int ll;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;
const ll INF = (ll)1e12;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

ll dp[20][2][2]; // 桁決めた桁、未満フラグ、４or9を含むフラグ


int main() {
    int n,m ;cin >> n >> m;

    vector<int> v(n+1,0);

    REP(i,m){
        int l,r;cin >> l >> r;
        l--;r--;

        v[l]++;
        v[r+1]--;
    }
    REP(i,n) v[i+1] += v[i];

    int ans = 0;
    REP(i,n) if(v[i]==m) ans++;

    pl(ans)    
}

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

#define debug(x) cout << #x << ": " << (x) << endl

int main(int argc, char *argv[]) {
  string S;
  set<string> strs;
  strs.insert("dream");
  strs.insert("dreamer");
  strs.insert("erase");
  strs.insert("eraser");
  cin >> S;

  int i = S.size();
  while (0 < i) {
    bool changed = false;
    for (auto s: strs) {
      int start = i - s.size();
      if (0 <= start and S.substr(start, s.size()) == s) {
        changed = true;
        i -= s.size();
        break;
      }
    }
    if (not changed)
      break;
  }

  cout << (i == 0 ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=2147483647;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
const int maxn=2e5+5;
int n,m,u,v,vis[maxn],dis[maxn],ans[maxn];
vector<int> g[maxn];
void bfs(int x){
	queue<int> q;
	q.push(x);
	vis[x]=1;
	while(!q.empty()){
		int now=q.front();
		q.pop();
		for(int i=0;i<g[now].size();i++){
			int x=g[now][i];
			if(!vis[x]){
				dis[x]=dis[now]+1;
				vis[x]=1;
				ans[x]=now;
				q.push(x);
			}
		}
	}
	for(int i=2;i<=n;i++)
		if(!vis[i]){
			printf("No\n");
			exit(0);
		}
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=m;i++){
		u=read(),v=read();
		g[u].push_back(v);
		g[v].push_back(u);
	}
	bfs(1);
	printf("Yes\n");
	for(int i=2;i<=n;i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 13752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N,A,B;
    cin >> N >> A >> B;
    cout << min(A,B) << " "<<max(0,A+B-N) << "\n";
}

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

signed main(){
    int a,b;
    cin >> a >>b;
    cout<<6-a-b<<endl;
}

Measured memory_bytes: 384
class Integer
  def cumulative_bit_count
    n = self + 1
    return [] if n <= 0

    l = n.to_s(2).size
    ret = []

    l.times do |i|
      s = 1 << i
      t = 1 << (i + 1)
      ret[i] = s * (n / t) + [n % t - s, 0].max
    end

    ret
  end
end

A, B = gets.split.map(&:to_i)

a_h = (A - 1).cumulative_bit_count
b_h = B.cumulative_bit_count

l = B.to_s(2).size

puts (0..l).map { |i| ((b_h[i] || 0) - (a_h[i] || 0)).odd? ? '1' : '0' }.reverse.join.to_i(2)

__END__
1 = (c + 1) / 2
2 = 2 * (c / 4) + [c % 4 - 1, 0].max
3 = 4 * (c / 8) + [c % 8 - 3, 0].max
4 = 8 * (c / 16) + [c % 16 - 7, 0].max
n = (2 ** i) * (c / (2 ** i)) + [c / 



Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a, b, c;
    cin >> a >> b >> c;
    char dif = 'A'-'a';
    string A,B,C;
    A = a[0]+dif;
    B = b[0]+dif;
    C = c[0]+dif;
    cout << A << B << C << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define ALL(V) V.begin(),V.end()
#define f1(a,b) for(int a=1;a<=b;a++)
#define f0(a,b) for(int a=0;a<b;a++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define de(x) cout<<#x<<": "<<x<<endl
using namespace std;
const LL N=1e6+69, base=1024*1024,mod=1e9+7;
int t[N],wyn,n,a;
int32_t main(void) {
    boost;
    cin>>n;
    f1(i,n) {
        cin>>a;
        t[a]=t[a-1]+1;
        wyn=max(wyn,t[a]);
    }
    cout<<n-wyn<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n,k;
  	cin>>n>>k;
  	vint h(n+1);
 	REP(i,1,n+1){
		cin>>h[i];
    }
	vint dp(n+1);
  	REP(i,2,n+1){
      	dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
      	REP(j,2,k+1){
          	if(i-j>=1){
          		dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
            }
        }
    }
  	cout<<dp[n];
    return(0);
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	int n,k;
	cin >> n >> k;
	double sum = 0;
	FOR(i,1,n){
		double prob = 1;
		int pt = i;
		while(pt < k){
			prob *= 0.5;
			pt *= 2;
		}
		sum += prob/n;
	}
	printf("%.12f\n",sum);

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<set>


int main() {
	std::set<int> s;
  	for(int i = 0; i < 3; i++){
    	int x;
      	scanf("%d", &x);
        s.insert(x);
    }
  	if(s.size() == 2){
        puts("Yes");
    }else{
    	puts("No");
    }
}

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

int main()
{
	int a;
	cin >> a;
	int b = a / 4;
	
	for (;;)
	{ 
		
		if ((a-4*b)%7==0)
		{ 
			cout << "Yes\n";
			break;
			
		} 
		else
		{
			b -= 1;
		}
		
		if (b<0)
		{ 
			cout << "No\n";
			break;
			
		}


	}
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int N, K;
  cin >> N >> K;
  vector<ll> a(N);
  cin >> a;
  ll ans = LLINF;
  for (int i = 0; i < (1 << N); i++) {
    int popcnt = 0;
    for (int j = 0; j < N; j++) {
      if ((i >> j) & 1) popcnt++;
    }
    if (popcnt < K) continue;
    ll res = 0ll;
    ll pre = -1;
    // dmp(bitset<5>(i));
    for (int j = 0; j < N; j++) {
      if ((i >> j) & 1) {
        if (pre >= a[j]) {
          res += pre + 1 - a[j];
          pre = pre + 1;
        } else {
          pre = a[j];
        }
      } else {
        chmax(pre, a[j]);
      }
    }
    // dmp(res);
    chmin(ans, res);
  }
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


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

int n;
int arr[200009];


int main(){

	cin>>n;
	int xo = 0;
	for(int i = 0; i < n; i ++) {
		cin>>arr[i];
		xo ^= arr[i];
	}
	// cout<<xo<<endl;
	for(int i = 0; i < n; i ++){
		int val = arr[i] ^ xo;
		cout<<(val)<<" ";
	}cout<<endl;

}


Measured memory_bytes: 4344
#include<bits/stdc++.h>
using namespace std;
int a[305][305],x[90005],y[90005],length[90005];
int main()
{
	int h,w,d,Q;
	scanf("%d%d%d",&h,&w,&d);
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
		{
			scanf("%d",&a[i][j]);
			x[a[i][j]]=i;
			y[a[i][j]]=j;
		}
	memset(length,0,sizeof(length));
	for(int i=1;i<=d;i++)
	{
		int j=i+d;
		while(j<=h*w)
		{
			length[j]=length[j-d]+abs(x[j-d]-x[j])+abs(y[j-d]-y[j]);
			j+=d;
		}
	}
	scanf("%d",&Q);
	while(Q--)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		printf("%d\n",length[r]-length[l]);
	}
}

Measured memory_bytes: 2560
package main

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

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func nextInt() int {
	i, e := strconv.Atoi(nextString())
	if e != nil {
		panic(e)
	}
	return i
}

func nextInt64() int64 {
	i, e := strconv.ParseInt(nextString(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

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

func putInt64(i int64) {
	wr.WriteString(strconv.FormatInt(i, 10))
	// wr.Flush()
}
func putString(s string) {
	wr.WriteString(s)
	// wr.Flush()
}

func main() {
	sc.Buffer(make([]byte, 0), 1000000009)
	sc.Split(bufio.ScanWords)

	var n int
	n = nextInt()

	a := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	var ans int64

	for i := 0; i < n; i++ {
		ans += int64(a[i])
		if i%2 == 1 {
			ans -= 2 * int64(a[i])
		}
	}

	for i := 0; i < n; i++ {
		putInt64(ans)
		ans = 2*int64(a[i]) - ans
		if i == n-1 {
			putString("\n")
		} else {
			putString(" ")
		}
	}
	wr.Flush()
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

const int MAX = 1e6 + 5;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int A, B, M;
    cin >> A >> B >> M;

    vector<int> a(A), b(B);
    rep(i, A) cin >> a[i];
    rep(i, B) cin >> b[i];

    vector<int> x(M), y(M), c(M);
    rep(i, M) cin >> x[i] >> y[i] >> c[i];
    
    int ans = 0;
    int mi = INF;
    for (int &i : a) mi = min(mi, i);
    ans += mi;

    mi = INF;
    for (int &i : b) mi = min(mi, i);
    ans += mi;

    rep(i, M) {
        ans = min(ans, a[x[i]-1] + b[y[i]-1] - c[i]);
    }

    cout << ans << endl;
}

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

int main()
{
    long long int l,r,i,j,n,mini=99999999;
    cin>>l>>r;
    if(l*r<2019)
    {
        cout<<l*(l+1)<<endl;
        return 0;
    }
    else
    {
        if((l*r)%2019==0)
            cout<<0<<endl;
        else if(l<2019 && r>2019)
            cout<<0<<endl;
        else if(l%2019==0 || r%2019==0)
            cout<<0<<endl;
        else
        {
            j=1;
            for(i=l*2019; i<=r; i*j,j++)
            {
                if(i%2019==0)
                {
                    cout<<0<<endl;
                    return 0;
                }
            }
            for(i=l; i<=r; i++)
            {
                for(j=i+1; j<=r; j++)
                {
                    mini=min(mini,(i*j)%2019);
                    if(mini==0)
                    {
                        cout<<0<<endl;
                        return 0;
                    }
                }
            }
            cout<<mini<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256