akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
const int N=100005;
int n,i,j,k,p[N],l,ans;
ll a[N],w,g,b[N],c[N];
bool v[N];
map<ll,ll> anti;
map<ll,int> mp;
map<ll,int>::iterator ddq;
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;++i)
		scanf("%lld",a+i);
	for(i=2;i<=100000;++i)
	{
		if(!v[i])
			p[++l]=i;
		for(j=1;j<=l&&p[j]*i<=100000;++j)
		{
			v[p[j]*i]=true;
			if(i%p[j]==0)
				break;
		}
	}
	for(i=1;i<=n;++i)
	{
		b[i]=c[i]=1;
		w=a[i];
		for(j=1;1ll*p[j]*p[j]*p[j]<=a[i]&&w>1;++j)
			if(w%p[j]==0)
			{
				k=0;
				while(w%p[j]==0)
					w/=p[j],++k;
				if(k%3==1)
					b[i]*=p[j],c[i]*=p[j]*p[j];
				else if(k%3==2)
					b[i]*=p[j]*p[j],c[i]*=p[j];
			}
		if(w>1)
		{
			b[i]*=w;
			g=(ll)sqrt(w);
			if(g*g==w)
				c[i]*=g;
			else
			{
				if(1000000000000000000ll/c[i]/w/w==0)
					c[i]=-1;
				else
					c[i]*=w*w;
			}
		}
		anti[b[i]]=c[i];
	}
	for(i=1;i<=n;++i)
		mp[b[i]]++;
	for(ddq=mp.begin();ddq!=mp.end();ddq++)
	{
		w=ddq->first,g=ddq->second;
		if(w!=1&&(g>mp[anti[w]]||(g==mp[anti[w]]&&w>anti[w])))
			ans+=g;
	}
	if(mp[1])
		ans++;
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 23296
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;


void main() {
    string s = readln.chomp;
    writeln("2018" ~ s[4 .. $]);
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <typeinfo>
#include <cmath>
using namespace std;
#define ll long long 
const ll MOD = 1e9 + 7;
 
set<int> graph[100005];
ll dp[100005][2]; 
 
void solve(int current_node, int parent){
    for (auto x: graph[current_node]) {
        if ((x == parent))
            continue;
        solve(x, current_node);
        dp[current_node][0] = (dp[current_node][0] % MOD * (dp[x][0] + dp[x][1]) % MOD) % MOD;    
        dp[current_node][1] = (dp[current_node][1] % MOD * (dp[x][0]) % MOD) % MOD; 
    }
    return;
}
 
int main()
{
    int N;
    cin >> N;
    if (N > 1){
        for (int i=0; i<N; ++i) {
            int src, dst;
            cin >> src >> dst;
            graph[src].insert(dst);
            graph[dst].insert(src);
        }
    }   
    
    // dp[i][j] is the number of ways of in which a sub-tree whose root is i has color j.
    // dp[cur_node][0] *= dp[child][0]+dp[child][1]; for every child of cur_node - if cur_node is white, child can be either white or black(hence summing both possibilities).
    // similarly, if cur_node is black child can only be white.
    // multiplication for every child is done to get the total no. of ways of getting j color for cur_node.
    // init condition for dp, # of ways of putting white(0) or black(1) is 1 for each node.
    for (int i=0; i<100005; ++i) {
        dp[i][0] = 1;
        dp[i][1] = 1;
    }
    
    // root is 1 and it's parent is -1, init condition for 0th(non-existing) node    
    solve(1, -1);
    cout << (dp[1][0] + dp[1][1]) % MOD;
    return 0;
}

Measured memory_bytes: 22784
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var n = next();
  var a = nexts(n,1);
  var ax = xArray(0,n);
  var ay = xArray(0,n);
  var ans = n;
  for(var y = 0; y < n; y++){
    for(var x = 0; x < n; x++){
      if(a[y][x] === "#"){
        ax[x]++, ay[y]++;
        if(ax[x] === n)ans--;
      }
    }
  }
  var id, mx = -1;
  for(var y = 0; y < n; y++){
    if(mx === ay[y])id.push(y);
    else if(mx < ay[y])mx = ay[y], id = [y];
  }
  if(mx === 0)return -1;
  ans += n-mx
  for(var i = 0; i < id.length; i++){
    var y = id[i];
    for(var x = 0; x < n; x++){
      if(a[x][y] === "#")return ans;
    }
  }
  return ans+1;
}

Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,t,T,c;
    cin>>n>>T;
    int a[n],b[n];
    for(int i=0; i<n; i++){
        cin>>c>>t;
        if(t<=T){
            a[i]=c;
            b[i]=t;
    }
    else
    {
      a[i]=1002;
      b[i]=1002;
    }
    }
    sort(a, a+n);
    if(a[0]==1002)
        cout<<"TLE"<<endl;
    else
    cout<<a[0]<<endl;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int A, B;
	cin >> A >> B;
	if (A + B >= 10)
	{
		cout << "error" << endl;
	}
	else
	{
		cout << A + B << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000000000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);ios::sync_with_stdio(false);

signed main()
{
    ll n, m,ans=0;
    cin >> n >> m;
    priority_queue<ll> q;
    rep(i, n){
        ll a;cin>>a;
        q.push(a);
    }

    while(m--){
        ll x=q.top();
        q.pop();
        q.push(x/2);
    }

    while(!q.empty()){
        ans+=q.top();
        q.pop();
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,K,X,Y;
  cin>>N>>K>>X>>Y;
 int cost;
  if(N>K){
	cout<<(K*X) + ((N-K) *Y);
  }
  else{
  	cout<<N*X;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	if((b-a)%2 == 0){
		puts("Alice");
	}
	else {
		puts("Borys");
	}
}



Measured memory_bytes: 764
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n;
  string s;
  cin >> n >> s;

  ll ans=0;
  for(ll i=1;i<n-1;i++){
    string t=s.substr(0,i+1),u=s.substr(i+1);
    sort(t.begin(),t.end());
    t.erase(unique(t.begin(),t.end()),t.end());
    ll k=0;
    for(ll j=0;j<t.size();j++){
      for(ll l=0;l<u.size();l++){
        if(t[j]==u[l]){
          k++;
          break;
        }
      }
    }
    ans=max(ans,k);
  }

  cout << ans << endl;

}

Measured memory_bytes: 3640
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math


def inputIntList():
  return [int(s) for s in input().split()]


def inputInt():
  return int(input())


def main():
  N, M = inputIntList()

  ac = 0
  wa = 0
  problem = [['', 0] for _ in range(N)]
  for _ in range(M):
    i, s = input().split()
    i = int(i)-1
    if problem[i][0] == 'AC':
      continue
    else:
      problem[i][0] = s

    if problem[i][0] == 'WA':
      problem[i][1] += 1
    else:
      ac += 1
  for result, wa_cnt in problem:
    if result == 'AC':
      wa += wa_cnt
  return '{} {}'.format(ac, wa)


if __name__ == "__main__":
  print(main())


Measured memory_bytes: 18804
#include <iostream>

using namespace std;

#define MAX 500000
#define INF 1000000000
int L[MAX/2+2];
int R[MAX/2+2];
int cnt = 0;

void merge( int * ary, int left, int mid, int right ) {
	int n1 = mid - left;
	int n2 = right - mid;

	for ( int i = 0 ; i < n1 ; i++ ) {
		L[i] = ary[i+left];
	}

	for ( int i = 0 ; i < n2 ; i++ ) {
		R[i] = ary[i+mid];
	}
	L[n1] = INF;
	R[n2] = INF;

	int i = 0, j = 0;
	for ( int k = left ; k < right ; k++ ) {
		cnt++;
		if ( L[i] <= R[j] ) {
			ary[k] = L[i];
			i++;
		} else {
			ary[k] = R[j];
			j++;
		}
	}
}



void mergeSort( int * ary, int left, int right ) {
	if ( left+1 < right ) {
		int mid = (left+right)/2;
		mergeSort( ary, left, mid );
		mergeSort( ary, mid, right );
		merge( ary, left, mid, right );
	}
}

int main() {
	int n;
	int ary[MAX];
	cin >> n;

	for ( int i = 0 ; i < n ; i++ ) {
		cin >> ary[i];
	}
	mergeSort( ary, 0, n );

	for ( int i = 0 ; i < n ; i++ ) {
		if ( i != n-1 ) {
			cout << ary[i] << " ";
		} else {
			cout << ary[i] << endl;
		}
	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 6984
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
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); }
//SOLVE


void solve (void)
{
  int N,A,B,C,D;
  cin>>N>>A>>B>>C>>D;
  A *= 2; B *= 2; C *= 2; D*= 2;//二倍しても解は不変、変換の妥当性を優先
  --N;
  int diff = abs(A - B);
  int gap = (C + D)/2;
  int center = 0;
  int radius = (D - C)/2*N;//半径/2
  if(N&1) center = gap;
  bool ok = false;
  for (int i = 0; i < N*2; i++)
  {
    int left = center - radius, right = center + radius;
    if(right > D*N)break;
    if(left <= diff && diff <= right) ok = 1;
    center += gap*2;
  }
  if(ok)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  
  
    
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}
    
void run(){
    int a[3][3];
    rep(i,3)rep(j,3)cin>>a[i][j];
    int n;
    cin>>n;
    rep(i,n){
        int b;
        cin>>b;
        rep(j,3)rep(k,3)if(a[j][k]==b)a[j][k]=0;
    }
    bool f=false;
    rep(i,3)if(a[i][0]==a[i][1]&&a[i][1]==a[i][2])f=true;
    rep(i,3)if(a[0][i]==a[1][i]&&a[1][i]==a[2][i])f=true;
    if(a[0][0]==a[1][1]&&a[1][1]==a[2][2])f=true;
    if(a[0][2]==a[1][1]&&a[1][1]==a[0][2])f=true;
    Yes(f);
}

Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}

double log(double a, double x){
  return log10(x)/log10(a);
}
  
/*
n
100000
 */
int n;
int dp[100][100001];
#define INF 100001
int main(){
  cin>>n;

  //int k = floor(log(6,n));
  //int l = floor(log(9,n));

  int k = 0, l=0;
  for(; pow(6,k) <= n; k++);
  for(; pow(9,l) <= n; l++);

  vector<int> a;
  a.push_back(1);
  for(int i=1; i<=k; i++)
    a.push_back(pow(6,i));
  for(int i=1; i<=l; i++)
    a.push_back(pow(9,i));

  REP(j, n+1){
    dp[0][j] = j==0 ? 0 : INF;
  }

  REP(i, k+l+1){
    REP(j,n+1){
      if(j>=a[i]){
        dp[i+1][j] = min(dp[i][j], dp[i+1][j-a[i]]+1);
      } else
        dp[i+1][j] = dp[i][j];
    }
  }

  cout << dp[k+l+1][n] << endl;

  return 0;
}


Measured memory_bytes: 6400
#include<iostream>
#include<set>
using namespace std;
int a[1002];
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]!=s[i+1]) ans++;
    }
    cout<<ans;
}


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

int main(){
  int i,j,cnt=0;
  int n;
  cin>>n;
  string s[n];
  for(i=0;i<n;i++)cin>>s[i];
  for(i=0;i<n;i++){
    for(j=1;j<s[i].size();j++){
      if(s[i][j-1]=='A' && s[i][j]=='B')cnt++;
    }
  }
  int a=0,b=0,ab=0;
  for(i=0;i<n;i++){
    if(!(s[i][0]=='B') && s[i][s[i].size()-1]=='A')a++;
    if(s[i][0]=='B' && !(s[i][s[i].size()-1]=='A'))b++;
    if(s[i][0]=='B' && s[i][s[i].size()-1]=='A')ab++;
  }
  if(a==0 && b==0)cnt+=max(0,ab-1);
  else if((a==0 && b!=0) || (a!=0 && b==0))cnt+=ab;
  else cnt+=min(a,b)+ab;
  cout<<cnt;
}

Measured memory_bytes: 768
intMax = -10000000000
inputData = int(input())
inputList = list()
for i in range(inputData):
    inputList.append(int(input()))

inputDataMax = intMax
inputDataMin = inputList[0]
for i in range(inputData - 1):
    inputDataMax = max(inputDataMax,  inputList[i + 1] - inputDataMin)
    inputDataMin = min(inputDataMin, inputList[i + 1])

print(inputDataMax)



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

int main(){
  int W,H,x,y,r;
  cin >> W >> H >> x >> y >> r;

  int xr=x+r,yr=y+r;

  if(xr<=W && yr<=H && x>=0 && y>=0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}



Measured memory_bytes: 3104
#include <stdio.h>

int main(){

	int A,B,C,X,Y;

	scanf("%d %d %d %d %d",&A,&B,&C,&X,&Y);

	int ans=0;

	if(X>Y){
		if(Y*2*C>(A*Y)+(B*Y)){
			ans+=(A*Y)+(B*Y);
		}
		else{
			ans+=Y*2*C;
		}
		if((X-Y)*2*C>A*(X-Y)){
			ans+=A*(X-Y);
		}
		else{
			ans+=(X-Y)*2*C;
		}
	}
	else{
		if(X*2*C>(A*X)+(B*X)){
			ans+=(A*X)+(B*X);
		}
		else{
			ans+=X*2*C;
		}
		if((Y-X)*2*C>B*(Y-X)){
			ans+=B*(Y-X);
		}
		else{
			ans+=(Y-X)*2*C;
		}
	}

	printf("%d\n",ans);

	return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N, B[1010101];
char A[1010101];
ll mk[10];
ll i, j, k;


bool calc(){
    ll i, j, k,ret;
    ret = 0;
    k = 0;
    fornum(i,0,N){
        if(k==0){
            ret ^= B[i] & 1;
        }
        ll a = N - 1 - i;
        if(a==0)
            break;
        while(a%2==0){
            ++k;
            a /= 2;
        }
        a = i + 1;
        while(a%2==0){
            --k;
            a /= 2;
        }
    }
    return ret;
}

int main(){
    scanf("%lld%s", &N,A);
    bool flg = false;
    fornum(i,0,N){
        if(A[i]=='1')
            B[i] = 0;
        if(A[i]=='2'){
            B[i] = 1;
            flg = true;
        }
        if(A[i]=='3')
            B[i] = 2;
    }
    if(calc()){
        printf("1\n");
        return 0;
    }
    fornum(i,0,N){
        B[i] /= 2;
    }
    if(flg||!calc()){
        printf("0\n");
        return 0;
    }
    printf("2\n");
    return 0;
}

Measured memory_bytes: 9088
program ABC166C
    implicit none
    integer(8)::N,M,i,ans,A,B
    integer(8),allocatable,dimension(:)::H,checked,C
    read*,N,M
    allocate(H(N))
    allocate(checked(N))
    allocate(C(N))
    read*,H
    C=0
    ans=0
    do i=1,M
        read*,A,B
        if(H(A)>H(B))then
            C(B)=1
        else if(H(A)<H(B))then
            C(A)=1
        else
            C(A)=1
            C(B)=1
        end if
    end do

    do i=1,N
        if(C(i)==0)ans=ans+1
    end do
    print'(i0)',ans
end program ABC166C

Measured memory_bytes: 4664
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		var S = GetString();
		var T = GetString();
		int A = GetInt();
		int B = GetInt();
		var U = GetString();
		if(S.Equals(U))
			A--;
		else
			B--;

		WriteLine($"{A} {B}");
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 13268
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
    int x;
    cin >> x;
    if (x == 1) {
        cout << 1 << endl;
        return 0;
    }
    for (int number = x; number >= 1; number--) {
        for (int b = 2; b <= number; b++) {
            for (int p = 2; std::pow(b, p) <= number; p++) {
                if (std::pow(b, p) == number) {
                    cout << number << endl;
                    return 0;
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[100000],i,p,q,r;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    p=n/2;
    q=p+1;
    r=a[q-1]-a[p-1];
    printf("%d",r);
}

Measured memory_bytes: 640
// Ala be zekrellah tatmaenolgholoob ...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F first
#define S second
#define MP make_pair
const int maxn = 5e3+9;
const ll mod = 1e9+7;

stack <int> st[205];
ll a[maxn], b[maxn][205], sum[maxn], dp[maxn][maxn]; 

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 1; i < n; i++)
		cin >> a[i];
	for (int i = 1; i <= n; i++)
		for (int t = 1; t <= m; t++)
			cin >> b[i][t];
	// dp
	for (int e = 1; e <= n; e++) {
		memset(sum, 0, sizeof sum);
		ll last = 0;
		for (int s = 1; s <= e; s++)
			dp[s][e] = dp[s][e - 1];
		for (int i = 1; i <= m; i++) {
			// add col[i] and update
			last = 0;
			sum[e] += b[e][i];
			while (st[i].size() && b[st[i].top()][i] < b[e][i]) {
				sum[st[i].top()] += last;
				last = b[st[i].top()][i];
				sum[st[i].top()] -= last;
				st[i].pop();
			}
			if (st[i].size()) {
				sum[st[i].top()] -= b[e][i];
				sum[st[i].top()] += last;
			}
			st[i].push(e);
		}
		// update from sum
		for (int s = e; s >= 1; s--) {
			sum[s] += sum[s + 1];
			dp[s][e] += sum[s];
		}
	}
	// ans
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		ll f = 0;
		for (int t = i; t <= n; t++) {
			ans = max(ans, dp[i][t] - f);
			f += a[t];
		}
	}
	cout << ans << "\n";
}



Measured memory_bytes: 204544
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<string, int> P;


class Graph{
    struct edge{
        int vertice;
        ll weight;
    };

    vector<vector<edge>> g;
    unsigned int n;

public:
    Graph(unsigned int n): n{n}{
        g.resize(n);
    }

    void add_edge(int u, int v){
        g[u].emplace_back(edge{v, 1});
    };

    void add_edge(int u, int v, ll w){
        g[u].emplace_back(edge{v, w});
    }

    vector<edge>& get_edge(int v){
        return g[v];
    }

    unsigned int size(){
        return n;
    }

    vector<edge>& operator[](int v){
        return get_edge(v);
    }
};


int main(){
    int n;  cin >> n;
    set<string> st;
    int res = 0;
    for(int i = 0; i < n; i++){
        string s;   cin >> s;
        if(st.find(s) == st.end()){
            st.insert(s);
            res++;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 19224
#include<stdio.h>
#include<string.h>

int main(){

    char s[3];
    scanf("%s", s);

    if(s[0] == 'S' && s[1] == 'U' && s[2] == 'N'){printf("7");}
    else if(s[0] == 'M' && s[1] == 'O' && s[2] == 'N'){printf("6");}
    else if(s[0] == 'T' && s[1] == 'U' && s[2] == 'E'){printf("5");}
    else if(s[0] == 'W' && s[1] == 'E' && s[2] == 'D'){printf("4");}
    else if(s[0] == 'T' && s[1] == 'H' && s[2] == 'U'){printf("3");}
    else if(s[0] == 'F' && s[1] == 'R' && s[2] == 'I'){printf("2");}
    else if(s[0] == 'S' && s[1] == 'A' && s[2] == 'T'){printf("1");}

    return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15); 
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i]; 
    }
    map<int, int> mpodd, mpeven;
    for (int i = 0; i < n; i += 2) {
        ++mpodd[a[i]]; 
    }  
    for (int i = 1; i < n; i += 2) {
        ++mpeven[a[i]];
    }
    vector<pair<int, int>> odd, even; 
    for (auto it: mpodd) {
        odd.push_back(make_pair(-it.second, it.first)); 
    }
    for (auto it: mpeven) {
        even.push_back(make_pair(-it.second, it.first));  
    }
    odd.push_back(make_pair(0, 0));
    even.push_back(make_pair(0, 0)); 
    sort(odd.begin(), odd.end());
    sort(even.begin(), even.end());
    int ans = 0; 
    if (odd[0].second != even[0].second) ans = n + odd[0].first + even[0].first; 
    else {
        ans = n + min(odd[1].first + even[0].first, odd[0].first + even[1].first); 
    }
    cout << ans << endl; 
    return 0; 
}

Measured memory_bytes: 6524
#include<bits/stdc++.h>
using namespace std;
char s[111111];int a[3];
bool chk(int x,int y,int A,int B,int C){
	if(A==0 && B==0 && C==0)return true;
	if(x == 0){
		if(A==0)return false;
		A--;
	}else
	if(x == 1){
		if(B==0)return false;
		B--;
	}else
	if(x == 2){
		if(C==0)return false;
		C--;
	}
	return chk(y,3-x-y,A,B,C);
}
int main(){
	scanf("%s",s);
	for(int i=0; s[i]; i++)
		a[s[i]-'a']++;
	for(int i=0; i<3; i++)for(int j=0; j<3; j++)if(j!=i && chk(i,j,a[0],a[1],a[2])){
		puts("YES");
		return 0;
	}
	puts("NO");
	return 0;
}


Measured memory_bytes: 384
def f(v):
    for i in range(4):
        if l[i] < v[i]:
            return
    else:
        return True

while True:
    N = int(raw_input())
    if N == 0: break
    data = [map(int, raw_input().split()) for n in range(N)]
    l = map(int, raw_input().split())
    flag = False
    for v in data:
        v.append(4*v[1]+9*v[2]+4*v[3])
        if f(v[1:]):
            print v[0]
            flag = True
    if not flag:
        print 'NA'

Measured memory_bytes: 4488
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

    vector<int> a(5);
    REP(i, 5) cin >> a[i];

    int mini = 10;
    int index = 0;
    int count = 0;
    REP(i, 5) {
        if (a[i] % 10 == 0) continue ;
        if (a[i] % 10 < mini) {
            index = i;
            count++;
            mini = a[i] % 10;
        }
    }

    int sum = 0;
    if (count) {
        REP(i, 5)
            if (i != index)
                if (a[i] % 10) a[i] += 10 - (a[i] % 10);
        sum = accumulate(a.begin(), a.end(), 0);
    } else {
        sum = accumulate(a.begin(), a.end(), 0);
    }

    cout << sum << '\n';
    return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE FlexibleContexts #-}

import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IMS
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Sequence as Seq
import Data.Sequence (Seq)
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Control.Monad.State.Strict
import Data.Int
import System.IO
import Data.Function
import Control.Monad.Primitive
import qualified Data.Vector.Primitive.Mutable as VPM
import qualified Data.Vector.Generic.Mutable as VGM
import Data.STRef
import Data.IORef

main :: IO ()
main = do
  ns <- map read . words <$> getLine :: IO [Int]
  putStrLn $ if sort ns == [1,4,7,9] then "YES" else "NO"


Measured memory_bytes: 508
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>

using namespace std;
int main(void){
 int N,K;
 string S;

 cin>>N>>S>>K;
 
 for(int i=0; i<S.length();i++){
  if(S[K-1]==S[i])cout<<S[K-1]; 
  else cout<<"*";
  
 }
 cout<<endl;
 return 0;
}

Measured memory_bytes: 256
A,B = map(int,input().split())

Acount = 1
Bcount = 1

print(40,100)
for j in range(19):
    OUTPUT = ""
    for i in range(100):
        if i%2==0 and j%2==0 and Acount<A:
            Acount += 1
            OUTPUT += "."
        else: OUTPUT += "#"
    print(OUTPUT)
print("".join(["#" for i in range(100)]))

B_OUTPUT = []
for j in range(19):
    OUTPUT = ""
    for i in range(100):
        if i%2==0 and j%2==0 and Bcount<B:
            Bcount += 1
            OUTPUT += "#"
        else: OUTPUT += "."
    B_OUTPUT.append(OUTPUT)
B_OUTPUT.append("".join(["." for i in range(100)]))

for b in B_OUTPUT[::-1]:
    print(b)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int A, B;
    int t=1, ans=0;

    cin >> A >> B;

    while(t<B) {
        t += A-1;
        ans++;
    }

    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  vector<int> x(5);
  rep(i, 5) cin >> x[i];
  int k;
  cin >> k;
  rep(i, 5) rep(j, i) if(abs(x[i] - x[j]) > k) {
    cout << ":(" << endl;
    return 0;
  }
  cout << "Yay!" << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program{
  static void Main()
  {
    string[] Sh=Console.ReadLine().Split(' ');
    int Th=int.Parse(Sh[0]);
    int Ta=int.Parse(Sh[1]);
    int Ah=int.Parse(Sh[2]);
    int Aa=int.Parse(Sh[3]);
    
    while(true)
    {
      Ah-=Ta;
      Th-=Aa;
      if(Ah<=0||Th<=0)
      {
          break;
      }
    }
    if(Ah<=0)
    {
      Console.WriteLine("Yes");
    }
    else if(Th<=0)
    {
      Console.WriteLine("No");
    }
  }
}

Measured memory_bytes: 27528
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#define rep(i,rept) for(long long i = 0; i <(long long)rept;i++)
using namespace std;
int main() {
	int a = 0, b = 0, c = 0, d[100][100], e[100000], f = 0, g = 0, h = 0, count = 0,x=0,y=0,z=0;
	char rikka, toka[100000];
	string saya, homu, kyok, mami, mado[50];
	bool gg = true;
	int manji, nk[26] = { false };
	cin >> a >> b;
	int s[3][2];
	//a[0][0],a[0][1],a[1][0]...
	count = 200000000;
	for (int i = 0; i < a; i++) {
		for (int j = 0; j < b; j++) {
			cin >> d[i][j];
		}
	}
	for (int k = 0; k < a; k++) {
		for (int l = 0; l < b; l++) {
			for (int m = 0; m < a; m++) {
				for (int n = 0; n < b; n++) {
					//cout << k << l << m << n << endl;
					f += d[m][n] * min(abs(m - k), abs(n - l));
				}
			}
			//cout << count << endl;
			count = min(f, count);
			f = 0;
		}
	}
	cout << count << endl;

	return 0;
}



Measured memory_bytes: 3136
h,w = map(int, input().split())
l = [None]*h
for i in range(h):
    l[i] = list(input())

from collections import deque
b_Q = deque()
for i in range(h):
    for j in range(w):
      if l[i][j]=="#":
          b_Q.append([i,j])

ans=0
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
visited=[[0 for i in range(w)] for j in range(h)]
while b_Q:
    p = b_Q.popleft()
    now = l[p[0]][p[1]]

    if visited[p[0]][p[1]] == 1:
        continue
    visited[p[0]][p[1]] = 1
    b_cnt=1
    w_cnt=0

    search_Q = deque()
    search_Q.append([p[0],p[1]])

    while search_Q:
        sch = search_Q.popleft()
        current = l[sch[0]][sch[1]]
        for i in range(4):
            nx = sch[1] + dx[i]
            ny = sch[0] + dy[i]
            if 0 <= nx < w and 0 <= ny < h:
                if current != l[ny][nx] and visited[ny][nx] == 0: # b->w or w->b
                    if current=="#":
                        w_cnt+=1
                    else:
                        b_cnt+=1
                    search_Q.append([ny,nx])
                    visited[ny][nx]=1
    ans+= b_cnt*w_cnt
print(ans)

Measured memory_bytes: 66268
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;

int main(){
    string s;
    char m;
    vector<char> si;
    getline(cin,s);
    while(s.size()>0){
        //si.resize(s.size());
        //for(int i=0;i<s.size();i++){
        //    si[i] = null;
        //}
        int i=0;
        while (s[i] != '\0' ){
            m=tolower(s[i]);
            if(m>='a' && m<='z'){
                si.push_back(m);
            }
            i++;
        }
        getline(cin,s);
    }
    sort(si.begin(),si.end());
    //for(int i=0;i<=si.size();i++){
    //    cout << si[i];
    //}
    char moji='a';
    int spos=0;
    int cnt=0;
    while(moji <= 'z'){
        if(spos<si.size() && moji==si[spos]){
            cnt++;
            spos++;
        } else{
            cout << moji << " : " << cnt << endl;
            moji=char(int(moji)+1);
            cnt =0;
        }
    }
    return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#define pii pair <int,int>
using namespace std;
int n,m,i,j,a[102][102],k,x,cnt;
pii pe,per;
pii next(pii per)
{
    int i,j;
    i=per.first; j=per.second;
    if(i%2==1)
    {
        if(j==m) {i++;}
        else j++;
    }
    else
    {
        if(j==1) {i++;j=1;}
        else j--;
    }
    return make_pair(i,j);
}
int main()
{
    cin>>n>>m>>k; pe=make_pair(1,0);
    for(cnt=1;cnt<=k;cnt++)
    {
        cin>>x;
        for(i=1;i<=x;i++)
        {
            pe=next(pe);
            a[pe.first][pe.second]=cnt;
        }
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            cout<<a[i][j]<<' ';
        }
        cout<<'\n';
    }
    return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String[] a = sc.next().split("");
        for (int i = 0; i < a.length; i++) {
            if (a[i].equals("1")) {
                a[i] = "9";
            } else {
                a[i] = "1";
            }
            System.out.print(a[i]);
        }
    }
}


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


int main() {
  int N;
  cin >> N;
  vector<long long> L = {2, 1};
  
  rep(i, N+1) {
    L.push_back(L[i] + L[i-1]);
  }
  
  cout << L[N] << endl;
  
}


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

int main(){
	int s; cin >> s;
	
	vector<int> v = {s};
	int fn = s;
	for(int i = 2; i <= 1000000; i++){
		if(fn % 2 == 0){
			fn = fn / 2;
		}
		else{
			fn = fn * 3 + 1;
		}

		auto result = find(v.begin(), v.end(), fn);
		if(result == v.end()){
			v.push_back(fn);
		}
		else{
			cout << i;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
//#define pop pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846
bool f(string s)
{
	int n=s.length();
	bool bo=true;
	for(int i=0;i<n;i++)
	{
		if(s[i]!=s[n-1-i])
		{
			bo=false;
			break;
		}
	}
	return bo;
}
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
       string s;
    cin>>s;
    int n=s.length();
    string s1="",s2="";
    int i=(n-1)/2;
    for(int j=0;j<i;j++)
    	s1+=s[i];
    i=(n+3)/2;
    i--;
    for(;i<n;i++)
    	s2+=s[i];
    if(f(s) and f(s1) and f(s2))
    	cout<<"Yes";
    else
    	cout<<"No";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

const int MAX_N = 1e5 + 10;
const ll INF = 1 << 30;

ll A[MAX_N];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    for (int i = 1; i <= N; i++) cin >> A[i];
    A[0] = 0;
    A[N + 1] = INF;
    sort(A, A + N + 2);
    int left = 0, right = N + 2;
    while (right - left > 1) {
        int mid = (right + left) / 2;
        ll now_a = 0;
        for (int i = 1; i <= mid; i++) now_a += A[i];
        bool is_ok = true;
        for (int i = mid + 1; i <= N; i++) {
            if (2 * now_a < A[i]) {
                is_ok = false;
                break;
            }
            now_a += A[i];
        }
        if (is_ok) right = mid;
        else left = mid;
    }
    cout << N - right + 1 << endl;
    return 0;
}

Measured memory_bytes: 1024
use std::char::from_u32;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut n: u64 = read();
    let mut result = String::new();
    while n > 0 {
        n -= 1;
        let mut remainder = n % 26;
        // a-zはコード表で97-122
        let digit = from_u32(remainder as u32 + 97).unwrap();
        result = format!("{}{}", digit, result); // 先頭に足していく
        n = (n - remainder) / 26;
    }
    println!("{}", result);
}

Measured memory_bytes: 2156
from collections import deque
n = int(input())
p = [[0 for i in range(10)] for j  in range(10)]
for i in range(1,10):
    for j in range(1,10):
        if i == j:
            if i <= n:
                p[i][j] += 1
        now = ""
        d = deque()
        d.append("")
        while d:
            now = d.popleft()
            for k in range(10):
                d.append(now+str(k))
            if int(str(i) + now + str(j)) <= n:
                p[i][j] += 1
            else:
                break
ans = 0            
    
for i in range(1,10):
    for j in range(1,10):
        ans += p[i][j]*p[j][i]

print(ans)

Measured memory_bytes: 9724
# -*- coding: utf-8 -*-
a=int(input())
l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(l[a-1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,a[105]={},b[105]={};
    string s[105];
    cin>>h>>w;
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    for(int i=0;i<h;i++){
        int c=0;
        for(int j=0;j<w;j++){
            if(s[i][j]=='.')
                c++;
        if(c==w)
            a[i]=1;
        }
    }
    for(int i=0;i<w;i++){
        int c=0;
        for(int j=0;j<h;j++){
            if(s[j][i]=='.')
                c++;
        if(c==h)
            b[i]=1;
        }
    }
    for(int i=0;i<h;i++){
        int c=0;
        for(int j=0;j<w;j++){
            if(a[i]!=1 && b[j]!=1){
                cout<<s[i][j];
                c++;
            }
        }
        if(c!=0)
            cout<<endl;
    }
    return(0);
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#define MAX_N 20
using namespace std;

int a[MAX_N];

bool rec(int key, int sum, int current, int n) {
  if (sum == key) return true;
  if (current == n) return false;
  if (sum > key) return false;
  
  return (rec(key, sum, current + 1, n)
	  || rec(key, sum + a[current], current + 1, n));
}

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

  for (int i = 0; i < q; i++) {
    if (rec(m[i], 0, 0, n)) cout << "yes" << endl;
    else cout << "no" << endl;
  }

  return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll  long long
#define ull unsigned long long  
using namespace std;
#define  inf 1e6+18
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod 1000000007
#define  f1(i,n) for(i=1;i<=n;i++)
#define f0(i,n)  for(i=0;i<n;i++)
#define w(x)   while(x--)
const int maxn=1000001;
#define  pq priority_queue
#define  ff first
#define  ss second 
#define pb  push_back
#define lb lower_bound
map<int,int>mp;
vector<int>pr;
int p[maxn];
void sieve()
{
  ll i,j;
  for(i=2;i<maxn;i++)
  {
  	if(p[i]==0)
  	{
  		pr.pb(i);
  		for(j=i*i;j<maxn;j+=i)
  			p[j]=1;
  	}
  }

 
}
int main()
{
	fastio;
	//int t;
	sieve();
	ll int i,j,k,n,m,g=0;
	cin>>n;
	ll a[n];
	
	for(i=0;i<n;i++){
		cin>>a[i];
		g=__gcd(g,a[i]);
		mp[a[i]]++;
	}
	int j1=1;
for(i=0;i<pr.size();i++)
{
	k=0;
	ll i1=pr[i];
	for(j=i1;j<maxn;j+=i1)
	{
       k+=mp[j];
	}
	
	if(k>=2)
		{
			j1=0;
			break;


		}
}
//cout<<j<<" ";
if(j1==1)
{
cout<<"pairwise coprime";
}
else if(g==1)
{
	cout<<"setwise coprime";

}
else
{
    cout<<"not coprime";
}

	
	

}
//Lordvishnu@almighty

Measured memory_bytes: 62148
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n,l; cin >> n >> l;
    vl a(n);
    rep(i,n) {
        cin >> a[i];
    }
    bool flag = false;
    ll last;
    rep(i,n-1){
        if(a[i]+a[i+1] >= l){
            flag = true;
            last = i+1;
            break;
        }
    }
    if(flag){
        puts("Possible");
        REP(i,1,last){
            cout << i << endl;
        }
        for(ll i=n-1; i>=last; i--){
            cout << i << endl;
        }
    }else{
        puts("Impossible");
    }
}


Measured memory_bytes: 1664
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    cout << max(0, C - A + B) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long int
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,k,i,j;
            cin>>n>>k;
            string s;
            cin>>s;
            int ct=0,ct2=0;
            int ans=0;
            for(i=0;i<n;++i)
            {
                if(s[i]=='L')
                {
                    if(i-1>=0 && s[i-1]=='L')
                        ++ans;
                }
                else
                {
                    if(i+1<n && s[i+1]=='R')
                        ++ans;
                }
            }
            vector<int> v;
            for(i=1;i<n;++i)
            {
                if(s[i]!=s[i-1])
                {
                    if(s[i]=='R')
                        ++ct;
                    else
                        ++ct2;
                    v.pb(1);
                }
            }
            if(s[n-1]=='L')
                ++ct;
            else
                ++ct2;
            //cout<<ans<<" "<<k<<" "<<ct<<" "<<ct2<<endl;
            if(k>=min(ct,ct2))
            {
                cout<<n-1<<endl;
                return 0;
            }
            ans=ans+k+k;
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 972