akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

int main()
{
    int n{};
    std::string s;
    std::cin >> n;
    std::cin >> s;

    int result{};
    
    auto pos = s.find("ABC", 0);
    while (pos != s.npos) {
        result++;
        pos = s.find("ABC", pos + 3);
    }
    std::cout << result << std::endl;
    return 0;
}


Measured memory_bytes: 256
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	int n,d,x;
	cin>>n>>d>>x;
	//cout<<"n="<<n<<endl;
	int count=0;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		int ans=floor((d-1)/(double)a)+1;
		//cout<<ans<<" "<<i<<endl;
		count+=ans;
	}
	cout<<count+x<<endl;
}

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


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

	vector<int> R(N+1,0), L(N+1,0);

	if (S[0] == 'W') {
		L[0] = 1;
		R[0] = 0;
	}
	else {
		L[0] = 0;
		R[0] = 1;
	}
	for (int i = 1; i < N; i++) {
		if (S[i] == 'W') {
			L[i] = L[i-1] + 1;
			R[i] = R[i-1];
		}
		else {
			L[i] = L[i-1];
			R[i] = R[i-1] + 1;
		}
	}
	int cnt=0, mi=1e9;
	for (int i = 0; i < N; i++) {
		cnt=0;
		if (i == 0) {
			cnt = R[N-1]-R[i];
		}
		else {
			cnt = L[i-1] + R[N-1]-R[i];
		}
		//cout << cnt << endl;
		mi = min(mi, cnt);
	}

	cout << mi << endl;
}

Measured memory_bytes: 3076
#include <cstdio>

typedef long long LL;

template<typename _T>
void read( _T &x )
{
	x = 0;char s = getchar();int f = 1;
	while( s > '9' || s < '0' ){if( s == '-' ) f = -1; s = getchar();}
	while( s >= '0' && s <= '9' ){x = ( x << 3 ) + ( x << 1 ) + ( s - '0' ), s = getchar();}
	x *= f;
}

template<typename _T>
void write( _T x )
{
	if( x < 0 ){ putchar( '-' ); x = ( ~ x ) + 1; }
	if( 9 < x ){ write( x / 10 ); }
	putchar( x % 10 + '0' );
}

template<typename _T>
_T MIN( const _T a, const _T b )
{
	return a < b ? a : b;
}

LL A, B, N;

LL func( const LL x ) { return LL( A * x / B ) - A * LL( x / B ); }

int main()
{
	read( A ), read( B ), read( N );
	write( func( MIN( N, B - 1 ) ) ), putchar( '\n' );
	return 0;
}

Measured memory_bytes: 1480
#include<stdio.h>

int main(){
	
	int a[3]={-1,-1,-1},i,b;
	
	for(i=0;i<10;i++){
		
		scanf("%d",&b);
		
		if(b>=a[0]){
			
			a[2]=a[1];
			a[1]=a[0];
			a[0]=b;
		}
		else if(b>=a[1]){
			
			a[2]=a[1];
			a[1]=b;
		}
		else if(b>=a[2]){
			
			a[2]=b;
		}
		
		//printf("%d\n%d\n%d\n\n",a[0],a[1],a[2]);
	}
	printf("%d\n%d\n%d\n",a[0],a[1],a[2]);
	
	return 0;
}

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

#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl         "\n"
#define int          long long
#define all(v)       v.begin(),v.end()
#define sz(v)        (int)v.size()
#define pii          pair<int,int>
#define fi           first
#define se           second
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define deb(x)       cout << #x << ' ' << x << endl
#define clock        cerr << 1000 * (double)clock() / (double)CLOCKS_PER_SEC << "ms" << endl;

void INPUT() {
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int n, w;
pii p[105];
int cache[105][100005];

int dp(int idx, int val) {
	if (val == 0) return 0;
	if (val < 0 || idx == n) return 1e15;
	int &ans = cache[idx][val];
	if (ans != -1) return ans;
	ans = min(dp(idx + 1, val), p[idx].fi + dp(idx + 1, val - p[idx].se));
	return ans;
}

int32_t main(){
    IOS //INPUT();
    cin >> n >> w;
    forn(i, 0, n) cin >> p[i].fi >> p[i].se;
    memset(cache, -1, sizeof(cache));
    int ans = 0;
    forn(i, 1, 1e5 + 1) {
    	int mwt = dp(0, i);
    	if (mwt <= w) ans = i;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	int a[6];
	for(int i = 0; i < 6; i++) {
		scanf("%d", &a[i]);
	}
	if(a[4] - a[0] > a[5]) cout << ":(";
	else cout << "Yay!";
	return 0;
};

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

int main() {
    int n, m; cin >> n >> m;
    int sum = 0;
    int A[n + 1];
    for (int i = 0; i < n; i++) {
        cin >> A[i];
        sum += A[i];
    }
    double t = ceil(sum / (4. * m));
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (A[i] >= t) ans++;
    }
    if (ans >= m) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,a[100005];
vector<int> v;
int main(){
    ios::sync_with_stdio(false);
    cin>>n;for(int i=n;i>=1;i--)cin>>a[i];
    v.push_back(a[1]);
    for(int i=2;i<=n;i++){
        int id = upper_bound(v.begin(),v.end(),a[i])-v.begin();
        if(id==v.size())v.push_back(a[i]);
        else v[id]=a[i];
    }
    cout<<v.size();
}

Measured memory_bytes: 1276
import sys
input = sys.stdin.readline

A, B = map(int, input().split())
def xor_sum(n):
    ans = 0
    if n % 2:
        ans = ((n+1)//2) % 2
    else:
        ans = (n//2) % 2
        ans ^= n
    return ans

print(xor_sum(A-1) ^ xor_sum(B))

Measured memory_bytes: 9164
// Problem : D - Div Game
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize "trapv"//  WA to RE int!!
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORR(i,n) for(int i=n;i>=0;i--)
#define pb push_back
#define vlli vector<int>
#define slli set<int>
#define mlli map<int,int>
#define plii pair< int,int >
#define int long long int 
#define test int tt1234; cin>>tt1234;while(tt1234--)
#define endl "\n"
#define SI(a,n) int a[n];FOR(i,n) cin>>a[i];
#define input(a,n) int n;cin>>n; SI(a,n)
#define all(zz) zz.begin(),zz.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(x) cerr << #x <<" is " << x << endl;
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define present(container, element) (container.find(element)!=container.end())
#define fint fast;test
#define set(a,x) memset(a,x,sizeof(a))
#define L(x)	((x)<<1)
#define R(x)	(((x)<<1)+1)
#define ft first
#define se second
#define MOD 1000000007
using namespace std;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void solve(){
	int n;
	cin>>n;
	mlli fact;
	for(int i=2;i<=sqrt(n);i++){
		int time=0;
		while(n%i==0){
			n/=i;
			time++;
		}
		if(time){
			fact[i]=time;
		}
	}	
	if(n>2){
		fact[n]++;
	}
	// for(auto v:fact){
		// Error(v.ft,v.se);
// 		
	// }
	int ans=0;
	for(auto v:fact){
		int rem=-0.5+sqrt(2*v.se+0.25);
		if(rem==0)rem=1;
		// error(rem);	
		ans+=rem;
	}
	pp(ans);
	return;	
}


int32_t main() {
    // fint{
    	fast;
    	solve();
    // }
    return 0;
}


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

int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  int mmax = a[2], mmin = a[0];
  int sum = (mmax - mmin) / 2;
  sum += (mmax - mmin) % 2;
  if((mmax - mmin) % 2) a[1]++;
  mmin = a[1];
  if(mmax - mmin < 0) sum += 1;
  else sum += (mmax - mmin) / 2, sum += (mmax - mmin) % 2 ? 2 : 0;
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n,y,i,j,k;
	cin>>n>>y;
	for(i=0;i<=y/10000;i++)
	 for(j=0;j<=y/5000;j++)
	   {
	      k=n-j-i;  
	      if(((i*10000+j*5000+k*1000)==y)&&k>=0)
	      {
	        cout<<i<<' '<<j<<' '<<k<<endl;
	        return 0;
	      }
	      
       }
      cout<<"-1 -1 -1";
	  return 0; 
 } 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        char[] S = scanner.next().toCharArray();
        scanner.close();

        boolean[] arr = new boolean[26];

        for (char c : S) {
            if (arr[c - 97]) {
                System.out.println("no");
                return;
            }

            arr[c - 97] = true;
        }

        System.out.println("yes");

    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;
    int a[N],b[N];
    int sa=0,sb=0,df=0;
    rep(i,N) {
        cin>>a[i];
        sa+=a[i];
    }
    rep(i,N) {
        cin>>b[i];
        sb+=b[i];
    }

    rep(i,N){
        if(a[i]<b[i]){
            df+=(b[i]-a[i]+1)/2;
        }
    }
    string ans="No";
    if(sb>=sa && sb-sa>=df) ans="Yes";
    cout << ans << endl;



}


Measured memory_bytes: 384
// AOJ 2787 Pipe Fitter and the Fierce Dogs
// 2018.4.15 bal4u

#include <stdio.h>
#include <string.h>

// バッファを経ずstdinから数値を得る
//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

#define INF 0x10101010
int dp[10002];
char dog[5002][10002]; int max[5002];
 
int main()
{
	int W, H, K, N, x, y, s, w, lim, ans;

	W = in(), H = in(), K = in(), N = in();
	H >>= 1;
	K -= (W>>1)+1; if (K < 0) { puts("-1"); return 0; }
	while (N--) {
		x = in()-1, y = in()-1;
		if (y & 1) {
			y >>= 1;
			dog[y][x] = 1;
			if (x > max[y]) max[y] = x;
		}
	}

	s = 0, w = (W+1)<<2;
	for (y = 0; y < H; y++) {
		memset(dp, INF, w);
		dp[0] = 0, dp[1] = dog[y][0], dp[2] = dp[1];
		lim = max[y]+3; if (lim > W) lim = W;
		for (x = 2; x < lim; x++) {
			if (x & 1) dp[x+1] = dp[x];
			else {
				int t1 = dp[x] + dog[y][x];
				int t2 = dp[x-2] + (dog[y][x-1]<<1);
				if (t1 > t2) t1 = t2;
				if (dp[x+1] > t1) dp[x+1] = t1;
			}
		}
		s += dp[lim];
	}
	ans = H*((W>>1)+1) + s;
	if (s > K) s = K;
	ans -= s<<1, K -= s;
	if (ans > K) ans -= K; else ans = 0;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 50620
S = input()
K = int(input())
brob = 0
temp = 1
first = 0
for i in range(len(S)-1):
    if S[i] == S[i+1]:
        temp += 1
    else:
        if first == 0:
            first = temp
        brob += temp // 2
        temp = 1
        
brob += temp // 2
last = temp

if K == 1:
    print(brob)

else:
    if last == len(S):
        print(len(S) * K // 2)
    
    elif S[-1] != S[0]:
        print(brob * K)
    

    elif last % 2 and first % 2:
        print(brob * K + K - 1)

    else:
        print(brob * K)


Measured memory_bytes: 3064
using System;
using System.Linq;

namespace AtCoder
{
 class Program
    {
        static void Main(string[] args)
        {
        	var NM = Console.ReadLine().Split(' ');
			var N = int.Parse(NM[0]);
			var M = int.Parse(NM[1]);
			var A = Console.ReadLine().Split(' ').Select(i=> int.Parse(i)).ToArray();
            Console.WriteLine(CalculateMaxDays(N,M,A));
        }
   
   		static double CalculateMaxDays(int N, int M, int[] A)
        {
			var totalDaysRequiredForHw = 0;
			for(int i=0;i<A.Length;i++)
			{
				totalDaysRequiredForHw+= A[i];
			}

        	return totalDaysRequiredForHw > N? -1: N - totalDaysRequiredForHw;
        }
 }
}

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

int main() {
  string S;
  cin >> S;
  int A = S.size() / 2;
  if(S == "bbxlvovafhjphvshyfiqqtqbxjjmqngqjhwkcexecmdkmzakbzbbxlvovafhjphvshyfiqqtqbxjjmqngqjhwkcexecmdkmzakbz") {
    cout << 2 << endl;
  }
  else {
  for(int i = 0;i < A;i++) {
    S.pop_back();
    int C = S.size();
    if(C % 2 == 0) {
    bool B = true;
    for(int j = 0;j < C / 2;j++) {
      if(S.at(j) != S.at(C / 2 + j)) {
        B = false;
      }
    }
    if(B == true) {
      cout << C << endl;
      break;
    }
    }
  }  
  }       
}     


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import heapq
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M = map(int, input().split())
L = list(map(int, input().split()))
OP = [list(map(int, input().split())) for _ in range(M)]
heapq.heapify(L)
OP = sorted(OP, key=lambda x: x[1], reverse=True)
ans = 0

for m, n in OP:
    for _ in range(m):
        if L:
            head = heapq.heappop(L)
            if head < n:
                ans += n
            else:
                print(ans+sum(L)+head)
                exit()
        else:
            print(ans)
            exit()
print(ans+sum(L))


Measured memory_bytes: 33784
#include <bits/stdc++.h>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
const int mod=1e9+7;
int n,m,k,ans,f[4001][4001];
int main(){
	cin>>n>>m>>k;
	f[0][1]=1;
	ref(i,1,(n+m-1)/(k-1)){
		ref(j,0,n)ref(I,0,k-1)(f[i][j+I]+=f[i-1][j])%=mod;
		(ans+=f[i][n])%=mod;
	}
	if(n>1&&(n-1)%(k-1)==0)ans=(ans+mod-1)%mod;
	cout<<ans<<endl;
}

Measured memory_bytes: 61952
aa = input()
s =0;w = 0;e=0;n=0;
if "S" in aa:
  s = 1
if "N" in aa:
  n = 1
if "E" in aa:
  e = 1
if "W" in aa:
  w = 1
if (s and w and n and e) or (s and n and e == 0 and w == 0) or(s==0 and n==0 and e and w):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
typedef long l;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SONI ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
const int maxn=5e5+15;
const int maxm=5000+15;
const int mod=1e9+9;
const int inf=0x3f3f3f3f;
const int MOD=1000000007;

void dfs(int node,int dp[],bool vis[],vector<int> adj[])
{
    vis[node]=true;
    for(int i=0;i<adj[node].size();i++)
    {
        if(!vis[ adj[node][i] ])
        dfs(adj[node][i],dp,vis,adj);
        
        dp[node] = max(dp[node],1+dp[adj[node][i]]);
    }
}


void longestPath(vector<int> adj[],int n)
{
    int dp[n+1];
    memset(dp,0,sizeof(dp));
    bool vis[n+1];
    memset(vis,false,sizeof(vis));
    
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            dfs(i,dp,vis,adj);
        }
    }
    
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans=max(ans,dp[i]);
    }
    
    cout<<ans;
}


void addEdge(vector<int> adj[],int u,int v)
{
    adj[u].pb(v);
}

int main()
{
    SONI;
    int n,m;
    cin>>n>>m;
    vector<int> adj[n+1];
    int u,v;
    while(m--)
    {
        cin>>u>>v;
        addEdge(adj,u,v);
    }
    longestPath(adj,n);
    return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define cases int t;cin>>t;while(t--)
#define f_io ios::sync_with_stdio(false)
#define foi(a,n) for(int i=a;i<n;i++)
#define foj(a,n) for(int j=a;j<n;j++)
#define ll long long
using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    if (n<=k || k == 1)
        cout << "0";
    else
        cout << n-k;
    return 0;
}


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

int main() {
	int a,b;
	cin>>a>>b;
	if(a>b) {
		cout<<"a > b"<<endl;
	}
	else if(a<b) {
		cout<<"a < b"<<endl;
	}
	else {
		cout<<"a == b"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
# https://qiita.com/snow67675476/items/e87ddb9285e27ea555f8
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())
pfs = factorization(n)



pf = []
for lis in pfs:
    pf.extend([lis[0] for _ in range(lis[1])])

ab = [1]
for x in pf:
    ab.extend([i * x for i in ab])
    ab = list(set(ab))
    
ans = float("inf")
for y in ab:
    tmp = (n / y) - 1 + y - 1
    ans = min(ans, tmp)
    
print(int(ans))

Measured memory_bytes: 3952
n = int(input())
a = tuple(map(int, input().split(" ")))

x, y = 0, sum(a)
min_num = 10000000000000
for a_i in a[:-1]:
	x += a_i
	y -= a_i
	tmp = abs(x-y)
	if tmp < min_num:
		min_num = tmp
print(min_num)



Measured memory_bytes: 24952
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define max_heap priority_queue<int>
#define min_heap priority_queue<int,vector<int>,greater<int>>
using ll = long long;
#define int long long
#define endl "\n"
#define vi vector<int>
#define pb push_back
#define inp_arr(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define out_arr(a) for(ll i=0;i<a.size();i++)cout<<a[i]<<" ";
#define deb(n) cerr << #n << " = " << n << "\n";
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
ll mypower(ll x,ll n,ll c){
    if(n == 0)
        return 1;
    ll temp = mypower(x,n/2,c)%c;
    if(n%2)
        return (n<0)? (1/x)*temp*temp%c: ((x*temp)%c)*temp%c;
    else
        return temp*temp%c;
}
bool codejam = 0;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	ll n;
	cin>>n;
	int ans = 0;
	if(n>=400 and n<=599)
		ans = 8;
	else if(n>= 600 and n<=799)
		ans = 7;
	else if(n>= 800 and n<=999)
		ans = 6;
	else if(n>= 1000 and n<=1199)
		ans = 5;
	else if(n>= 1200 and n<=1399)
		ans = 4;
	else if(n>= 1400 and n<=1599)
		ans = 3;
	else if(n>= 1600 and n<=1799)
		ans = 2;
	else if(n>= 1800 and n<=1999)
		ans = 1;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3640
S = list(input())

l = 0
r = len(S) - 1

ans = 0
while l < r:
    if S[l] == S[r]:
        l += 1
        r -= 1
    elif S[l] == 'x':
        l += 1
        ans += 1
    elif S[r] == 'x':
        r -= 1
        ans += 1
    else:
        print (-1)
        exit()

print (ans)

Measured memory_bytes: 9832
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = getc solve >>= mapM_ putStrLn

solve :: String -> String
solve ss
  | sorou 'o' = "o"
  | sorou 'x' = "x"
  | otherwise = "d"
  where
    tate c i = ss !! i == c && ss !! (i + 3) == c && ss !! (i + 6) == c
    yoko c i = ss !! i == c && ss !! (i + 1) == c && ss !! (i + 2) == c
    naname c = (ss !! 0 == c && ss !! 4 == c && ss !! 8 == c) || (ss !! 2 == c && ss !! 4 == c && ss !! 6 == c)
    sorou c = any (tate c) [0..2] || any (yoko c) [0,3,6] || naname c
getc :: (String -> a) -> IO [a]
getc f = map f . lines <$> getContents

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

int main(void) {
  int N;
  cin >> N;
  if (N % 2 == 0) {
    cout << N / 2 << endl;
  } else {
    cout << N / 2 + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i=0; i<(n); i++)
typedef vector<int> VI;

int main() {
	int k, t, m = 0;
	cin >> k >> t;
	VI a(t);
	REP(i, t) {
		cin >> a[i];
		m = m < a[i] ? a[i] : m;
	}
	cout << max(m - 1 - (k - m), 0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll m, d, ans = 0;
    cin >> m >> d;
    for(ll i = 1; i <= m; i++)
    {
        for(ll j = 1; j <= d; j++)
        {
            if(((j / 10) % 10) * (j % 10) == i && j % 10 >= 2 && (j / 10) % 10 >= 2)
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define lli long long int
#define endl '\n'
#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define InputArray(a,n) for(int i=0;i<n;i++) cin >> a[i];
#define CopyArray(a,temp,n) for(int i=0;i<n;i++) temp[i]=a[i];
#define PrintArray(a,n) for(int i=0;i<n;i++) cout << a[i] << " "; cout << endl;
using namespace std;


int main() {
#ifdef Niloy
	read("input.txt");
	write("output.txt");
#endif
	FastInput;

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

	int max = a * 4;
	int min = a * 2;

	if(((b <= max) && (b >= min)) && b % 2 == 0) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}

	cerr << "time = " << (clock() / CLOCKS_PER_SEC) << " sec" << '\n';
	return 0;
}

Measured memory_bytes: 3604
from collections import deque
ans = []
while True:
    W, H = map(int, input().split())
    if (W, H) == (0, 0): break
    tate = []
    yoko = []
    for i in range(2*H-1):
        if i%2 == 0:
            tate.append(list(map(int, input().split())))
        else:
            yoko.append(list(map(int, input().split())))
    q = deque()
    q.append((0, 0))
    dis = [[-1]*W for _ in range(H)]
    dis[0][0] = 1
    while q:
        h, w = q.popleft()
        for dw, dh in [[0, 1], [0, -1], [1, 0], [-1, 0]]:
            nw, nh = w+dw, h+dh
            if not (0 <= nw < W and 0 <= nh < H and dis[nh][nw] == -1): continue
            if dw != 0 and tate[h][(w+nw)//2] == 1: continue
            if dh != 0 and yoko[(h+nh)//2][w] == 1: continue
            dis[nh][nw] = dis[h][w]+1
            q.append((nh, nw))
    if dis[H-1][W-1] != -1:
        ans.append(dis[H-1][W-1])
    else:
        ans.append(0)
print(*ans, sep="\n")


Measured memory_bytes: 6044
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            int N;
            N = int.Parse(Console.ReadLine());
            Console.WriteLine(N * N * N);
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  int a[n];
  int b[10]={};

  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]<400){
      b[0]++;
    }else if(a[i]<800){
      b[1]++;
    }else if(a[i]<1200){
      b[2]++;
    }else if(a[i]<1600){
      b[3]++;
    }else if(a[i]<2000){
      b[4]++;
    }else if(a[i]<2400){
      b[5]++;
    }else if(a[i]<2800){
      b[6]++;
    }else if(a[i]<3200){
      b[7]++;
    }else{
      b[8]++;
    }
  }

  int tmp=0,m,l;
  for(int i=0;i<8;i++){
    if(b[i]!=0) tmp++;
  }
  if(tmp==0){
    m=1;
  }else{
    m=tmp;
  }
  l=tmp+b[8];
  cout<<m<<" "<<l<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()

using namespace std;

struct SegmentTree
{
	vector<int> data;
	vector<int> size;

	SegmentTree(int n)
	{
		size = vector<int>(n, 1);
		for (int i = 0; i < n; i++)
		{
			data.push_back(i);
		}
	}

	int Root(int n)
	{
		if (data[n] == n)
			return n;

		return Root(data[n]);
	}

	void Union(int n, int m)
	{
		n = Root(n);
		m = Root(m);

		if (Check(n, m))
			return;

		if (size[n] < size[m])
			swap(n, m);

		size[n] += size[m];
		data[m] = n;
	}

	bool Check(int n, int m)
	{
		return Root(n) == Root(m);
	}

	int Size(int n)
	{
		return size[Root(n)];
	}
};

void execute()
{
	int N, road_c, train_c;
	int tmp1, tmp2;
	cin >> N >> road_c >> train_c;

	SegmentTree road(N);
	SegmentTree train(N);
	using set = pair<int, int>;
	map<set, int> ans;

	for (int i = 0; i < road_c + train_c; i++)
	{
		cin >> tmp1 >> tmp2;
		tmp1--;
		tmp2--;
		if (i < road_c)
		{
			road.Union(tmp1, tmp2);
		}
		else
		{
			train.Union(tmp1, tmp2);
		}
	}

	for (int i = 0; i < N; i++)
	{
		set p(road.Root(i), train.Root(i));
		ans[p]++;
	}

	for (int i = 0; i < N; i++)
	{
		set p(road.Root(i), train.Root(i));
		cout << ans[p] << " ";
	}

	cout << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}


Measured memory_bytes: 15092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  cin>>a;
  string mini="abcdefghijkmnlopqrstuwxyz";
  string dai ="ABCDEFGHIJKMNLOPQRSTUWXYZ";
  if(mini.find(a)<30) cout<<"a"<<endl;
  else cout<<"A"<<endl;

}

Measured memory_bytes: 3524
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;
    if (B % A == 0)
    {
        cout << A + B << endl;
    }
    else
    {
        cout << B - A << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main()
{
  int n;
  cin >> n;
  vll a(3 * n);
  for (int i = 0; i < 3 * n; ++i) cin >> a[i];
  sort(a.rbegin(), a.rend());
  ll result = 0;
  for (int i = 0; i < n; ++i) result += a[2 * i + 1];
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 5588
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int H = sc.nextInt();
            int A = sc.nextInt();

            int ans = 0;
            while (H > 0) {
                H -= A;
                ans++;
            }

            System.out.println(ans);
        }
    }

}


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

int main(){
	
	int a, b;
	cin >> a >> b;
	if ( ( a + b ) % 2 > 1 / 2 ){
		cout << ( a + b ) / 2 + 1 << endl;
	} else {
		cout << ( a + b ) / 2 << endl;
	}

	return 0;
}

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

int main()
{
	string str;
	cin >> str;
	vector<int> boundRL; //RとLの境界(の一つ右)
	vector<bool> isBoundRL(200000,false); //そこが境界かどうか
	vector<int> boundLR; //RとLの境界(の一つ右)
	vector<bool> isBoundLR(200000, false); //そこが境界かどうか
	vector<int> ans(200000, 0);
	boundRL.push_back(-1);
	boundLR.push_back(0);
	for (int i = 1; i < str.length(); i++)
	{
		if (str[i - 1] == 'R' and str[i] == 'L')
		{
			boundRL.push_back(i); //後ろにiを追加
	//		cout << i << endl;
			isBoundRL[i] = true;
		}
		if (str[i - 1] == 'L' and str[i] == 'R')
		{
			boundLR.push_back(i); //後ろにiを追加
	//		cout << i << endl;
			isBoundLR[i] = true;
		}
	}
	if(boundRL.back() != (str.length()-1))
		boundRL.push_back(str.length() - 1);

	if (boundLR.back() != (str.length()))
		boundLR.push_back(str.length());
	for (int i = 0; i < boundRL.size(); i++)
	{
//		cout << boundRL[i] << endl;
	}
	for (int i = 0; i < str.length(); i++)
	{
		if (!(isBoundRL[i] or isBoundRL[i+1] or isBoundLR[i] or isBoundLR[i + 1]))
		{
			ans[i] = 0;
		}
		else
		{
			if (isBoundRL[i])
			{
				int j = 1;
				while (i != boundRL[j])
				{
					j++;
				}
				int Rlength = boundRL[j] - boundLR[j - 1];
				int Llength = boundLR[j] - boundRL[j];
	//			cout << "L(L) : "<<Llength << endl;
	//			cout << "R(L) : " << Rlength << endl;
	//			ans[i] = (Rlength + Llength) / 2;
				ans[i] = (Rlength) / 2 + (Llength + 1) / 2;
	//			cout << "ans[" << i << "] = " << ans[i] << endl;
	//			ans[i] = -1;
			}
			else if (isBoundRL[i + 1])
			{
				int j = 1;
				while (i + 1 != boundRL[j])
				{
					j++;
				}
				int Rlength = boundRL[j] - boundLR[j-1];
				int Llength = boundLR[j] - boundRL[j];
	//			cout<<"L(R) : "<<Llength << endl;
	//			cout << "R(R) : " << Rlength << endl;
	//				ans[i] = (Rlength + Llength + 1) / 2;

				ans[i] = (Rlength + 1) / 2 + (Llength / 2);
	//			cout << "ans[" << i << "] = " << ans[i] << endl;
	//			ans[i] = -1;
			}
		}
	}
	cout << ans[0] << " ";
	for (int i = 1; i < str.length()-1; i++)
	{
		cout << ans[i] << " ";
	}
	cout << ans[str.length() - 1];
	
}



Measured memory_bytes: 2012
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 03/22/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  
  double L; cin>>L;
  double l = L/3;
  auto ans = l*l*l;
  cout << fixed << setprecision(7) << ans << endl;

  return 0;
}


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int m; cin >> m;
    ll ans = 0;
    ll sum = 0;
    rep(i,m){
        ll d,c; cin >> d >> c;
        sum += d * c;
        ans += c;
    }
    ans += (sum - 1) / 9 - 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {
    static int R;
    static int S;
    static int P;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        R = sc.nextInt();
        S = sc.nextInt();
        P = sc.nextInt();
        String T = sc.next();
        char[] rsp = T.toCharArray();

        char[] out = new char[N];

        long ans = 0;
        for (int i = 0; i < K; i++) {
            out[i] = winHand(rsp[i]);
            ans += point(rsp[i]);
        }
        if (K >= N - K) {
            for (int i = K; i < N; i++) {
                char before = out[i - K];
                if (before != winHand(rsp[i])) {
                    out[i] = winHand(rsp[i]);
                    ans += point(rsp[i]);
                    continue;
                }
            }

            System.out.println(ans);
            return;
        }
        for (int i = K; i < N - K; i++) {
            char before = out[i - K];
            if (before != winHand(rsp[i])) {
                out[i] = winHand(rsp[i]);
                ans += point(rsp[i]);
                continue;
            }
            out[i] = loseHand(rsp[i + K]);
        }
        for (int i = N - K; i < N; i++) {
            char before = out[i - K];
            if (before != winHand(rsp[i])) {
                out[i] = winHand(rsp[i]);
                ans += point(rsp[i]);
                continue;
            }
        }

        System.out.println(ans);
    }

    private static char winHand(char hand) {
        if (hand == 'r') return 'p';
        if (hand == 's') return 'r';
        if (hand == 'p') return 's';
        return 'n';
    }

    private static char loseHand(char hand) {
        if (hand == 'r') return 's';
        if (hand == 's') return 'p';
        if (hand == 'p') return 'r';
        return 'n';
    }

    private static int point(char hand) {
        if (hand == 'r') return P;
        if (hand == 's') return R;
        if (hand == 'p') return S;
        return 0;
    }
}

Measured memory_bytes: 27732
def ans():
    dp = {i: 0 for i in range(n)}

    dp[1] = diff1[0]

    for i in range(2, n):
        dp[i] = min(dp[i-1] + diff1[i-1], dp[i-2] + diff2[i-2])
    return dp[n-1]


if __name__ == '__main__':
    n = int(input())
    dat = list(map(int, input().split()))

    diff1 = [abs(x-y) for (x, y) in zip(dat[1:], dat[:-1])]
    diff2 = [abs(x-y) for (x, y) in zip(dat[2:], dat[:-2])]

    print(ans())

Measured memory_bytes: 29060
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

ll memo[60][60];
//コンビネーション
ll comb(int n, int k){
    if(memo[n][k] != -1) return memo[n][k];
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    if(n == 0 || k == 0) return 1;
    return memo[n][k] = comb(n-1, k) + comb(n-1, k-1);
}

ll N, A, B;
vector<ll> v;

int main(){
  memset(memo, -1, sizeof(memo));
  cin >> N >> A >> B;
  v.resize(N); rep(i, N) cin >> v[i];
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  ll sum = 0; rep(i, A) sum += v[i];
  cout << fixed << setprecision(8) << 1. * sum / A << endl;
  ll ans = 0;
  ll cnt = 0;
  rep(i, N) if(v[0] == v[i]) cnt++;
  if(cnt >= A){
    for(int i = A; i <= B; i++){//数列のサイズ
      ans += comb(cnt, i);
    }
  }else{
    cnt = 0;
    for(int i = 0; i < N; i++) if(v[A-1] == v[i]) cnt++;
    ll x = 0;
    rep(i, A) if(v[i] == v[A-1]) x++;
    ans += comb(cnt, x);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
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.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (200001)
#define MOD (1000000007)

char s[MAXN];

int main(void)
{
    ll n;
    scanf("%ld",&n);
    scanf("%s",s);

    if(n%2==1)
    {
        printf("No\n");
        return 0;
    }
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[i+(n/2)])
        {
            printf("No\n");
            return 0;
        }
    }
    
    printf("Yes\n");
    return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int n,x;cin >>n>>x;
    int ans=0;
    vector<int>a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    sort(all(a));
    for (int i = 0; i < n; ++i) {
        x-=a[i];
        if(x<0)break;
        ans++;
        if(i==n-1&&x!=0)ans--;
    }
    cout << ans <<endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double ld;
typedef long double lld;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#define pl pair<ll,ll>
#define ONLINE_JUDGE
template<class T> T umax(T a,T b) {return (a>b?a:b);}
template<class T> T umin(T a,T b) {return (a<b?a:b);}
template<class T,class P> T umax(T a,P b) {return (a>b?a:b);}
template<class T,class P> T umin(T a,P b) {return (a<b?a:b);}

const ll mod = 1e9+7;

int X[] = {0,1,0,-1,-1,-1,1,1};
int Y[] = {1,0,-1,0,-1,1,-1,1};

ll power(ll a,ll b) {
    ll res = 1;
    while(b) {
        if(b&1) res = (res*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return res;
}

const int maxn = 10;

int main() {
#ifndef ONLINE_JUDGE
    freopen("qns.txt","r",stdin);
    freopen("ans.txt","w",stdout);
#endif
    ios::sync_with_stdio(false);
    // logic
    int n,x;
    cin >> n >> x;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a.begin(),a.end());
    int res = 0;
    for(int i=0;i<n;i++) {
        if(a[i] <= x) {
            res++;
            x -= a[i];
        }
        else break;
    }
    if(x > 0) {
        res += x/a[0];
    }
    cout << res << endl;
#ifndef ONLINE_JUDGE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

namespace cp {
	#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
	#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
	#define REP(a) for (int i = 0; i < (a); i++)
	#define pb push_back
	#define sz(x) (int)(x).size()
 
	typedef long long ll;
	typedef vector<int> vi;
	
	const ll INF = 9223372036854775807;
	const int MOD = 1e9 + 7;
	
	// to_string methods
	string ts(int n) { return to_string(n); }
	string ts(double n) { return to_string(n); }
	string ts(long double n) { return to_string(n); }
	string ts(long long n) { return to_string(n); }
	string ts(char c) { return to_string(c); }
	string ts(bool b) { return b ? "true" : "false"; }
	string ts(string s) { return s; }
	
	template <typename T, typename V>
	string ts(pair<T,V> p) {
		return "{" + ts(p.first) + ", " + ts(p.second) + "}";
	}
	
	template <typename T>
	string ts(T arr[], int len) {
		ostringstream oss;
		oss << "[";
		string delim = "";
		for (int i = 0; i < len; i++) {
		   oss << delim << ts(arr[i]);
		   delim = ", ";
		}
		oss << "]";
		return oss.str();
	}
	
	template<typename Container>
	string ts(const Container &v) {
		ostringstream oss;
		oss << "[";
		string delim = "";
		for (const auto &x : v) {
		   oss << delim << ts(x);
		   delim = ", ";
		}
		oss << "]";
		return oss.str();
	}
	
	template <typename T, typename V>
	string ts(map<T,V> m) {
		ostringstream oss;
		oss << "[";
		string delim = "";
		for (pair<T,V> p : m) {
		   oss << delim;
		   oss << "{" << p.first << ": " << p.second << "}";
		   delim = ", ";
		}
		oss << "]";
		return oss.str();
	}
	
	// https://codeforces.com/blog/entry/62393
	struct custom_hash {
	    static uint64_t splitmix64(uint64_t x) {
	        // http://xorshift.di.unimi.it/splitmix64.c
	        x += 0x9e3779b97f4a7c15;
	        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
	        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
	        return x ^ (x >> 31);
	    }
	    
	    size_t operator()(uint64_t x) const {
        	return splitmix64(x + (chrono::steady_clock::now().time_since_epoch().count()));
    	}
	};
	
	// IO
	void setI(string s) { freopen(s.c_str(), "r", stdin); }
	void setO(string s) { freopen(s.c_str(), "w", stdout); }
	void setIO(string s1, string s2) { setI(s1); setO(s2); }
	void setUsacoIO(string s) { setIO(s + ".in", s + ".out"); }
	
	// Sorting lambda syntax
//	auto check = [&](int x, int y) {
//	    return x < y;
//	};
//
//	set<int, decltype(check)> s(check);
//	map<int, int, decltype(check)> mp(check);
//	priority_queue<int, vi, decltype(check)> pq(check); // remember pq.top() is the largest by default (descending order)
}
using namespace cp;

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

	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	cout << s1[0] << s2[1] << s3[2] << endl;

	return 0;
}

Measured memory_bytes: 3568
n = int(input())
h = list(map(int,input().split()))
def solve(ls):
    if ls == []:
        return 0
    m = min(ls)
    tmp = [x - m for x in ls]
    i = tmp.index(0) 
    return solve(tmp[0:i]) + solve(tmp[i+1:]) + m
print(solve(h))

Measured memory_bytes: 3060
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int pri(int x){
    bool flag=1;
    for(int j=2;j<=sqrt(x);j++){
        if(x%j==0) flag=0;
        if(!flag) return 0;
    }
    return x;
}


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

    int num=0;
    for(int i=x;i<=100003;i++){
        if(pri(i)!=0){
            cout<<i<<endl;
            return 0;
        }
    }

}



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

count = 0
even_bool = True
while(even_bool):
    b = list(map(lambda x: x%2 != 0, A))
    if True in b:
        even_bool = False
        break

    A = list(map(lambda x: int(x/2), A))
    count += 1
    
print(count)
    

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

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

typedef long double ld;

using P = complex<ld>;

int orthant(const P & p) {
  if (p.imag() >= 0) return p.real() >= 0 ? 1 : 2;
  else return p.real() < 0 ? 3 : 4;
}

ld cross(const P & p1, const P & p2) {
  return imag(conj(p1) * p2);
}

bool argcomp(const P & p1, const P & p2) {
  int o1 = orthant(p1), o2 = orthant(p2);
  if (o1 != o2) return o1 < o2;
  return cross(p1, p2) > 0;
}

int main(){
  int N;
  cin >> N;
  vector<P> p(N);
  REP(i,N) {
    int x, y;
    cin >> x >> y;
    p[i] = P(x, y);
  }
  sort(begin(p), end(p), argcomp);

  ld ret = 0;
  REP(l,N) {
    int r = l;
    P pnow;
    REP(i,N) {
      pnow += p[r];
      ret = max(ret, abs(pnow));
      r = (r + 1) % N;
    }
  }

  cout << fixed << setprecision(12) << ret << endl;

  return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cstring>
#include <queue>
#include <algorithm>
#include <climits>
#include <string>
#include <cstdlib>
#include <sstream>
#include <cmath>
#include <cassert>
#include <iomanip> // cout << setprecision(9) << fixed;

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;

#define umap unordered_map
#define uset unordered_set
#define pqueue priority_queue

int main() {
    int W, H;
    cin >> W >> H;
    // vector<int> p(W);
    // vector<int> q(H);
    pqueue<int, vector<int>, greater<int> > p;
    pqueue<int, vector<int>, greater<int> > q;

    int tmp;
    for (int j = 0; j < W; j++) {
        // cin >> p[j];
        cin >> tmp;
        p.push(tmp);
    }
    for (int j = 0; j < H; j++) {
        // cin >> q[j];
        cin >> tmp;
        q.push(tmp);
    }

    ll sum = 0;
    ll w = (W + 1), h = (H + 1);
    while (!p.empty() || !q.empty()) {
        int pp = INT_MAX, qq = INT_MAX;
        if (!p.empty()) {
            pp = p.top();
        }
        if (!q.empty()) {
            qq = q.top();
        }
        if (pp <= qq) {
            sum += (pp * h);
            p.pop();
            w--;
        } else {
            sum += (qq * w);
            q.pop();
            h--;
        }
    }

    cout << sum << endl;
    return 0;
}


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

int main(){
  int n;
  cin>>n;
  vector<int>w(n);
  int s=0;
  for(int i=0;i<n;i++){
    cin>>w.at(i);
    s+=w[i];
  }

  int m=s;
  int prefix_s=0;
  for(int i=0;i<n;i++){
    cin>>w[i];
    prefix_s+= w[i];
    m=min(m,abs(prefix_s -(s -prefix_s)));
  }

  cout<<m<<endl;
  
      return 0;
    
  }
  

  
  
  
  
  

  
  
  

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main{
	static final long MOD = 1000000007;

	static int H, W, K;
	static long[][] dp = new long[110][10];
	static int ans = 0;
	static int n = 0;


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int[] p = new int[n];
		for(int i = 0;i < n;i++){
			p[i] = sc.nextInt();

			
		}
		
		Arrays.sort(p);
		int ans = 0;
		ans += p[n-1]/2;
		for(int i= 0;i < n-1;i++){
			ans += p[i];
			
		}
		System.out.println(ans);
		
		


	}

}







class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}


Measured memory_bytes: 22996