akhauriyash/Code-Regression huggingface dataset:
#include<string>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include <iomanip>
#include<cmath>
#include<stack>
#include <algorithm>
#include<cstdio>
#include <cstring>
#include <iostream>
#define inf 0n7fffffff
using namespace std;
int main ()
{
    char mp[15];
    int mmp[15];
    scanf("%s",mp);
    int l=strlen(mp);
    int i,j,k,cnt=0;
    for(i=0;i<l;i++)
    {
        if(mp[i]=='0')
            {
                mmp[cnt]=0;
                cnt++;
            }
        else if(mp[i]=='1')
        {
            mmp[cnt]=1;
            cnt++;
        }
        else
            {
                if(cnt!=0)
                    cnt--;
            }

    }
    for(i=0;i<cnt;i++)
        printf("%d",mmp[i]);
    return 0;
}

Measured memory_bytes: 256
import sys
from functools import lru_cache

sys.setrecursionlimit(1000000)

H, N = map(int, input().split())

AB = []
for i in range(N):
    A, B = map(int, input().split())
    AB.append((A, B))


@lru_cache(maxsize=None)
def f(h):
    if h <= 0:
        return 0
    best = float("inf")
    for a, b in AB:
        val = b + f(h - a)
        if val < best:
            best = val
        else:
            break
    return best


AB.sort(key=lambda ab: (ab[0] / ab[1], -ab[0]), reverse=True)
bestA, bestB = AB[0]

print(f(H))


Measured memory_bytes: 30180
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	string s;
	cin >> n >> s;
	
	for(int i = 0; i < (int)s.size(); ++i) {
		cout << (char)( ( (s[i] - 'A') + n ) % 26 + 'A');
	}
	
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 200001
#define MOD 1000000007
#define INF 1000000007
typedef long long int lli;

int main(void) {
  int n;
  lli a[MAX];
  scanf("%d", &n);

  rep(i, 0, n) scanf("%lld", &a[i]);

  lli sum[MAX] = {0};
  for (int i = n-1; i >= 1; i--) 
    sum[i-1] = (sum[i] + a[i]) % MOD;
  
  lli ans = 0;
  rep(i, 0, n) ans = (ans + sum[i] * a[i]) % MOD;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;
 
string board[2123];
int boardt[2123][2123];
int boardy[2123][2123];
int h,w;
void ca(){
    rep(i,h){
        rep(j,w){
            cout<<boardy[i][j];
        }
        cout<<endl;
    }
}

int ans=0;
signed main(){
    cin>>h>>w;
    rep(i,h)cin>>board[i];
    
    rep(i,h){
        int hikari=0;
        int j=0;
        while(j<w){
            while(board[i][j]!='#' && j<w){
                hikari++;
                j++;
            }
            int tmp=hikari;
            // dump(i);
            // dump(j);
            // dump(tmp);
            while(tmp--)boardy[i][j-tmp-1]=hikari;
            //boardy[i][j]=0;
            hikari=0;
            j++;

            //ca();
        }
    }

    

    rep(i,w){
        int hikari=0;
        int j=0;
        while(j<h){
            while(board[j][i]!='#' && j<h){
                hikari++;
                j++;
            }
            int tmp=hikari;
            while(tmp--)boardt[j-tmp-1][i]=hikari;
            //boardt[i][j]=0;
            hikari=0;
            j++;
        }
    }

    rep(i,h){
        rep(j,w){
            chmax(ans,boardt[i][j]+boardy[i][j]);
        }
    }


    //cout<<endl;

    // rep(i,h){
    //     rep(j,w){
    //         cout<<boardt[i][j];
    //     }
    //     cout<<endl;
    // }

    cout<<ans-1<<endl;
 
}

Measured memory_bytes: 39168
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

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

    vector<long long> a(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }

    cout << max(-1LL, n - accumulate(a.begin(), a.end(), 0LL)) << endl;
}


Measured memory_bytes: 3668
from collections import Counter
N, K = map(int, input().split())
L = list(map(int, input().split()))
S = len(set(L))
C = Counter(L).most_common()[::-1]
ans = 0
for c in C:
    if S <= K:
        break
    ans += c[1]
    S -= 1
print(ans)

Measured memory_bytes: 49752
N=int(input())
cnt=[0,]*26
base=input()
for i in range(len(base)):
    cnt[ord(base[i])-97]+=1
for i in range(N-1):
    cnt2=[0,]*26
    cmp=input()
    for i in range(len(cmp)):
        cnt2[ord(cmp[i])-97]+=1
    for i in range(26):
        if cnt[i] > cnt2[i]:
            cnt[i]=cnt2[i]
ans=""
for i in range(26):
    for j in range(cnt[i]):
        ans+=chr(i+97)
print(ans)

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template <typename T1, typename T2> 
inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

ll k, n;

bool check(ll x, VLL & a){
  // x 未満の個数が k 個 未満
  ll cnt = 0;
  rep(i, n) {
    if(a[i] >= 0){
      // l = small , r = big
      ll ok = -1;
      ll ng = n;
      while(abs(ng-ok) > 1){
        ll mid = (ok + ng) / 2;
        if (a[i] * a[mid] < x) {
          ok = mid;
        }else {
          ng = mid;
        }
      }
      cnt += ok + 1;
    } else {
      // l = big , r = small
      ll ok = n;
      ll ng = -1;
      while(abs(ok-ng)>1){
        ll mid = (ok + ng) / 2;
        if(a[i]*a[mid] < x){
          ok = mid;
        }else{
          ng = mid;
        }
      }
      cnt += (n-1) - ok + 1;
    }
    if (a[i] * a[i] < x) cnt--;
  }
  cnt /= 2ll;
  return cnt < k;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  VLL a(n);
  rep(i, n) cin >> a[i];

  sort(all(a));

  ll ok = - (ll)(1e18) + 1ll;
  ll ng = (ll)(1e18) + 1ll;

  while (abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2ll;
    if (check(mid,a))
      ok = mid;
    else
      ng = mid;
  }

  cout << ok << endl;
  return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
main()
{
    vector<int>a;
    int x;
    for(int i=0; i<3; i++)
    {
        cin>>x;
        //cout<<x;
        a.push_back(x);

    }
            sort(a.begin(),a.end());
            cout<<a[0]<<' '<<a[1]<<' '<<a[2]<<endl;
}



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


//This code is written by Sneh Thakkar.

/*       AUTHOR NAME:

        _/_/_/_/   _/\        _/     _/_/_/_/_/    _/      _/
       _/         _/ _\      _/     _/            _/      _/
      _/_/_/_/   _/   _\    _/     _/_/_/_/_/    _/_/_/_/_/
           _/   _/     _\  _/     _/            _/      _/
    _/_/_/_/   _/       _\_/     _/_/_/_/_/    _/      _/
       
        
*/

using namespace std;

#define ll long long
#define ld double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007

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

int main() {
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    map<string,ll>mp;
    ll n;
    cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define ALL(x) begin(x), end(x)

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

  vector<string> A(N);
  for (int i = 0; i != N; ++i) {
    cin >> A[i];
  }
  vector<string> B(M);
  for (int i = 0; i != M; ++i) {
    cin >> B[i];
  }

  for (int i = 0; i <= N - M; ++i) {
    for (int j = 0; j <= N - M; ++j) {
      bool p{true};
      for (int k = 0; p && k != M; ++k) {
        p = equal(begin(B[k]), end(B[k]), begin(A[k+i]) + j);
      }
      if (p) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
// vim:ts=4:sts=4:sw=4:et
// MOSCOW IPT JINOTEGA
// Table #14
#include <bits/stdc++.h>
using namespace std;
#define forn(i,n) for (int i = 0; i < int(n); ++i)
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
typedef long double ld;
typedef long long ll;
typedef long long i64;

ll x;

ll ceil(ll a, ll b) {
    return (a + b - 1) / b;
}

ll step(ll a, ll b, ll x) {
    return ((a + 1) * x - b) / x;
}


bool CanA(ll a, ll b) {
    ll na = a - x;
    ll nb = b - 1;
    return (na + 1) * x >= nb + 1;
}

char solve(ll a, ll b, ll c) {
    x = max(ceil(b, a + 1), ceil(a, b + 1));
    //cerr << x << endl;
    if (x == 1) {
        char first = 'A';
        if (b > a)
            first = 'B';
        char second = 'A' ^ 'B' ^ first;
        if (c % 2 == 0)
            return first;
        else
            return second;
    }

    for (ll t = (1ll << 30); t >= 1; t >>= 1) {
        ll na = a - t * x;
        ll nb = b - t;
        ll nc = c - t * (x + 1);

        if (nc < 0 || nb < 0 || nc < 0)
            continue;

        if ((na + 1) * x < nb + 1)
            continue;

        a = na;
        b = nb;
        c = nc;
    }

    if (CanA(a, b)) {
        if (c < x)
            return 'A';
        else
            return 'B';
    }

    ll t = step(a, b, x);
    assert(t <= x);

    if (c < t)
        return 'A';

    c -= t;
    a -= t;

    t = b - a * x;
    assert(t <= x);
    if (c < t)
        return 'B';

    c -= t;
    b -= t;

    if (c % (x + 1) == 0)
        return 'A';
    else
        return 'B';

    return '!';
}

void read() {
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        --c;
        for (ll i = c; i < d; ++i)
            cout << solve(a, b, i);
        cout << endl;
    }
}

int main() {
#ifdef LOCAL
    assert(freopen("d.in", "r", stdin));
#endif
    ios_base::sync_with_stdio(false);
    
    read();
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n==1){cout<<1<<endl;return 0;}
	for(int i=1;i<=n;i++)
		if(pow(2,i)<=n&&pow(2,i+1)>n)
		{
			cout<<pow(2,i)<<endl;
			return 0;
		}
    return 0;
}

Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))
C = {}
for i in A:
    if i in C.keys():
        C[i] += 1
    else:
        C[i] = 1

total = 0

for i in C.keys():
   if C[i]>1:
        total += (C[i]*(C[i]-1))//2

for i in A:
    print(total-(C[i]-1))


Measured memory_bytes: 24748
#include<cstdio>
int main()
{
	int a,b,c;
	scanf(" %d %d %d",&a,&b,&c);
	if(a==5&&b==5&&c==7||a==5&&b==7&&c==5||a==7&&b==5&&c==5)printf("YES\n");
	else printf("NO\n");
	return 0;
}


Measured memory_bytes: 128
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    int N=int.Parse(Console.ReadLine());
     if(N==3||N==5||N==7){
       Console.WriteLine("YES");
     }else{
       Console.WriteLine("NO");
    }
    }
  }

}

Measured memory_bytes: 27468
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define endl "\n"
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define cn cin>>
#define co cout<<
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{

long long a,b,c,d,e,f,g,h;

cin>>a;

std::vector<int> v(a);



for (int i = 0; i < a; ++i)
{
	/* code */
	cin>>v[i];
}
int max=v[0];
long long count=1;
for (int i = 1; i < a; ++i)
{
	/* code */
	if(v[i]>=max){
		max=v[i];
		count++;
	}
}

cout<<count<<endl;

return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i, x;
    
    for (i=1; ; i++) {
        scanf("%d", &x);
        if (x==0) {
            break;
        }
        printf("Case %d: %d\n",i,x);
    }
    return 0;
}



Measured memory_bytes: 2020
def main():
    S=input()
    l=len(S)
    if l == 0:
        print(0)
    else:
        ans = 0
        for i in range(l // 2):
            if S[i] != S[-i-1]:
                ans+=1
        print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>

int readint()
{
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9')
	{
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}

const int maxn=55; 
const int maxm=2505;
int n,A;
ll ans;
int a[maxn];
ll dp[maxn][maxn][maxm];

int main(){
	scanf("%d%d",&n,&A);
	REP(i,n)scanf("%d",&a[i]);
	dp[0][0][0]=1LL;
	REP(i,n)rep(k,n+1)rep(j,2501){
		if(k>i)continue;
		dp[i][k][j]=dp[i-1][k][j];
		if(j>=a[i]&&k)dp[i][k][j]+=dp[i-1][k-1][j-a[i]];
//		cout<<i<<" "<<k<<' '<<j<<" "<<dp[i][k][j]<<endl; 
	}
	REP(i,n)ans+=dp[n][i][i*A];
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 53504
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;
const LL mod=1e9+7;

LL modpow(LL x, LL n){
	LL r=1;
	while(n){
		if(n&1) r=r*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return r;
}

int main(){
  int N;
  cin >> N;
  vector<LL> C(N);
  rep(i,N) cin >> C[i];
  sort(C.begin(),C.end());
  vector<LL> P(N);
  rep(i,N){
    P[i]=modpow(2,2*N-2)*(N+1-i);
    P[i]%=mod;
  }
  LL ans=0;
  rep(i,N){
    ans+=C[i]*P[i];
    ans%=mod;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF int(1e9+1)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}
int A[5],K;
int main(void){
    ga(5,A),scanf("%d",&K);
    F(5)FT(i+1,5)if(abs(A[i]-A[k])>K)return puts(":("),0;
    puts("Yay!");
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    
    val edges = mutableListOf<Pair<Int, Int>>()

    val cntMax = if (N % 2 == 0) N else (N - 1)

    for (i in 1..cntMax) {
        for (j in i + 1..cntMax) {
            if (i + j == cntMax + 1) {
                continue
            }
            edges.add(Pair(i, j))
        }
    }
    
    if (N % 2 == 1) {
        for (i in 1 until N) {
            edges.add(Pair(i, N))
        }
    }

    println(edges.size)
    
    for ((a, b) in edges) {
        println("$a $b")
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 33732
def fun(x):
  var=1
  first=0
  while True:
     if (x-var) not in n:
        first +=(x-var)
        # print("var is",var)
        return var
    
     var +=1

def funco(x):
  var=1
  first=0
  while True:
     if (x-var) not in n:
        first +=(x-var)
        # print("var is",var)
        return first
    
     var +=1
      
      

    

def fun2(x):
  var=1
  second=0
  while True:
    if (x+var) not in n:
       second +=(x+var)
      #  print("var is",var)
       return var

    var +=1

def fun2co(x):
  var=1
  second=0
  while True:
    if (x+var) not in n:
       second +=(x+var)
      #  print("var is",var)
       return second

    var +=1


def main(x):
  if x not in n:
    print(x)
    return
  s=(fun(x))
  t=(fun2(x))
  # print(s)
  # print(t)
  if s>t:
    print(fun2co(x))
  else:
    print(funco(x))

x=list(map(int,input().split()))


if x[1]<=0:
  print(x[0])

else:
  n=list(map(int,input().split()))
  main(x[0])
# n.append(x[0])
# print(sorted(n))







Measured memory_bytes: 9188
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        if (n >= 30) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

bool d[100000];
int n, a[100000], ans;

int main(void) {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
        if (d[i]) continue;
        if (a[a[i]-1]-1 == i) {
            d[i] = d[a[i]-1] = true;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
n, k = map(int, input().split())
ab = []
for i in range(n):
    ab.append(list(map(int, input().split())))
ab.sort()
num1 = 0
num2 = 0
while num1 < k:
    num1 += ab[num2][1]
    num2 += 1
print(ab[num2 - 1][0])

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

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

  int A1[N], A2[N];
  rep(i,0,N-1) cin >> A1[i];
  rep(i,0,N-1) cin >> A2[i];

  int ans = 0;
  rep(i,0,N-1) {
    int cnt = 0;
    rep(j,0,i) cnt += A1[j];
    rep(j,i,N-1) cnt += A2[j];
    ans = max(ans, cnt);
  }

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


Measured memory_bytes: 256
//
// Created by hide on 2020/05/15.
//

//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード(アルファベット順,bits/stdc++.hは使わない派閥)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
//#define S second //pairの二つ目の要素
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)


struct comp{
    int num;
    int parent;

    comp(int num, int parent) : num(num), parent(parent){};
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M),B(M);
    unordered_map<int,vector<int>> mp;
    REP(i,M){
        cin >> A[i] >> B[i];
        mp[A[i]].push_back(B[i]);
        mp[B[i]].push_back(A[i]);
    }

    vector<int> answer(N+1);
    vector<bool> visited(N+1, false);
    queue<comp> q;
    q.push(comp(1,1));

    while(!q.empty()){
        comp top = q.front();
        q.pop();
        if(visited[top.num])
            continue;
        visited[top.num]=true;
        answer[top.num] = top.parent;
        for(const auto& num : mp[top.num]){
            q.push(comp(num, top.num));
        }
    }

    cout << "Yes" << endl;
    for(int i=2; i<=N; i++)
        cout << answer[i] << endl;
}

Measured memory_bytes: 17044
N = int(input())

if N==2:
    print(3,5)
    exit()
if N==3:
    print(2,5,63)
    exit()
if N==4:
    print(2,5,20,63)
    exit()

if N==5:
    print(2,5,20,30,63)
    exit()

S=set()
i=2
while len(S)<N:
    if i%2==0 or i%3==0:
        S.add(i)
    i+=1

i+=1
r=sum(S)

if r%6==0:
    pass
elif r%6==2:
    S.remove(8)
    while len(S)<N:
        if i%6==0:
            S.add(i)
            break
        i+=1
elif r%6==3:
    S.remove(9)
    while len(S)<N:
        if i%6==0:
            S.add(i)
            break
        i+=1
elif r%6==5:
    S.remove(9)
    while len(S)<N:
        if i%6==4:
            S.add(i)
            break
        i+=1

assert len(S)==N,len(S)
print(" ".join(map(str,S)))


Measured memory_bytes: 72492
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  vi cnt(n);
  rep(i,n) cnt[i] = 0;
  for(int i = 1; i <= n-1; i++)for(int j = i+1; j <= n; j++) {
    int a = j-i;
    int b = abs(i-x) + abs(j-y) + 1;
    int c = min(a,b);
    cnt[c]++;
  }
  rep(i,n-1) cout << cnt[i+1] << endl;
  return 0;
}

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

int main()
{
    string s;
    cin >> s;
    int count = 0;
  
for(int i= 0; i < s.size();i++){
if( (i+1) % 2 == 0){
        if (s.at(i) == 'L'|| s.at(i) == 'U' || s.at(i) == 'D')
            {
                count++;
            }
   }else if((i+1) % 2 == 1){
       if (s.at(i) == 'R' || s.at(i) == 'U' || s.at(i) == 'D')
       {
           count++;
       }
   }

}


    if(count == s.size()){
        cout << "Yes" <<endl;
    }else{
        cout <<"No"<<endl;
    }


return 0;
}


Measured memory_bytes: 256
X, K, D = map(int,input().split())

if abs(X) >= K*D:
    ans = abs(X) - K*D
else:
    if (abs(X)//D)%2 == K%2:
        ans = abs(X)%D
    else:
        ans = abs(abs(X)%D - D)

print(ans)

Measured memory_bytes: 9144
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  unsigned int n, k, total = 0;
  cin >> n >> k;
  unsigned int p[n];
  for (unsigned int i = 0; i < n; i++) {
    cin >> p[i];
  }
  
  sort(p, p + n);
  
  for (unsigned int i = 0; i < k; i++) {
    total += p[i];
  }
  
  cout << total;
  
  return 0;
}

Measured memory_bytes: 3592
# origami
import sys
input = sys.stdin.readline

def f(a, n):
    a = [list(e) for e in a]
    for j in range(len(a)):
        for i in range(n):
            if n + i >= len(a[j]):
                a[j].append(a[j][n-1-i])
            else:
                a[j][n+i] += a[j][n-1-i]
        a[j] = a[j][n:]
    return a


def g(a, n):
    return list(zip(*f(list(zip(*a)),n)))


while True:
    n, m, t, p = map(int, input().split())
    a = [[1]*n for _ in range(m)]
    if n == 0: break
    for _ in range(t):
        d, c = map(int, input().split())
        a = (f if d == 1 else g)(a, c)
    for _ in range(p):
        x, y= map(int, input().split())
        print(a[y][x])



Measured memory_bytes: 5784
/*
      author : nishi5451
      created: 12.08.2020 14:22:16
*/

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


int main(){
    string s;
    cin >> s;
    int ans = 0;
    rep(i,s.size())
        if(s[i]=='1') ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i<=i##end;++i)
#define DREP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i>=i##end;--i)
template<typename T>bool chkmin(T &x,const T &y){return x>y?x=y,1:0;}
template<typename T>bool chkmax(T &x,const T &y){return x<y?x=y,1:0;}
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
template<typename T>T read(){
	T x=0,f=1;
	char c=getchar();
	while((c<'0')||(c>'9')){if(c=='-')f=-1;c=getchar();}
	while((c>='0')&&(c<='9'))x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
#define read() read<int>()
template<typename T>void write(T x,char c){
	static char t[25];
	static int tlen;
	t[tlen=1]=c;
	if(x<0)putchar('-'),x=-x;
	do t[++tlen]=(x%10)^48;
	while(x/=10);
	while(tlen)putchar(t[tlen--]);
}
#define pb push_back
typedef long long ll;
typedef double lf;
typedef unsigned long long llu;
const int maxn=355,mod=1e9+7;
map<llu,vector<pair<ll,ll> > >h;
map<llu,vector<pair<ll,ll> > >::iterator it;
ll a[maxn],b[maxn],c[maxn],m,B[maxn];
int n,d[maxn];
bool cmp(const int &x,const int &y){
	return c[x]==c[y]?x<y:c[x]<c[y];
}
void work(){
	h.clear();
	n=read(),m=read<ll>();
	REP(i,1,n)a[i]=read<ll>();
	sort(a+1,a+1+n);
	REP(k,0,60){
		REP(i,1,n)
			b[i]=a[i]/(1ll<<k),c[i]=a[i]%(1ll<<k),d[i]=i;
		c[n+1]=(1ll<<k)-1,d[n+1]=n+1;
		sort(d+1,d+1+n+1,cmp);
		REP(i,1,n+1){
			ll x=c[d[i]],y=c[d[i-1]];
			int cnt=0;
			if(i!=1){
				if(x==y)continue;
				DREP(j,60,0){
					if(((x>>j)&1)^((y>>j)&1)){++cnt;break;}
					else cnt+=(x>>j)&1;
				}
			}else y=-1;
			REP(j,1,n)
				B[j]=b[j]-(c[j]<=y);
			llu hs=0;
			REP(j,2,n)hs=hs*11+(B[j]-B[j-1]);
			ll l=max(0ll,B[1]-(m-k-cnt)),r=B[1];
			if(l<=r)h[hs].pb(make_pair(l,r));
		}
	}
	int ans=0;
	static vector<pair<ll,ll> >tmp;
	for(it=h.begin();it!=h.end();++it){
		tmp=(*it).second;
		sort(tmp.begin(),tmp.end());
		ll l=0,r=-1;
		REP(i,0,tmp.size()-1){
			if(tmp[i].first>r)ans=(ans+r-l+1)%mod,l=tmp[i].first,r=tmp[i].second;
			else chkmax(r,tmp[i].second);
		}ans=(ans+r-l+1)%mod;
	}write(ans,'\n');
}
int main(){
	work();
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define MAX_N 10
using namespace std;
int table[MAX_N+1][MAX_N+1];
int n;

void print() {
    for(int r = 0; r < n + 1; r++) {
        for(int c = 0; c < n + 1; c++) {
            printf("%5d", table[r][c]);
        }
        putchar('\n');
    }
}

int calcVirtual(int x) {
    int sum = 0;
    for(int r = 0; r < n; r++) {
        sum += table[r][x];
    }
    return(sum);
}

int calcHorizontal(int y) {
    int sum = 0;
    for(int r = 0; r < n; r++) {
        sum += table[y][r];
    }
    return(sum);
}

int main(void) {
    while(cin >> n, n != 0) {
        for(int r = 0; r < n; r++) {
            for(int c = 0; c < n; c++) {
                cin >> table[r][c];
            }
        }
        int sum = 0;
        for(int r = 0; r < n; r++) {
            sum += (table[n][r] = calcVirtual(r));
            table[r][n] = calcHorizontal(r);
        }
        table[n][n] = sum;
        print();
    }
}

Measured memory_bytes: 1164
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H - h) * (W - w) << endl;
    return 0;
}


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

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

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

using namespace std;
typedef long long lint;

const int MOD = 100000007;
const int INF = 1 << 29;
const double EPS = 1e-9;


int main() {

	cin.tie(0);

	int N;
	string s;
	cin >> N >> s;
	s += s;

	DMP(s);
	vector<vector<char>> ans(4);
	string ans_in = "SSSWWWWS";

	FOR(i, 0, 4) {

		ans[i].emplace_back(ans_in[2 * i]);
		ans[i].emplace_back(ans_in[2 * i + 1]);

		FOR(j, 1, N + 1) {

			if (s[j] == 'o') {
				     if (*(ans[i].end() - 2) == 'S' && *(ans[i].end() - 1) == 'S') ans[i].emplace_back('S');
				else if (*(ans[i].end() - 2) == 'W' && *(ans[i].end() - 1) == 'S') ans[i].emplace_back('W');
				else if (*(ans[i].end() - 2) == 'W' && *(ans[i].end() - 1) == 'W') ans[i].emplace_back('S');
				else if (*(ans[i].end() - 2) == 'S' && *(ans[i].end() - 1) == 'W') ans[i].emplace_back('W');
				else return -1;
			}
			if (s[j] == 'x') {
					 if (*(ans[i].end() - 2) == 'S' && *(ans[i].end() - 1) == 'S') ans[i].emplace_back('W');
				else if (*(ans[i].end() - 2) == 'W' && *(ans[i].end() - 1) == 'S') ans[i].emplace_back('S');
				else if (*(ans[i].end() - 2) == 'W' && *(ans[i].end() - 1) == 'W') ans[i].emplace_back('W');
				else if (*(ans[i].end() - 2) == 'S' && *(ans[i].end() - 1) == 'W') ans[i].emplace_back('S');
				else return -1;
			}
		}

		if (ans[i].front() == *(ans[i].end() - 2) && *(ans[i].begin() + 1) == ans[i].back()) {
			ans[i].erase(ans[i].end() - 1);
			ans[i].erase(ans[i].end() - 1);
			for (auto &elem : ans[i]) cout << elem;
			cout << "\n";
			return 0;
		}
	}
		cout << "-1";
		return 0;
}

Measured memory_bytes: 1064
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] x = new int[N][2];
		for(int i = 0; i < N; i++) {
			String S = sc.next();
			int A = 0, B = 0, l = 0, r = 0;
			for(int j = 0; j < S.length(); j++) {
				if(S.charAt(j) == '(')
					l++;
				else
					r++;
				A = Math.max(r-l, A);
			}
			l = 0; r = 0;
			for(int j = S.length()-1; j >= 0; j--) {
				if(S.charAt(j) == '(')
					l++;
				else
					r++;
				B = Math.max(l-r, B);
			}
			x[i][0] = B;
			x[i][1] = A;
		}
		Arrays.sort(x, (a, b) -> a[1] - b[1]);
		int l = 0;
		boolean okl = true;
		for(int i = 0; i < N; i++) {
			if(x[i][0]-x[i][1] >= 0) {
				l -= x[i][1];
				if(l < 0) {
					okl = false;
					break;
				}
				l += x[i][0];
			}
		}
		Arrays.sort(x, (a, b) -> b[0] - a[0]);
		boolean okr = true;
		if(x[0][0]-x[0][1] < 0) {
			l += x[0][0]-x[0][1];
			if(x[0][0] != 0)
				okr = false;
		}
		for(int i = 1; i < N; i++)
			if(x[i][0]-x[i][1] < 0) {
				okr = true;
				l += x[i][0]-x[i][1];
				if(x[i][0] != 0 || x[i][1]-x[i][0] < x[i-1][0])
					okr = false;
			}
		System.out.println(okl && okr && l == 0 ? "Yes" : "No");
	}

}

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

int main()
{
    string a, b;
    cin >> a >> b;
    if(a==b)cout << "EQUAL";
    else if(a.size()==b.size() and a>b)cout << "GREATER";
    else if(a.size()==b.size() and a<b)cout << "LESS";
    else if(a.size()>b.size())         cout << "GREATER";
    else                                cout << "LESS";
}

























































































































































































































Measured memory_bytes: 3620
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define End return 0

int main ()
{
    ll a,b;
    cin>>a>>b;
    if(a>b){
        for(int i=0; i<a; i++){
            cout<<b;
        }
    }
    else{
        for(int i=0; i<b; i++){
            cout<<a;
        }
    }
    cout<<endl;
    End;
}
/* pray for me
All is well
*/


Measured memory_bytes: 256
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

S = gets.chomp
T = gets.chomp

sx = S.split('')
tx = T.split('')


puts sx.zip(tx).count { |s, t| s == t }


Measured memory_bytes: 14428
#include <stdio.h>
#define n_max 45

int main(){
  int n, i;
  int fib[n_max];
  
  scanf("%d",&n);
  
  fib[0]=1;
  fib[1]=1;
  for(i=2;i<=n;i++){
    fib[i]=fib[i-1]+fib[i-2];
  }

  printf("%d\n",fib[n]);
  return 0;
}



Measured memory_bytes: 2104
/**
 * Author: Martin Leshko (leshko.martin@gmail.com)
 */

#include <bits/stdc++.h>
#define F0R(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, n) for (int i = 1; i <= (int)(n); i++)
#define LOOP(i, a, b) for (int i = (a); i < (b); i++)
#define trav(i, a) for (auto& i: a)
#define sz(x) (int)x.size()
#define psb push_back
template<class T> void re(T& x) { std::cin >> x; }
template<class T, class... Ts> void re(T& t, Ts&... ts) { re(t); re(ts...); }
void pr(int x) { std::cout << x; }
void pr(long long x) { std::cout << x; }
void pr(float x) { std::cout << x; }
void pr(double x) { std::cout << x; }
void pr(char x) { std::cout << x; }
void pr(const char* x) { std::cout << x; }
void pr(const std::string& x) { std::cout << x; }
template<class T> void pr(const T& x);
template<class T, class... Ts> void pr(const T& t, const Ts&... ts) {  pr(t); pr(ts...); }
void ps() { std::cout << "\n"; }

using namespace std;
using ll = long long;
using vi = vector<int>;

int main() {
  int h,w,a,b; re(h,w,a,b);
  F0R(i,h)
    F0R(j,w)
      cout<<((i < b) ^ (j < a))<<(j==w-1 ? "\n" : "");
  return 0;
}

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

using namespace std;

#define REP(i,last) for (int i=0;i<last;i++)
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)
#define prints(str) cout << str << " ";
#define printn(str) cout << str << endl;

typedef long long ll;

ll table_comb[51][51];

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  vector<ll> v;
  ll t;
  for(int i = 0; i < N; i++){
      scanf("%lld", &t);
      v.push_back(t);
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  double max_average = 0.0;
  for(int i = 0; i < A; i++){
      max_average += v[i];
  }
  max_average /= A;

  REP(i,N+1){
    for (int j=0;j<=i;++j) {
      if (i == 0 || j == 0) {
        table_comb[i][j] = 1;
      } else {
        table_comb[i][j] = table_comb[i-1][j-1] + table_comb[i-1][j];
      }
    }
  }

  int n = 0,k = 0;
  for(int i = 0; i < N; i++){
      if(v[i] == v[A-1]){
          n++;
          if(i < A)k++;
      }
  }
  ll ans = 0LL;
  if(k == A){
      for(int i = A; i <= B; i++)
          ans += table_comb[n][i];
  }
  else{
      ans += table_comb[n][k];
  }

  // cout << fixed << max_average << endl;
  printf("%lf\n%lld\n", max_average, ans);
  // printn(ans);
}

Measured memory_bytes: 256
n=10
x=10
count=0
n,x=map(int,input().split())
while True:
    if n==0 and x==0:
        break
    else:
        for p in range(1,n+1):
            for q in range(p+1,n+1):
                r=x-p-q
                if q<r<=n:
                    count+=1
    print(count)
    count=0
    n,x=map(int,input().split())



Measured memory_bytes: 5592
function main(input) {
  const s = input.trim();
  let cnt = 0;
  for (let i = 0; i < s.length; i++) {
    const char = s[i];
    if (char === "0") cnt++;
  }
  const min = Math.min(cnt, s.length - cnt);
  const result = 2*min;
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
void YES(bool anser){
    if(anser)printf("YES\n");
    else printf("NO\n");
}
void Yes(bool anser){
    if(anser)printf("Yes\n");
    else printf("No\n");
}
void yes(bool anser){
    if(anser)printf("yes\n");
    else printf("no\n");
}
int n,m,ans=1;
int main(void){
    cin>>n>>m;
    for(int i=1;i*i<=m;i++){
        if(m%i==0){
            if(i>=n)ans=max(ans,m/i);
            if(m/i>=n)ans=max(ans,i);
        }
    }
    cout<<ans<<endl;
}


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

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

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

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

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

int main() {
    string S;
    cin >> S;
    ll N = S.size();
    if (S[N - 1] != 's')
        S += 's';
    else
        S += "es";
    cout << S << endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,K;
  string S;
  cin >> N >> K;
  cin >> S;
  int rev=0;
  for(int i=1;i<N;i++)if(S[i-1]!=S[i])rev++;
  cout << N-1+min(0,-rev+K*2) << endl;
}

Measured memory_bytes: 512
#!/usr/bin/env python3
import sys
import numpy as np


def solve(K: int, X: int):
    result = set()
    point = X - K
    for start in range(1, K + 1):
        base = [i for i in range(start, start + K)]
        arr = np.array(base) + point
        for element in arr:
            result.add(element)

    result = sorted(result)
    result = map(str, result)
    result = " ".join(result)

    print(result)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(K, X)


if __name__ == "__main__":
    main()


Measured memory_bytes: 12496
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
#define vll vector<ll>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

template<typename T>
void vecin(vector<T>& v, int n = 0){
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
}
template <typename T>
void vecout(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n-1; ++i)
    {
        cout << v[i] << " ";
    }
    cout << v[n - 1] << endl;
}
void print(string s){
    cout << s << endl;
}

vector<int> ans(200'008);
vector<vector<int>> G(200008);
vector<int> counter(200'008);

int dfs(int now, int from, int sum){
    for (int edge : G[now]){
        if (edge != from){
            dfs(edge, now, sum + counter[edge]);
        }
    }
    ans[now] = sum;
}

int main()
{
    ciosup;
    int n, q;
    cin >> n >> q;
    REP(i, n - 1)
    {
        int a,b;
        cin >> a >> b;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    REP(i,q){
        int p,x;
        cin>>p>>x;
        counter[p] += x;
    }
    dfs(1, -1, counter[1]);
    FOR(i,1,n){
        cout << ans[i] << " ";
    }
    cout << ans[n] << endl;
}

Measured memory_bytes: 27392
#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;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

LL pp[] = {1,10,100,1000,10000,100000,1000000,10000000,100000000};
LL ch[] = {0,3,7,4,1,2,6,5};
LL ch1[] = {0,4,5,1,3,7,6,2};
LL ch2[] = {6,5,4,7,2,1,0,3};

LL get_hash(LL k,LL i){
    return k * pp[i];
}


int main(){
    while(true){
        map<string,int> m;
        vector<int> a(8,0);
        int key = 0;
        for (int i = 0; i < 8; i++) {
            string s="";cin >> s;
            if(s=="") return 0;
            if(m.find(s)==m.end()) m[s] = key++;
            a[i] = m[s];
        }
        vector<int> v(8);
        for (int i = 0; i < 8; i++) {
            v[i] = i;
        }
        sort(RALL(a));
        int ans = 0;
        set<LL> st;
        auto f = [&](vector<LL> q){
            for (int p = 0; p < 2; p++) {
                for (int k = 0; k < 4; k++) {
                    auto b = q;
                    for (int i = 0; i < 4; i++) {
                        b[i] = q[(i+k)%4];
                        b[i+4] = q[(i+k)%4+4];
                    }
                    LL t = 0;
                    for (int i = 0; i < 8; i++) {
                        t += get_hash(b[i],i);
                    }
                    if(st.find(t) != st.end()) return false;
                }
                auto qq = q;
                for (int i = 0; i < 8; i++) {
                    q[i] = qq[ch2[i]];
                }
            }
            return true;
        };
        do{
            vector<LL> c(8);
            bool ff = true;
            for (int i = 0; i < 8; i++) {
                c[i] = a[v[i]];
            }
            auto cc = c;
            ff &= f(cc);
            for (int i = 0; i < 8; i++) {
                cc[i] = c[ch[i]];
            }
            ff &= f(cc);
            for (int i = 0; i < 8; i++) {
                cc[i] = c[ch1[i]];
            }
            ff &= f(cc);
            if(ff){
                ans++;
                LL t = 0;
                for (int i = 0; i < 8; i++) {
                    t += get_hash(c[i],i);
                }
                st.insert(t);
            }
        }
        while(next_permutation(ALL(v)));
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3148