akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(3)
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
//#include<windows.h>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define INF 1e9
#define LLINF 1e18
#define EPS 1e-7
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,b) for(int a=1;a<=b;a++)
#define forr(a,n) for(int a=n;a>0;a--)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define REP(a,m,n) for(int a=m;a<n;a++)
#define REPN(a,m,n,p) for(int a=m;a<n;a+=p)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define iofopen(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define ifopen(a) freopen(a,"r",stdin);
#define ofopen(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
	ios::sync_with_stdio(0);
	ll a,b,n;
	cin>>a>>b>>n;
	ll x=min(n,b-1);
	cout<<a*x/b-a*(x/b);
	return 0;
}

Measured memory_bytes: 3612
As, Bs = readlines.drop(1).map{|l| l.split.map(&:to_i)}.transpose

bs, is = Bs.each_with_index.sort.transpose
as = is.map{|i| As[i]}.inject([0]){|s, a| s << s.last + a}.drop(1)
puts as.zip(bs).all?{|a, b| a <= b} ? 'Yes' : 'No'

Measured memory_bytes: 53212
#include<bits/stdc++.h>
   using namespace std;
   int main()
   {
   ios::sync_with_stdio(0);
   cin.tie(0);
  string a,b;
  cin>>a>>b;
  int count=0;
  for(int i=0;i<a.length();i++)
  {
      if(a[i]!=b[i])
      count++;
  }
  cout<<count;
   return 0;
   }

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
#define lg 18
//<<fixed << setprecision(9)
int k;
vi G[space];
int nbr[space];
ll ans;

void dfs(int n,int p)
{
    nbr[n]=1;
    
    if(p!=-1)
    {
        if(nbr[p]>=k) 
        {
            cout<<0;
            exit(0);
        }
        nbr[n]=2;
        ans*=(k-nbr[p]);
        ans%=mod;
    }
    for(auto z:G[n])
    {
        if(z!=p)
        {
            dfs(z,n);
            nbr[n]++;
        }
    }
}
int main()
{
    int n,i,j,t;
    boost;

    cin>>n>>k;
    int u,v;
    ans=k;
    rep(i,0,n-1)
    {
        cin>>u>>v;
        G[u].pb(v);
        G[v].pb(u);
    }
    dfs(1,-1);

    
    cout<<ans;
    return 0;
}



Measured memory_bytes: 9600
def myAnswer(N:int, D:list) -> int:
   index = N//2
   D.sort()
   if( D[index - 1] == D[index]): return 0
   return D[index] - D[index - 1]

def modelAnswer():
   tmp=1
def main():
   N = int(input())
   D = list(map(int,input().split()))
   print(myAnswer(N,D))

if __name__ == '__main__':
   main()

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

int main() {
  ll red, green, a, b, c;
  cin >> red >> green >> a >> b >> c;
  
  vector<ll> p(a+1), q(b+1), r(c+1);
  p.at(0) = INF;
  q.at(0) = INF;
  r.at(0) = INF;
  REP(i, a)
    cin >> p.at(i+1);
  REP(i, b)
    cin >> q.at(i+1);
  REP(i, c)
    cin >> r.at(i+1);
  
  sort(next(p.begin()), p.end(), greater<int>());
  sort(next(q.begin()), q.end(), greater<int>());
  sort(next(r.begin()), r.end(), greater<int>());
  
  ll l = red;
  ll m = green;
  ll n = 0;
  
  ll mini = min(p.at(l), q.at(m));
  
  bool cont = true;
  while(cont) {
    ll tmp = r.at(n+1);
    
    if (p.at(l) <= q.at(m) && p.at(l) < tmp) {
      --l;
      ++n;
    }
    else if (p.at(l) > q.at(m) && q.at(m) < tmp) {
      --m;
      ++n;
    }
    else
      cont = false;
    
    if ((l == 0 && m == 0) || n == c)
      cont = false;
  }
  
  ll ans = 0;
  for (int i = 1; i <= l; ++i)
    ans += p.at(i);
  for (int i = 1; i <= m; ++i)
    ans += q.at(i);
  for (int i = 1; i <= n; ++i)
    ans += r.at(i);
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 2560
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    int K;
    cin >> K;
    int num = 7, ans = 0, sum = 7;
    vb data(K + 1, false);
    while (true) {
        ans++;
        if (sum % K == 0) {
            break;
        }
        data[sum] = true;
        num = (num * 10) % K;
        sum += num;
        sum %= K;
        if (data[sum]) {
            ans = -1;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3744
import sys
#import time
#import copy
from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
import heapq
import time

start = time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
q = ri()
lr = [rl() for _ in range(q)]

def Is_prime(n):
    if n<2:return False
    elif n==2:return True
    elif n>3 and n%2==0:return False
    for i in range(3, n):
        if i*i>n:
            break
        if n%i==0:return False
    return True

dp=[0]*(10**5+1)
for i in range(1,10**5+1):
    if i%2==0:
        dp[i]=dp[i-1]
    if Is_prime(i) and Is_prime((i+1)//2):
        dp[i]=dp[i-1]+1
    else:
        dp[i]=dp[i-1]

for j in lr:
    print(dp[j[1]]-dp[j[0]-1])

Measured memory_bytes: 66520
// Simple C++ program to count occurrences 
// of pat in txt. 
#include<bits/stdc++.h> 
using namespace std; 

int countFreq(string &pat, string &txt) 
{ 
	int M = pat.length(); 
	int N = txt.length(); 
	int res = 0; 
	
	/* A loop to slide pat[] one by one */
	for (int i = 0; i <= N - M; i++) 
	{ 
		/* For current index i, check for 
		pattern match */
		int j; 
		for (j = 0; j < M; j++) 
			if (txt[i+j] != pat[j]) 
				break; 

		// if pat[0...M-1] = txt[i, i+1, ...i+M-1] 
		if (j == M) 
		{ 
		res++; 
		j = 0; 
		} 
	} 
	return res; 
} 
	
/* Driver program to test above function */
int main() 
{ int n;
string txt;
 cin>>n;
 cin>>txt;
string pat = "ABC"; 
cout << countFreq(pat, txt); 
return 0; 
} 


Measured memory_bytes: 3596
fn main() {
    let mut input: Vec<i128> = {
        let mut count = String::new();
        std::io::stdin().read_line(&mut count).unwrap();
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.split_whitespace()
            .map(|i| i.parse::<i128>().unwrap())
            .collect()
    };

    let z: i128 = 0;

    if input.contains(&z) {
        println!("0");
        return;
    }
    let mut result: i128 = 1;
    for n in input.iter() {
        result = result * n;
        if result > 1000000000000000000 {
            println!("-1");
            return;
        }
    }
    println!("{}", result)
}


Measured memory_bytes: 5584
#include<bits/stdc++.h>
using namespace std;
vector<int>vec;
int main(){
  int sum=0;
  int a[10];
  for(int i=0;i<5;i++)cin>>a[i];
  for(int i=0;i<5;i++){
    if(a[i]%10!=0){
      vec.push_back(10-a[i]%10);
    }
    else{
      vec.push_back(0);
    }
    sum+=a[i];
  }
  sort(vec.begin(),vec.end());
  for(int i=0;i<4;i++){
    sum+=vec[i];
  }
  cout<<sum<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <set>

using namespace std;

int f(int n){
  if(n%2 == 0) return n/2;
  else return 3 * n + 1;
}

int main(){
  int s;
  std::cin >> s;

  set<int> a;
  int val = s;
  int count = 1;
  while(true){
    if(a.find(val) != a.end()){
      std::cout << count << '\n';
      return 0;
    }
    a.insert(val);
    val = f(val);
    count++;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
typedef long long ll;
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
typedef struct{
    int p;
    int q;
}data;

//降順
int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}
int asc(const void *a, const void *b) {
  long *A = (long *)a;
  long *B = (long *)b;
  if (*A > *B) return 1;
  if (*A < *B) return -1;
  return 0;
}

int kai(int n){
    if(n==0){
        return 1;
    }
    int sum=1;
    for(int i=1;i<=n;i++){
        sum*=i;
    }
    return sum;
}
//構造体の.pを降順
int comp( const void *c1, const void *c2 )
{ data test1 = *(data *)c1;
  data test2 = *(data *)c2;
  int tmp1 = test1.p;   /* b を基準とする */
  int tmp2 = test2.p;
    return tmp2 - tmp1;}




int main(){
    int N,L;
    scanf("%d%d",&N,&L);
    char s[N][L+1];
    rep(i,N){
        scanf("%s",s[i]);
    }
    char temp[L+3];
    for(int i=1;i<N;i++){
        for(int j=1;j<N;j++){
            if(strcmp(s[j-1],s[j])>=0){
                strcpy(temp,s[j-1]);
                strcpy(s[j-1],s[j]);
                strcpy(s[j],temp);
            }
        }
    }
    for(int i=0;i<N;i++){
        printf("%s",s[i]);
    }
}


Measured memory_bytes: 1696
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S, T;
  cin >> S >> T;
  int n = S.length();
  int ans = n;
  for (int i = 0; i < n; i++) {
    ans -= S[i] == T[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3884
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(x) memset(x,0,sizeof(x))
#define MINUS(x) memset(x,-1,sizeof(x))
#define UNIQUE(x) (x).erase(unique(ALL(x)), (x).end())
#define TOUPPER(x) transform(ALL(x), (x).begin(), ::toupper)
#define TOLOWER(x) transform(ALL(x), (x).begin(), ::tolower)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int INF = 1e9;
const ll INFL = 1e18;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;

int main() {
    ll N; cin >> N;
    int ans = 0;
    for(ll i = 2; i*i <= N; i++) {
        if(N % i == 0) {
            ans++;
            N /= i;
            int cnt = 0;
            int mx = 1;
            while(N % i == 0) {
                N /= i;
                cnt++;
                if(cnt > mx) {
                    ans++;
                    mx = cnt;
                    cnt = 0;
                }
            }
        }
    }
    if(N != 1) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int N,M,a,sum=0;
	cin>>N>>M;
	for(int i=0;i<M;i++){
		cin>>a;
		sum+=a;
	}
	if(sum>N)cout<<-1;
	else cout<<N-sum;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
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(a > b) { a = b; return true; } return false; }
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 


int main() {
  int n; cin >> n;
  ll mx = -INF;
  ll ans = 0;
  rep(i,n) {
    ll a; cin >> a;
    if (mx > a)  {
      ans += mx - a;
    }
    chmax(mx, a);
  }
  cout << ans << endl;
  return 0;
}

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

namespace ABC_115A
{
    class Program
    {
        static void Main(string[] args)
        {
            int D;

            var word = Console.ReadLine().Split(' ');

            D = int.Parse(word[0]);

            if (D == 25)
                Console.WriteLine("Christmas");

            else if (D == 24)
                Console.WriteLine("Christmas Eve");

            else if (D == 23)
                Console.WriteLine("Christmas Eve Eve");

            else
                Console.WriteLine("Christmas Eve Eve Eve");

            Console.ReadKey();
                
            
        }
    }
}


Measured memory_bytes: 11092
n = int(input())
a = [int(x) for x in input().split()]

I = a.count(3)
J = a.count(2)
K = a.count(1)

dp = [[[0 for _ in range(I+J+K+1)] for __ in range(I+J+1)]
      for ___ in range(I+1)]

for i in range(I+1):
    for j in range(I+J+1-i):
        for k in range(I+J+K+1-i-j):
            if i + j + k == 0:
                continue
            if k-1 > -1:
                dp[i][j][k] += (n/(i+j+k))*(k/n)*dp[i][j][k-1]
            if j-1 > -1:
                dp[i][j][k] += (n/(i+j+k))*(j/n)*dp[i][j-1][k+1]
            if i-1 > -1:
                dp[i][j][k] += (n/(i+j+k))*(i/n)*dp[i-1][j+1][k]
            dp[i][j][k] += n/(i+j+k)

print(dp[I][J][K])


Measured memory_bytes: 500884
#include <bits/stdc++.h>
using namespace std;
int main() {
  int s;
  cin >> s;
  set<int> st;
  int x=s;
  while(st.count(x) == 0){
    st.insert(x);
    if(x%2 == 0){
      x = x / 2;
    }
    else{
      x = x*3 + 1;
    }
  }
  cout << st.size() + 1 << endl;
}

Measured memory_bytes: 256
n, w = map(int, input().split())
wv = [tuple(map(int, input().split())) for _ in range(n)]

INF = 10**9 + 100
MAX_V = 10**5 + 100
dp = [INF] * (MAX_V + 1)
dp[0] = 0
for wi, vi in wv:
    for sum_v in reversed(range(vi, MAX_V+1)):
        dp[sum_v] = min(dp[sum_v - vi] + wi, dp[sum_v])
#print(dp)
ans = 0
for i in reversed(range(MAX_V+1)):
    if dp[i] <= w:
        print(i)
        exit()
#print(ans)


Measured memory_bytes: 41452
#include <iostream>
#include <vector>
#include <set>
#include <queue>
using namespace std;
const int MAXN = 2e5+5;
vector<int> v1x[MAXN];
int n;
vector<int> v1y[MAXN];
int x[MAXN];
int y[MAXN];
bool found[MAXN];
bool visx[MAXN];
bool visy[MAXN];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x[i]>>y[i];
        v1x[x[i]].push_back(i);
        v1y[y[i]].push_back(i);
    }
    long long ans = -1*n;
    for(int i=1;i<=n;i++){
        if(found[i]){
            continue;
        }
        set<int> usedx,usedy;
        queue<int> q1;
        usedx.insert(x[i]);
        usedy.insert(y[i]);
        q1.push(i);
       
        while(!q1.empty()){
            int curr = q1.front();
            q1.pop();
            vector<int> tovisit;
            if(!visx[x[curr]]){
                visx[x[curr]]= true;
                for(int j:v1x[x[curr]]){
                    tovisit.push_back(j);
                }
            }
            
            if(!visy[y[curr]]){
                visy[y[curr]] = true;
                for(int j:v1y[y[curr]]){
                    tovisit.push_back(j);
                }
            }
            for(int j:tovisit){
                if(found[j]){
                    continue;
                }
                found[j] = true;
                usedx.insert(x[j]);
                usedy.insert(y[j]);
                q1.push(j);
            }
            
        }
        ans+=(long long)usedx.size()*(long long)usedy.size();
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 18688
#include <iostream>
#include <string>

int main()
{
	std::string innings;
	getline(std::cin, innings);
	int bInnings = std::stoi(innings);
	
	int outs = 0;
	int score = 0;
	int base[3] = {0, 0, 0};
	for (int i=0; i<bInnings; ) {
		std::string event;
		getline(std::cin, event);
		if (event == "HIT") {
			if (base[2] == 1) score++;
			base[2] = base[1];
			base[1] = base[0];
			base[0] = 1;
		}
		else if (event == "HOMERUN") {
			score += base[0] + base[1] + base[2] + 1;
			base[0] = base[1] = base[2] = 0;
		}
		else {
			outs++;
			if (outs == 3) {
				std::cout << score << std::endl;
				score = 0;
				base[0] = base[1] = base[2] = 0;
				outs = 0;
				i++;
			}
		}
	}
	
	return 0;
}



Measured memory_bytes: 3024
n,k,c=[int(x) for x in input().split()]
s=list(input())

L=[]
R=[]

i=0
while i < n:  
    if s[i]=="o":
        L.append(i)
        i+=c
    i+=1

i=0
while i < n:
    if s[n-i-1]=="o":
        R.append(n-i-1)
        i+=c
    i+=1
    
days=[]
for i in range(k):
    if L[i]==R[k-i-1]:
        days.append(L[i])


for i in range(len(days)):
    print(days[i]+1)

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

using namespace std;

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

  int n, m, q;
  cin >> n >> m >> q;
  vector<vector<int>> trains(n, vector<int>(n + 1, 0));

  for (int i = 0; i < m; ++i) {
    int l, r;
    cin >> l >> r;
    l--, r--;
    for (int j = 0; j <= l; ++j) {
      trains[j][r]++;
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 1; j <= n; ++j) {
      trains[i][j] += trains[i][j - 1];
    }
  }

  for (int i = 0; i < q; ++i) {
    int f, t;
    cin >> f >> t;
    f--, t--;
    cout << trains[f][t] << "\n";
  }
}


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

int main() {
  int a,b,i,j,e;
  char d;
  cin>>a>>b;
  vector<string>c(a);
  for(i=0;i<a;i++){
    cin>>c.at(i);
  }
  for(i=0;i<a;i++){
    for(j=0;j<b;j++){
      d=(c.at(i)).at(j);
      if(d!='#'){
        e=0;
        if(i>0&&j>0){
          if((c.at(i-1)).at(j-1)=='#')
            e++;
        }
        if(i>0){
          if((c.at(i-1)).at(j)=='#')
            e++;
        }
        if(i>0&&j<b-1){
          if((c.at(i-1)).at(j+1)=='#')
            e++;
        }
        if(j>0){
          if((c.at(i)).at(j-1)=='#')
            e++;
        }
        if(j<b-1){
          if((c.at(i)).at(j+1)=='#')
            e++;
        }
        if(i<a-1&&j>0){
          if((c.at(i+1)).at(j-1)=='#')
            e++;
        }
        if(i<a-1){
          if((c.at(i+1)).at(j)=='#')
            e++;
        }
        if(i<a-1&&j<b-1){
          if((c.at(i+1)).at(j+1)=='#')
            e++;
        }
        cout<<e;
      }else{
        cout<<'#';
      }
    }
    cout<<endl;
  }
}


Measured memory_bytes: 256
/* Author : fenwick123 */

#include <bits/stdc++.h>
using namespace std;

int main(){
    
    int n;
    cin >> n;
    vector<int> a(n);
    map<int , int> mp;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        mp[a[i]]++;
    }
    int ans = 0;
    for (int i = 0; i < n; i++){
        bool ok = true;
        for (int j = 1; (long long) j * j <= a[i]; j++){
            if (a[i] % j == 0){
                if (j != a[i] && mp.count (j)) ok = false;
                if ( (long long)j * j != a[i]){
                    int f = a[i] / j;
                    if (f != a[i] && mp.count (f)) ok = false;
                }
            }
        }
        if (mp[a[i]] >= 2) ok = false;
        ans += ok;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13520
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int n,y;

int main(){
    scanf("%d%d",&n,&y);
    for(int i=0;i<=n&&10000*i<=y;i++)
        for(int j=0;i+j<=n&&10000*i+5000*j<=y;j++)
            if((y-10000*i-5000*j)%1000==0&&(y-10000*i-5000*j)/1000==n-i-j){
                printf("%d %d %d\n",i,j,(y-10000*i-5000*j)/1000);
                return 0;
            }
    printf("-1 -1 -1\n");
    return 0;
}

Measured memory_bytes: 256
import sys
from heapq import heappush, heappop
readline = sys.stdin.readline
V, E, r = map(int, readline().split())
inf = 10**10
edges = [[] for _ in [None]*V]
vertices = [inf]*V
vertices[r] = 0

for _ in [None]*E:
    s, t, d = map(int, readline().split())
    edges[s].append((t, d))

q = [(0, r)]
rem = V-1
while q and rem:
    cost, v = heappop(q)
    if vertices[v] < cost:
        continue
    rem -= 1
    for dest, _cost in edges[v]:
        newcost = cost + _cost
        if vertices[dest] > newcost:
            vertices[dest] = newcost
            heappush(q, (newcost, dest))

print("\n".join([str(n) if n!=inf else "INF" for n in vertices]))

Measured memory_bytes: 98040
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//a^n mod p
//n > 0
//#include <cmath>
long long modpow(long long a, long long n, long long p) {
	a %= p;
	if (a == 0) return 0;
	if (a == 1) return 1;
	long long b = 1, cnt = 0;
	while (b < p && cnt < n) {
		b *= a;
		cnt++;
	}
	if (b < p) return b;
	b %= p;
	return modpow(b, n / cnt, p) * (long long)pow(a, n % cnt) % p;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	const ll p = 998244353;

	ll n;
	cin >> n;
	vll d(n);
	map<ll, ll> mp;
	for (ll i = 0; i < n; i++) {
		cin >> d[i];
		mp[d[i]]++;
	}
	if (mp[0] != 1) {
		cout << 0 << endl;
		return 0;
	}
	ll ans = 1;
	for (ll i = 1; i < n; i++) {
		ans *= mp[d[i] - 1];
		ans %= p;
	}
	cout << ans << endl;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
using pos = tuple<ll, int, int>;

int main() {
  int H, W;
  cin >> H >> W;

  int y, x;
  cin >> y >> x;
  pos start = make_tuple(0, --y, --x);
  int goal_y, goal_x;
  cin >> goal_y >> goal_x;
  goal_y--;
  goal_x--;

  vector<vector<char>> m(H, vector<char>(W, false));
  vector<vector<ll>> dis(H, vector<ll>(W, INF));
  for (auto &l : m) {
    for (auto &i : l) {
      cin >> i;
    }
  }

  priority_queue<pos, vector<pos>, greater<pos>> q;
  q.push(start);
  while (!q.empty()) {
    auto p = q.top();
    q.pop();
    const auto [d, y, x] = p;
    if (d >= dis[y][x]) continue;
    dis[y][x] = d;

    for (int i = 0; i < 4; i++) {
      int nx = x + dx[i], ny = y + dy[i];
      if (nx < 0 || nx >= W || ny < 0 || ny >= H || dis[ny][nx] <= d ||
          m[ny][nx] == '#')
        continue;
      q.push(make_tuple(d, ny, nx));
    }

    for (int dy = -2; dy < -2 + 5; dy++) {
      for (int dx = -2; dx < -2 + 5; dx++) {
        int nx = x + dx, ny = y + dy;
        if (nx < 0 || nx >= W || ny < 0 || ny >= H || dis[ny][nx] <= d + 1 ||
            m[ny][nx] == '#')
          continue;
        q.push(make_tuple(d + 1, ny, nx));
      }
    }
  }
  if (dis[goal_y][goal_x] == INF) {
    cout << -1 << endl;
  } else {
    cout << dis[goal_y][goal_x] << endl;
  }
  // for (const auto &l : dis) {
  //  for (auto i : l) {
  //    if (i == INF)
  //      cout << "#";
  //    else
  //      cout << i;
  //  }
  //  cout << endl;
  //}
}


Measured memory_bytes: 14044
# coding: utf-8
# Your code here!

def MI():return map(int,input().split())
def LI():return list(MI())

N,K=map(int,open(0).read().split())

# from juppyさん
mod = 10**9+7
MAX_N = 20020

fact = [1]
fact_inv = [0]*(MAX_N+4)
for i in range(MAX_N+3):
    fact.append(fact[-1]*(i+1)%mod)

fact_inv[-1] = pow(fact[-1],mod-2,mod)
for i in range(MAX_N+2,-1,-1):
    fact_inv[i] = fact_inv[i+1]*(i+1)%mod


def mod_comb_k(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod
    
# ここまで

for i in range(1,K+1):
    if N-K+1<i:print(0);continue
    ans=mod_comb_k(N-K+1,i,mod)*mod_comb_k(K-1,i-1,mod)
    print(ans%mod)

Measured memory_bytes: 4852
from collections import deque
N = int(input())
adj = [[] for _ in range(N + 1)]

for _ in range(N - 1):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)

def bfs(S):
    dist = [N] * (N + 1)
    dist[S] = 0
    q = deque([S])
    while q:
        u = q.pop()
        for v in adj[u]:
            if dist[v] == N:
                dist[v] = dist[u] + 1
                q.appendleft(v)
    return dist

db = bfs(1)
dw = bfs(N)

if sum(db[i] > dw[i] for i in range(1, N + 1)) >= N / 2:
    print('Snuke')
else:
    print('Fennec')

Measured memory_bytes: 29336
#include<iostream>

using namespace::std;

int ar[100005];

int main(){
	int n;
  	cin>>n;
  	for(int i=0,t;i<n;i++)
    	cin>>t,ar[t]=i+1;
  	for(int i=1;i<=n;i++)
      	cout<<ar[i]<<' ';
  	cout<<'\n';
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define lli  long long int
#define mod 1000000007

lli min(lli a,lli b)
{
    if(a<b)
    {
        return a;
    }
    return b;

}
lli n;
lli arr[200009];
lli c[200009];
lli res[200009];
lli power(lli x,lli n)
{
    lli res=1;
    while(n>0)
    {
        if((long long)n%2==1)
        {
            res=(res*x);
        }
        x=(x*x);
        n=n/2;
    }
    return res;
}

int main()
{
    cin>>n;
    memset(c,0,sizeof(c));
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        c[arr[i]]++;
    }
    lli sum=0;
    for(int i=0;i<=200005;i++)
    {
        lli x=c[i];
        res[i]=x*(x-1)/2;
        sum+=res[i];
    }
    for(int i=0;i<n;i++)
    {
        lli p=res[arr[i]];
        lli q=c[arr[i]];
        q--;
        cout<<sum-p+q*(q-1)/2<<"\n";
    }


	return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
int n;
int tree[40000005];
int lowbit(int x)
{
	return x&(-x);
}
void add(int x,int k)
{
	while(x<=n)
	{
		tree[x]+=k;
		x+=lowbit(x);
	}
}
int sum(int x)
{
	int ans=0;
	while(x!=0)
	{
		ans+=tree[x];
		x-=lowbit(x);
	}
	return ans;
}
int main()
{
	cin>>n;
	for(int i=1;i<1000000;i++)
	{
		for(int j=1;j*i<1000000;j++)
		{
			add(j*i,1);
		}
	}
	cout<<sum(n-1)<<endl;
}

Measured memory_bytes: 7496
#include<cstdio>
long long a[200005];

int isOk(int n,long long have,long long len){
    long long left = have;
    for(int i = 1; i <= n; i++){
        long long L = 0, R = left;
        long long res = -1;
        while(L<=R){
            long long M = (L+R)/2;
            if((M+1)*len>=a[i]){
                res = M;
                R = M-1;
            }
            else L = M+1;
        }
        if(res==-1) return 0;
        else left -= res;
    }
    return 1;
}

int main(){
    int n; long long k;
    scanf("%d%lld",&n,&k);
    for(int i = 1; i <= n; i++) scanf("%lld",&a[i]);
    long long L = 1, R = 1000000000;
    long long res = -1;
    while(L<=R){
        int M = (L+R)/2;
        if(isOk(n,k,M)){
            res = M;
            R = M-1;
        }
        else L = M+1;
    }
    printf("%lld\n",res);
    return 0;
}


Measured memory_bytes: 3240
#include <stdio.h>

#define N 100001
#define Q 50001

int binarySearch(int *, int, int);

int main(){
  int i, n, q, S[N], T[Q], cnt = 0;

  scanf("%d", &n);
  for(i = 1; i <= n; i++) scanf("%d", &S[i]);

  scanf("%d", &q);
  for(i = 1; i <= q; i++) scanf("%d", &T[i]);

  for(i = 1; i <= q; i++) if(binarySearch(S, n, T[i])) cnt++;

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

  return 0;
}

int binarySearch(int *S, int n, int key){
  int left = 1, right = n + 1, mid;

  while(left < right){
    mid = (double)(left + right)/2;

    if(S[mid] == key) return mid;
    else if(S[mid] > key) right = mid;
    else left = mid + 1;
  }

  return 0;
}

Measured memory_bytes: 1184
n, a, b = map(int, input().split())
s = input()

a_passed = 0
b_passed = 0

for i in range(n):
    if s[i] == "a":
        if a_passed + b_passed < a+b:
            print("Yes")
            a_passed += 1
        else:
            print("No")
    elif s[i] == "b":
        if a_passed + b_passed < a+b and b_passed < b:
            print("Yes")
            b_passed += 1
        else:
            print("No")
    else:
        print("No")

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

r = [0] * (N//2)
Nn =  N//2
r.extend(A[Nn:])

for i in range(Nn):
    n = Nn - i - 1
    s = 0
    for j in range(N//(n+1)):
        if r[(n+1)*(j+1) -1] == 1:
            s += 1
    s += A[n]
    s %= 2
    r[n] = s

x = ''
y = 0
k = 0
for num, i in enumerate(r):
    if i == 1:
        k = 1
        x += str(num+1) + ' '
        y += 1

print(y)
if k:
    print(x)


Measured memory_bytes: 9144
N,M =  map( int ,input().split())
H_list = list(map( int , input().split()))
A_B_list = [[0] * 2  for i in range(M)]
bad_list = []
J_list = []
for i in range(M):
    A,B = map( int ,input().split())
    A_B_list[i][0] = A
    A_B_list[i][1] = B
for j in range(M):
    if H_list[A_B_list[j][0]-1] > H_list[A_B_list[j][1]-1]:
        bad_list.append(A_B_list[j][1])
    elif H_list[A_B_list[j][0]-1] < H_list[A_B_list[j][1]-1]:
        bad_list.append(A_B_list[j][0])
    else:
        bad_list.append(A_B_list[j][0])
        bad_list.append(A_B_list[j][1])
J_list = list(set(bad_list))
print(N-len(J_list))
        

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


int main(){

    long long  N;
    cin >> N;

    long long sum = 0;

    for(long long i = 1; i <= N; i++){
        if(i % 3 != 0 and i % 5 != 0){
            //printf(" i: %d\n", i);
            sum = sum + i;
        }
    }

    printf("%lld\n", sum);

    return 0;
    
}

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

long long c[26];
long long s[365][26];

int main() {
    int D;
    cin >> D;
    for (int i = 0; i < 26; ++i) cin >> c[i];
    for (int i = 0; i < D; ++i) {
        for (int j = 0; j < 26; ++j) {
            cin >> s[i][j];
        }
    }

    vector<int> LatestProb(26, 0);
    long long score = 0;
    vector<int> res(D);

    for (int d = 0; d < D; ++d) {
        int cd = -1;
        long long cd_delta = -100000000000000LL;
        for (int j = 0; j < 26; ++j) {
            // もしj番目の問題を選んだ時のスコアの増減を計算
            long long delta = s[d][j];
            int latest_prev = LatestProb[j];
            LatestProb[j] = d + 1;
            for (int k = 0; k < 26; ++k) {
                delta -= c[k] * (d + 1 - LatestProb[k]);
            }
            if (cd_delta < delta) {
                cd = j;
                cd_delta = delta;
            }
            // 元に戻す
            LatestProb[j] = latest_prev;
        }
        res[d] = cd;
        LatestProb[cd] = d + 1;
        score += cd_delta;
    }

    for (int ans : res) {
        cout << ans + 1 << endl;
    }
    return 0;
}

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

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 ***/

int main(){
    double pai=3.141592653589;
    int r,c,tmp;
    scanf("%d %d",&r,&c);
    int sheet[r+1][c+1];
    sheet[r][c]=0;
    for(int i=0;i<r;i++){
        tmp=0;
        for(int j=0;j<c;j++){
            if(i==0) sheet[r][j]=0;
            scanf("%d",&sheet[i][j]);
            tmp+=sheet[i][j];
            sheet[r][j]+=sheet[i][j];
            sheet[r][c]+=sheet[i][j];
        }
        sheet[i][c]=tmp;
    }
    for(int i=0;i<r+1;i++){
        for(int j=0;j<c+1;j++){
            if(j<c){
                printf("%d ",sheet[i][j]);
            }else{
                printf("%d\n",sheet[i][j]);
            }
        }
    }
    return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

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

  lli q, h, s, d, n;
  while (cin >> q >> h >> s >> d >> n) {
    // q 0.25
    // h 0.5
    // s 1
    // d 2

    // q 1
    // h 2
    // s 4
    // d 8

    const lli inf = 1LL << 60;
    const int N = 10;
    lli dp[N];
    fill(dp, dp + N, inf);
    dp[0] = 0;

    vector<pair<int, int>> v;
    v.push_back(make_pair(1, q));
    v.push_back(make_pair(2, h));
    v.push_back(make_pair(4, s));
    v.push_back(make_pair(8, d));
    for (int i = 0; i < N; ++i) {
      each (j, v) {
        if (i + j.first < N) {
          dp[i + j.first] = min(dp[i + j.first], dp[i] + j.second);
        }
      }
    }

    lli sum = (n / 2) * dp[8];
    if (n % 2) sum += dp[4];
    cout << sum << endl;
  }
  
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> X(N), P(N), Q(N);
    for(int i = 0; i < N; i++) {
        cin >> P[i];
    }
    for(int i = 0; i < N; i++) {
        cin >> Q[i];
    }
    for(int i = 0; i < N; i++) {
        X[i] = i+1;
    }
    int A = 0;
    int B = 0;
    int cnt = 0;
    do{
        cnt++;
        if(P == X) A = cnt;
        if(Q == X) B = cnt;
    }while(next_permutation(X.begin(), X.end()));
    cout << abs(A-B) << endl;
}




Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,d,r;
    double f;
    
    scanf("%d %d",&a,&b);
    d =a/b;
    r = a%b;
    f = (double)a/(double)b;
    printf("%d %d %f",d,r,f);
    
    return 0;
    
}


Measured memory_bytes: 2100
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back

string o(ll n){
  string ret;
  while(n){
    ret+='0'+n%8;
    n/=8;
  }
  reverse(ret.begin(),ret.end());
  return ret;
}

main(){
  ll n;
  while(cin>>n,n){
    string str=o(n);

    rep(i,str.size()){
      if(str[i]>'4')str[i]+=2;
      else if(str[i]>'3')str[i]+=1;
    }
    cout<<str<<endl;
  }
}

Measured memory_bytes: 908
#include <iostream>
#include <string>
using namespace std;
 
int main(){
  int A,B;
  string S;
  cin >> A >> B;
  cin >> S;
  string ans="Yes";
  for(int i=0;i<A;i++){
    if(S.at(i)=='-'){
      ans="No";
    }
  }
  if(S.at(A)!='-'){
    ans="No";
  }
  for(int i=A+1;i<A+B+1;i++){
    if(S.at(i)=='-'){
      ans="No";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long int N, a[100001] = {}, one = 0, two = 0, four = 0;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
		if (a[i] % 4 == 0) {
			four++;
		}
		else if (a[i] % 2 == 0) {
			two++;
		}
		else {
			one++;
		}
	}
	if (one == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	if (one-1 > four) {
		cout << "No" << endl;
		return 0;
	}
	four -= one-1;
	if (two == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	if (four >= 1) {
		cout << "Yes" << endl;
		return 0;
	}
	else {
		cout << "No" << endl;
		return 0;
	}
}

Measured memory_bytes: 1024
'use strict'
function main(input) {
  input = input.trim().split('\n')
  const N = Number(input.shift())
  input = input.map((val, i) => [i+1, ...val.split(' ')])
    .sort((a, b) => {
      if (a[1] === b[1]) {
        return Number(b[2] - a[2])
      } else if (a[1] < b[1]) {
        return -1;
      }
      if (a[1] > b[1]) {
        return 1;
      }
    }).map(arr => arr[0])

  console.log(input.join('\n'))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N,x;
    cin >> N >> x;
    auto a = InputVec(N);
    sort(a.begin(),a.end());
    ll count = 0;
    for (int i = 0; i < N; ++i) {
        if(x >= a[i]){
            if(i == N-1){
                if(x == a[i]){
                    x-=a[i];
                    count++;
                }
            }else{
                x-=a[i];
                count++;
            }
        }
    }
    cout << count << endl;

}


Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    ll N; cin>>N;
    ll minimum = 1000000000;
    for (int i = 1; (double)i*(double)i <= N; ++i) {
        if(N % i == 0){
            ll b = N/i;
            minimum = min(minimum, max(ll(i),b));
        }
    }
    cout<<ll(log10(minimum))+1<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const unsigned int M = 1000000007;
#define ll long long
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string d;
    while(cin>>d){
        int index=0;
        for(int i=0;i<7;i++){
            if(d==day[i]){
                index=i+1;
                break;
            }
        }
        if(index>1)cout<<(7-index+1)<<endl;
        else cout<<"7"<<endl;

    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  bool a = false, b = false, c = false;
  REP(i, 3){
    if(s[i] == 'a') a = true;
    if(s[i] == 'b') b = true;
    if(s[i] == 'c') c = true;
  }

  if(a && b && c) Yes;
  else No;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,q;
vector<int> go[200010];
int a,b;
int cnt[200010];
int add[200010];
int p,x;
void dfs(int t) {
	cnt[t]+=add[t];
	for(int i=0;i<go[t].size();i++) {
		add[go[t][i]]+=add[t];
		dfs(go[t][i]);
	}
}
int main() {
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n-1;i++) {
		scanf("%d%d",&a,&b);
		go[a].push_back(b);
	}
	for(int i=1;i<=q;i++) {
		scanf("%d%d",&p,&x);
		add[p]+=x;
	}
	dfs(1);
	for(int i=1;i<=n;i++)
		printf("%d ",cnt[i]);
	return 0;
}

Measured memory_bytes: 24320
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll x[n];
    rep(i, n)cin >> x[i];

    ll res = 0;
    rep(i, n-1)res += min(b, (x[i+1]-x[i])*a);
    
    cout << res << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
//ll mod=1000000007;
//ll mod=67280421310721;
ll mod=998244353;
ll INF=1e18;
struct va
{
	int sum=0,left=0,right=0,ms=0;
};
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
vector<int> pos[61];
int in[61];
int ans=0;
int a[100001];
va dnc(int l,int r,int n)
{
//	cout<<l<<' '<<r<<'s'<<'\n';
	va res,t,tem;
	if(l>r || n==-1)
	return res;
	if(l==r)
	{
		res.sum=res.ms=a[l];
		if(a[l]>0)
		{
			res.left=res.right=a[l];
		}
		in[a[l]+30]++;
//		cout<<l<<' '<<r<<' '<<n<<' '<<res.ms<<'\n';
		return res;
	}
	bool f=1;
	n++;
	while(f)
	{
		n--;
		int o=in[n];
		FOR(i,o,pos[n].size())
		{
			if(pos[n][i]>r)
			break;
			f=0;
			in[n]++;
			if(i==o)
			{
				res=dnc(l,pos[n][i]-1,n-1);
			}
			else
			{
				t=dnc(pos[n][i-1]+1,pos[n][i]-1,n-1);
				tem.sum=res.sum+t.sum+n-30;
				tem.left=max(res.left,res.sum+t.left+n-30);
				tem.right=max(t.right,t.sum+res.right+n-30);
				tem.ms=max(res.right+t.left+n-30,max(res.ms,t.ms));
				res=tem;
			}
		}
	}
	t=dnc(pos[n][in[n]-1]+1,r,n-1);
	tem.sum=res.sum+t.sum+n-30;
	tem.left=max(res.left,res.sum+t.left+n-30);
	tem.right=max(t.right,t.sum+res.right+n-30);
	tem.ms=max(res.right+t.left+n-30,max(res.ms,t.ms));
	res=tem;
	if(n>30)
	ans=max(ans,(res.ms-(n-30)));
//	cout<<l<<' '<<r<<' '<<n<<' '<<res.ms<<'\n';
	return res;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		int n;
		cin>>n;
		string s[n];
		int cnt[26]={0},te[26]={0};
		FOR(i,0,n)
		{
			cin>>s[i];
		}
		FOR(i,0,s[0].size())
		{
			cnt[s[0][i]-'a']++;
		}
		FOR(i,1,n)
		{
			FOR(j,0,s[i].size())
			{
				te[s[i][j]-'a']++;
			}
			FOR(j,0,26)
			{
				cnt[j]=min(cnt[j],te[j]);
				te[j]=0;
			}
		}
		char c;
		FOR(i,0,26)
		{
			c='a'+i;
			FOR(j,0,cnt[i])
			cout<<c;
		}
	}
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
HERE:
	for {
		max := 0
		shop := 'A'
		for i := 0; i < 5; i++ {
			scanner.Scan()
			buf := strings.Split(scanner.Text(), " ")
			a, _ := strconv.Atoi(buf[0])
			b, _ := strconv.Atoi(buf[1])
			if a == 0 && b == 0 {
				break HERE
			}
			if max < a+b {
				max = a + b
				shop = 'A' + int32(i)
			}
		}
		fmt.Println(string(shop), max)
	}
}



Measured memory_bytes: 1084
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

const int maxn = 1e5 + 10;
int a[maxn], n;

int main()
{
    //freopen("demo.in", "r", stdin);
    //freopen("demo.out", "w", stdout);

    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", a + i);
    }
    sort(a + 1, a + n + 1);
    printf("%d\n", a[(n >> 1) + 1] - a[n >> 1]);
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, f, n) for (int i = (f); i < (n); i++)
ll const INF = 1LL << 60;

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

    int ans = 700;
    
    for (int i = 0; i < 3; i++) {
        if (N[i] == 'o')
            ans += 100;
    }

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

Measured memory_bytes: 256