akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n,m;
    cin>>n>>m;
    ll ans=n*m;
    ans /= __gcd(n,m);
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>



int cal_longest_palindrome_subsequence(const std::string& str, const int left, const int right, std::vector<std::vector<int>>& memo) {
	if (left > right) return 0;
	if (left == right) return 1;
	if (memo[left][right - left - 1] >= 0) return memo[left][right - left - 1];
	if (str[left] == str[right]) memo[left][right - left - 1] = cal_longest_palindrome_subsequence(str, left + 1, right - 1, memo) + 2;
	return memo[left][right - left - 1] = std::max({ memo[left][right - left - 1], cal_longest_palindrome_subsequence(str, left + 1, right, memo), cal_longest_palindrome_subsequence(str, left, right - 1, memo) });
}
std::string make_longest_palindorome(const std::string& str) {
	std::string prev_half;
	std::vector<std::vector<int>> memo; memo.reserve(str.size());
	for (auto i = 0; i < str.size(); ++i) memo.push_back(std::vector<int>(str.size() - i, -1));
	for (int left = 0, right = str.size() - 1; left <= right; ) {
		if (str[left] == str[right]) {
			prev_half.push_back(str[left]); ++left; --right;
		}
		else if (cal_longest_palindrome_subsequence(str, left + 1, right, memo) > cal_longest_palindrome_subsequence(str, left, right - 1, memo)) {
			++left;
		}
		else {
			--right;
		}
	}
	const auto result_length = cal_longest_palindrome_subsequence(str, 0, str.size() - 1, memo);
	if (result_length % 2 == 1) {
		for (int i = prev_half.size() - 2; i >= 0; --i) prev_half.push_back(prev_half[i]);
	}
	else {
		for (int i = prev_half.size() - 1; i >= 0; --i) prev_half.push_back(prev_half[i]);
	}
	return prev_half;
}

int main() {
	std::string str;
	while (std::cin >> str) {
		std::cout << make_longest_palindorome(str) << '\n';
	}
}


Measured memory_bytes: 10868
s = input()
odd_i = []
even_i = []
for i in range(len(s)):
    if i % 2 == 0 :
        even_i.append(int(s[i]))
    else : odd_i.append(int(s[i]))

def counter(list):
    b_count = 0
    w_count = 0
    for i in range(len(list)):
        if list[i] == 0 : b_count += 1
        else : w_count += 1
    return b_count,w_count

b_odd , w_odd = counter(odd_i)
b_even , w_even = counter(even_i)

o_diff = b_odd - w_odd
e_diff = b_even - w_even

if o_diff >  e_diff : print(w_odd + b_even)
else : print(b_odd+w_even)

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)

using namespace std;



int main(){
    ll n, c, k;
    cin >> n >> c >> k;
    vector<ll> t(n);
    rep(i, n)   cin >> t[i];

    priority_queue<ll, vector<ll>, greater<ll>> que;
    for(auto e : t) que.push(e);

    ll head = que.top();    que.pop();
    ll cnt = 1;

    ll b = 0;
    while(!que.empty()){
        ll v = que.top();   que.pop();
        if(head + k < v || c <= cnt){
            b++;
            head = v;
            cnt = 1;
        }
        else    cnt++;
    }
    b++;

    cout << b << endl;




    return 0;
}


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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  for(int i=0; i<n; i++){
    cin >> h[i];
  }
  sort(h.begin(), h.end());
  int ans=1000000000;
  for(int i=0; i<n-k+1; i++){
    ans = min(ans, h[i+k-1]-h[i]);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N, max, j = 0, sum = 0;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++)
    cin >> vec.at(i);
  while (true){
    max = 0;
    for (int i = 0; i < N; i++){
      if (max < vec.at(i)){
        max = vec.at(i);
        j = i;
      }
      else if (max == vec.at(i))
        vec.at(i) = 0;
    }
    if (max == 0)
      break;
    sum++;
    vec.at(j) = 0;
  }
  cout << sum << endl;
}
      
  

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

bool[3000] leap_table;

void init_leap_table() {
  foreach(i, ref x; leap_table) {
    if (((i % 4) == 0) && (((i % 100) != 0) || ((i % 400) == 0))) x = true;
  }
}

void main() {
  init_leap_table;
  bool first = true;
  while(true) {
    int[] date = readln.chomp.split(" ").map!(to!(int)).array;
    bool ans = false;
    if (date[0] == 0 && date[1] == 0) break;
    if (!first) writeln;
    foreach(d; date[0]..(date[1] + 1))
      if (leap_table[d]) {writeln(d); ans = true;}
    if (!ans) writeln("NA");
    first = false;
  }
}

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

int main(){
    string A;
   cin >> A;
   int count = 0;
    for (int i = 0; i < 3; i++){
        if(A.at(i) == '7'){
            count++;
        }
    }
    if(count != 0){cout << "Yes" << endl;}
    else{cout << "No" << endl;}
}

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

int main(){
	int n,a,Mx=-1e9,Mn=1e9;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a;
		Mx=max(a,Mx);
		Mn=min(a,Mn);
	}
	
	cout << Mx-Mn << endl;
	
	return 0;
}

Measured memory_bytes: 256
import heapq

n,m = map(int,raw_input().split())
a = map(int,raw_input().split())
h = []
for x in a:
	heapq.heappush(h, -1*x)
for i in xrange(m):
	x = heapq.heappop(h)
	new = (-1*x) >> 1
	heapq.heappush(h, -1*new)
res = 0
for i in xrange(n):
	res += heapq.heappop(h)
print -1*res

Measured memory_bytes: 11400
#include<iostream>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
using namespace std;
int n,d; 
int main(){
	cin>>n>>d;
	d=d*2+1;
	cout<<(n+d-1)/d<<endl;
system ("pause");
return 0;
}


Measured memory_bytes: 504
sx, sy, tx, ty = map(int,input().split())
dx = abs(sx-tx)
dy = abs(sy-ty)
print("U"*dy,end="")
print("R"*dx,end="")
print("D"*dy,end="")
print("L"*(dx+1),end="")
print("U"*(dy+1),end="")
print("R"*(dx+1),end="")
print("DR",end="")
print("D"*(dy+1),end="")
print("L"*(dx+1),end="")
print("U")

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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  string o,e; cin >> o >> e;
  rep(i,e.size()) cout << o[i] << e[i];
  if(e.size() < o.size()) cout << o[o.size() - 1];
  cout << endl;
}


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


int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int left = min(a,c), right = max(b,d);
    int test = right-left -b+a -d+c;
    cout << max(-test, 0) << endl;
}



Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, k = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    a.sort()
    f = list(map(int, readline().split()))
    f.sort(reverse=True)

    cor_v = 10 ** 13
    inc_v = -1
    while cor_v - inc_v > 1:
        bin_v = (cor_v + inc_v) // 2
        cost = 0
        #条件を満たすcostを全検索
        for i in range(n):
            if a[i] * f[i] >= bin_v:
                cost += ((a[i] * f[i]) - bin_v + f[i] - 1) // f[i]
            if cost > k:
                break
        #costが制約を満たすか
        if cost <= k:
            cor_v = bin_v
        else:
            inc_v = bin_v
    print(cor_v)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 83728
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    ($arg:expr) => (println!("{:?}",$arg));
}


#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}


fn main() {
    input!{
        a:i32,
        b:i32,
        c:i32
    }

    let result = c - (a-b);
   let ret  = if result < 0 {0}else{result};
   
   println!("{}",ret);


}


Measured memory_bytes: 4352
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=9e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,a[100005]={};
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=n-1; i>=1; i--) {
    if(a[i-1]>a[i]) {
      a[i-1]--;
    }
    if(a[i-1]>a[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 640
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;
    vi x(n);
    int e=0, o=0, f=0;
    forn(i,n){
        cin>>x[i];
        if(x[i]%2==0 && x[i]%4!=0)   e++;
        else if(x[i]%2!=0)  o++;
        else f++;
    }
    //cout<<e<<" "<<o<<" "<<f<<endl;
    if(e==0){
        if(o<=f+1)  cout<<"Yes\n";
        else        cout<<"No\n";
    }
    else if(e>0){
        if(o<=f)    cout<<"Yes\n";
        else        cout<<"No\n";
    }
    else{
        cout<<"No\n";
    }
    
    /*
    sort(all(x));
    bool flag1 = false;
    
    do{
        bool flag2 = true;
        for(int i=0;i<n-1;i++){
           // cout<<"yo\n";
            if((x[i]*x[i+1])%4!=0){
                flag2 = false;
                break;
            }
        }
        if(flag2){
            flag1 = true;
            //cout<<flag1<<endl;
            break;
        }
    }while(next_permutation(all(x)));

    if(flag1)   cout<<"Yes\n";
    else        cout<<"No\n";
    */
    return 0;
}



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

int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	for (int i = a; i <= min(b, a+k-1); i++) cout << i << endl;
	for (int i = max(min(b, a+k-1)+1, b-k+1); i <= b; i++) cout << i << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int maxn = 200000 + 5;
const int mod = 10007;
const double PI = acos(-1.0);
const double eps = 1e-10;
int n, a[maxn], c[maxn];
stack<int> stk;
ULL ans ;
int main()
{
    while (~scanf("%d", &n)) {
        memset(c,0,sizeof c);
        int q = 0, m = 233;
        for (int i=1; i<=n; i++) {
            scanf("%d", &a[i]);
            c[a[i]]++;
            q = max(q, a[i]); m = min(m, a[i]);
        }
        int flag = 0;
        if (m != (q+1)/2) flag = 1;
        else {
            if ((q%2==1 && c[m]!=2) || (q%2==0 && c[m]!=1)) flag = 1;
            else {
                for (int i=m+1; i<=q; i++) {
                    if (c[i] < 2) {flag = 1; break;}
                }
            }
        }
        if (flag) puts("Impossible");
        else puts("Possible");
    }
    return 0;
}


Measured memory_bytes: 1152
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   const compare = (a, b)=>{
    return a - b;
    }
	xs.sort(compare);
 	console.log(xs[0] + xs [1]);	
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 21952
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;
#define ll long long

int main(){
  int A, B;
  string S;
  cin >> A >> B >> S;
  bool ret = true;
  for(int i=0; i<A; i++)
    if(!isdigit(S[i]))
      ret = false;
  if(!(S[A] == '-'))
    ret = false;
  for(int i=0; i<B; i++)
    if(!isdigit(S[A+1+i]))
      ret = false;
  if(ret)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,a[1500];
	scanf("%d%d",&n,&m);
	double s=0;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		s+=a[i];
	}
	s/=4*m;
	int ss=0;
	for(int i=0;i<n;i++)
	   {
	   	if(a[i]>=s)ss++;
	   }
	if(ss>=m)printf("Yes\n");
	  else printf("No\n");
	
	
	
 } 

Measured memory_bytes: 256
#include <stdio.h>

int main( void ) {
	int i, ch, count[ 4 ] = {}, min;

	while ( ( ch = getchar() ) != EOF )
		switch ( ch ) {
			case 'K': count[ 0 ]++; break;
			case 'U': count[ 1 ]++; break;
			case 'P': count[ 2 ]++; break;
			case 'C': count[ 3 ]++; break;
		}

	min = count[ 3 ];
	for ( i = 3; i--;  )
		if ( count[ i ] < min )
			min = count[ i ];

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

	return 0;
}

Measured memory_bytes: 524
// D - Xor Sum 4
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define MOD 1000000007
 
ll O[60];
 
int main(){
	int ans=0, N; cin>>N;
	rp(i,0,N){ ll j,a; scanf("%lld",&a); for(j=0; a; a>>=1) O[j++]+=a&1; }
	rp(i, 0, 60) ans = (ans + (O[i]*(N-O[i]) % MOD) * ((1LL<<i) % MOD)) % MOD;
	cout<< ans <<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    System.out.println(n>=30?"Yes":"No");
  }
}

Measured memory_bytes: 32640
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define vsort(v) sort(v.begin(),v.end())
#define asort(a,n) sort(a, a + n)
#define vi vector<int>
#define vd vector<double>

//ここからAtCoder向けdefine
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    int kakuketanowa;
    int kakuketa;
    int m;
    int sum = 0;
    REP(i, 1, n + 1){
        m = i;
        kakuketanowa = 0;
        while(m){
            kakuketa = m % 10;
            kakuketanowa += kakuketa;
            m /= 10;
        }
        if(kakuketanowa >= a && kakuketanowa <= b){
            sum += i;
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 888
#include <cstdio>
#include <cstring>
#include <vector>
#define N_MAX 501
 
using namespace std;
 
int input(int &n, int &m) {
 
    scanf("%d%d", &n, &m);
    if(n == 0 && m == 0) return 0;
    else return 1;
}
 
int F[N_MAX][N_MAX];
int party[N_MAX];
 
int main() {
    int a, b, n, m;
 
    while(input(n,m) == 1) {
 
        memset(F, 0, sizeof(F));
        memset(party, 0, sizeof(party));
 
        for (int i = 0; i < m; i++ ) {
            scanf("%d%d", &a, &b);
            F[a][b] = F[b][a] = 1;
        }
 
        for(int x = 2; x <= n; x++) {
            if(F[1][x] == 1) {
                party[x] = 1;
                for(int y = 2; y <= n; y++) 
                    if(F[x][y] == 1) party[y] = 1;
            }
        }
        int cnt = 0;
        for(int i = 2; i <= n; i++ ) 
            cnt = cnt + party[i];
        printf("%d\n", cnt);
    }
 
    return 0;
}


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


int main(){


    int n, i;

    int k = 0;


    cin >> n;


    for( i = 1 ; i <= n ; i = i + 1 ){

         if( i == 10 || i == 1000 ) i *= 10;

         if( i <= n && i != 100000 ) k += 1;

         }


    cout << k << endl;

    
    return 0;


    }

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

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


Measured memory_bytes: 1024
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace std;
const long long N=200005, INF=2000000000000000000;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n,lim;
    cin>>n>>lim;
    int w[n+1],v[n+1];
    for(int i=1;i<=n;i++)
    cin>>w[i]>>v[i];
    int dp[n+1][lim+1];
    fill(dp, -1);
    dp[0][0]=0;
    for(int i=1;i<=n;i++)
    {
        dp[i][0]=0;
        for(int j=0;j<=lim;j++)
        {
            if(dp[i-1][j]!=-1)
            {
                dp[i][j]=max(dp[i][j], dp[i-1][j]);
                if((j+w[i])<=lim)
                dp[i][j+w[i]]=max(dp[i-1][j]+v[i], dp[i][j]);
            }
        }
    }
    int ans=0;
    for(int i=0;i<=lim;i++)
    ans=max(ans, dp[n][i]);
    //print2d(dp,n,lim);
    cout<<ans;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];

int32_t main(){_
         
      string s;
   cin >> s;

   bool a = false, b = false;

   for(auto it: s){
      a |= it == 'A';
   }
   
   for(auto it: s){
      b |= it == 'B';
   }

   if (a and b){
      cout<<"Yes\n";
   }
   else{
      cout<<"No\n";
   }

   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

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

	int N;
	cin>>N;
	int dig = N % 10;

	if(dig == 2 || dig == 4 || dig == 5 || dig == 7 || dig == 9)
		cout<<"hon"<<endl;

	else if(dig == 0 || dig == 1 || dig == 6 || dig == 8)
		cout<<"pon"<<endl;

	else if(dig == 3)
		cout<<"bon"<<endl;

	return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <algorithm> // sort
using namespace std;
 
int main()
{
  int n,k;
  int ans = 0;
  cin >> n;
  cin >> k;
  int p[n] = {};
  int q[1010] = {};
  for(int i=0;i<n;i++){
      cin >> p[i];
  }
  sort(p, p + n); 
  for(int i = 0; i < k; ++i){
     ans += p[i];
  }
   cout << ans << endl;

  
} 

Measured memory_bytes: 3644
S = input()
Slen = len(S)
cnt = 0
index = 0
if S[0] == "B":
    while index <= Slen-2:
        if S[index] == "B" and S[index+1] == "W":
            cnt += 1
            index += 2
        else:
            index += 1
    if S[-1] == "W":
        print(str(cnt*2-1))
    else:
        print(str(cnt*2))
else:
    while index <= Slen-2:
        if S[index] == "W" and S[index+1] == "B":
            cnt += 1
            index += 2
        else:
            index += 1
    if S[-1] == "B":
        print(str(cnt*2-1))
    else:
        print(str(cnt*2))

Measured memory_bytes: 3188
#include<stdio.h>

int main(void){

  int x,y;
  int i,j;

  while(1){

    scanf("%d %d",&y,&x);

    if(x == 0 && y == 0){
      break;
    }

    for(j = 0; j< y; j++){
      for(i = 0;i < x;i++){
        if(i == 0 || i == x-1){
          putchar('#');
        }else if(j == 0 || j == y-1){
          putchar('#');
        }else{
          putchar('.');
        }
      }
      putchar('\n');
    }
    putchar('\n');
  }

  return(0);
}



Measured memory_bytes: 2020
a,b,c = map(int,input().split())
cnt = 0

if a == b and a== c and a%2 == 0:
    print(-1)
    exit()

while a%2 == 0 and b%2 == 0 and c%2 == 0:
    cnt+=1
    i=a
    j=b
    a=(b+c)//2
    b=(i+c)//2
    c=(i+j)//2

print(cnt)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
   int n,k;cin>>n>>k;
   if (n%k==0)
   {
      /* code */
      cout<<0<<endl;
   }

   else
   {
      cout<<1<<endl;
   }
   
   
   
   }
   

Measured memory_bytes: 256
<?php

fscanf(STDIN, '%s', $s);

switch ($s) {
    case 'a':
    case 'i':
    case 'u':
    case 'e':
    case 'o':
        echo 'vowel';
        break;
    
    default:
        echo 'consonant';
        break;
}

echo PHP_EOL;


Measured memory_bytes: 16080
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    long long c=0,ans=0;
    cin>>s;
    for(int j=0;j<3;j++)
    {
        if(s[j]=='R')
            {c++;
            ans=max(ans,c);}
        else
        {
             c=0;
        }

    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
#define ll long long 
#define pb push_back
int main(){	
	fast;
		ll a,b; cin>>a>>b;
		if(a<=b) {
			for(ll i=0;i<b;i++) cout<<a;
			}
		else {
			for(ll i=0;i<a;i++) cout<<b;
			}
			}
	

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

f = None
p = None
ans = 0
for t in map(int, input().split()):
  if f is None:
    f = t
    p = f - T

  ans += T
  rest = p + T - (t - f)
  if rest > 0:
    ans -= rest
  p = t - f

print(ans)


Measured memory_bytes: 19220
/*
     Author:Raghav Bansal
     IIIT Una
                  */
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BOLT ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define X first
#define Y second
#define endl "\n"
using namespace std;
void solve() {
	string s;
	cin>>s; 
	for(int i=0;i<s.size();i++){
		if(s[i]=='7'){ 
			cout<<"Yes"<<endl;
			return;
		}
	}
	cout<<"No"<<endl; 
}
int32_t main() {
	BOLT;
	int t;
	t = 1;
	while (t--)
	{
		solve();
	}
}

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

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  
  for(int i=0; i<N; i++) cin >> P.at(i);
  sort(P.begin(),P.end());
  reverse(P.begin(),P.end());
  
  int sum =0;
  for(int i=1; i<N; i++) sum +=P.at(i);
  
  cout << sum + P.at(0)/2 << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}



int main(){

  ll N;
  cin >> N;
  vector<ll> l(N,0),r(N,0);//r->(  l->)

  FOR(i,0,N){
    string s;
    cin >> s;
    int cnt=0; // ( のあまり
    FOR(j,0,s.size()){
      if(s[j] == '(')cnt++;
      else{
        if(cnt==0)l[i]++;
        else cnt--;
      }
    }
    r[i] = cnt;
  }


  vector<P> rl;
  ll r_sum = 0;
  ll l_sum = 0;
  FOR(i,0,N){
    if(r[i]==0){
      l_sum += l[i];
    }else if(l[i]==0){
      r_sum += r[i];
    }else{
      rl.push_back({r[i]-l[i],l[i]});
    }
  }
  SORT(rl);
  REV(rl);
  
  bool ok = true;
  ll cntr = r_sum;
  FOR(i,0,rl.size()){
    rl[i].first += rl[i].second;
    //rl[i].second *= -1;
    cntr -= rl[i].second;
    if(cntr < 0)ok = false;
    cntr += rl[i].first;
  }

  if(ok && cntr==l_sum){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}


Measured memory_bytes: 18680
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

ll gcd(ll x,ll y){
  return y==0? x:gcd(y,x%y);
}
bool used[30000];
int main() {
  int N;
  cin >> N;
  set<ll> S;
  for(ll i=2;i<=30000;i+=2){
    S.insert(i);
  }
  for(ll i=3;i<=30000;i+=3){
    S.insert(i);
  }
  ll sum=0;
  for(auto a:S){
    cout << a << " ";
    used[a]=true;
    sum+=a;
    N--;
    if(N==1) break;
  }
  for(int i=2;i<=30000;i++){
    if(!used[i]&&gcd(sum,i)!=1&&(sum+i)%2==0&&(sum+i)%3==0){
      cout << i << endl;
      break;
    }
  }
  return 0;
}


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

int main() {
	long long n;
	cin >> n;
	long long ans = n - 1;

	for (long long i = 1; i*i <= n; i++) {
		if (n % i == 0) {

			ans = min(ans, n / i + i -2);
		} 

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  long long int N,A,B;
  long long int ans=0,D=0;
  cin>>N>>A>>B;
  D=N%(A+B);
  if(D>A){
    D=A;
  }
    ans=N/(A+B)*A+D;
  cout<<ans;
}
  

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
       PROGRAM-ID. MAIN.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 CARDS.
           03 R      PIC 9.
           03 FILLER PIC X.
           03 G      PIC 9.
           03 FILLER PIC X.
           03 B      PIC 9.
       01 X          PIC 9(3).
       01 Y          PIC 9.
       PROCEDURE DIVISION.
       MAIN.
           ACCEPT CARDS FROM CONSOLE.
           COMPUTE X = R * 100 + G * 10 + B
           DIVIDE X BY 4 GIVING X REMAINDER Y
           IF Y = 0 THEN
               DISPLAY "YES"
           ELSE
               DISPLAY "NO"
           END-IF.
           STOP RUN.


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main() {
  long long int n,max1=-1,b,sum=0;
  cin>>n;
  while(n--){
  cin>>b;
    if(b<max1){
     sum+=(max1-b);
    }
    max1=max(max1,b);
  }
  cout<<sum;
}

Measured memory_bytes: 3624
/* * * * * * * * * * * **
*                      *
*	   saurabh8522	   *
*	  I will handle	   *
*		   it.		   *
*                      *
* * * * * * * * * * * **/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ld long double
#define zero(a) memset((a),0,sizeof((a)))
#define one(a) memset((a),1,sizeof((a)))
#define minus(a) memset((a),-1,sizeof((a)))
#define all(g) g.begin(),g.end()
#define ppb pop_back
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> //indexed_set;
typedef long long int ll;
#define MOD 1000000007
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b,ll m) {ll res=1;a%=m;for(;b;b>>=1){if(b&1)res=res*a%m;a=a*a%m;}return res;}
ll numdigit(ll n){return floor(log10(n)) + 1;}
bool isPowerTwo (ll x) { return x && (!(x&(x-1))); } 
int  main(){
	FastRead;
	ll t=1;
	// cin>>t;
	while(t--){
		ll n,m;
		cin>>n>>m;
		vector<ll>h(n);
		for(int i=0;i<n;i++){
			cin>>h[i];
		}
		vector<bool>v(n,1);
		for(int i=0;i<m;i++){
			ll u,w;
			cin>>u>>w;
			u--,w--;
			if(h[u]>h[w]){
				v[w]=false;
			}
			else if(h[w]>h[u]){
				v[u]=false;
			}
			else{
				v[u]=v[w]=false;
			}
		}
		ll ans=0;
		for(int i=0;i<n;i++){
			if(v[i]){
				ans++;
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 4000
#include <stdio.h>

int main(void){
 int n,m;
  int sum=0;
  scanf("%d", &n);
  scanf("%d", &m);
  int a[n];
  for(int i=0;i<n;i++){
  scanf("%d", &a[i]);
    sum+=a[i];
  }
  int t,i,j;
  for(i=1;i<n;i++){
     for(j=i-1;j>=0;j--){
      if(a[j]>a[j+1]){
      t=a[j];
        a[j]=a[j+1];
        a[j+1]=t;
       }
       else
         break;
      }
     }
  j=0;
 for(i=n-1;i>=n-m;i--){
  if((double)a[i]<sum*(double)1/(4*m))
    j++;
 }
if(j>0)
  printf("No\n");
  else
    printf("Yes\n"); 
  return 0;
}

Measured memory_bytes: 1656
import numpy as np
H,W,K = map(int, input().split())
c = []
for i in range(H):
  tmp = list(input())			# リスト型に変換することで文字列を１文字ずつ分解
  c.append(tmp)

count = 0
for i in range(int(2**H)):
  tmp = str(bin(i))				# bit変換
  h_flag = tmp[2:].zfill(H)		# 先頭にゼロを追加してH桁にする
  for j in range(int(2**W)):
    tmp = str(bin(j))			# bit変換
    w_flag = tmp[2:].zfill(W)	# 先頭にゼロを追加してH桁にする
    num_black = 0
    for m in range(H):
      for n in range(W):
        if h_flag[m] == '0' and w_flag[n] == '0' and c[m][n] == '#':
          num_black += 1
    if num_black == K:
      count += 1
print(count)
        
  

Measured memory_bytes: 27108
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<pair<int,int>>A(N);for (int i=0; i<N; i++)cin>>A[i].first>>A[i].second;
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  cout<<A[0].first+A[0].second<<endl;
}


Measured memory_bytes: 4020
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws Exception {

        ModScanner ms = new ModScanner();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        int n = ms.nextInt();
        int k = ms.nextInt();
        int[] heights = new int[n];
        for (int i = 0; i < n; i++) {
            heights[i] = ms.nextInt();
        }
        int[] dp = new int[n];
        Arrays.fill(dp, -1);
        out.println(findTotalJumpCost(heights, 0, dp, k));
        out.close();
    }

    private static int findTotalJumpCost(int[] heights, int ind, int[] dp, int k) {
        if (ind == heights.length - 1) {
            return 0;
        }

        if (dp[ind] != -1) {
            return dp[ind];
        }

        int minCost = Integer.MAX_VALUE;
        
        for (int i = ind + 1, j = 0; i < heights.length && j < k; i++, j++) {
            int cost = Math.abs(heights[ind] - heights[i]);
            minCost = Math.min(minCost, cost + findTotalJumpCost(heights, i, dp, k));
        }

        return dp[ind] = minCost;
    }

}

class ModScanner {

    BufferedReader br;
    StringTokenizer st;

    public ModScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String nextToken() throws Exception {
        while (st == null || !st.hasMoreElements()) {
            st = new StringTokenizer(br.readLine());

        }
        return st.nextToken();
    }

    String nextString() throws Exception {
        return br.readLine();
    }


    int nextInt() throws Exception, Exception {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }

}


Measured memory_bytes: 59812
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define x3 dflgkg
#define MOD 1000000007
#define y1 dskgj
#define y2 dskfj
#define y3 dfhgdh
#define SQ 320
#define PI 3.14159265359
typedef int ll;
using namespace std;
ll n,i,j,k,x,y,z,m,q,h,r,timer,mx,l,sum;
ll a[100500], used[100500];
vector<ll> g[100500], comp;
set<ll> needed;
void dfs(ll v) {
    if (used[v])
        return;
    used[v] = 1;
    comp.push_back(v);
    for (int i = 0; i < g[v].size(); i++)
        dfs(g[v][i]);
}
int main() {
    //freopen("input.txt","r",stdin);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 0; i < m; i++) {
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++)
    if (!used[i]) {
        comp.clear();
        needed.clear();
        dfs(i);
        for (int j = 0; j < comp.size(); j++)
            needed.insert(comp[j]);
        for (int j = 0; j < comp.size(); j++)
            if (needed.find(a[comp[j]]) != needed.end())
                ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 13560
from collections import deque
def is_bridge(start, nodes, edge_tuple, n):
    seen = set()
    queue = deque()

    queue.append(start)
    seen.add(start)
    while len(queue) > 0:
        head = queue.popleft()
        for child in nodes[head]:
            if child not in seen and not (  (child == edge_tuple[0] and head == edge_tuple[1]) or   (child == edge_tuple[1] and head == edge_tuple[0])):
                seen.add(child)
                queue.append(child)


    return len(seen) != n



line_one = raw_input().split()
n = int(line_one[0])
m = int(line_one[1])

nodes = {}
edges = []
rand_start = None

for i in range(m):
    line = raw_input().split()
    edge = (int(line[0]), int(line[1]))
    if rand_start is None:
        rand_start = edge[0]

    if edge[0] not in nodes:
        nodes[edge[0]] = []
    if edge[1] not in nodes:
        nodes[edge[1]] = []

    nodes[edge[0]].append(edge[1])
    nodes[edge[1]].append(edge[0])

    edges.append(edge)
count = 0
for edge in edges:
    if is_bridge(rand_start, nodes, edge, n):
        count += 1

print count


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

int main(int argc, char** argv) {
  int N; cin >> N;
  vector<string> s(N);
  vector<int> t(N);
  for (auto i = 0;i < N;++i) {
    cin >> s[i] >> t[i];
  }
  string X; cin >> X;
  bool is_add = false;
  int sum_time {};
  for (auto i = 0;i < N;++i) {
    if (s[i] == X) {
      is_add = true;
    } else if (is_add == true) {
      sum_time += t[i];
    }
  }
  cout << sum_time << '\n';
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define X first
#define Y second
using namespace std;

int main(){
	string input;
	map<char, int> mozi;
	cin >> input;
	for(int i = 0; i < input.size(); i++){
		if(mozi.count(input[0])) mozi[input[i]]++;
		else mozi[input[i]] = 1;
	}
	int count = 0;
	while(1){
		if(!mozi['K']||!mozi['U']||!mozi['P']||!mozi['C']) break;
		mozi['K']--;
		mozi['U']--;
		mozi['P']--;
		mozi['C']--;
		count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1192
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>

using namespace std;

int main()
{
    int H, W, N;
    std::cin >> H >> W >> N;

    std::vector<int> A;

    for (int i = 1; i <= N; ++i) {
        int t;
        std::cin >> t;
        for (int j = 0; j < t; ++j) {
            A.push_back(i);
        }
    }

    bool rev = false;
    for (int h = 0; h < H; ++h) {
        if (rev) {
            for (int w = W-1; w >= 0; --w) {
                std::cout << A[h*W + w] << " ";
            }
        }
        else {
            for (int w = 0; w < W; ++w) {
                std::cout << A[h*W + w] << " ";
            }
        }
        std::cout << std::endl;
        rev = !rev;
    }

    return 0;
}


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

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

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

using namespace std;


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

    vector<vector<int>> x(H);
    for(int i = 0; i < H; ++i) { x[i].resize(W, 0);}

    for(int h = 0; h < H; ++h)
    {
        for(int w = 0; w < W; ++w)    
        {
            char c;    
            cin >> c;

            if(c == '.') { x[h][w] = 0;}
            if(c == '#') { x[h][w] = 1;}
        }
    }

    int WW = (1 << W);
    int HH = (1 << H);
    int count = 0;

    for(int hh = 0; hh < HH; ++hh)    
    {
        for(int ww = 0; ww < WW; ++ww)    
        {
            int total = 0;    
            for(int h = 0; h < H; ++h)    
            {
                for(int w = 0; w < W; ++w)    
                {
                    if( (((1 << h) & hh) == 0 ) && (((1 << w) & ww) == 0) )
                    {
                        total += x[h][w];
                    }
                }
            }

            //cout << hh << ", " << ww << ", " << total << endl;

            if(total == K)            
            {
                ++count;    
            }
        }
    }

    cout << count << endl;

    return 0;    
}

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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/


  double N;

  cin>>N;

  cout<<pow(N,3)<<endl;
  
  return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String answer="";
		answer+=change(sc.next());
		while(sc.hasNext()){
			answer+=" "+change(sc.next());
		}
		System.out.println(answer);
	}
	static String change(String str){
		char[] apple={'a','p','p','l','e'};
		char[] peach={'p','e','a','c','h'};
		char[] c=str.toCharArray();
		if(str.length()>=apple.length){
			for(int i=0;i<str.length()-apple.length+1;i++){
				boolean appleFlag=true;
				boolean peachFlag=true;
				for(int j=0;j<5;j++){
					if(c[j+i]!=apple[j]){
						appleFlag=false;
					}
					if(c[j+i]!=peach[j]){
						peachFlag=false;
					}
				}
				if(appleFlag){
					for(int j=0;j<5;j++){
						c[i+j]=peach[j];
					}
					i+=5;
				}
				if(peachFlag){
					for(int j=0;j<5;j++){
						c[i+j]=apple[j];
					}
					i+=5;
				}
			}
			str=String.valueOf(c);
		}
		return str;
	}
}

Measured memory_bytes: 17308
A = 0
def solve(l,c,sa,sb):
    if 2*sa>=A: return 2*sa-A
    if 2*sb>=A: return 2*sb-A
    return min(solve(l,c+1,sa+l[c],sb),solve(l,c+1,sa,sb+l[c]))
while 1:
    n = input()
    if n==0: break
    a = map(int, raw_input().split())
    ans = 10**7; A = sum(a);
    print solve(a,0,0,0)

Measured memory_bytes: 4248
#include<iostream>
#include<iomanip>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1LL << 60)
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }

//LCS
//系列が二つ、復元
//https://atcoder.jp/contests/dp/tasks/dp_f
int dp[3001][3001];	//Sのi文字目までと、Tのj文字目までの最長共通部分(LCS)の長さ
int main()
{
	string S, T; cin >> S >> T;
	int Sz = S.size(), Tz = T.size();
	memset(dp, 0, sizeof(dp));

	rep(s, Sz) {
		rep(t, Tz) {
			if (S[s] == T[t]) chmax(dp[s + 1][t + 1], dp[s][t] + 1);
			chmax(dp[s + 1][t + 1], dp[s + 1][t]);
			chmax(dp[s + 1][t + 1], dp[s][t + 1]);
		}
	}
	//復元
	string ans = "";
	int si = Sz, ti = Tz;
	while (si > 0 && ti > 0) {
		if (dp[si][ti] == dp[si - 1][ti]) --si;
		else if (dp[si][ti] == dp[si][ti - 1]) --ti;
		else {
			ans = S[si - 1] + ans;
			--si; --ti;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 38340
#include <stdio.h>
int main(void){
	int n,m,checker=0,counter=1,ans=0;
	scanf("%d%d",&n,&m);
	int s[m+1],c[m+1];
	while(checker<m){
		scanf("%d%d",&s[checker],&c[checker]);
		checker++;
	}
	checker=0;
	while(checker<m){
		counter=1;
		while(checker+counter<m){
			if(s[checker]==s[checker+counter]){
				if(c[checker]!=c[checker+counter]){
					ans=-1;
				}
			}
			counter++;
		}
		checker++;
	}
	checker=0;
	while(checker<m){
		if(s[checker]==1){
			if(c[checker]==0){
				if(n!=1){
					ans=-1;
				}
			}
		}
		checker++;
	}
	checker=0;
	counter=0;
	if(ans!=-1){
		while(checker<m){
			if(s[checker]==1){
				counter++;
		}
			checker++;
		}
		if(counter==0){
			if(n==3){
				ans+=100;
			}else if(n==2){
				ans+=10;
			}
		}
		checker=0;
		while(checker<m){
			if((n-s[checker])==0){
				ans+=c[checker];
				break;
			}
			checker++;
		}
		checker=0;
		while(checker<m){
			if((n-s[checker])==1){
				ans+=(10*c[checker]);
				break;
			}
			checker++;
		}
		checker=0;
		while(checker<m){
			if((n-s[checker])==2){
				ans+=(100*c[checker]);
				break;
			}
			checker++;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128