akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using namespace std;

// #define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll mod = (1000000007LL);

inline ll poww(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if(b & 1) res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res;
}
inline pii operator+(pii A, pii B){
	return pii(A.f + B.f, A.s + B.s);
}
inline pii operator-(pii A, pii B){
	return pii(A.f - B.f, A.s - B.s);
}
inline ll mult(ll a, ll b){
	return (a * b) % mod;
}

ll gcd (ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

/*
	>Colocar (>DEFINE INT LONG LONG<) no inicio do template
	>mod = (1e9 + 7), por padrao (NAO ESQUECER DE ALTERAR)
	>NAO ESQUECER DEFINE INT LONG LONG
	> N = 1 ? 
*/

///CUIDADO COM MAXN
#define N 300050

int n, m, q, k, v[N];

pii TT, w[N];

int s;
int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(0);
    cin>>n>>k>>s;
    for(int i = 1; i <= n; i++){
        if(i <= k) cout<<s<<" ";
        else if(s == (1000000000)) cout<<"1 ";
        else cout<<s+1<<" ";
    }
    cout<<"\n";
}

Measured memory_bytes: 1280
import math

a,b,c=(int(x) for x in input().split())
s=1/2*a*b*math.sin(c/180*math.pi)
l=math.sqrt(a**2+b**2-2*a*b*math.cos(c/180*math.pi))+a+b
h=s/a*2
print('{:.05f}'.format(s))
print('{:.05f}'.format(l))
print('{:.05f}'.format(h))



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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    ll a, b;
    cin >> a >> b;
    if(abs(a - b) % 2 == 1){
        cout << "IMPOSSIBLE" << endl;
    }else{
        cout << max(a, b) - abs(a - b) / 2 << endl;
    }
}

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

int A, B = 0;

int main(){
  cin >> A >> B;
  if (A >= 13) cout << B << endl;
  else if (6 <= A and A <= 12) cout << B/2 << endl;
  else cout << "0" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >

using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=2e5+10, mod=1e9+7;


int main ()
{
    FASTIO
    int a;
    string s;
    cin >> a >> s;
    if(a>=3200){
        cout << s << endl;
    }
    else {
        cout << "red" << endl;
    }
    return 0;
}
/**

*/


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

using namespace std;

#define int long long
#define MP make_pair

constexpr int INF = 1LL << 60;
constexpr int MOD = 998244353;
constexpr double EPS = 1.0e-11;

typedef pair<int, int> pii;
typedef pair<int, pii> pipii;

constexpr int MAX_N = 200005;
constexpr int MAX_IDX = 2 * MAX_N;

int cnts[MAX_IDX], n, a[MAX_N];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(16);

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        int idx = i + 1 + a[i];
        if (idx < 0 || MAX_IDX <= idx) continue;
        cnts[idx]++;
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int idx = i + 1 - a[i];
        if (idx < 0 || MAX_IDX <= idx) continue;
        ans += cnts[idx];
    }

    cout << ans << endl;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
#define dbg(x) cout << #x << ": " << (x) << '\n'
#define ff first
#define ss second
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

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

   int n;
   cin >> n;
   vector <double> p(n);
   vector <vector <double>> dp(n + 1, vector <double> (n + 1));

   dp[0][0] = 1;
   for (auto &i : p)
      cin >> i;
   for (int i = 0; i < n; i++) {
      for (int j = 0; j <= i; j++) {
         dp[j + 1][i - j] += dp[j][i - j] * p[i];
         dp[j][i - j + 1] += dp[j][i - j] * (1 - p[i]);
      }
   }

   double ans = 0;
   for (int i = (n + 1) / 2; i <= n; i++) {
      ans += dp[i][n - i];
   }

   cout << fixed << setprecision(10) << ans << '\n';

   return 0;
}

Measured memory_bytes: 70784
x,n=map(int, input().split()) 
p=list(map(int,input().split()))
s=100
t=0
c=0
if p==[]:
    print(x)
    c=1
if c==0:
    for i in range(-201,201):
        if not i in p:
            if abs(x-i)<s:
                # print(i,abs(x-i))
                s = abs(x-i)
                t=i
    print(t)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, b;
  cin >> n >> a >> b;
  long long x = 0;
  if (n % (a+b) > a) {
    x = a;
  }
  else {
    x = n%(a+b);
  }
  cout << n/(a+b)*a+x << endl;
}

Measured memory_bytes: 3616
#include <stdio.h>
int main(void)
{
 int n=0,i,j;
 char s[202];
 scanf("%s",s);
 while(s[n]!='\0'){
  n++;
 }
 for(i=n-1;i>0;i--){
  if(i%2==0){
   for(j=0;j<i/2;j++){
    if(s[j]!=s[(i/2)+j])
      break;
   }
   if(j==i/2)
    break;
  }
 }
 printf("%d",j*2);
 
 return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define nn 65536*2
#define mod 1000000007
#define ll long long
string s;
int has[32453];
int main()
{
	cin>>s;for(int i=0;i<s.size();i++) has[s[i]]++;
	if((has['N']>0)^(has['S']>0) or (has['W']>0)^(has['E']>0))
		puts("No");
	else puts("Yes");
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define ABS(a,b) max(a,b) - min(a,b)

ll n, a, b, dp[1100][1100],ans = INF;
int main(){
	cin >> n >> a >> b;
	REP(i, 1000) REP(j, 1000) dp[i][j] = INF;
	dp[0][0] = 0;
	REP(k, n) {
		int x, y, z;
		cin >> x >> y >> z;
		REPR(i, 500) {
			REPR(j, 500) {
				dp[i + x][j + y] = min(dp[i][j] + z, dp[i + x][j + y]);
			}
		}
	}
	REPO(i, INF) {
		ans = min(dp[i * a][i * b], ans);
		if (i * a > 500 or i * b > 500)break;
	}
	cout << (ans == INF ? -1 : ans) << endl;

}

Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
int n,wei,m;
bool f(int i)
{
	int maxn=pow(-2,i),minn=pow(-2,i);
	for(int j=0;j<i;j+=2)
		maxn+=pow(-2,j);
	for(int j=1;j<i;j+=2)
		minn+=pow(-2,j);
	if(maxn>=n&&minn<=n)
		return 1;
	return 0;
}
int main()
{
	cin>>n;
	if(n==0)
	{
		cout<<0<<endl;
		return 0;
	}
	for(int i=0;;i++)
		if(f(i)==1)
		{
			wei=i;
			n-=pow(-2,i);
			cout<<1;
			break;
		}
	for(int i=wei-1;i>=0;i--)
	{
		if(f(i)==1)
		{
			n-=pow(-2,i);
			cout<<1;
		}
		else
			cout<<0;
	}
	return 0;
}

Measured memory_bytes: 512
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val ww = next().toList().sorted()

    var lastChar = '-'
    var count = 0

    for (w in ww) {
        if (w != lastChar) {
            if (count % 2 == 1) {
                println("No")
                return
            }
            lastChar = w
            count = 1
            continue
        }
        count++
    }

    println(if (count % 2 == 1) "No" else "Yes")
}

fun next() = readLine()!!

fun println(value : Any) {
    pw.println(value)
}

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

int main()
{
    // input
    int N;

    cin >> N;
    vector<int> v(N);

    for (int i = 0; i < N; i++)
        cin >> v[i];

    sort(v.begin(), v.end());

    double r = v.at(0);

    for (int i = 1; i < N ; i++)
    {
        r = ( r + v.at(i )) / 2;
    }

    cout << r << endl;
}

Measured memory_bytes: 256
#include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<cstdlib>
    using namespace std;
    int n,m,a[100005],cnt[100005];
    int main(){
    	cin>>n;
    	int ans=0;
    	for(register int i=1;i<=n;i++)cin>>a[i];
    	for(register int i=1;i<=n;i++)if(a[i]==i){
    		if(i==n)ans++,swap(a[i],a[i-1]);
    		else swap(a[i],a[i+1]),ans++;
    	}
    	cout<<ans<<endl;
    	return 0;
    }

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] lst = new int[3];
        for(int i=0;i<3;i++){lst[i]=sc.nextInt();}
        for(int i=1;i<3;i++){
            int x=lst[i],g=i-1;
            while(g>=0 && x<lst[g]){
                lst[g+1]=lst[g];lst[g]=x;g--;
            }
        }
        System.out.printf("%d %d %d\n",lst[0],lst[1],lst[2]);
    }
}



Measured memory_bytes: 26328
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()

typedef long long ll;
typedef pair < int , int >  pii;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
//#define int long long

inline void solve(){
    
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++) {
        cin >> h[i] ;
    }
    int p = h[0];
    int ma = 0,cnt=0;
    for(int i = 1; i < n; i++) {
        if(h[i] > p){
            chmax(ma,cnt);
            cnt = 0;
        }
        else{
            cnt++;
        }
        p = h[i];
    }
    chmax(ma,cnt);
    
    cout << ma << endl;
            

}

struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}



Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char* F(char *b,int n,FILE *f){char *r=fgets(b,n,f);if(!r)return NULL;b[strlen(b)-1]=0;return r;}
char Q[29999],*q[9],L[29999];
int n;
dfs(old_indent,depth){
	int indent=0;
	if(!F(L,sizeof(L),stdin)){puts("no such property");exit(0);}
	for(;L[indent]==' ';indent++);
	if(old_indent>=indent){puts("no such property");exit(0);}
	char *name=strtok(L+indent,":"),*value=name+strlen(name)+1;
	if(!strcmp(name,q[depth])){
		if(depth==n-1){
			if(*value)
				printf("string \"%s\"\n",value+1),exit(0);
			else
				puts("object"),exit(0);
		}
		dfs(indent,depth+1);
	}
	dfs(old_indent,depth);
}
main(){F(Q,sizeof(Q),stdin);q[0]=strtok(Q+1,".");for(n=1;;n++)if(!(q[n]=strtok(NULL,".")))break;dfs(-1,0);}

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

vector<int>d(5);
int main(void){
    rep(i, 5){
        cin>>d[i];
    }
    vector <int>v(5);
    int max=0;
    rep(i, 5){
        int a;
        if(d[i]%10==0){
            a=d[i];
        }
        else{
            a=10*(d[i]/10)+10;
        }
        v[i]=a;
        if(max<a-d[i]) max=a-d[i];        
    }

    int ans=accumulate(v.begin(), v.end(), 0);

    cout<<ans-max<<endl;


}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
int a[200005],b[200005];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		b[i]=a[i]; 
	}
	sort(a,a+n);
	int x=n/2;
	for(int i=0;i<n;i++)
	{
		if(b[i]<a[x])
		{
			printf("%d ",a[x]);
		}
		else
		printf("%d ",a[x-1]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    string s = "01235789";
    while(cin >> n, n){
        string ans;
        while(n){
            ans += s[n%8];
            n /= 8;
        }
        reverse(ans.begin(),ans.end());
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define NUM 1000000007
unordered_set<ll> hot,cold;
void ft(vector<ll> &v, ll m){
    ll n = v.size();
    cold.insert(0);
    for(ll i=0;i<=m;i++){
        int flag=0;
        for(int j=0;j<n;j++){
            if(v[j]<=i){
                if(cold.find(i-v[j])!=cold.end()){
                    hot.insert(i);
                    flag=1;
                    break;
                }
            }
        }
        if(flag==0)
            cold.insert(i);
    }
}
int main(){
	ios::sync_with_stdio();
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,k,tmp;
	cin>>n>>k;
	vector<ll> v;
	for(int i=0;i<n;i++){
        cin>>tmp;
        v.pb(tmp);
	}
	hot.clear();
	cold.clear();
	ft(v,k);
	/*cout<<"hot"<<endl;
	for(auto x : hot){
        cout<<x<<" ";
	}
	cout<<endl;
	cout<<"cold"<<endl;
	for(auto x : cold)
        cout<<x<<" ";
    cout<<endl;*/
	if(hot.find(k)!=hot.end())
        cout<<"First"<<endl;
    else
        cout<<"Second"<<endl;
  	return 0;
}


Measured memory_bytes: 7388
s=raw_input()

def calc(c):
    ma=0
    count=0
    fi=True
    for i in range(len(s)):
        if s[i] == c:
            if not fi:
                count = (count+1)/2
            if count > ma:
                ma = count
            count=0
        else:
            count+=1
    if count > ma:
        ma = count
    return ma

mi=1000
for c in "abcdefghijklmnopqrstuvwxyz":
    if c not in s:
        continue
    m=calc(c)
    if m < mi:
        mi = m
print mi

Measured memory_bytes: 2568
w = sorted(input())
count = 0
ans = 'Yes'
for i in range(len(w)-1):
  count += 1
  if w[i]!=w[i+1]:
    if count%2!=0:
      ans = 'No'
      break
    else:
      count = 0
print(ans if len(w)>1 else 'No')

Measured memory_bytes: 9012
#include<iostream>
int main()
{
	int a[300], b[300], c[300];
	int i = 0;
	int j = 0;
	for ( int i = 0; i < 300; i++ )
	{
		std::cin >> a[i] >> b[i] >> c[i];
		if ( a[i] == -1 && b[i] == -1 && c[i] == -1 )
		{
			break;
		}
		else
			{
				j++;
		    }
	}
		for ( int i = 0; i < j; i++ )
	{
        if ( a[i] == -1 || b[i] == -1 )
		{
			std::cout << 'F'<< '\n' ;
		}
        else if ( a[i] + b[i] >= 80 )
	    {
			std::cout << 'A' << '\n';
		}
		else if ( (a[i] + b[i] < 80) && ( a[i] + b[i] >= 65) )
		{
			std::cout << 'B' << '\n';
		}
		else if ( (a[i] + b[i] < 65) && ( a[i] + b[i] >= 50) )
			{
			std::cout << 'C'<< '\n' ;
		    }
		else if ( a[i] + b[i] < 30 )
			{
			std::cout << 'F'<< '\n' ;
		    }
		else if ( (a[i] + b[i] < 50) && ( a[i] + b[i] >= 30) && (c[i] >= 50) )
		{
		std::cout << 'C' << '\n';
		}
		else if ( (a[i] + b[i] < 50) && ( a[i] + b[i] >= 30) && (c[i] < 50) )
		{
		std::cout << 'D' << '\n';
		}
	}
	return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(void){
    int n,x,dis,i,count=1,sum=0;
    scanf("%d %d",&n,&x);
    for(i=0;i<n;i++){
        scanf("%d",&dis);
        sum+=dis;
        if(sum>x){
            break;
        }
        count++;
    }
    printf("%d",count);
}

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

int main() {
  int x;
  cin >> x;
  if (1200>x){
    cout << "ABC"<< endl;
  } else if (2800>x){
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  } if (0){
    cout << "ababababababa nandekonnanowo,,,tukasa-moukoregutidayona-" << endl;
}}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int N;
      cin >> N;
      
      vector<int> left(N);
      vector<int> right(N);
      
      for(int i=0;i<N;i++){
        cin >> left.at(i) >> right.at(i);
      }
      
      for(int i=0;i<N-2;i++){
        if(left.at(i)==right.at(i)){
          if(left.at(i+1)==right.at(i+1)){
            if(left.at(i+2)==right.at(i+2)){
              cout << "Yes" << endl;
              break;
            }
          }
        }
        if(i==N-3){
          cout << "No" << endl;
        }
      }
      
    }

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

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

  int a, b, c;
  cin >> a >> b >> c;

  for (int x = 1; x <= b; ++x) {
    if ((a * x - c) % b == 0) {
      cout << "YES" << "\n";
      return 0;
    }
  }
  cout << "NO" << "\n";

}


Measured memory_bytes: 3628
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
b = [[sum(a[i]), i] for i in range(n)]

taka, aoki = 0, 0
b.sort()
b.reverse()
for i in range(n):
  if i % 2 == 0:
    taka += a[b[i][1]][0]
  else:
    aoki += a[b[i][1]][1]

print(taka-aoki)

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

#define int long long
#define REP(i, n) for ( int i = 0; i < (n); i++ )

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int A, B, M;
  cin >> A >> B >> M;

  vector<int> a(A), b(B);
  int mia = 1000000, mib = 1000000;
  for ( int i = 0; i < A; i++ ) {
    cin >> a[i];
    mia = min(mia, a[i]);
  }

  for ( int i = 0; i < B; i++ ) {
    cin >> b[i];
    mib = min(mib, b[i]);
  }

  int ans = mia+mib;  
  for ( int i = 0; i < M; i++ ) {
    int x, y, c;
    cin >> x >> y >> c;
    x--; y--;
    ans = min(ans, a[x]+b[y]-c);    
  }

  cout << max(0LL, ans) << endl;
  
  return 0;
}


Measured memory_bytes: 1792
N=int(input())
l = [[] for _ in range(9)]
for i in range(0,9):
    for j in range(0,9):
        l[i].append(0)
for i in range(N+1):
    if (int(str(i)[0])!=0 and int(str(i)[-1])!=0):
        l[int(str(i)[0])-1][int(str(i)[-1])-1]+=1
t=0
for i in range(9):
    for j in range(9):
        t+=l[i][j]*l[j][i]
print(t)

Measured memory_bytes: 9152
#include <stdio.h>
#define ll long long int

int main() {
    int n;
    scanf("%d", &n);
    ll arr[n], max = 1000000000000000000, prod = 1, flag = 0, zero = 0;
    for (int i = 0; i < n; i++) {
        scanf("%lld", &arr[i]);
        arr[i] > max ? flag = 1 : flag = flag;
        prod *= arr[i];
        arr[i] ? max /= arr[i] : zero = 1;
    }
    if (zero) {
        puts("0");
    }
    else {
        flag ? printf("-1\n") : printf("%lld\n", prod);
    }
    return 0;
}


Measured memory_bytes: 2484
#include<iostream>
#include<string>
#include<cmath>
using namespace std;

int main(void){
  string st1, st2;
  int q, val[1001][1001];

  cin >> q;

  for(int i=0; i<q; i++){
    cin>>st1;
    cin>>st2;

    for(int j=0; j<=st1.length(); j++){
      for(int k=0; k<=st2.length(); k++){

	if(j==0 || k==0) val[j][k] = 0;
	else{
	  if(val[j-1][k] == min(st1.length(), st2.length())){
	    val[j][k] = st1.length();
	  }else{

	    if(st1[j-1] == st2[k-1]){
	      val[j][k] = val[j-1][k-1]+1;
	    }else{
	      val[j][k] = max(val[j-1][k], val[j][k-1]);
	    }
	  }
	}
      }
    }

    /*
      for(int j=0; j<=st1.length(); j++){
      for(int k=0; k<=st2.length(); k++){
      cout << val[j][k] << " ";
      }
      cout << "\n";
      }
    */

    cout << val[st1.length()][st2.length()] << "\n";
  }

  return 0;
}



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

using namespace std;
int main(){
  int str;
  cin >> str;
  int a=str%10;
  int b=(str%100-a)/10;
  int c=(str-a-(b*10))/100;
  if(a==1) a=9;
  else a=1;
  if(b==1) b=9;
  else b=1;
  if(c==1) c=9;
  else c=1;
  str=a+(b*10)+(c*100);
  cout << str << endl;
}


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

bool comp(vector<int> a, vector<int> b){
    return a[0] < b[0];
}

int time(string str){  //入力形式に対して秒を返す

    //hh:mm:ss
    int s = (int)str[7] - '0' + ((int)str[6] - '0')*10;
    int m = (int)str[4] - '0' + ((int)str[3] - '0')*10;
    int h = (int)str[1] - '0' + ((int)str[0] - '0')*10;
    
    return s + 60*m + 3600*h;
}

int main(){

    while(1){

        int n; cin >> n;
        if(!n) break;

        vector<vector<int> > train(2*n, vector<int> (2));
        

        for(int i = 0; i < n; i++){
            string s;
            cin >> s;
            train[i][0] = 2*time(s) + 1;
            train[i][1] = 1;
            cin >> s;
            train[n + i][0] = 2*time(s) - 1;
            train[n + i][1] = -1;
        }

        sort(train.begin(), train.end(), comp);

        /*for(int i = 0; i < 2*n; i++){
            cout << train[i][0] << " " << train[i][1] << endl;
        }*/

        int count = 0;
        int ans = 0;

        for(int i = 0; i < 2*n; i++){
            if(train[i][1] == 1) count++;
            else count--;
            ans = max(ans, count);
        }

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


Measured memory_bytes: 3884
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int H, W;
    char field[120][120];
    scanf("%d%d", &H, &W);
    for(int i = 0; i < H; i++){
        scanf("%s", field[i]);
    }
    
    for(int i = 0; i < H; i++){
        int flag = 0;
        for(int j = 0; j < W; j++){
            if(field[i][j] == '#'){
                flag = 1;
                break;
            }
        }
        
        if(flag == 0){
            for(int j = 0; j < W; j++){
                field[i][j] = '0';
            }
        }
    }
    
    for(int i = 0; i < W; i++){
        int flag = 0;
        for(int j = 0; j < H; j++){
            if(field[j][i] == '#'){
                flag = 1;
                break;
            }
        }
        if(flag == 0){
            for(int j = 0; j < H; j++){
                field[j][i] = '0';
            }
        }
    }
    
    for(int i = 0; i < H; i++){
        int flag = 0;
        for(int j = 0; j < W; j++){
            if(field[i][j] != '0'){
                printf("%c", field[i][j]);
                flag++;
            }
        }
        if(flag > 0)
        printf("\n");
    }
    
    return 0;
}

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

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	long long n, i, j, k, x, ans, s, head;
	ans = 0;
	cin >> n;
	vector<long long> a(n);
	for (i = 0; i < n; i++) cin >> a[i];

	s = 0; head = 0;
	for (i = 0; i < n; i++) {
		while (s & a[i]) {
			s ^= a[head];
			head++;
		}
		ans += (i + 1 - head);
		s ^= a[i];
	}

	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 1792
import sys

n = int(input())
dp = [0, 0, 0]
for line in sys.stdin.readlines():
    a, b, c = map(int, line.split())
    ndp = [0, 0, 0]
    ndp[0] = max(dp[1], dp[2]) + a
    ndp[1] = max(dp[0], dp[2]) + b
    ndp[2] = max(dp[0], dp[1]) + c
    dp = ndp
print(max(dp))


Measured memory_bytes: 57948
N = int(input())
S = list(input())
Q = int(input())
query = [input().split() for _ in range(Q)]

bit = [[0 for _ in range(26)] for _ in range(N + 1)]

def bit_add(i, s, x):
    j = ord(s) - ord("a")
    while i <= N:
        bit[i][j] += x
        i += i & - i
        
def bit_sum(i):
    s = [0] * 26
    while i:
        for j in range(26):
            s[j] += bit[i][j]
        i -= i & -i
    return s
for i in range(1, N + 1):
    s = S[i - 1]
    bit_add(i, s, 1)

for x, y, z in query:
    if x == "1":
        y = int(y)
        bit_add(y, S[y - 1], -1)
        bit_add(y, z, 1)
        S[y - 1] = z
    if x == "2":
        answer = 0
        y, z = int(y) - 1, int(z)
        sum_y = bit_sum(y)
        sum_z = bit_sum(z)
        for i in range(26):
            if sum_z[i] - sum_y[i] > 0:
                answer += 1
        print(answer)


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

const int N = 500009;
const int mod = 1000000007;

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);
#define int long long int
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(a) a.begin(), a.end()

int n, m, v, p;
int a[N];

bool check(int x)
{
	int idx = n - x;
	int val = a[idx] + m;
	int inc = 0;
	for (int i = 0; i <= (n - p); i++)
	{
		if (i == idx)
			continue;
		if (a[i] > val)
			return 0;
		inc += min(m, val - a[i]);
	}
	int bacha = v - p;
	if (bacha <= 0)
		return 1;
	if (inc >= (bacha * m))
		return 1;
	return 0;
}

void pre()
{
}

int32_t main()
{
	IOS;
	pre();
	cin >> n >> m >> v >> p;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a, a + n);
	int l = p;
	int r = n;
	while (l < r)
	{
		if (check((l + r + 1) / 2))
		{
			l = (l + r + 1) / 2;
		}
		else
		{
			r = ((l + r + 1) / 2) - 1;
		}
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 1024
import sys
C = [list(map(int,input().split())) for _ in range(3)]

for j in range(2):
    for i in range(2):
        if C[i+1][j+1]-C[i+1][j]!=C[i][1+j]-C[i][j]:
            print('No')
            sys.exit()

print('Yes')


Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main(void) {
    int n, cnt = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        if (a % 2 == 1)cnt++;
    }
    cout << (cnt % 2 == 0 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
n = int(input())
lis = [list(map(int,input().split())) for i in range(n)]
for i in range(n):
  lis[i].append(lis[i][1]-lis[i][0])
lis.sort(key = lambda x:x[1])
time = 0
for i in range(n):
  time += lis[i][0]
  if time > lis[i][1]:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 60000
n=int(input())
p="".join([i for i in input().split()])
q="".join([i for i in input().split()])
hoge=[]
def dfs(q,st):
    global hoge
    if q==n:
        hoge.append(st)
    else:
        for i in range(1,n+1):
            if str(i) not in st:
                dfs(q+1,st+str(i))
dfs(0,"")
hoge.sort()
print(abs(hoge.index(p)-hoge.index(q)))

Measured memory_bytes: 5912
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <functional>
#include <string.h>

using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a,0,sizeof(a))
#define minus(a) memset(a,0xff,sizeof(a))
#define chmax(a,b) a=min((a),(b))
#define chmin(a,b) a=max((a),(b))


#define MOD 1000000007

typedef pair<int,int>P;
#define INF (1<<29)

template <typename T>
class Bit {
public:
	vector<T> a;
	Bit(int n) {
		a.resize(n + 1);
	}
	void add(int x, T y) {
		for (int i = x; i < a.size(); i += (i&-i)) {
			a[i] += y;
		}
	}

	T sum(int x) {
		T ret = 0;
		for (int i = x; i > 0; i -= (i&-i)) {
			ret += a[i];
		}
		return ret;
	}
};

string s;
vector<vector<int> > a(26), aa(26);
vector<vector<int> > b(26);

int main(){
	cin >> s;
	rep(i, s.size()) {
		a[s[i] - 'a'].push_back(i);
		b[s[i] - 'a'].push_back(1);
	}
	int cnt = 0;
	string ss;
	ll ans = 0;
	char kisuu;
	rep(i, 26) {
		if (a[i].size() % 2) {
			cnt++;
			kisuu = i + 'a';
		}
	}
	if (s.size() % 2 && (cnt != 1)) {
			ans = -1;
	}
	else if ((s.size() % 2 == 0) && (cnt != 0)) {
		ans = -1;
	}
	else {
		rep(i, s.size()) {
			if(aa[s[i] - 'a'].size() < a[s[i] - 'a'].size() / 2) {
				aa[s[i] - 'a'].push_back(i);
				ss += s[i];
			}
		}
		string sss = ss;
		if (s.size() % 2) {
			sss += kisuu;
		}
		reverse(all(sss));
		ss += sss;
	}
	Bit<ll> bit(s.size());
	rep(i, ss.size()) {
		int c = ss[i]-'a';
		int pos = lower_bound(b[c].begin(), b[c].end(), 1) - b[c].begin();

		b[c][pos] = 0;
		ans += i - bit.sum(a[c][pos] + 1);
		bit.add(a[c][pos] + 1, 1);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4856
function main(input){
  var num = 0;//合計回復量
  var i = 0;//たこやきカウンタ
  var counter = 0;//かけるたこ焼きカウンタ
  var inputN;
  var inputD;
  input = input.split('\n');
  inputN = parseInt(input[0]);
  inputD =  input[1].split(' ');

  while(i<inputN){
    while(counter<inputN){
      if(i != counter && i < counter ){
        num = num + parseInt(inputD[i]) * parseInt(inputD[counter]);
      }
      counter++;
    }
    counter=0;
    i++;
  }
  console.log(num);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


template<std::size_t T>
class ncr_t {
public:
  ncr_t() {
    memo_ = std::unique_ptr<std::unique_ptr<long long[]>[]>(new std::unique_ptr<long long[]>[T]);

    for (int i = 0; i < T; i ++) {
      memo_[i] = std::unique_ptr<long long[]>(new long long[T]);

      memo_[i][0] = memo_[i][i] = 1;
    }

    for (int i = 1; i < T; i ++)
      for (int j = 1; j < i; j ++)
        memo_[i][j] = memo_[i - 1][j - 1] + memo_[i - 1][j];
  };

public:
  long long operator()(int n, int r) const {
    assert(r <= n);

    return memo_[n][r];
  };

private:
  std::unique_ptr<std::unique_ptr<long long[]>[]> memo_;
};


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, A, B;

  long long v[55];

  std::cin >> N >> A >> B;

  for (int i = 0; i < N; i ++)
    std::cin >> v[i];

  std::sort(v, v + N, std::greater<long long>());

  std::vector<std::pair<long long, int>> a;

  long long sp = 0, np = 1;

  long long s = 0;
  
  for (int i = 1; i <= N; i ++) {
    s += v[i - 1];

    if (A <= i && i <= B) {
      double m = 1. * s / i;

      a.emplace_back(s, i);

      if (s * np > sp * i) {
        sp = s;
        np = i;
      }
    }
  }

  std::cout << 1. * sp / np << std::endl;

  long long C = 0;

  ncr_t<100> ncr;

  for (const auto& pair : a) {
    long long s = pair.first, n = pair.second;

    if (s * np == sp * n) {
      long long target = v[n - 1];
      
      int c1 = std::count(v, v + N, target), c2 = std::count(v, v + n, target);

      C += ncr(c1, c2);
    }
  }

  std::cout << C << std::endl;

  return 0;
}


Measured memory_bytes: 384
q=int(input())

for _ in [0]*q:
    x0,y0,x1,y1,x2,y2,x3,y3=map(int,input().split())
    a1=x1-x0
    a2=x3-x2
    b1=y1-y0
    b2=y3-y2
    parallel=a1*b2-a2*b1
    orthogonal=a1*a2+b1*b2
    if parallel==0:
        print("2")
    elif orthogonal==0:
        print("1")
    else:
        print("0")


Measured memory_bytes: 5620
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	sort.Sort(sort.IntSlice(arr))

	preSize := -1
	count := 0
	for _, e := range arr {
		if preSize != e {
			count++
			preSize = e
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
N = int(input())
S = input()
 
ans = 0
for i in range(1000):
    s = str(i).zfill(3)
 
    index = 0
    for j in range(N):
        if s[index] == S[j]:
            index += 1
        if index == 3:
            ans += 1
            break
print(ans)

Measured memory_bytes: 41052
import sys


def query(li):
    # tmp_b = 0
    # tmp_r = 0
    # for i in li:
    #     if s[i] == "B":
    #         tmp_b += 1
    #     else:
    #         tmp_r += 1

    for i in range(len(li)):
        li[i] += 1
    print("?", *li)

    # if tmp_b > tmp_r:
    #     return "Blue"
    # else:
    #     return "Red"

    sys.stdout.flush()
    res = input()
    return res

n = int(input())
# s = input()

tmp = [j for j in range(n)]
ans = query(tmp)
if ans == "Blue":
    b = 0
    r = n
else:
    b = n
    r = 0

while abs(b - r) > 1:
    mid = (b + r) // 2
    tmp = [j + mid for j in range(n)]
    if query(tmp) == "Blue":
        b = mid
    else:
        r = mid
ans = [None]*(2*n)

if b < r:
    ans[b] = "B"
    ans[(b+n) % (2*n)] = "R"
else:
    ans[r] = "R"
    ans[(r+n) % (2*n)] = "B"

min_rb = min(r, b)
tmp = [j + min_rb + 1 for j in range(n-1)]
tmp2 = [(j + min_rb + n + 1) % (2*n) for j in range(n-1)]

for i in range(2*n):
    if ans[i] is None:
        if i in tmp:
            c = query(tmp2+[i])
        else:
            c = query(tmp+[i])
    else:
        continue
    if c == "Blue":
        ans[i] = "B"
    else:
        ans[i] = "R"
print("!", "".join(ans))


Measured memory_bytes: 42172
#include<iostream>
#include<deque>
#include<algorithm>
#include<vector>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<P> VP;
typedef vector<VP> VVP;
int mincost;


void NoJump(VVP &G,VVI &dp)
{
  int n= dp.size();
  rep(i,dp[0].size())dp[0][i] = 0;
  rep(i,n-1)
    {
      int m = dp[i].size();
      int o = dp[i+1].size();
      rep(j,m)
	{
	  rep(k,o)
	    {
	      int cost = (G[i+1][k].S+G[i][j].S)*abs(G[i+1][k].F-G[i][j].F);
	      dp[i+1][k] = min(dp[i+1][k],cost+dp[i][j]);
	    }	
	}
    }
  rep(i,G[n-1].size())mincost = min(mincost,dp[n-1][i]);
}

void printVVI(VVI &G)
{
  cout << "printVVI ------------ "<< endl;
  rep(i,G.size())
    {
      rep(j,G[i].size())
	{
	  cout << G[i][j] << " ";
	} 
      cout << endl;
    }
  cout << endl;
}

int main()
{
  int n,m;
  while(cin >> n >> m,n|m)
    {
      mincost = (1<<29);
      VVP G(n);
      rep(i,n)
	{
	  int k;
	  cin >> k;
	  rep(j,k)
	    {
	      int x,d;
	      cin >> x >> d;
	      G[i].push_back(P(x,d));
	    }
	}
    
      VVI dp(n);
      rep(i,n)dp[i].resize(G[i].size(),(1<<29));
      NoJump(G,dp);

      //cout << "NO.1" << endl;
      //printVVI(dp);      

      //First jump
      VVI prev = dp;
      if(m != 0){
	
	rep(i,G[1].size())prev[1][i] = 0;    
	rep(i,n)	
	  {
	    if(i+2 >= n)
	      {
		rep(k,G[i].size())mincost = min(mincost,dp[i][k]);
		break;
	      }
	  rep(j,G[i].size())
	    {
	      rep(k,G[i+2].size())
		{
		  int cost = (G[i][j].S+G[i+2][k].S)*abs(G[i][j].F-G[i+2][k].F);
		  prev[i+2][k] = min(prev[i+2][k],cost+dp[i][j]); 
		}
	    }
	  }
	dp = prev;
	NoJump(G,dp);
	//cout << "No.2" << endl;
	//printVVI(dp);
      }
      
      if(m == 1 || m == 0)goto Next;

      for(int i=1,cnt=1;cnt<m;cnt++,i+=2)
	{
	  prev = dp;
	  REP(j,i,n)
	    {
	      if(j+2 >= n)
		{
		  rep(k,G[j].size())mincost = min(mincost,dp[j][k]);
		  break;
		}
	      rep(k,G[j].size())
		{
		  rep(l,G[j+2].size())
		    {	  
		      int cost = (G[j][k].S+G[j+2][l].S)*abs(G[j][k].F-G[j+2][l].F);
		      prev[j+2][l] = min(prev[j+2][l],cost+dp[j][k]);
		    }
		}
	    }
	  dp = prev;
	  NoJump(G,dp);
	}      
      //cout << "No.3" << endl;
      //printVVI(dp);
     
    Next:;
    
      NoJump(G,dp);

      //cout << "No.4" << endl;
      //printVVI(dp);

      if(!G[n-1].empty())
	rep(i,G[n-1].size())mincost = min(mincost,dp[n-1][i]);
      else
	rep(i,G[n-2].size())mincost = min(mincost,dp[n-2][i]);
      
      cout << mincost << endl;
    }
  return 0;
}

Measured memory_bytes: 1268
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s = r.readLine();
    String[] sl = s.split("[\\s]+");
    int n = Integer.parseInt(sl[0]);
    int k = Integer.parseInt(sl[1]);

    int v = 0;

    int a[] = new int[100001];
    s = r.readLine();
    sl = s.split("[\\s]+");

    for(int i = 1; i < n; i++)
    {
      a[i] = Integer.parseInt(sl[i - 1]);
      if(a[i] == 1)
      {
        v = i;
      }
    }

    int c = (v - 1 + k - 2) / (k - 1);

    int z = c * (k - 1) + 1;

    if(z < n) c += (n - z + k - 2) / (k - 1);

    System.out.println(c);
  }

}


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

int N;
int arr[5];
string str;

int main() {
	
	ios_base::sync_with_stdio(false);
	cin >> N;
	for(int i = 0; i < N; i++) {
		cin >> str;
		if(str == "AC") arr[1]++;
		else if(str == "WA") arr[2]++;
		else if(str == "TLE") arr[3]++;
		else if(str == "RE") arr[4]++;
	}
	cout << "AC x " << arr[1] << "\n";
	cout << "WA x " << arr[2] << "\n";
	cout << "TLE x " << arr[3] << "\n";
	cout << "RE x " << arr[4] << "\n";
}

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

signed main(){
  char c;
  bool a=0, b=0;
  for(int i=0;i<3;i++){
    cin>>c;
    if(c == 'A'){
      a=1;
    } else {
      b=1;
    }
  }
  if(a && b){
    cout<<"Yes\n";
  } else {
    cout<<"No\n";
  }
  return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;
int K;
void input() {
  cin >> N >> K;
  ;
  ;
}
void solve() {
  // N <= 10^5 . O(N)?
  // 2^30 kurai
  double ans = .0;
  ;

  int tmp = 0;
  rep(i, 1, N) {
    ;
    ;
    rep(coinc, 0, 30) {
      ;
      if (i * pow(2, coinc) >= K) {
        ans += 1.0 / pow(2, coinc) / N;
        break;
      }
      // int waru = pow(2, coinc) * N;
      // ans += (double)((double)(tmp) / (double)(waru));
    }
  };
  printf("%.20f\n", ans);
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 512
/* **************************************************** */
/*                      Author : rakati                 */
/* **************************************************** */

#include <bits/stdc++.h>

using namespace std;

#define RP(i,a,b) for(int i = (a); i < (int)(b); i++)
#define RV(i,a,b) for(int i = (a); i > (int)(b); i--)
#define SHOW(v,d) {RP(i,0,v.size()) cout << v[i] << d;cout << '\n';}
#define ALL(x) x.begin(),x.end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

const double EPS = 1e-9;
const double PI = 2 * acos(0.0);
const int INF = 1e9;

using ll    = long long;
using ull   = unsigned long long;
using vi    = vector<int>;
using vl    = vector<ll>;
using vb    = vector<bool> ;
using vc    = vector<char>;
using vii   = vector<vi>;
using vll   = vector<vl>;
using pii   = pair<int, int>;
using pll   = pair<ll, ll>;
using vpii  = vector<pii>;
using vpll  = vector<pll>;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    int n, k;
    cin >> n >> k;
    vi arr(n);
    RP(i,0,n) cin >> arr[i];
    int dp[n][k];
    RP(i,0,k) dp[0][i] = 0;
    RP(i,1,n) RP(j,0,k) dp[i][j] = INF;
    RP(i,1,n) for (int j = 1; i-j >= 0 && j <= k; j++) dp[i][j-1] = *min_element(dp[i-j], dp[i-j] + k) + abs(arr[i] - arr[i-j]);
    cout << *min_element(dp[n-1], dp[n-1] + k) << endl;
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
const ll mod = 1e9+7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int n;
  cin >> n;
  vi d(n);
  re(i, n) cin >> d[i];

  int hp = 0;
  re(i, n) {
    re(j, n) {
      if(i < j) hp += d[i] * d[j];
    }
  }
  cout << hp << endl;

  return 0;
}


Measured memory_bytes: 256
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

def main():
    x=L()
    for i in range(5):
        if x[i]!=i+1:
            print(i+1)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN int(2*(10e5+3))
#define fim '\n'
#define ll long long
#define f first
#define s second
#define debug(x) cout << "DEBUG " << x << endl
using namespace std;
typedef pair<int, int> pii;

int vet[MAXN], dp[MAXN];
int n, c, k;


int main(){
	cin.tie(NULL);
	cout.tie(NULL);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> vet[i];
		
	dp[1] = 0;
	dp[2] = abs(vet[2]-vet[1]);
	for(int i = 3; i <= n; i++) {
		dp[i] = min(dp[i-1]+abs(vet[i]-vet[i-1]), dp[i-2]+abs(vet[i]-vet[i-2]));
	}
	cout << dp[n] << endl;

}



Measured memory_bytes: 4736
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
//if(strcmp(s[i],"AC")==0)
//if(s[l]=='#')
/*小文字判定
if((moji>= 'a') && (moji<='z')){
    printf("a\n");
    return 0;
  }
  */
//文字列中の一文字⇒数字の時は s[i]-'0'
int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

void swap(long long int *a, long long int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}
//swap(&a, &b)

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

long long int cmp( const void *p, const void *q ) {
    return *(long long int*)p - *(long long int*)q;
}//ちいさい順
//qsort(a,n,sizeof(long long int),cmp);


int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);
//char s[n][11]

long long int GCD(long long int a, long long int b){
  long long int L=a,S=b;
  while(1){
    if(S>L){
      L=S+L;
      S=L-S;
      L=L-S;
    }
    if(L%S==0){
      return S;
    }
    L=L%S;
  }
  
}

long long int LCM(long long int a, long long int b){
  return a*b/(GCD(a,b));
}

long long int nCr[3000][3000]={0};
 
long long int combination(long long int n, long long int r)
{
    if (r == 0 || r == n){
      nCr[n][r]=1;
        return (1);
    }
    else if (r == 1){
      nCr[n][r]=n;
        return (n);
    }
  if(nCr[n-1][r-1]==0&&nCr[n-1][r]==0){
    nCr[n-1][r-1]=combination(n - 1, r - 1)%1;
    nCr[n-1][r]=combination(n - 1, r)%1;
    return (nCr[n-1][r-1]+nCr[n-1][r]);
  }
  else if(nCr[n-1][r-1]!=0&&nCr[n-1][r]==0){
    nCr[n-1][r]=combination(n-1,r)%1;
    return(nCr[n-1][r-1]+ nCr[n - 1][r]);
  }
  else if(nCr[n-1][r-1]==0&&nCr[n-1][r]!=0){
    nCr[n-1][r-1]=combination(n-1,r-1)%1;
    return(nCr[n-1][r]+ nCr[n - 1][r-1]);
  }
  else{
    return nCr[n-1][r]+nCr[n-1][r-1];
  }
    
}


int main (void)
{
	long long int n,i,min,k,a[210000],max,j=1,count=0,len;
  char st[20000];
scanf("%s",st);

  len=W_Length(st);
  if(st[len-1]=='s'){
    printf("%s",st);
    printf("es\n");
    return 0;
  }
  printf("%s",st);
    printf("s\n");
return 0;
}


Measured memory_bytes: 1740
d=[0]*1e5;d[1]=p=1;(2..gets.to_i).map{|i|p*=i;i}.map{|i|c=0;(p/=i;c+=1)while p%i<1;75.downto(0){|k|c.times{|j|d[k.*j+2]+=d[k]}}};p d[75]

Measured memory_bytes: 2556
c = [tuple(map(int, input().split(' '))) for _ in range(3)]

for a1 in range(100 + 1):
    b1 = c[0][0] - a1
    b2 = c[0][1] - a1
    b3 = c[0][2] - a1
    a2_1 = c[1][0] - b1
    a2_2 = c[1][1] - b2
    a2_3 = c[1][2] - b3
    a3_1 = c[2][0] - b1
    a3_2 = c[2][1] - b2
    a3_3 = c[2][2] - b3

    if a2_1 == a2_2 == a2_3 and a3_1 == a3_2 == a3_3:
        print('Yes')
        break
else:
    print('No')


Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
import numpy as np  # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N = II()
    A = LI()

    dp = np.zeros((N + 1, 2), np.float64)
    dp[0, 1] = -INF  # A[0]より左は存在しないためdp[0, 1]からの派生は存在しない （初期状態でA[0]がフリップされていることはない）
    for i in range(N):
        dp[i + 1, 0] = max(dp[i, 0] + A[i], dp[i, 1] - A[i])
        dp[i + 1, 1] = max(dp[i, 0] - A[i], dp[i, 1] + A[i])
    # print(dp)

    # dp[N, 1]は操作できないため存在しない
    print(int(dp[N, 0]))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38108
#include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;

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

double a, b, x;
double h;

bool C(double t){
    double s;
    if(x > h){
        s = (a * a) * b -  (a * a * a * tan(t)) / 2;
    }else{
        s = (a * b * b) / (2 * tan(t));
    }
    return s > x;
}

int main(){
    cin >> a >> b >> x;
    h = ((a * a) * b) / 2;
    double l = 0;
    double r = M_PI;
    r /= 2;
    // cout << 1 << endl;
    rep(i, 100){
        double mid = (r + l) / 2;
        if(C(mid)){
            l = mid;
        }else{
            r = mid;
        }
        // cout << mid << endl;
    }
    double ans = 180 * (r / M_PI);
    printf("%.10lf\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vi a;

int main(){
	cin>>n;
	a=vi(n+2);
	for(int i=1;i<=n;i++) cin>>a[i];
	ll res=0;
	for(int i=0;i<n+1;i++) res+=abs(a[i]-a[i+1]);
	for(int i=1;i<=n;i++){
		cout<<res-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1])<<endl;
	}
}

Measured memory_bytes: 1664