akhauriyash/Code-Regression huggingface dataset:
/*
    Take me to church
    I'll worship like a dog at the shrine of your lies
    I'll tell you my sins and you can sharpen your knife
    Offer me that deathless death
    Good God, let me give you my life
*/
#include<bits/stdc++.h>
using namespace std;
const int N = 303, Mod = 998244353;
int n, m;
bitset < N > A[N];
inline int Power(int a, int b)
{
    int ret = 1;
    for (; b; b >>= 1, a = 1LL * a * a % Mod)
        if (b & 1) ret = 1LL * ret * a % Mod;
    return (ret);
}
int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i ++)
        for (int j = 0, a; j < m; j ++)
            scanf("%d", &a), A[i][j] = a;
    int r = 0;
    for (int i = 0; i < m; i ++)
    {
        for (int j = r; j < n && A[r][i] == 0; j ++)
            if (A[j][i]) swap(A[r], A[j]);
        if (r < n && A[r][i])
        {
            for (int j = 0; j < n; j ++)
                if (r != j && A[j][i])
                    A[j] ^= A[r];
            r ++;
        }
    }
    return !printf("%d\n", (Power(2, n + m - 1) - Power(2, n - 1 + m - r) + Mod) % Mod);
}

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

int a[3][3];

int main(){
  rep(i,3){
  	rep(j,3){
  		cin >> a[i][j];
  	}
  }
  int n;
  cin >> n;
  int b[n];
  rep(i,n){
  	cin >> b[i];
  }
  
  bool can = false;
  rep(i,3){
  	rep(j,3){
  		rep(k,n){
  			if(a[i][j] == b[k]){
  				a[i][j] = 0;
  			}
  		}
  	}
  }
  if(a[0][0] + a[0][1] + a[0][2] == 0) can = true;
  if(a[1][0] + a[1][1] + a[1][2] == 0) can = true;
  if(a[2][0] + a[2][1] + a[2][2] == 0) can = true;
  if(a[0][0] + a[1][0] + a[2][0] == 0) can = true;
  if(a[0][1] + a[1][1] + a[2][1] == 0) can = true;
  if(a[0][2] + a[1][2] + a[2][2] == 0) can = true;
  if(a[0][0] + a[1][1] + a[2][2] == 0) can = true;
  if(a[2][0] + a[1][1] + a[0][2] == 0) can = true;
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
void sleep( double sec = 1021 ){
  clock_t s = clock();
  while( clock() - s < CLOCKS_PER_SEC * sec );
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
void build(){

}
#define N 20
int n , a[ N ];
int ans;
void init(){
  cin >> n;
  for( int i = 0 ; i < n ; i ++ )
    cin >> a[ i ];
}
void go( int now , int prob ){
  if( now == n ){
    ans += (prob == 0);
    return;
  }
  for( int i = -1 ; i <= 1 ; i ++ )
    go( now + 1 , ( prob * ( a[ now ] + i ) ) & 1 );
}
void solve(){
  go( 0 , 1 );
  cout << ans << endl;
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int c = s.indexOf('C');
		int f = s.indexOf('F', c + 1);
		if (c != -1 && f != -1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 9676
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <list>
#define INF 0x3f3f3f3f
#define maxn 105000
#define maxnn 6000
#define juzheng 300
#define line cout << "-------------------------" << endl;
#define PI acos(-1.0)
#define mem(a,b) memset(a,b,sizeof(a))
#define fill_(a,b,n) fill(a,a + n,b)
#define esp 1e-9
 
#define ri(n) scanf("%d",&n)
#define ri2(a,b) scanf("%d %d",&a,&b)
#define ri3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define rd(n) scanf("%lf",&n)
#define rd2(a,b) scanf("%lf %lf",&a,&b)
#define rd3(a,b,c) scanf("%lf %lf %lf",&a,&b,&c)
#define rl(n) scanf("%lld",&n)
#define rl2(a,b) scanf("%lld %lld",&a,&b)
#define rl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define rui(n) scanf("%u",&n)
#define rui2(a,b) scanf("%u %u",&a,&b)
#define rui3(a,b,c) scanf("%u %u %u",&a,&b,&c)
#define rs(str) scanf("%s",str)
#define pr(n) cout << n << endl
#define debug(str,x) cout << str << ":" << x << endl
#define ll long long
#define int64 __int64
#define ui unsigned int

using namespace std;

const ll mod = 1e9 + 7;

//Date:2018-8-18
//Author：HarryBlackCat

char str[maxn];
ll k;

int main() {
	//cin.sync_with_stdio(false);//降低cin，cout时间
	while(~rs(str)){
		rl(k);
		
		int len = strlen(str);
		ll ans;
		for(int i = 0;i < len;i++){
			ll x = str[i] - '0';
			if(x == 1){
				k--;
				if(!k){
					ans = 1;
					break;
				}
			}
			else{
				ans = x;
				break;
			}
		}
		
		pr(ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a)
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;

inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=100005;
//i_am_noob
int l,a[20],x;
vector<int> vec[3];

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> l;
    a[0]=l;
    if(l==2){
        print2(2,2);
        print3(1,2,0);
        print3(1,2,1);
        return 0;
    }
    rep2(i,1,19){
        a[i]=a[i-1]>>1;
        if(a[i]==1){
            x=i+1;
            reverse(a,a+x);
            break;
        }
        if(i==18){
            x=19;
            reverse(a,a+19);
        }
    }
    rep(a[0]) vec[0].pb(1),vec[1].pb(2),vec[2].pb(i);
    rep2(i,1,x){
        vec[0].pb(i+1),vec[1].pb(i+2),vec[2].pb(0);
        vec[0].pb(i+1),vec[1].pb(i+2),vec[2].pb(a[i-1]);
        if(a[i]>a[i-1]*2) vec[0].pb(1),vec[1].pb(i+2),vec[2].pb(a[i-1]*2);
    }
    print2(x+1,sz(vec[0]));
    rep(sz(vec[0])) print3(vec[0][i],vec[1][i],vec[2][i]);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;

int main(){

	int a, b, c;
	int ans ;

	cin >> a >> b >> c;

	ans = a * b * c / (max(a, max(b, c)) * 2);

    cout << ans << endl;

}

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

int main()
{
    int n;
    cin >> n;
    double ans = 0;
    vector<pair<double, string>> p;
    rep(i, n)
    {
        double x;
        string v;
        cin >> x >> v;
        p.push_back(make_pair(x, v));
    }
    rep(i, n)
    {
        if (p[i].second == "JPY")
            ans += p[i].first;
        else
            ans += p[i].first * 380000;
    }
    cout << setprecision(20) << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;
template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}

const ll MAX = MOD;

ll N;
ll a[1000005];

bool isNotCoprime(){
  ll temp = a[0];
  REP(i,N){
    temp = gcd(temp,a[i]);
  }
  return temp>1;
}

void solve(){
  cin>>N;
  CINA(a,N);
  if(isNotCoprime()){
    cout << "not coprime\n";
    return;
  }
  map<ll,int> mp;
  REP(i,N){
    vector<ll> v;
    map<ll,int> mp_temp;
    ll temp = a[i];
    while(temp>1){
      dprint(temp);
      bool did = false;
      for(ll x=2;x<=(ll)sqrt(temp+1)+1;++x){
        while(temp%x==0){
          temp /= x;
          did = true;
        }
        if(did){
          ++mp_temp[x];
          v.push_back(x);
          break;
        }
      }
      if(!did){
        ++mp_temp[temp];
        if(mp_temp[temp]==1){
          v.push_back(temp);
        }
        break;
      }
    }
    for(ll x:v){
      ++mp[x];
      if(mp[x]>1){
        cout << "setwise coprime\n";
        return;
      }
    }
  }
  cout << "pairwise coprime\n";
  return;
}

int main(int argc, char *argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG = 1;}
  solve();
  return 0;
}

Measured memory_bytes: 11536
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int x[100000];
int y[100000];
int black[2001][2001];
int white[2001][2001];
char c[100000];

int Square(int xl,int xr,int yd,int yu,bool B)
{
	int ret=0;
	int a,b,c;
	if(B==true)
	{
		if(yu>0)
		{
			a = black[xr][yu-1];
		}else{
			a=0;
		}
		if(xl>0)
		{
			b=black[xl-1][yd];
		}else{
			b=0;
		}
		if(yu>0&&xl>0)
		{
			c=black[xl-1][yu-1];
		}else{
			c=0;
		}
		ret = black[xr][yd]-a-b+c;
	}else{
		if(yu>0)
		{
			a = white[xr][yu-1];
		}else{
			a=0;
		}
		if(xl>0)
		{
			b=white[xl-1][yd];
		}else{
			b=0;
		}
		if(yu>0&&xl>0)
		{
			c=white[xl-1][yu-1];
		}else{
			c=0;
		}
		ret = white[xr][yd]-a-b+c;
	}
	return ret;
}

int main()
{
	int n,k;
	int M=0;
	int cnt=0;
	int xl,xr,yd,yu;
	
	cin>>n>>k;
	for(int i=0;i<2001;i++)
	{
		for(int j=0;j<2001;j++)
		{
			black[i][j]=0;
			white[i][j]=0;
		}
	}
	for(int i=0;i<n;i++)
	{
		cin>>x[i]>>y[i]>>c[i];
		x[i]%=(2*k);
		y[i]%=(2*k);
		if(c[i]=='B')
		{
			black[x[i]][y[i]]++;
		}else if(c[i]=='W'){
			white[x[i]][y[i]]++;
		}
	}
	//x方向の累積和
	for(int i=0;i<2*k;i++)
	{
		for(int j=1;j<2*k;j++)
		{
			black[j][i]=black[j][i]+black[j-1][i];
			white[j][i]=white[j][i]+white[j-1][i];
		}
	}
	//y方向の累積和
	for(int j=0;j<2*k;j++)
	{
		for(int i=1;i<2*k;i++)
		{
			black[j][i]=black[j][i]+black[j][i-1];
			white[j][i]=white[j][i]+white[j][i-1];
		}
	}
	//累積和チェック
	/*
	for(int j=0;j<2*k;j++)
	{
		for(int i=0;i<2*k;i++)
		{
			cerr<<black[i][j]<<" ";
		}
		cerr<<endl;
	}*/
	//x
	for(xl=0;xl<k;xl++)
	{
		//y
		for(yd=0;yd<k;yd++)
		{
			cnt=0;
			//初期位置白
			//白の数え上げ
			cnt += Square(xl,xl+k-1,yd+k-1,yd,false)+Square(xl+k,2*k-1,2*k-1,yd+k,false);
			if(xl>0)
			{
				cnt += Square(0,xl-1,2*k-1,yd+k,false);
			}
			if(yd>0)
			{
				cnt += Square(xl+k,2*k-1,yd-1,0,false);
			}
			if(xl>0&&yd>0)
			{
				cnt += Square(0,xl-1,yd-1,0,false);
			}
			//黒の数え上げ
			cnt += Square(xl+k,2*k-1,yd+k-1,yd,true)+Square(xl,xl+k-1,2*k-1,yd+k,true);
			if(xl>0)
			{
				cnt += Square(0,xl-1,yd+k-1,yd,true);
			}
			if(yd>0)
			{
				cnt += Square(xl,xl+k-1,yd-1,0,true);
			}
			//cerr<<"("<<xl<<","<<yd<<") ... "<<cnt<<endl;
			if(M<cnt)
			{
				M=cnt;
			}
			//初期位置黒
			cnt = n-cnt;
			if(M<cnt)
			{
				M=cnt;
			}
		}
	}
	cout<<M<<endl;
	return 0;
}

Measured memory_bytes: 32384
import math

N = int(input())
num_fac = [0 for _ in range(N + 1)]
MOD = 10 ** 9 + 7

if N == 1:
	print(1)
else:
	for i in range(2, N + 1):
		for j in range(2, math.floor(math.sqrt(i)) + 1):
			while i % j == 0:
				i //= j
				num_fac[j] += 1
			if i == 1:
				break
		if i != 1:
			num_fac[i] += 1
	ans = 1		
			
	for i in range(len(num_fac)):
		if num_fac[i] != 0:
			ans *= ((num_fac[i] + 1) % MOD)
			ans %= MOD
	
	print(ans)

Measured memory_bytes: 39792
use proconio::input;
//use itertools::Itertools;

fn main() {
    input!{aa: [i128]};
    let mut total = 1 as i128;
    let dig_of = |n| { ((n as f64).log10() as u128) / 10 + 1 };
    if aa.iter().any(|&a| a == 0) {
        total = 0;
    } else {
        for a in aa {
            let d_total = dig_of(total);
            let d_a = dig_of(a);
            if d_a + d_total > 18 {
                total = -1;
                break;
            } else {
                total *= a;
            }
        }
        if total > (10 as i128).pow(18) { total = -1; }
    }
    println!("{}", total)
}

Measured memory_bytes: 5696
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORa(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
ll INF = 1e15;
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,INF))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

template< typename T >
struct edge {
  ll src, to;
  T cost;

  edge(ll to, T cost) : src(-1), to(to), cost(cost) {}

  edge(ll src, ll to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator ll() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< ll > >;
template< typename T >
using Matrix = vector< vector< T > >;


template< typename T = ll >
void warshall_floyd(Matrix< T > &g)
{
  for(ll k = 0; k < g.size(); k++) {
    for(ll i = 0; i < g.size(); i++) {
      for(ll j = 0; j < g.size(); j++) {
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
}
ll border = 1e13;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll v,e;
    cin>>v>>e;
    VEC2(g,v,v);
    FOR(i,0,e){
      ll in1,in2,c;
      cin>>in1>>in2>>c;
      g[in1][in2] = c;
    }
    warshall_floyd(g);
    ll flag = 0;
    FOR(i,0,v){
      if(g[i][i]<0)flag=1;
      g[i][i] = 0;
    }
    if(flag == 1) cout<<"NEGATIVE CYCLE"<<endl;
    else{

      FOR(i,0,v){
        FOR(j,0,v){
          if(g[i][j] > border) cout<<"INF";
          else cout<<g[i][j];
          if(j!=v-1)cout<<" ";
        }
        cout<<endl;
      }
    }
}



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

int main()
{
    vector<int> a(3);
    for(int i = 0;i < 3;i++) cin >> a[i];
    sort(a.begin(),a.end());
    if(a[0] + a[1] == a[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n,a,b = map(int, input().split())
l = min(a, b)
r = max(a, b)
k = r - l
if k % 2 == 1:
    count = min(l - 1, n - r) + 1 + ((k - 1) // 2)
    print(int(count))
else:
    print(int(k // 2))

Measured memory_bytes: 3060
/*
csc -debug C.cs && mono --debug C.exe <<< "3 10"
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Reflection;

public class HelloWorld {
    public static void SolveCodeForces() {
        var N = cin.NextInt();
        var K = cin.NextInt();

        var prob = 1m / (decimal)N;

        var ans = 0m;
        for (var i = 1; i <= Math.Min(N, K-1); i++) {

            var p = 1m;
            var mul = i;
            while (mul < K) { mul *= 2; p /= 2m; }

// System.Console.WriteLine(new {i, prob, p, mul});

            ans += prob * p;
        }

        for (var i = Math.Min(N, K-1)+1; i <= N; i++)
            ans += prob;

        System.Console.WriteLine(ans);
    }

    static Scanner cin = new Scanner();
    static StringBuilder cout = new StringBuilder();

    static public void Main () {
        SolveCodeForces();
        // IncreaseStack(SolveCodeForces);
        // System.Console.Write(cout.ToString());
    }

    public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)
    {
        var thread = new Thread(action, stackSize);
        thread.Start();
        thread.Join();
    }
}

public static class Helpers {
    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }
}

public class Scanner
{
    private string[] line = new string[0];
    private int index = 0;

    public string Next() {
        if (line.Length <= index) {
            line = Console.ReadLine().Split(' ');
            index = 0;
        }
        var res = line[index];
        index++;
        return res;
    }

    public int NextInt() {
        return int.Parse(Next());
    }

    public long NextLong() {
        return long.Parse(Next());
    }

    public ulong NextUlong() {
        return ulong.Parse(Next());
    }

    public string[] Array() {
        line = Console.ReadLine().Split(' ');
        index = line.Length;
        return line;
    }

    public int[] IntArray(int emptyPrefixLen = 0) {
        var array = Array();
        var result = new int[emptyPrefixLen + array.Length];
        for (int i = 0; i < array.Length; i++)
            result[emptyPrefixLen + i] = int.Parse(array[i]);
        return result;
    }

    public long[] LongArray() {
        var array = Array();
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = long.Parse(array[i]);
        return result;
    }

    public ulong[] UlongArray() {
        var array = Array();
        var result = new ulong[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = ulong.Parse(array[i]);
        return result;
    }
}

Measured memory_bytes: 13140
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);

		while (true) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			if ((n | m) == 0)
				break;
			int[] num = new int[n + m];
			for (int i = 0; i < num.length; i++)
				num[i] = scanner.nextInt();
			Arrays.sort(num);
			int ans = num[0];
			for (int i = 1; i < num.length; i++)
				ans = Math.max(ans, num[i] - num[i - 1]);
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 63400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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; }


int main(){
    double n; ll k; cin>>n>>k;
    double res=0;
    for(ll i=1; i<=n; i++){
        ll cnt=1;
        ll j=i;
        while(j<k){
            j*=2; cnt*=2;
        }
        res+=1/(n*cnt);
    }
    cout<<setprecision(15)<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import combinations
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

def inversion(inds):
    bit = [0] * (N+1)
    def bit_add(x,w):
        while x <= N:
            bit[x] += w
            x += (x & -x)
    def bit_sum(x):
        ret = 0
        while x > 0:
            ret += bit[x]
            x -= (x & -x)
        return ret
    inv = 0
    for ind in reversed(inds):
        inv += bit_sum(ind + 1)
        bit_add(ind + 1, 1)
    return inv

INF = float('inf')
ans = INF
for odd_idxs in combinations(range(N), N//2):
    odd_idxset = set(odd_idxs)
    odds = []
    evens = []
    for i in range(N):
        if i in odd_idxset:
            odds.append((A[i] if i%2 else B[i], i))
        else:
            evens.append((B[i] if i%2 else A[i], i))
    odds.sort()
    evens.sort()
    vals = []
    inds = []
    for (e,ei),(o,oi) in zip(evens, odds):
        vals.append(e)
        vals.append(o)
        inds.append(ei)
        inds.append(oi)
    if len(evens) > len(odds):
        v,i = evens[-1]
        vals.append(v)
        inds.append(i)
    if any(a>b for a,b in zip(vals,vals[1:])): continue
    ans = min(ans, inversion(inds))

print(-1 if ans==INF else ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, M;
    cin >> N >> M;
    vvc<ll> G(N);
    rep(i, M) {
        ll s, t;
        cin >> s >> t;
        s--, t--;
        G[s].eb(t);
    }

    // 頂点iからN-1までのパス長の期待値, その頂点にたどり着く確率
    vc<ld> E(N), T(N);
    repr(i, N - 1) {
        repa(to, G[i]) E[i] += E[to];
        E[i] /= G[i].size();
        E[i] += 1;
    }

    T[0] = 1;
    rep(now, N - 1) {
        ll gsize = G[now].size();
        repa(to, G[now]) T[to] += T[now] / gsize;
    }

    ld ans = E[0];
    rep(now, N) {
        ll gsize = G[now].size();
        if (gsize <= 1) continue;
        repa(to, G[now]) {
            chmin(ans, E[0] - T[now] * (E[now] - (E[now] * gsize - E[to] - 1) / (gsize - 1)));
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 5920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef long int li;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
#define PI 3.14159265359
#define MOD 998244353
const int MAX = 510000;

int main() {
  ll N,M;cin>>N>>M;
  ll ans=0;
  if(N==1&&M==1){ans=1;}
  if(N==1&&M!=1){ans=M-2;}
  if(N!=1&&M==1){ans=N-2;}
  if(N>1&&M>1){ans=(N-2ll)*(M-2ll);}
  cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    int w,a,b,tmp;
    cin >> w >> a >> b;
    if(b < a){tmp = a; a = b; b = tmp;}
    if(a <= b && b <= a + w){cout << 0 << endl;}
    else{cout << b - (a + w) << endl;}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int f(int num, const vector<int>& v) {
    int n = v.size();
    if (num <= v[0]) return -1;
    int b = 0, e = n - 1;
    while (b < e) {
        int m = (b + e) / 2 + 1;
        if (v[m] < num) {
            b = m;
        } else {
            e = m - 1;
        }
    }
    return b;
}

int main() {
    int n;
    cin >> n;
    vector<int> va(n, 0), vb(n, 0), vc(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> va[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> vb[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> vc[i];
    }
    sort(va.begin(), va.end());
    sort(vb.begin(), vb.end());
    sort(vc.begin(), vc.end());
    vector<long long int> res1(n, 1), res2(n, 0), res3(n, 0);
    for (int i = 0; i < n; i++) {
        res1[i] = i + 1;
    }
    for (int i = 0; i < n; i++) {
        int index = f(vb[i], va);
        if (index >= 0) {
            res2[i] = res1[index];
            if (i > 0) {
                res2[i] += res2[i - 1];
            }
        }
    }
    for (int i = 0; i < n; i++) {
        int index = f(vc[i], vb);
        if (index >= 0) {
            res3[i] = res2[index];
            if (i > 0) {
                res3[i] += res3[i - 1];
            }
        }
    }
    cout << res3.back() << endl;
}




Measured memory_bytes: 6644
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN (-2147483647 - 1)
#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#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 Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;

class Union_Find {
private:
	vi p, r;
	int find(int x) {
		if (p[x] == x) return x;
		else return find(p[x]);
	}
public:
	Union_Find(int N) {
		p.resize(N);
		r.resize(N);
		Loop(i, N) {
			p[i] = i;
			r[i] = 0;
		}
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (r[x] < r[y]) p[x] = y;
		else {
			p[y] = x;
			if (r[x] == r[y]) r[x]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};


int main() {
	int n, q; cin >> n >> q;
	Union_Find uf(n);
	Loop(i, q) {
		int com, x, y; cin >> com >> x >> y;
		if (com == 0) {
			uf.unite(x, y);
		}
		else {
			cout << uf.same(x, y) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3096
// In The Name Of Allah
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e10;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pii;
const ll mod = 1e9 + 7;

 
void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const ll M = 500 + 10;
const ll N = 100 * 1000 + 10;

pair <ll , pii> p[N];


int main()	
{
	faster();
	ll n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> p[i].second.first >> p[i].second.second;
		p[i].first = p[i].second.first + p[i].second.second;
	}
	sort(p, p + n);
	reverse(p, p + n);
	ll ans = 0;
	for (int i = 0; i < n; i++)
	{
		if(i % 2 == 0)
			ans += p[i].second.first;
		else
			ans -= p[i].second.second;
	}
	cout << ans << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ff first
#define ss second
#define N 100005


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

	int n;
	cin >> n;
	int a[n];
	int sum  = 0;
	vector<int> pos, neg;
	pos.push_back(0);
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		sum += abs(a[i]);
		if(a[i] >= 0)
			pos.push_back(a[i]);
		else
			neg.push_back(a[i]);
	}
	sort(pos.begin(), pos.end());
	sort(neg.begin(), neg.end(), greater<int>());
	int ans;
	if(neg.size() > 0)
	{
		pos[0] = neg[0];
		neg.erase(neg.begin());
		if(pos.size() > 1)
			ans = sum;
		else
			ans = sum + 2 * pos[0]; 
	}
	else
	{
		pos.erase(pos.begin());
		ans = sum - 2 * pos[0];
	}

	int n1= pos.size();
	cout << ans << "\n";
	int in = 0;
	int last;

	last = pos[0];
	for (int i = 0; i < n1 - 2; ++i)
	{
		cout << last << " " << pos[i + 1] << "\n";
		last = last - pos[i + 1];
	}
	if(n1 != 1)
	{
		cout << pos[n1 - 1] << " " << last << '\n';
		last = pos[n1-1] - last;
	}
	
	int n2 = neg.size();
	for (int i = 0; i < n2; ++i)
	{
		cout << last << " " << neg[i] << "\n";
		last = last - neg[i];
	}
	return 0;
} 

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

int main(void){
    ll a,b;
    cin>>a>>b;
    if(a==b) cout<<a<<endl;
    else if(a%2==1&&b%2==1){
        if((b-a)%4==0) cout<<ll(a)<<endl;
        if((b-a)%4==2) cout<<ll(a^b^(b-1))<<endl;
    }
    else if(a%2==1&&b%2==0){
        if((b-a)%4==1) cout<<ll(a^b)<<endl;
        if((b-a)%4==3) cout<<ll(a^b^(b-1)^(b-2))<<endl;
    }
    else if(a%2==0&&b%2==1){
        if((b-a+1)%4==0) cout<<0<<endl;
        if((b-a+1)%4==2) cout<<1<<endl;
    }
    else if(a%2==0&&b%2==0){
        if((b-a)%4==0) cout<<b<<endl;
        if((b-a)%4==2) cout<<ll(b^(b-1)^(b-2))<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define pi 3.1415926535897932384
#define INF 2147483647
#define MOD 1000000007
#define MAX 200005
using namespace std;

typedef long long ll;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

int cost[MAX];
vector<int> graph[MAX];

void dfs(int u, int par)
{
    for(int i = 0; i < graph[u].size(); i++){
        int v = graph[u][i];
        if(v == par)
            continue;
        cost[v] += cost[u];
        dfs(v, u);
    }
}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, q, u, v;
    cin>>n>>q;

    for(int i = 0; i < n - 1; i++){
        cin>>u>>v;
        graph[u].pb(v);
    }

    for(int i = 0; i < q; i++){
        cin>>u>>v;
        cost[u] += v;
    }

    dfs(1, -1);

    for(int i = 1; i <= n; i++){
        cout<<cost[i]<<" ";
    }
    cout<<endl;

    return 0;
}



Measured memory_bytes: 26624
#include <iostream>
#include <stack>

using namespace std;

int main() {
    stack<int> s;
    int n;
    while(cin >> n) {
        if(n == 0) {
            cout << s.top() << endl;
            s.pop();
        }
        else s.push(n);
    }
    return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<algorithm>
#define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
#define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

using namespace std;
double b[110000];
double c[110000];
int w[110000];
double dp[110000];
int n;
double solve(int a){
	if(a==n)return 0;
	if(dp[a]>-0.5)return dp[a];
	double ret=999999999;
	double p=1;
	double ks=0;
	int val=0;
	for(int i=1;i<=100;i++){
		if(a+i>n)break;
		if(p<1e-9)break;
		val+=w[a+i-1];
		ks+=p*(1.0-c[a+i-1])*val;
		p*=c[a+i-1];
		ret=min(ret,solve(a+i)+(ks+p*val)/p+(a+i==n?0:1));
	}
	return dp[a]=ret;
}
int main(){
	BEGIN_STACK_EXTEND(60*1024*1024)
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++){
			scanf("%lf",b+i);
		}
		int now=0;
		for(int i=0;i<a;i++){
			if(i&&b[i]>0.999&&b[i-1]>0.999){
				w[now-1]++;
			}else{
				w[now]=1;
				c[now]=b[i];
				now++;
			}
		}
		n=now;
		for(int i=0;i<=n;i++){
			dp[i]=-1;
		}
		printf("%.12f\n",solve(0));
	//	for(int i=0;i<=n;i++)printf("%f ",dp[i]);
	//	printf("\n");
	}
	END_STACK_EXTEND
}

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

int main(){
  int n;
  cin>>n;
  long arr[100000][3];
    long dp[100000][3];
  for(int i=0;i<n;i++){
    cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
  }
  dp[0][0]=arr[0][0];
  dp[0][1]=arr[0][1];
  dp[0][2]=arr[0][2];
  for(int i=1;i<n;i++){
   dp[i][0]=arr[i][0]+max(dp[i-1][1],dp[i-1][2]); 
   dp[i][1]=arr[i][1]+max(dp[i-1][0],dp[i-1][2]); 
   dp[i][2]=arr[i][2]+max(dp[i-1][1],dp[i-1][0]); 
    }
  cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 4992
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

    /**
    * お金
    */
    private static final String MONEY = "100000";

    /**
    * 利子
    */
    private static final String INTEREST_RATE = "0.05";

    /**
    * @param args n週間
    */
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int weeks = in.nextInt();

        //借金を計算します。
        int debt = calcDebt(MONEY, INTEREST_RATE, weeks);

        System.out.println(debt);
        in.close();
    }

    /**
    * n週間後の借金を計算。1000未満は切り上げる。<br>
    * @param money 借金
    * @param interestRate 利子
    * @param weeks n週間
    * @return n週間後の借金
    */
    private static int calcDebt(String money,
            String interestRate, int weeks) {

        BigDecimal debt = new BigDecimal(money);

        for(int i = 0; i < weeks; i++){
            debt  = debt.add(calcInterest(debt, INTEREST_RATE));
        }
        return debt.intValue();
    }

    static BigDecimal calcInterest(BigDecimal debt, String interestRate){
        debt = (debt).multiply(new BigDecimal(interestRate));
        return debt.setScale(-3, BigDecimal.ROUND_UP);
    }
}

Measured memory_bytes: 17256
n,m=map(int,input().split())
last=0
x=[-1]*n
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    x[b]=max(a,x[b])
ans=0
for i in range(0,n):
    if last<=x[i]:
        ans+=1
        last=i
print(ans)


Measured memory_bytes: 5944
import java.io.PrintWriter
import java.util.*

fun main(args: Array<String>) = IO().exec {
    val k = int()
    val a = LongArray(k){long()}
    a.reverse()
    var range = 2L..3
    var isOk = true
    if (a[0] != 2L) isOk = false
    if (isOk) for (i in 1 until k) {
        val p = range.first.ceilMod(a[i])
        if (p in range) {
            range = p until (range.last / a[i] + 1) * a[i]
        } else {
            isOk = false
            break
        }
    }
    if (isOk) {
        println("${range.first} ${range.last}")
    } else {
        println(-1)
    }
}

fun Long.ceilDiv(k: Long): Long = (this + k - 1) / k
fun Long.ceilMod(m: Long): Long = this.ceilDiv(m)*m

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = PrintWriter(System.out)
    fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = System.`in`.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }
    fun readByte(): Byte {
        return if (hasNextByte()) buffer[ptr++] else return -1
    }
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }
    fun string(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }
    fun long(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }
    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }
    fun double(): Double {
        return string().toDouble()
    }
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}

Measured memory_bytes: 38348
N,L= map(int,input().split())

min=100
sum=0
for i in range(1,N+1):
  if abs(L+i-1)<=abs(min):
    min= L+i-1
  sum += L+i-1 
  #print(i,L+i-1,sum)
sum -= min

print(sum)
  

Measured memory_bytes: 2940
n = int(input())
a = list(map(int,input().split()))
ans = [[0 for i in range(n+1)] for j in range(n+1)]
p = []
for i in range(n):
    p.append([a[i],i])
p.sort(reverse=True)

for i in range(1,n+1):
    ans[0][i] = ans[0][i-1] + p[i-1][0]*abs(p[i-1][1]-i+1)
for i in range(1,n+1):
    ans[i][0] = ans[i-1][0] + p[i-1][0]*abs(n-i-p[i-1][1])

for i in range(1,n):
    for j in range(1,n-i+1):
        ans[i][j] = max(ans[i][j-1] + p[i+j -1][0]*abs(p[i+j -1][1]-j+1),
        ans[i-1][j] + p[i+j - 1][0]*abs(n-i-p[i+j-1][1]))

ma = 0
for i in range(n):
    ma = max(ma,ans[0+i][n-i])
print(ma)

Measured memory_bytes: 107580
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<limits.h>

using namespace std;

int main(){
  int A,B,M;
  int mina, minb;
  mina = INT32_MAX; minb = mina;
  cin >> A >> B >> M;
  int a[A], b[B], m[M][3];

  for(int i=0; i< A; i++){
    int x;
    cin >> x;
    a[i]=x;
    if(x<mina ) mina = x;
  }
  for(int i=0; i<B; i++){
    int x;
    cin >> x;
    b[i]=x;
    if(x<minb ) minb = x;
  }
  int minc ;
  minc = mina + minb;

  for (int i=0; i<M; i++){
    int x,y,c;
    cin >> x>>y>>c;

    if(a[x-1]+b[y-1]-c < minc ) minc = a[x-1]+b[y-1]-c;
    
  }
  cout << minc << endl;
  return 0;
  }

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

    char c = s[k-1];

    for(int i=0; i<n; i++) {
        if (s[i] != c)  s[i] = '*';
    }

    cout << s << endl;

}


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

int main(){
  int n;
  int a[10];
  cin>>n;
  while(n--){
    for(int i=0;i<10;i++) cin>>a[i];
    stack<int> b,c;
    b.push(0);c.push(0);
    for(int i=0;i<10;i++){
      if(b.top()>a[i]&&c.top()>a[i]){
	cout<<"NO"<<endl;
	break;
      }
      else if(b.top()>=c.top()&&b.top()<a[i]) b.push(a[i]);
      else c.push(a[i]);
      if(i==9) cout<<"YES"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1192
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int x;
    cin >> x;
    if (x >= 400 && x <= 599) {
        cout << "8" << endl;
    }
    else if (x >= 600 && x <= 799) {
        cout << "7" << endl;

    }
    else if (x >= 800 && x <= 999) {
        cout << "6" << endl;
    }
    else if (x >= 1000 && x <= 1199) {
        cout << "5" << endl;;
    }
    else if (x >= 1200 && x <= 1399) {
        cout << "4" << endl;
    }
    else if (x >= 1400 && x <= 1599) {
        cout << "3" << endl;
    }
    else if (x >= 1600 && x <= 1799) {
        cout << "2" << endl;
    }
    else if (x >= 1800 && x <= 1999) {
        cout << "1" << endl;
    }

    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a[n+1];
    for(int i=0;i<n+1;i++){
        cin>>a[i];
    }
    int b[n];
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        if(a[i]>=b[i]){
            ans+=b[i];
            a[i] = a[i] - b[i];
            b[i] = 0;
        }else{
            ans += a[i];
            b[i] = b[i] - a[i];
            a[i] = 0;
            if(a[i+1]>=b[i]){
                ans+=b[i];
                a[i+1] = a[i+1] - b[i];
                b[i] = 0;
                
            }else{
                ans+= a[i+1];
                b[i] = b[i] - a[i+1];
                a[i+1] = 0;
                
            }
        }
       // cerr<<ans<<endl;
    }
    cout<<ans<<endl;
    return 0;
    
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    string S;
    cin >> S;
    S = "#" + S;
    int maxi = max(C, D);
    for(int i = A; i < maxi; i++) {
        if(S[i] == '#' && S[i+1] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }
    if(C < D) {
        cout << "Yes" << endl;
        return 0;
    }
    for(int i = B; i <= D; i++) {
        if(S[i-1] == '.' && S[i] == '.' && S[i+1] == '.') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 892
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        int n, r, p, c;
        Scanner scan = new Scanner(System.in);
        while((n = scan.nextInt()) != 0 && (r = scan.nextInt()) != 0) {
            int[] number = new int[n];

            for(int i=1; i<=n; i++){
                number[i-1] = i;
            }

            for (int i = 0; i < r; i++) {
                ArrayList<Integer> tmp = new ArrayList<Integer>();
                p = scan.nextInt();
                c = scan.nextInt();

                for(int j=0; j<p-1; j++){
                    tmp.add(number[n-j-1]);
                }

                for (int k = 0; k < c; k++) {
                    number[n - 1 - k] = number[n - p - k];
                }

                for(int m=0; m<p-1; m++){
                    number[n-c-m-1] = tmp.get(m);
                }
            }
            System.out.println(number[n-1]);
        }
    }
}

Measured memory_bytes: 31232