akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int X = cin.nextInt();
        int ret = 1;
        for (int i = 2; i <= X; i++)
        {
            int tmp = i;
            while (true)
            {
                tmp *= i;
                if (tmp <= X)
                {
                    ret = Math.Max(tmp, ret);
                }
                else
                {
                    break;
                }
            }
        }
        Console.WriteLine(ret);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


Measured memory_bytes: 11092
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define mod 998244353
#define MAX 405
using namespace std;
//char nc()
//{
//	static char buf[100000],*p1=buf,*p2=buf;
//	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
char nc(){return getchar();}
int read()
{
	int x=0,y=1;
	char c=nc();
	while(!isdigit(c))
	{
		if(c=='-')y=-1;
		c=nc();
	}
	while(isdigit(c))
	{
		x=(x<<1)+(x<<3)+(c^48);
		c=nc();
	}
	return x*y;
}
int n,a[MAX],b[MAX],sa=0,sb=0;
long long f[2][MAX][MAX],fac[MAX],inv[MAX],facinv[MAX],pw[MAX][MAX];
long long mo(long long x)
{
	return x<mod?x:x-mod;
}
long long quick_pow(long long x,long long y)
{
	long long re=1;
	while(y)
	{
		if(y&1) re=re*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return re;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read(),b[i]=read(),sa+=a[i],sb+=b[i];
	fac[0]=fac[1]=1;inv[0]=0;inv[1]=1;facinv[0]=facinv[1]=1;
	for(int i=2;i<=400;i++)
		fac[i]=fac[i-1]*i%mod,
		inv[i]=inv[mod%i]*(mod-mod/i)%mod,
		facinv[i]=facinv[i-1]*inv[i]%mod;
	for(int i=1;i<=n;i++)
	{
		pw[i][0]=1;
		for(int j=1;j<b[i];j++)
			pw[i][j]=pw[i][j-1]*a[i]%mod;
	}
	int now=0,last=1;
	f[now][0][0]=mod-1;
	for(int i=1;i<=n;i++)
	{
		now^=1;last^=1;
		for(int j=0;j<=sa;j++)
			for(int k=0;k<=sb;k++)
				if(f[last][j][k])
				{
					f[now][j][k]=mo(f[now][j][k]+f[last][j][k]);
					if(j+a[i]<=sa)
						for(int t=0;t<min(b[i],sb-k+1);t++)
							f[now][j+a[i]][k+t]=mo(f[now][j+a[i]][k+t]-f[last][j][k]*pw[i][t]%mod*facinv[t]%mod+mod);
					f[last][j][k]=0;
				}
	}
	long long ANS=0;
	for(int j=0;j<=sa;j++)
		for(int k=0;k<=sb;k++)
			if(f[now][j][k])
				ANS=(ANS+f[now][j][k]*quick_pow(inv[j],k+1)%mod*fac[k]%mod*sa)%mod;
	printf("%lld",ANS);
	return 0;
}


Measured memory_bytes: 7436
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder200531
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inputs = Console.ReadLine().Split(' ').Select(s=>int.Parse(s)).ToArray();

            for(int i = 0; i < inputs.Length; i++)
            {
                if (inputs[i] == 0)
                {
                    Console.WriteLine(i+1);
                    return;
                }
            }
        }
    }
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Graph Template
//-------------------------------------------------
template<class E>
struct Graph
{
    vector<vector<E> > adj;
    Graph(int N):adj(N){}
    virtual void add_edge(int v, E e){adj[v].push_back(e);}
    vector<E>& operator[](int v){return adj[v];}
    inline int size(){return adj.size();}
};

struct NormalEdge {
    int to;
    NormalEdge(int to):to(to){}
};

struct UWGraph : public Graph<NormalEdge>
{
    UWGraph(int N):Graph(N){}
    void add_edge(int v, int e){adj[v].push_back({e});}
};

struct Edge{int to; ll cost;};

const ll INF=1e15;

ll dp[100][100];

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin>>N>>M;
    Graph<Edge> G(N);
    rep(i,N)rep(j,N) dp[i][j]=INF;
    rep(i,N) dp[i][i]=0;
    rep(i,M){
        int a,b; ll c; cin>>a>>b>>c;
        G.add_edge(a,{b,c});
        dp[a][b]=c;
    }
    rep(k,N)rep(i,N)rep(j,N)
        if (dp[i][k]!=INF&&dp[k][j]!=INF)
            chmin(dp[i][j],dp[i][k]+dp[k][j]);
    rep(i,N)if(dp[i][i]<0){
        cout<<"NEGATIVE CYCLE\n";
        return 0;
    }
    rep(i,N){
        rep(j,N){
            if (j>0) cout<<" ";
            if (dp[i][j]!=INF) cout<<dp[i][j];
            else cout<<"INF";
        }
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 3380
#include <iostream>
#include <cstdio>
#define N 105
using namespace std;

int n, c, a[N], b[N], ans[N];
bool z, v[N];
int main()
{
	int i, j;
	cin >> n;
	for (i =0; i < n; i++) {
		scanf ("%d", &a[i]);
	}
	for (i = 0; i < n; i++) {
		z = 0;
		c = 0;
		for (j = n - 1; j >= 0; j--) {
			if (v[j]) {
				c++;
				continue;
			}
			if (i - c + 1 == a[j]) {
				z = 1;
				ans[i] = a[j];
				v[j] = 1;
				break;
			}
		}
		if (!z) {
			cout << -1;
			return 0;
		}
	}
	for (i =0; i < n; i++) {
		printf("%d\n", ans[i]);
	}
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int a,b,c,temp;
  scanf("%d %d %d",&a,&b,&c);
  temp = a;
  a = b;
  b = temp;

  temp = a;
  a = c;
  c = temp;

  printf("%d %d %d\n",a,b,c);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
long long int mod = (long long int)1000000007;
using namespace std;

void solve()
{
    ll i,j,k,n;
    std::cout.precision(10);
    ll a;
    string b;
    cin>>a>>b;
    ll p[3];
    p[0]=(ll)(b[0]-'0')*a*100;
    p[1]=(ll)(b[2]-'0')*a*10;
    p[2]=(ll)(b[3]-'0')*a;
    ll x=p[0]+p[2]+p[1];
    x/=100;
    cout<<x;
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int i,j,k;
    int t;
    std::cout.precision(10);
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 3596
n=int(input())
h=list(map(int,input().split()))

dp=[0]*(n)
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
  dp[i]=min(dp[i-1]++abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
  
print(dp[-1])



Measured memory_bytes: 13928
import sys

mod = 2019
l, r = map(int, input().split())
if r-l >= mod:
  print(0)
  sys.exit()
  
l %= mod
r %= mod
if l >= r:
  print(0)
  sys.exit()
  
ans = mod
for i in range(l, r):
  for j in range(i+1, r+1):
    ans = min(ans, i * j % mod)
    
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

char list[100]; //n < 50, so char is ok.

int main(){
  int n, q, m, a, x, i;

  while(1){
    scanf("%d %d", &n, &q);
    if(!n&&!q)return 0;
    memset(list, 0, 100);
    q--;
    for(i=0;i<n;i++){
      scanf("%d",&m);
      for(a=0;a<m;a++){
        scanf("%d", &x);
        list[x]++;
      }
    }

    a=0;
    for(i=0;i<100;i++){
	  if(list[i]>q){
	    a=i;q=list[i];
	  }
    }
    printf("%d\n", a);
  }
}

Measured memory_bytes: 600
import itertools
n,m,q = map(int,input().split())

a=[0]*q 
b=[0]*q
c=[0]*q
d=[0]*q

for i in range(q):
    a[i],b[i],c[i],d[i] = map(int,input().split())

k=list(itertools.combinations_with_replacement(range(1,m+1), n))

ma = 0
for elm in k:
    cnt = 0
    for j in range(q):
        if (elm[b[j]-1] - elm[a[j]-1] ==c[j]):
            cnt += d[j]
    if ma != max(ma,cnt):
        ma = cnt    
print(ma)

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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    vector<vector<pair<ll,ll>>> A(n);
    for(i=0;i<n;i++){
        ll t;
        cin >> t;
        for(j=0;j<t;j++){
            ll x,y;
            cin >> x >> y;
            A[i].push_back({x,y});
        }
    }
    ll ret = 0;
    for(i=0;i<1<<n;i++){
        bool f=0;
        ll cnt = 0;
        for(j=0;j<n;j++){
            if((i>>j)%2==1){
                cnt++;
                for(pair<ll,ll> p:A[j]){
                    if((i>>(p.first-1))%2!=p.second){
                        f =1;
                    }
                }
            }
        }
        if(f==0)ret = max(ret,cnt);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String t = sc.nextLine();
        sc.close();
        char[] sChar = s.toCharArray();
        char[] tChar = t.toCharArray();

        int count = 0;
        for(int i = 0; i < 3; i++){
            if(sChar[i]==tChar[i]){
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 22100
import re
 
s = input()
k = int(input())
 
frag = False
 
def nchars(s, n):
    assert n > 0
    reg = re.compile("(.)\\1{%d,}" % (n - 1))
    while True:
        m = reg.search(s)
        if not m:
            break
        yield m.group(0)
        s = s[m.end():]
        
s_ = list(nchars(s,1))
 
for i in s_[0]:
  s1 = i
for i in s_[-1]:
  s2 = i
 
if s1 == s2:
  frag = True
 
l = [len(i) for i in s_]
 
c = l[0]//2
 
c1 = 0
c2 = 0
c3 = 0

for i in range(len(l)):
  if i != len(l)-1:
    c1 += l[i]//2
  else:
    if not frag:
      c1 += l[i] // 2
    else:
      c2 = (l[0]+l[i])//2
      c3 = l[i]//2

if len(l) == 1:
  print((l[0]*k)//2)

elif not frag:
  print(c1*k)
else:
  print(c + (c1-c)*k + c2*(k-1) + c3)

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


int main() {
  ll N;
  cin >> N;
  map<ll, ll> L, R;
  rep(i, N) {
    ll a;
    cin >> a;
    L[i + 1 + a]++;
    R[i + 1 - a]++;
  }
  
  ll ans = 0;
  rep(i, N) {
    ans += L[i] * R[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 46304
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  ll a, v;
  cin >> a >> v;
  ll b, w;
  cin >> b >> w;
  ll t;
  cin >> t;
  ll d = abs(a - b);
  ll d2 = (v - w) * t;
  puts(d <= d2 ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 3512
# -*- coding: utf-8 -*-       

n, m = list(map(int,input().split()))

ans = 0
t = (n-m)*100+m*1900
p = (0.5)**m
for i in range(10000):
    ans += (1-p)**i*(i+1)*p*t
print(int(round(ans)))

    

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

ans = [0] * N
ans[0] = sum(A) - 2 * sum(A[1:N-1:2])
for i in range(N-1):
    ans[i+1] = 2 * A[i] - ans[i]
print(*ans)


Measured memory_bytes: 14028
#include <cstdio>
#include <set>

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

  std::set<int> s;
  int a;
  int total = 0;
  for(int i = 0; i < n; i++)
  {
    scanf("%d", &a);
    if(s.find(a) == s.end())
    {
      total++;
      s.insert(a);
    }
    else
    {
      total--;
      s.erase(a);
    }
  }
  printf("%d\n", total);
  return 0;
}


Measured memory_bytes: 4864
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    
    int N = scanner.nextInt();
    int K = scanner.nextInt();
    long[] x = new long[N];
    for (int i = 0; i < N; i++) x[i] = scanner.nextInt();

    long min = 1_000_000_000;
    for (int left = 0; left + K - 1 < N; left++) {
      int right = left + K - 1;
      if (x[right] < 0) {
        min = Math.min(min, -x[left]);
      } else if (x[left] > 0) {
        min = Math.min(min, x[right]);
      } else {
        min = Math.min(min, Math.min(-x[left] * 2 + x[right], -x[left] + x[right] * 2));
      }
    }
    System.out.println(min);
  }
}


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

#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;

const int MAX = 3 * (1e6 + 5) + 5;
//const int MOD = 1000000007;

ll PowMod(ll n,ll m)
{
    ll temp;
    if (m == 0)
    {
        return 1;
    }
    if (m % 2 == 0)
    {
        temp = PowMod(n,m / 2);
        return temp * temp % MOD;
    }
    return n * PowMod(n, m - 1) % MOD;
}
ll inv_num(ll num)
{
    return PowMod(num, MOD - 2);
}
ll COM(ll n, ll a)
{
    ll X=1;
    ll Y=1;

    for (ll i = 0; i < a; i++)
    {
        X = X* (n - i) % MOD;
        Y = Y*(a - i) % MOD;
    }
    //cout << X <<" " <<  Y << endl;
    return X * (inv_num(Y)) % MOD;
}

int main()
{
    ll n,a,b;
    cin >> n >> a >> b;
    ll ans = 0;
    ll two = 2;
    ans = PowMod(two,n);
    //cout << COM(n, a) << endl;
    //cout << COM(n, b) << endl;
    ans = (ans - 1 - COM(n,a)- COM(n,b))%MOD;
    if (ans < 0)
    {
        ans += MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
using namespace std;
long a[100100];
int b[100100];
int cc(int x)
{
    int m=0;
    long long c[2]= {0};
    long long qq=0;
    for(int k=0; k<x-1; k++)
    {
        for(int j=k+1; j<x; j++)
        {
            if(a[k]!=a[j]||m>1)
            {
                break;
            }
            else if(a[k]==a[j]&&b[k]==0&&b[j]==0)
            {
                b[k]=1;
                b[j]=1;
                c[m]=a[k];
                m++;
            }
        }
    }
    qq=c[0]*c[1];
    cout<<qq<<endl;
}
int  fuzhi(int n)
{
    for(int i=0; i<=n; i++)
    {
        b[i]=0;
    }
}
bool cmp(int a,int b)
{
    return a>b;
}

int main()
{
    int n;
    while(cin>>n&&n>=4)
    {
        for(int i=0; i<n; i++)
        {
            cin>>a[i];
        }


        sort(a,a+n,cmp);
        fuzhi(n);
        cc(n);
    }


}


Measured memory_bytes: 1408
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)
#define MP make_pair
typedef long long LL;

LL gcd( LL m, LL n )
{
  if((0 == m) || (0 == n))
    return 0;
	
  while(m != n)
    {
      if (m > n)
	m -= n;
      else
	n -= m;
    }
  return m;
}
LL lcm( LL m, LL n )
{
  if(( 0 == m ) || (0 == n))
    return 0;
	
  return ((m*n) / gcd(m, n));
}

int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(6);

  int INF = 1000000;

  int a,b;
  while(cin>>a>>b){
    cout << gcd(a,b) << " " << lcm(a,b) << endl;
  }


  return 0;
}

Measured memory_bytes: 1156
def d170(n,a):
    k=max(a)+1
    count=0
    dp=[0 for i in range(k)]
    for x in a:
        if dp[x]!=0:
                dp[x]=2
                
        else:
            for j in range(x,k,x):
                     dp[j]+=1
    for x in a:
        if dp[x]==1:
            count+=1
    return count
    
n=int(input())
a=list(map(int, input().split()))    
print(d170(n,a))
            

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

int main(){
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    auto getPositions = [&](){
        vector<int> res;
        for(int i = 0; i < n && res.size() < k;){
            if(s[i] == 'o'){
                res.push_back(i);
                i += c + 1;
            } else {
                ++i;
            }
        }
        return res;
    };
    vector<int> l, r;
    l = getPositions();
    reverse(s.begin(), s.end());
    r = getPositions();
    rep(i,k) r[i] = n - 1 - r[i];
    reverse(s.begin(),s.end());

    vector<int> lastL(n+1,-1);
    rep(i,k) lastL[l[i]+1] = i;
    rep(i,n){
        if(lastL[i+1] == -1) lastL[i+1] = lastL[i];
    }

    vector<int> lastR(n+1,-1);
    rep(i,k) lastR[r[i]] = i;
    for(int i = n-1;i >= 0; --i){
        if(lastR[i] == -1) lastR[i] = lastR[i+1];
    }

    rep(i,n) {
        if (s[i] == 'x') continue;
        int li = lastL[i];
        int ri = lastR[i+1];
        int cnt = 0;
        if (li != -1) cnt += li+1;
        if (ri != -1) cnt += ri+1;
        if (li != -1 && ri != -1 && r[ri]-l[li] <= c) {
            --cnt;
        }
        if (cnt >= k) continue;
        printf("%d\n", i+1);
    }
    return 0;
}

Measured memory_bytes: 4984
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,k;
  cin >> n >> k;
  vector<double> p(n),s(n+1,0);
  rep(i,n){
    cin >> p[i];
    p[i] = 1.0/2.0*p[i]*(p[i]+1)/p[i];
  }
  rep(i,n)s[i+1] = s[i]+p[i];
  double mx = 0;
  srep(i,k,n+1){
    maxs(mx,s[i]-s[i-k]);
  }
  printf("%.10f\n",mx);
  return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
//#include <math.h>
long Gcd(long m, long n)
{
	long temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}
long Lcm(long m, long n)
{
	return m * n / Gcd(m,n); 
}

int main(){
	long a,b;
	while(scanf("%ld %ld",&a,&b)!=EOF){
		long ans1,ans2;
		ans1=Gcd(a,b);
		ans2=Lcm(a,b);
		printf("%ld %ld\n",ans1,ans2);
	}
	return 0;
}

Measured memory_bytes: 592
#!/usr/bin/env python3
import os
import sys
from atexit import register
from io import StringIO

sys.stdin = StringIO(os.read(0, os.fstat(0).st_size).decode())
sys.stdout = StringIO()
register(lambda: os.write(1, sys.stdout.getvalue().encode()))

input = lambda: sys.stdin.readline().rstrip('\r\n')

n, m = map(int, input().split())

w, v = [0] * n, [0] * n
for i in range(n):
    w[i], v[i] = map(int, input().split())

dp = [[0] * (m + 1) for _ in range(n)]
for j in range(w[0], m + 1):
    dp[0][j] = v[0]

for i in range(1, n):
    for j in range(m + 1):
        if j < w[i]:
            dp[i][j] = dp[i - 1][j]
        else:
            dp[i][j] = max(v[i] + dp[i - 1][j - w[i]], dp[i - 1][j])

print(dp[-1][-1])


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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,h,ans,memo;

main() {
    cin >> n >> h;
    ans=memo=h;
    rep(i,n-1) {
        cin >> h;
        if (memo<h) ans+=h-memo,memo=h;
        if (memo>h) memo=h;
    }
    ct(ans)
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	long x, k, d;
	scanf("%ld", &x);
	scanf("%ld", &k);
	scanf("%ld", &d);
	long abs_x;
	long ans;
	if(x > 0){
		abs_x = x;
	} else{
		abs_x = -x;
	}
	long q = abs_x / d;
	if(q >= k){
		if(x > 0){
			ans = x - d*k;
		} else{
			ans = x + d*k;
		}
	} else if((k-q)%2 == 0){
		if(x > 0){
			ans = x - d*q;
		} else{
			ans = x + d*q;
		}
	} else{
		if(x > 0){
			ans = x - d*(q+1);
		} else{
			ans = x + d*(q+1);
		}
	}
	if(ans > 0){
		printf("%ld\n", ans);
	} else{
		printf("%ld\n", -ans);
	}
	return 0;
}

Measured memory_bytes: 1736
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0
for i in range(N):
    if B[i]>=A[i]+A[i+1]:
       # print(A[i]+A[i+1])
        ans+=A[i]+A[i+1]
        A[i]=0
        A[i+1]=0
    elif B[i]>=A[i]:
        ans+=B[i]
        A[i+1]=A[i+1]-B[i]+A[i]
        A[i]=0
        #print(A[i+1])
    else:
        ans+=B[i]
        A[i]-=B[i]
    #print(ans)

print(ans)

Measured memory_bytes: 18476
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    string s;
    long long int ans = 0;
    int cnt = 0;

    cin >> s;

    for (int i = 0; i < (int)s.size(); i++) {
        if (s[i] == 'W') {
            ans += cnt;
        }
        else {
            cnt++;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

template <typename T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, T;
  cin >> N >> T;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  vector<int> idx(N);
  iota(idx.begin(), idx.end(), 0);
  sort(idx.begin(), idx.end(), [&](int a, int b) { return A[a] < A[b]; });
  vector<int> dp(T + 1, 0);
  for (int i : idx) {
    for (int t = T - 1; t > -1; t--) {
      chmax(dp[min(T, t + A[i])], dp[t] + B[i]);
    }
  }
  cout << dp[T] << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int gcd(int a, int b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

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

	string S, T;
	cin >> S >> T;

	int g = gcd(N, M);
	int ptS = 0;
	int ptT = 0;

	rep(i, g) {
		if (S[ptS] != T[ptT]) {
			cout << -1 << endl;
			return 0;
		}
		ptS += N / g;
		ptT += M / g;
	}

	cout << N * M / g << endl;

    return 0;
}


Measured memory_bytes: 764
a,b,c = gets.chomp.split(' ').map(&:to_i)
ans = 0
count = 0
while true
  if a % 2 + b % 2 + c % 2 != 0
    break
  end 
  if a == b && b == c
    ans =  -1
    break
  end
  new_a = (b + c)/2
  new_b = (c + a)/2
  new_c = (a + b)/2
  a = new_a
  b = new_b
  c = new_c
  ans += 1
end
puts ans

Measured memory_bytes: 14416
#include <iostream>
 

using namespace std;


int main() 
{
    int i, a, b, c, n;
    cin>>a>> b>> c;
    n = 0;
     for( int i = a; i <= b; i = i + 1 )
   {
       if(c %i ==0)
       n++;
      
  
   }
   cout << n << endl;
}


Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n;
  int a[105]={0},b[105]={0};
  cin>>n;
  rep(i,n)cin>>a[i];
  REP(i,1,n)a[i]+=a[i-1];
  rep(i,n)cin>>b[i];
  reverse(b,b+n);
  REP(i,1,n)b[i]+=b[i-1];
  reverse(b,b+n);
  int ans=0;
  rep(i,n){
    ans=max(ans,a[i]+b[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
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;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,x,t;
    cin>>n>>x>>t;
    cout<<((n-1)/x+1)*t<<endl;
    return 0;
}

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

int main(){
    string s;
    cin>>s;
    int a[s.length()] = {};
    for(int i=0; i<s.length(); i++){
        if(s[i]=='R'){
            if(s[i+1]=='R') a[i]=-2;
            //else a[i] = i;
        }else if(s[i]=='L'){
            if(s[i-1]=='L') a[i]=-1;
            //else a[i] = i;
        }
    }
    int ans[s.length()] = {};
    for(int i=0; i<s.length(); i++){
        if(a[i]==0){
            int index=i-1, left=0, right=0;
            while(index>=0 && index<s.length() && a[index]==-2){
                left++;
                index--;
            }
            ans[i]=left+1;
            i++;
            index = i+1;
            while(index>=0 && index<s.length() && a[index]==-1){
                right++;
                index++;
            }
            ans[i]=right+1;
        }
    }
    int ans2[s.length()] = {};
    for(int i=0; i<s.length(); i++){
        if(ans[i]>0){
            int num = (ans[i]-1)/2;
            ans2[i] += num+1;
            ans2[i+1] += (ans[i]-num);
            i++;
            num = (ans[i]-1)/2;
            ans2[i] += num;
            ans2[i-1] +=(ans[i]-num-1);
        }
    }
    for(int i=0; i<s.length(); i++){
        cout<<ans2[i]<<' ';
    }
    cout<<endl;
}

Measured memory_bytes: 1792
//NAOTO172さん の解読
#include <stdio.h>

int main(){
	int countTable[256] = {0};
	char ch;

	while((ch = getchar()) != EOF){ //getchar 考察
				countTable[ch]++; //aなら97番
	}
	for(int i = 97; i <=122;i++)printf("%c : %d\n",i,countTable[i]+countTable[i-32]);
//i=97 -> a   i=97-32=65 -> A
}



Measured memory_bytes: 2724
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static long[] ReadLongArray()
    {
        return ReadLine().Split().Select(x => long.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        int n = int.Parse(ReadLine());
        long[] a = ReadLongArray();
        long x = 0;
        for (int i = 0; i < n; i++) x ^= a[i];
        WriteLine(x == 0 ? "Yes" : "No");
    }
}

Measured memory_bytes: 22240
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,-1,1,1,-1};
int dy[]={0,1,0,-1,-1,-1,1,1};


int main(){
    int n;cin >> n;
    vector<LL> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(RALL(a));
    LL ans = a[0];
    int cnt = n - 2;
    for (int i = 1; i < n; i++) {
        if(cnt >= 2){
            ans += a[i] * 2;
            cnt-=2;
        }
        else if(cnt){
            ans += a[i];
            cnt--;
        }
        else{
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4812
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<map>
using namespace std;

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

    map<int, int> A;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;

        A[a]++;
        if (A[a] >= 2) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 9600
n = int(input())
#a = [list(map(int, input().split())) + [i] for i in range(n)]
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
a = []
b = []
c = []
for i in range(n):
    a.append([])
    b.append([])
    c.append([])
for i in range(n):
    a[i].append(A[i])
    a[i].append(2)
    b[i].append(B[i])
    b[i].append(1)
    c[i].append(C[i])
    c[i].append(0)
d = a + b + c
d.sort(key=lambda x:(x[0], x[1]))
lenli = []
allli = []
count = 0
for i in range(len(d)):
    if d[i][1] == 2:#a
        if lenli == []:
            lenli.append(1)
        else:
            lenli[-1] += 1
    elif d[i][1] == 1:#b
        if allli == [] and lenli != []:
            allli.append(lenli[-1])
            allli.append(allli[-1])
            lenli.append(lenli[-1])
        elif allli == [] and lenli == []:
            pass
        else:
            allli[-1] += lenli[-1]
            allli.append(allli[-1])
            lenli.append(lenli[-1])
    elif d[i][1] == 0:#c
        if allli == []:
            count += 0
        else:
            count += allli[-2]

print(count)

Measured memory_bytes: 77848
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	string S;
	cin >> S;
	
	// 解法
	ll y = stoi(S.substr(0,4)+S.substr(5,2)+S.substr(8,2));
	ll ans = (y<=20190430);
	
	//出力
	if (ans) printf("Heisei\n");
	else printf("TBD\n");
}


Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    int N, K;
    cin >> N >> K;
    int ans = 1;
    while (N / K > 0)
    {
        ans++;
        N /= K;
    }
    cout << ans << endl;
}

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

int main() {
    int h, n;
    cin >> h >> n;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        h -= t;
    }

    cout << (h <= 0 ? "Yes" : "No") << endl;
}


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

using namespace std;

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

    int ans = 0;
    int a[ n ];

    for( int i = 0; i < n; i++ )
        cin >> a[ i ];
    
    for( int i = 0; i < n; i += 2 )
        ans += ( a[ i ] % 2 == 1 );
    
    cout << ans << "\n";
    
    return 0;
}

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

int main() {
  string s;
  cin >> s;

  int ans = 0;
  if (s == "RRR") ans = 3;
  if (s == "SRR" or s == "RRS") ans = 2;
  if (s == "SSR" or s == "SRS" or s == "RSS" or s == "RSR") ans = 1;

  cout << ans << endl;
}



Measured memory_bytes: 3608
def calcMax(i):
  now = numbers[i]

  future_max = max(numbers[i+1:])
  #print(numbers[i+1:])
  t = numbers[i+1:]
  #print((max(t)))
  return future_max - now

n = int(input())

numbers = []
for i in range(n):
  numbers.append(int(input()))

m = -1000000001
ti = 1000000001
for i in range(len(numbers) - 1):
    if numbers[i] < ti:
      if (i == 0 or i == len(numbers) - 1 or (numbers[i-1] >= numbers[i] and numbers[i] <= numbers[i+1])):
        temp = calcMax(i)
        #print("temp: " + str(temp))
        if temp > m:
            m = temp
            ti = numbers[i]

print (m)


Measured memory_bytes: 15168
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e7 + 555;
const double PI = acos(-1.0);


void solve()
{
	
	int a, b;
	cin >> a >> b;
	cout << max(0, a -  2 * b);
}
 
int main()
{
    Red;
	// freopen("hamming.in", "r", stdin);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h> 
int main(void){
  int N,a,b;
  scanf("%d\n", &N);
  char A[N];
  b = 0;
  for(int i = 1; i <= N; i++){
    scanf("%c", &A[i]);
  }
  for(int j = 1; j <= N; j++){
    if(A[j+1] == A[j]){
    }else{
      b++;
    }      
  }
  printf("%d", b);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
typedef long long  ll;
//typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set
// this for long double
#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fore(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define ld long double
#define kek cout<<endl; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
#define halt {cout<<-1; return 0;}
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const int N = 1010;
const int INF = 1e8;
const ll MOD1=1073741824;
const long double pi=3.1415926535;
using namespace std;
using namespace __gnu_pbds;
typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
string bin_rep(int n)
{
          string s="";
      for(int i=31;i>=0;i--)
   {
           if(n&(1<<i)) s+='1';
           else s+='0';
   }
   return s;
}
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 press_F_to_pay_respect;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
int n,k;
cin>>n>>k;
vector<int> v(n);
forn cin>>v[i];
sort(all(v));
int ans=0;
rep(i,0,k) ans+=v[i];
cout<<ans;
         

    
 
 
 
  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
   
 
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>

using namespace std;

int main()
{
	set<string> table;
	
	string s;
	int K;
	cin >> s >> K;

	for (int i = 0; i < 5; i++)
	{
		for (int j = 0; j < s.size(); j++)
		{
			table.insert(s.substr(j, i + 1));
		}
	}

	int idx = 0;
	for (auto itr = table.begin(); itr != table.end(); itr++)
	{
		if (idx + 1 == K)
		{
			cout << *itr << endl;
			break;
		}
		
		idx++;
	}

	return 0;
}


Measured memory_bytes: 1664
def solve():
    a, b = map(int, input().split())

    atimesb = str(a) * b
    btimesa = str(b) * a

    if len(atimesb) > len(btimesa):
        print(atimesb)
    elif len(atimesb) < len(btimesa):
        print(btimesa)
    else:

        for i in range(min(len(atimesb), len(btimesa))):
            if int(atimesb[i]) != int(btimesa[i]):
                if atimesb[i] < btimesa[i]:
                    print(atimesb)
                else:
                    print(btimesa)
                break
        else:
            print(atimesb)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 38256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
  
public class Main {
  
    public static void main(String[] args) throws NumberFormatException, IOException {
        // TODO Auto-generated method stub
        int n;
        String[] token;
        int rank;
        boolean[] S = new boolean[13]; 
        boolean[] H = new boolean[13]; 
        boolean[] C = new boolean[13]; 
        boolean[] D = new boolean[13];
          
        for (int i = 0; i < 13; i++) {
            S[i] = H[i] = C[i] = D[i] = false;
        }
          
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        n = Integer.parseInt(br.readLine());
          
        for (int i = 0; i < n; i++) {
            token = br.readLine().split(" ");
            rank = Integer.parseInt(token[1]);
            if (token[0].equals("S")) {
                S[rank - 1] = true;
            } else if (token[0].equals("H")) {
                H[rank - 1] = true;
            } else if (token[0].equals("C")) {
                C[rank - 1] = true;
            } else if (token[0].equals("D")) {
                D[rank - 1] = true;
            }
        }
          
        for (int i = 0; i < 13; i++) {
            if (!S[i]) System.out.println("S " + (i + 1));
        }
        for (int i = 0; i < 13; i++) {
            if (!H[i]) System.out.println("H " + (i + 1));
        }
        for (int i = 0; i < 13; i++) {
            if (!C[i]) System.out.println("C " + (i + 1));
        }
        for (int i = 0; i < 13; i++) {
            if (!D[i]) System.out.println("D " + (i + 1));
        }
    }
}

Measured memory_bytes: 24432
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("YES");
    } else {
        println!("NO");
    }
}

fn main() {
    let n = read::<usize>();

    let v = read_vec::<u32>();
    let mut v2 = v.clone();
    v2.sort();

    let mut diff_count = 0;
    for i in 0..n {
        if v[i] != v2[i] {
            diff_count += 1;
        }
    }
    yn(diff_count == 0 || diff_count == 2)
}




Measured memory_bytes: 4352
n,k = map(int,input().split())

ans = 0

for i in range(1,n+1):
    num = 0
    p = i
    while True:
        if p >= k:
            x = (1/n) * (1/2)**num
            ans += x
            break
        p *= 2
        num += 1


print(ans)

Measured memory_bytes: 2940
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
6
1 2 2 3
2 2 3 4
3 1 5
4 1 6
5 1 6
6 0

output:
1 1 12
2 2 11
3 3 8
4 9 10
5 4 7
6 5 6
"""
import sys
from collections import deque

UNVISITED, VISITED_IN_STACK, POPPED_OUT = 0, 1, 2


def generate_adj_matrix(v_info):
    for v_detail in v_info:
        v_index, adj_num, *adj_list = map(int, v_detail)
        # assert len(adj_list) == adj_num
        init_adj_table[v_index].extend(sorted(adj_list))
    return init_adj_table


def graph_dfs(v_init):
    global time

    # init the first node of overall graph iterations(times >= 1)
    stack.append(v_init)
    color[v_init] = VISITED_IN_STACK
    d_time[v_init] += time
    # init end

    while len(stack) > 1:
        current = stack[-1]
        v_table = adj_table[current]
        adj = v_table.popleft() if v_table else None

        if adj:
            if color[adj] is UNVISITED:
                color[adj] = VISITED_IN_STACK
                time += 1
                d_time[adj] += time
                stack.append(adj)
        else:
            stack.pop()
            color[current] = POPPED_OUT
            time += 1
            f_time[current] += time

    return None


def dfs_start():
    global time
    for i in range(vertices_num):
        if color[i + 1] == UNVISITED:
            # print('round: ', i + 1)
            graph_dfs(i + 1)
            time += 1


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices_num = int(_input[0])
    vertices_info = map(lambda x: x.split(), _input[1:])
    init_adj_table = tuple(deque() for _ in range(vertices_num + 1))
    # assert len(vertex_info) == vertex_num

    # config length = (vertex_num + 1)
    stack = [-1]
    color = [UNVISITED] * (vertices_num + 1)
    d_time, f_time = ([0] * (vertices_num + 1) for _ in range(2))

    adj_table = generate_adj_matrix(vertices_info)
    # timing start from 1
    time = 1
    dfs_start()
    for k, v in enumerate(zip(d_time[1:], f_time[1:]), 1):
        print(k, *v)

Measured memory_bytes: 8164
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val ss = (1..N).map { readLine()!! }
    val march = "MARCH".toCharArray()

    val counts: Map<Char, Int> = march.associateBy({it}, { ss.count {x -> x[0]==it} })
    val ans: Long = arrayOf(
            "MAR",
            "MAC",
            "MAH",
            "MRC",
            "MRH",
            "MCH",
            "ARC",
            "ARH",
            "ACH",
            "RCH"
    ).map {
        val init: Long = 1
        it.map { x -> counts[x] }.fold(init) { x,y -> x * (y ?: 1) }
    }.sum()
    println(ans)
}

Measured memory_bytes: 41372