akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <cstdio>
#include <cmath>
#include <time.h>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n)
#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.begin(),v.end(),greater<int>())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n, q;

int main() {
	while (cin >> n >> q) {
		if (n == 0)return 0;
		int m; int ok[110];
		for (int i = 0; i < 110; i++)ok[i] = 0;
		for (int i = 0; i < n; i++) {
			cin >> m; 
			for (int j = 0; j < m; j++) {
				int d; cin >> d;
				ok[d]++;
			}
		}
		int ans = 0;
		int nowpeople=0;
		for (int i = 0; i < 110; i++) {
			if (ok[i] >= q){
				int h = nowpeople;
				nowpeople = max(nowpeople, ok[i]);
				if (nowpeople > h)ans = i;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3012
use std::io::{stdin, Read};
use std::str::FromStr;

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

#[allow(dead_code)]
fn main() {
    let x = read::<i64>();
    let y = read::<i64>();

    let mut cx = 0;
    let mut cy = 0;

    for i in 0..x + 1 {
        let rx = x - i;
        let ry = y - 2 * i;
        if rx % 2 == 0 && ry == rx / 2 {
            cy = i;
            cx = rx / 2;

            println!("{}", comb_m((cx + cy) as usize, (cy) as usize, 1000000007));
            return;
        }
    }
    println!("0");

    // https://abc034.contest.atcoder.jp/submissions/7354299
    fn pow_m(n: usize, mut p: usize, d: usize) -> usize {
        let mut r = n;
        let mut ret = 1;
        while p > 0 {
            if p % 2 == 0 {
                r = r * r % d;
                p /= 2;
            } else {
                ret = ret * r % d;
                p -= 1;
            }
        }
        ret
    }

    fn inv_m(n: usize, d: usize) -> usize {
        pow_m(n, d - 2, d)
    }

    fn comb_m(n: usize, r: usize, d: usize) -> usize {
        (n - r + 1..n + 1).fold(1, |ac, x| ac * x % d)
            * inv_m((1..r + 1).fold(1, |ac, x| ac * x % d), d)
            % d
    }
}


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

int main(){
  int i,j,cnt;
  int n;
  cin>>n;
  int a[n],b[n],c[n-1];
  for(i=0;i<n;i++)cin>>a[i];
  for(i=0;i<n;i++)cin>>b[i];
  for(i=0;i<n-1;i++)cin>>c[i];
  int sum=0;
  for(i=0;i<n;i++)sum+=b[i];
  for(i=0;i<n-1;i++){
    if(a[i+1]==a[i]+1)sum+=c[a[i]-1];
  }
  cout<<sum;
}

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

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

  for(int i=0; i<S.size(); i++){
    S.erase(S.size()-1);
    if(S.size()%2 != 0) continue;
    if(S.substr(0, S.size()/2) == S.substr(S.size()/2, S.size())){
      cout << S.size() << endl;
      return 0;
    }
  }

  cout << "2" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include<iostream>
//#include<vector>
//#include<map>
//#include<math.h>
//#include<algorithm>

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define rrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n, k;
    cin >> n >> k;
    int r,s,p;
    cin >> r >> s >> p;
    
    string jan;
    cin >> jan;
    
    map<char, int> v;
    v['r'] = p;
    v['s'] = r;
    v['p'] = s;

    v_string t(k);
    rep(i,n) {
        t[i%k] += jan[i];
    }

    ll ans = 0;
    rep(i,k) {
        int m = t[i].size();
        ll dp[m+1][2]; 
        rep(j,m+1) {
            rep(k,2) {
                dp[j][k] = 0;
            }
        }
        
        char pre = 'z';
        rep(j,m) {
            chmax(dp[j+1][0], max(dp[j][0], dp[j][1]));
            if(pre == t[i][j]) {
                chmax(dp[j+1][1], dp[j][0]+v[t[i][j]]); 
            } else {
                chmax(dp[j+1][1], max(dp[j][0], dp[j][1])+v[t[i][j]]);
            }
            pre = t[i][j];
        }
        ans += max(dp[m][0], dp[m][1]);
    }
    cout << ans << endl;
    return 0;
} /*atcoder*/


Measured memory_bytes: 6056
function  main()
  
  (N,L) = map(x -> parse(Int,x), split(readline()))
  apple = [L+i-1 for i in 1:N]
  
  check = 1000
  num = 0
  
  for i in 1:N
    if min(abs(sum(apple)-(sum(apple)-apple[i])),check) != check
      num = i
    end
    
    check = min(abs(sum(apple)-(sum(apple)-apple[i])),check)

  end

  println(sum(apple)-apple[num])

end

main()

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


int main()
{
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n)
    cin >> h[i];
  int ans = 0;
  int tmp = 0;
  rep(i, n - 1)
    if (h[i] >= h[i+1])
      tmp++;
    else
    {
      ans = max(ans, tmp);
      tmp = 0;
    }
  ans = max(ans, tmp);
  cout << ans << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(k,i,n) for(long long i=k;i<n;++i)
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    string S,T;
    cin>>S;
    cin>>T;
    ll c=0;
    rep(0,i,3)if(S.substr(i,1)==T.substr(i,1))++c;
    cout<<c<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    long long int j=0;
    cin>>n;
    long long int arr[n],i,c=0;
    for(i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    for(i=1; i<n; i++)
    {

        if(arr[i]<arr[i-1])
        {
            j=arr[i-1]-arr[i];
           arr[i]=arr[i]+j;
            c+=j;
        }

    }cout<<c;

}


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

//////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// ここからコピペ ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////
// Range Update Query //
////////////////////////

class RUQ {
private:
	std::vector<int64_t> container_, time_container_;
	const int64_t optional_{(1ll << 31) - 1};
	int update_num_{};

	void build(const unsigned int array_size)
	{
		unsigned int length{1};
		while (length < array_size)
			length <<= 1;
		container_.resize(2 * length, optional_);
		time_container_.resize(2 * length, -1);
	}

public:
	RUQ(const unsigned int array_size) { build(array_size); }
	RUQ(const std::vector<int64_t> &array)
	{
		build(array.size());
		std::copy(array.begin(), array.end(), container_.begin() + (container_.size() >> 1));
		for (int i{((int)container_.size() >> 1) - 1}; i > 0; i--)
			container_[i] = container_[2 * i] + container_[2 * i + 1];
	}
	// left,rightは0-indexed、[left, right)の半開区間
	void update(const int left, const int right, const int64_t assigned)
	{
		for (int left_i{std::max(0, left) + ((int)container_.size() >> 1)}, right_i{std::min((int)container_.size() >> 1, right) + ((int)container_.size() >> 1)};
			left_i < right_i; left_i >>= 1, right_i >>= 1
			)
		{
			if (left_i & 1)
			{
				container_[left_i] = assigned;
				time_container_[left_i] = update_num_;
				left_i++;
			}
			if (right_i & 1)
			{
				right_i--;
				container_[right_i] = assigned;
				time_container_[right_i] = update_num_;
			}
		}
		update_num_++;
	}
	// indexは0-indexed
	int64_t get(const int index) const
	{
		int64_t last{optional_};
		int last_time{-1};
		for (int assign_place{index + ((int)container_.size() >> 1)}; assign_place > 0; assign_place >>= 1)
			if (time_container_[assign_place] > last_time)
			{
				last = container_[assign_place];
				last_time = time_container_[assign_place];
			}
		return last;
	}
};


//////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// ここまでコピペ ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////


// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_E
int main()
{
	int n, q;
	scanf("%d%d", &n, &q);

	RUQ raq(n);
	for (int q_i{}; q_i < q; q_i++)
	{
		int com;
		scanf("%d", &com);
		if (com)
		{
			int i;
			scanf("%d", &i);
			printf("%lld\n", raq.get(i));
		}
		else
		{
			int s, t, x;
			scanf("%d%d%d", &s, &t, &x);
			raq.update(s, t + 1, x);
		}
	}
	return 0;
}


Measured memory_bytes: 7028
#include<iostream>
#include<stdio.h>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<cstdlib>
typedef long long ll;
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mm(a) memset(a,0,sizeof(a))
#define lr rt<<1
#define rr rt<<1|1
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0);
#define inf 0x3f3f3f3f
#define eqs 1e-8
#define lb(x) (x&(-x))
#define ch(a) (int(a-'a')+1)
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef pair<int,int> pii;
const double pi=acos(-1);
const int maxn=3005;;
//const ll Mod=1000000007;
const ll Mod=998244353;
using namespace std;

ll ans=0;
ll dp[maxn];
ll a[maxn];
int main()
{
    sync;
    int n,k;
    cin>>n>>k;
    rep(i,1,n)
    cin>>a[i];
    ll ans=0;
    dp[0]=1;
    rep(i,1,n)
    {
        for(int j=k;j-a[i]>=0;j--)
        {
            dp[j]+=dp[j-a[i]];
            dp[j]%=Mod;
        }
        ans+=dp[k];
        ans%=Mod;
        dp[0]++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,k,n) for(int i = (k); i < (n); i++)
#define rep(i,n) repr(i,0,n)
#define ALL(a) begin(a),end(a)
const int MOD = 1000000007;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
  }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, C;
    cin >> A >> B >> C;
    cout << (A - B - C > 0 ? 0 : (A - B - C ) * -1) << endl;
    return 0;
}

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

int main(){
        string s;
    cin>>s;
    bool a = s[0] == 'R';
    bool b = s[1] == 'R';
    bool c = s[2] == 'R';
    int ans;
    if(a and b and c){
        ans = 3;
    }else if((a and b)or(b and c)){
        ans = 2;
    }else if(a or b or c){
        ans = 1;
    }else{
        ans = 0;
    }
    cout<<ans<<endl;
}

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

int main() {
    int N;
    map<string,int>a;
	string y;
    cin >> N;
    for(int i=0;i<N;i++){
    cin >> y;
      a[y]+=1;
    }
 	 cout << "AC x " << a["AC"] << endl;
     cout << "WA x " << a["WA"] << endl;
     cout << "TLE x " << a["TLE"] << endl;
     cout << "RE x " << a["RE"] << endl;
  return 0;
}

Measured memory_bytes: 3592
//C
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int height[] = new int[n];
		for (int i = 0; i < n; i++) {
			height[i] = sc.nextInt();
		}
		
		int count[] = new int[n];
		for (int i = 0; i < m; i++) {
			int a_i = sc.nextInt() - 1;
			int b_i = sc.nextInt() - 1;
			if (height[a_i] <= height[b_i]) {
				count[a_i] = 1;
			}
			if (height[a_i] >= height[b_i]) {
				count[b_i] = 1;
			}
		}
		
		int countAll = 0;
		for (int i = 0; i < n; i++) {
			if (count[i] == 0) {
				countAll++;
			}
		}
		System.out.println(countAll);
	}
}

Measured memory_bytes: 59352
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> p;
    for(int i = 0;i < n;i++) {
        int x;
        cin >> x;
        p.push_back(x);
    }
    sort(p.rbegin(), p.rend());
    p[0]/=2;
    cout << accumulate(p.begin(), p.end(), 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
#define all(cont) cont.begin(), cont.end()
#define unique(a)  sort(all(a)) , (a).erase(unique((a).begin(), (a).end()),(a).end())
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(x) (int)(x).size()
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define f first
#define s second
#define mset(m,v) memset(m,v,sizeof(m))
#define mod 1000000007
const int N = 2e5 + 5;
#define PI acos(-1.0)
long double EPS = 1e-9;
typedef long long ll;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
#define pqll_max priority_queue<ll> // max heap. push(),pop(),top(),size(),empty()
#define pqll_min priority_queue<ll,vector<ll>,greater<ll> >
#define lb(v,val)   lower_bound(v.begin(),v.end(),val) //first equal to or lower than [------------
#define ub(v,val)   upper_bound(v.begin(),v.end(),val) //first greater than ------------)
#define bs(v,x) binary_search(v.begin(),v.end(),x)
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x; }
inline ll sub(int x, int y) { x -= y; if (x < 0) x += mod; return x; }
inline ll mul(ll x, ll y) { return (x%mod * 1ll * y%mod) % mod; }
inline ll pwr(ll a, ll b) { ll x = 1 % mod; while (b) { if (b & 1) x = mul(x, a); a = mul(a, a); b >>= 1; }return x % mod; }
inline ll inv(ll a) { return pwr(a, mod - 2) % mod; }
ll gcd(ll a, ll b) { if (!a)return b % mod; return gcd(b%a, a) % mod; }
#define debug(x) cout << #x << " = " << x << endl;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#define in(container) for (auto &it : container) cin>>it;
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
void solve() {
	int k;
	cin >> k;
	string s;
	cin >> s;
	if (sz(s) <= k) {
		cout << s << endl;
	}
	else {
		cout << s.substr(0, k);
		rep(i, 3) {
			cout << ".";
		}
		cout << endl;
	}
}
signed main()
{
	fastio;
	//cout<<fixed<<setprecision(15);
	//clock_t begin = clock();
	int tc;
	tc = 1;
	//cin >> tc;
	while (tc--) {
		solve();
	}
	//clock_t end = clock();double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;cerr << elapsed_secs;
}


//Error?
// clear lists for every test case
// print new line for each tc
// check for int or ll
// check if problem can be solved without any heavy DS like priority_queue or map



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

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define eps 1e-9
#define fast_cin ios_base::sync_with_stdio(false)

const int MOD = 1e9+7;

typedef long long ll;
typedef pair<int,int> pii;

int main()
{
	//freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);
	fast_cin;
	string s;
	cin >> s;
	int len = s.size();
	cout << s[0] << len-2 << s[len-1] << endl;
	return 0;
}

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

int main() {
    int N, Y;
    cin >> N >> Y;
    int res10000 = -1, res5000 = -1, res1000 = -1;
    for (int a = 0; a <= N; ++a) {  // 10000円の枚数を 0 〜 N で調べる
        for (int b = 0; b + a <= N; ++b) {  // 5000円の枚数を 0 〜 N-a で調べる
            int c = N - a - b;  // 1000円の枚数は決まる
            int total = 10000*a + 5000*b + 1000*c;
            if (total == Y) {  // 答えが見つかったら
                res10000 = a;
                res5000 = b;
                res1000 = c;
            }
        }
    }

    // 答えを出力 (見つかっていなくても -1 -1 -1 になるので OK です)
    cout << res10000 << " " << res5000 << " " << res1000 << endl;
}

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

#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define IN(i,l,r) (l<i&&i<r) //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)

#define F(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FF(i,L,R) for (int i = L; i > R; i--)
#define FFE(i,L,R) for (int i = L; i >= R; i--)

#define getI(a) scanf("%d", &a) //next three are handy ways to get ints, it's also force you to use '&' sign
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)

#define wez(n) int (n); scanf("%d",&(n)) //handy if the input is right after the definition of a variable
#define wez2(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define wez3(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))

#define whileZ int T; getI(T); while(T--)
#define lastEle(vec) vec[vec.size()-1]
#define SZ(x) ((int)((x).size()))

#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) // traverse an STL data structure

#define ALL(c) (c).begin(),(c).end() //handy for function like "sort()"
#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int

#define mp make_pair
#define fi first
#define se second

// for debug
#define printA(a,L,R) FE(i,L,R) cout << a[i] << (i==R?'\n':' ')
#define printV(a) printA(a,0,a.size()-1)

#define pb push_back
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;

ll dp[10001][2][101];        // dp -- pos - tight - mod
string s;
int d;

ll getans (int pos, int tight, int mod)
{
    if (pos == s.size()) 
        return (ll)(mod==0);
    if (dp[pos][tight][mod]!=-1)
        return dp[pos][tight][mod];
    dp[pos][tight][mod] = 0LL;
    int en = tight ? (s[pos]-'0') : 9;
    FE(i,0,en)
        dp[pos][tight][mod] = (dp[pos][tight][mod] + getans (pos+1,tight&(i==en),(mod+i)%d)) % 1000000007LL;
    return dp[pos][tight][mod];
}

int main()
{
    cin >> s;
    memset(dp,-1,sizeof(dp));
    getI(d);
    cout << (getans(0,1,0) + 1000000006LL) % 1000000007LL << "\n";
    return 0;
}

Measured memory_bytes: 16896
import java.util.*;

public class Main{
	public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int k = sc.nextInt();
        
        List<Integer> p = new ArrayList<>();
      
      	for(int i = 0; i < n; i++){
        	p.add(sc.nextInt());
        }
      
      	Collections.sort(p);
      
      	int result = 0;
      
      	for(int i=0; i < k; i++){
        	result += p.get(i);
        }
      
      	System.out.print(result);
    }
}


Measured memory_bytes: 30192
import sys

sys.setrecursionlimit(1000000)

#dfs...orderに帰りがけ順の逆順を保存
def dfs(v, visited, edges, order):
  visited[v] = True
  for to in edges[v]:
    if not visited[to]:
      dfs(to, visited, edges, order)
  order.append(v)

#最初のノードを強連結成分の親にする
def search_strongly_connection(v, visited, reverse_edges, parent, num):
  visited[v] = True
  for to in reverse_edges[v]:
    if not visited[to]:
      parent[to] = num
      search_strongly_connection(to, visited, reverse_edges, parent, num)

def main():
  #input
  v_num , e_num = map(int, input().split())
  edges = [[] for _ in range(v_num)]
  reverse_edges = [[] for _ in range(v_num)]
  for _ in range(e_num):
    s, t = map(int, input().split())
    edges[s].append(t)
    reverse_edges[t].append(s)
  
  #帰りがけ順の取得
  order = []
  visited = [False] * v_num
  for v in range(v_num):
    if not visited[v]:
      dfs(v, visited, edges, order)
  order.reverse()
  
  #強連結の探索
  visited = [False] * v_num
  parent = [i for i in range(v_num)]
  for v in order:
    if not visited[v]:
      search_strongly_connection(v, visited, reverse_edges, parent, v)
  
  #output
  for i in range(v_num):
    if parent[i] != i:
      print(1)
      break
  else:
    print(0)
main()


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
  int n, a;
  cin >> n >> a;
  vi x(n);
  rep(i,n) cin >> x[i];
  // dp[i][j][k] = i番目まででj枚選んで和がkになる組み合わせの個数
  vector<vll> dp(n+1,vll(n+1,vl(2550)));
  dp[0][0][0] = 1;
  for(int i = 1; i <= n; i++) {
    for(int j = 0; j <= i; j++) {
      rep(k,2510) {
        if(x[i-1] <= k && j > 0) dp[i][j][k] += dp[i-1][j-1][k-x[i-1]];
        dp[i][j][k] += dp[i-1][j][k];
      }
    }
  }
  ll ans = 0;
  for(int j = 1; j <= n; j++) {
    ans += 1LL * dp[n][j][a*j];
  }
  cout << ans << endl;
}

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

int main()
{
	int n;
	cin>> n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>> a[i];
	}
	int q;
	cin  >> q;
	vector<int> m(q);
	vector<string> ans(q);
	for(int i=0;i<q;i++){
		cin>> m[i];
		ans[i] = "no";
	}
  
  
	vector<int> sum(1<<n);
	for(int bit = 0;bit < (1<<n);bit++){
		for(int i=0;i<n;i++){
			if(bit&(1<<i)){
				sum[bit] += a[i];
			}
		}
	}
	
	for(int bit = 0;bit < (1<<n);bit++){
		for(int j=0;j<q;j++){
			if(sum[bit] == m[j]){
				ans[j] = "yes";
			}
		}
	}
	
	
	for(int i=0;i<q;i++){
		cout<< ans[i] <<endl;
	}
}



Measured memory_bytes: 6964
// Because I am lazy
// Template Start
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define REP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define REPI(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define REPITER(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds

#define eps 1e-6
#define pi 3.141592653589793

using namespace std;

template<class T> inline T gcd(T a, T b) { while(b) b ^= a ^= b ^= a %= b; return a; }
template<class T> inline T mod(T x) { if(x < 0) return -x; else return x; }

typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII > PPII;
typedef vector< PII > VPII;
typedef vector< PPII > VPPI;

const int MOD = 1e9 + 7;
const int INF = 1e9;
// Template End

int f(ll a)
{
    int x = 0;
    while(a)
    {
        a /= 10;
        x++;
    }
    return x;
}

int main(int argc, char* argv[])
{
    if(argc == 2 or argc == 3) freopen(argv[1], "r", stdin);
    if(argc == 3) freopen(argv[2], "w", stdout);
    ll n;
    int ans = 100;
    cin >> n;
    int m = sqrt(n) + 1;
    REP(i, 1, m, 1)
    {
        if(n % i == 0)
        {
            ans = min(max(f(i), f(n/i)), ans);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

class Program
{
	static void Main(string[] args)
	{
		var HW = Console.ReadLine().Split().Select(int.Parse);
		int H = HW.First(), W = HW.Last();
		var S = new string[H];
		for (int i = 0; i < H; i++)
		{
			S[i] = Console.ReadLine();
		}
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				if (S[i][j] == '#')
				{
					Console.Write('#');
				}
				else
				{
					var mine = 0;
					if (i > 0)
					{
						if (j > 0 && S[i - 1][j - 1] == '#')
						{
							mine++;
						}
						if (S[i - 1][j] == '#')
						{
							mine++;
						}
						if (j < W - 1 && S[i - 1][j + 1] == '#')
						{
							mine++;
						}
					}
					if (j > 0 && S[i][j - 1] == '#')
					{
						mine++;
					}
					if (j < W - 1 && S[i][j + 1] == '#')
					{
						mine++;
					}
					if (i < H - 1)
					{
						if (j > 0 && S[i + 1][j - 1] == '#')
						{
							mine++;
						}
						if (S[i + 1][j] == '#')
						{
							mine++;
						}
						if (j < W - 1 && S[i + 1][j + 1] == '#')
						{
							mine++;
						}
					}
					Console.Write(mine);
				}
			}
			Console.WriteLine();
		}
	}
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a,b;
  	ci(a>>b);
  ll c,d;
  	ci(c>>d);
  ll A=0;
	co(M(A,rM(b,d)-M(a,c)))
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = {-1,0,1,0}; const int dy[] = {0,1,0,-1};

int main() {
	vi pre_line;
	string s;
	for(int y = 0; getline(cin, s) ; y++){
		stringstream ss(s+',');
		vi line;
		char c;
		for(int x=0, n; ss >> n >> c; x++){
			line.push_back(n);
		}
		if(line.size() > pre_line.size()){
			vi line_stk = line;
			REP(i, pre_line.size()){
				line_stk[i] = max(line_stk[i], line[i] + pre_line[i]);
				line_stk[i+1] = max(line_stk[i+1], line[i+1] + pre_line[i]);
			}
			pre_line = line_stk;
		}else{
			REP(i, line.size()){
				line[i] += max(pre_line[i], pre_line[i+1]);
			}
			pre_line = line;
		}
		if(y > 0 && line.size() == 1){
			cout << line[0] << endl;
			break;
		}
	}
}

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

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

    int n = s.size();
    bool okfalg = true; 

    rep(i, n) {
        if (s[i] != s[n-1-i]) {
            cout << "No" << endl;
            return 0;
        } 
    }
    rep(i, (n-1)/2) {
        if (s[i] != s[n-1-i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    for (int i = (n + 3) / 2 - 1; i < n; i++) {
        if (s[i] != s[(3 * n - 1) / 2 - i]) {
            cout << "No" << endl;
            return 0;
        }
    }

 
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  int a, b, c;
  cin>>a>>b>>c;
  int ans = max(a,max(b,c));
  if(ans ==(a+b) || ans == (a+c) || ans == (b+c)){
    cout<<"Yes";
  }
  else{cout<<"No";}
}


Measured memory_bytes: 3592
import math
n = int(input())
l = [list(map(int,input().split())) for i in range(n)]
dist = 0
for x1,y1 in l:
    for x2,y2 in l:
        dist += math.sqrt((x1-x2)**2 + (y1-y2)**2)
ave = dist/n
print(ave)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
    int a;
  cin>>a;
  out(a*a*a);
}


Measured memory_bytes: 3144
def main():
    """
    1 <=  N <= 2 * 10^5
    1 <= ai <= 10^9
    """
    N = int(input())
    *A, = map(int, input().split())

    #ans = WA3(N, A)
    ans = editorial(N, A)
    print(ans)


def editorial(N, A):
    ans = 0
    C = sorted(a - i for i, a in enumerate(A, 1))
    if N % 2 == 1:
        b = C[N // 2]
    else:
        # 中央値だけど、整数？
        s = C[N // 2 - 1] + C[N // 2 - 1]
        b = (s + 1) // 2

    ans = sum(abs(c - b) for c in C)
    return ans


if __name__ == '__main__':
    main()


Measured memory_bytes: 26180
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
    long long H, W;
    cin >> H >> W;
    
    if (H == 1 || W == 1) {
        cout << 1;
        return 0;
    }
    
    long long ans = 0;
    long long odd_col = (H + 1) / 2;
    long long even_col = H / 2;
    long long odd_num = (W + 1) / 2;
    long long even_num = W - odd_num;

    ans = odd_col * odd_num + even_col * even_num;
    
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
SP = [list(map(str, input().split())) for _ in range(N)]
SP2 = [[0] * 2 for i in range(N)]
for i in range(N):
    SP2[i][0] = SP[i][0]
    SP2[i][1] = int(SP[i][1])
    SP[i][1] = int(SP[i][1])
SP2.sort(key=lambda x:(x[0],-x[1]))
for i in range(N):
    print(SP.index(SP2[i]) + 1)

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

int main(){
  long long N;
  cin>>N;
  long long A[N];
  long long O[65];
  for(long long i=0;i<65;i++){
    O[i]=0;
  }
  
  for(long long i=0;i<N;i++){
    cin>>A[i];
    int count=0;
    long long temp=A[i];
    while(temp!=0){
      O[count]+= temp%2;
      temp/=2;
      count++;
    }
    //cout<<i<<" "<<A[i]<<" "<<count<<" "<<O[count]<<endl;
  }
  long long ans=0;
  long long t=1;
  for(long long i=0;i<63;i++){
    ans=(ans+((t*O[i])%1000000007)*(N-O[i]))%1000000007;
    t=(t*2)%1000000007;
    //cout<<i<<" "<<O[i]<<" "<<ans<<endl;
  }
  
  cout<<ans<<endl;
  return 0;
}




Measured memory_bytes: 5904
N = int(input())
S = input()

hist = {}
out = 0
for c in "abcdefghijklmnopqrstuvwxyz":
    hist[c] = 1
for c in S:
    hist[c] += 1

tmp = 1
for a in hist.values():
    tmp *= a
out = (tmp -1) % (10**9 + 7)
print(out)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<tuple<string, int, int>> a;
  
  for(int i = 1; i <= N; i++){
    string S;
    int P;
    cin >> S >> P;
    P = -P;
    a.push_back(tie(S, P, i));
  }
  
  sort(a.begin(), a.end());
  for(int i; i < N; i++){
    cout << get<2>(a[i]) << endl;
  }
  
  return 0;
  
}

Measured memory_bytes: 256
s = input()

if s[0] == 'A' and 'C' in s[2:-1]:
    s = s.replace('C', '', 1)
    s = s.replace('A', '', 1)
    if s.islower() :
        print('AC')
    else:
        print('WA')
else:
    print('WA')

Measured memory_bytes: 2940
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,m=nii()

def divisore(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort(reverse=True)
    return divisors

d=divisore(m)

for x in d:
  zan=m-(x*n)
  if zan>=0 and zan%x==0:
    print(x)
    exit()

Measured memory_bytes: 9428
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll M = 1e9+7;
const ll INF = 1e9+7;

ll n, k, ans;
ll a[220000];
ll in[220000], out[220000];

int main() {
  cin >> n >> k;
  
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  
  
  while (k--) {
    for (ll i = 0; i <= n; i++) {
      in[i] = out[i] = 0;
    }
    for (ll i = 0; i < n; i++) {
      in[max(0LL, i-a[i])]++;
      out[min(n, i+a[i]+1)]++;
    }
    ll sum = 0;
    for (ll i = 0; i < n; i++) {
      sum += in[i] - out[i];
      a[i] = sum;
    }
    bool f = true;
    for (ll i = 0; i < n; i++) {
      if (a[i] != n) f = false;
    }
    if (f) break;
  }
  
  for (ll i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 8320
s = input()

a = ''
b = ''
count_a = 0
count_b = 0
count_c = 0

for i in range(4):
    if s[i] == a:
        count_a += 1
    elif s[i] == b:
        count_b += 1
    elif a == '':
        a = s[i]
        count_a += 1
    elif b == '':
        b = s[i]
        count_b += 1
    else:
        count_c += 1

if count_c > 0 or count_a != 2 or count_b != 2:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 3188
a, b, c, x, y = map(int, input().split(' '))

ans1 = c*max(x, y)*2

tmp = min(x, y)
ans2 = c*tmp*2 + a*max(x-tmp, 0) + b*max(y-tmp, 0)

ans3 = a*x + b*y

print(min(ans1, ans2, ans3))

Measured memory_bytes: 38384
#include <stdio.h>
#include <stack>
typedef long long ll;

int main(void) {
  ll n;
  std::stack<char> s;
  scanf("%lld", &n);
  while(n) s.push(--n % 26 + 'a'), n /= 26;
  while(s.size()) printf("%c", s.top()), s.pop();
  return 0;
}

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

ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

ll a, b, c, d;

ll f(ll x){
  ll res=x;
  res -= x/c;
  res -= x/d;
  res += x/lcm(c,d);
  return res;
}

int main(){
  cin >> a >> b >> c >> d;
  ll ans = f(b) - f(a-1);
  cout << ans << endl;
}

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

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>
int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int N;  cin >> N;
	V a(N), b(N);  ll sum_a = 0, sum_b = 0;
	REP(i, N){  cin >> a[i];  sum_a += a[i];  }
	REP(i, N){  cin >> b[i];  sum_b += b[i];  }

	if(sum_b > sum_a){  cout << -1 << endl;  return 0;  }
	
	V diff(N);
	REP(i, N)   diff[i] = a[i] - b[i];
	SORT(diff);
  	if(diff[0] >= 0){  cout << 0 << endl;  return 0;  }
  
	int low_ite = 0, high_ite = N - 1, ans = 0;
	while(true){
			if(diff[low_ite] > 0)  break;

			int low = diff[low_ite], high = diff[high_ite];
			if(abs(high) > abs(low)){
					low_ite += 1;
					diff[high_ite] += low;
					ans += 1;
			}else{
					high_ite -= 1;
					diff[low_ite] += high;
					ans += 1;
			}
	}

	cout << ans + 1 << endl;

	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s;
	cin>>n;
	cin>>s;
	int cnt=1;
	for(int i=1;i<n;i++){
		if(s[i]!=s[i-1])
			cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 512
n=int(input())
s=input()
alh="abcdefghijklmnopqrstuvwxyz"
max=0
for i in range(n):
  front=s[:i]
  rear=s[i:]
  cnt=0
  for j in alh:
    if j in front and j in rear:
      cnt+=1
  if cnt>max:
    max=cnt
print(max)

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

using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define f first
#define s second
#define pii pair<int,int>
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int MAX_N = 2e6 + 1;

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a,a + n);
    int ans = 0;
    for (int i = 0; i < k; ++i) {
        ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int M;
    cin >> M;
    cout << 24 + 24 - M << endl;;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 1e18+5;

ll t, n, a, b, c, d, ans, cnt;
priority_queue<P> pq;

void dfs(ll x, ll coin) {
  cnt++;
  if (x == 1) {
    ans = min(ans, coin + d);
    return;
  }
  ans = min(ans, coin + d * x);
  ll mod = x % 2;
  if (mod == 0) {
    dfs(x / 2, coin + a);
  } else {
    dfs((x-1) / 2, coin + a + d);
    dfs((x+1) / 2, coin + a + d);
  }
  mod = x % 3;
  if (mod == 0) {
    dfs(x / 3, coin + b);
  } else {
    if (x-mod != 0)
    dfs((x-mod) / 3, coin + b + d * mod);
    dfs((x+3-mod) / 3, coin + b + d * (3-mod));
  }
  mod = x % 5;
  if (mod == 0) {
    dfs(x / 5, coin + c);
  } else {
    if (x-mod != 0)
    dfs((x-mod) / 5, coin + c + d * mod);
    dfs((x+5-mod) / 5, coin + c + d * (5-mod));
  }
}

int main() {
  cin >> t;

  for (ll i = 0; i < t; i++) {
    ans = INF;
    cin >> n >> a >> b >> c >> d;
    pq.push(P(n, 0));
    ll last = n+1;
    while (pq.size()) {
      P p = pq.top();
      pq.pop();
      ll x = p.first, coin = p.second;
      if (last == x) continue;
      last = x;
      if (to_string(x).length() + to_string(d).length() < 18) {
        ans = min(ans, -coin + x * d);
      }
      if (x == 1) continue;
      ll mod = x % 2;
      if (mod == 0) {
        pq.push(P(x/2, coin-a));
      } else {
        pq.push(P((x-1)/2, coin-a-d));
        pq.push(P((x+1)/2, coin-a-d));
      }
      mod = x % 3;
      if (mod == 0) {
        pq.push(P(x/3, coin-b));
      } else {
        if (x-mod != 0) {
          pq.push(P((x-mod)/3, coin-b-d*mod));
        }
        pq.push(P((x+3-mod)/3, coin-b-d*(3-mod)));
      }
      mod = x % 5;
      if (mod == 0) {
        pq.push(P(x/5, coin-c));
      } else {
        if (x-mod != 0) {
          pq.push(P((x-mod)/5, coin-c-d*mod));
        }
        pq.push(P((x+5-mod)/5, coin-c-d*(5-mod)));
      }
    }
    cout << ans << endl;
  }
    
  return 0;
}

Measured memory_bytes: 3812
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

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


def solve():
    if ord("A") <= ord(input()) <= ord("Z"):
        print ("A")
    else:
        print ("a")






mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()


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


void call(int n) {
	int i = 1;
	do{
		int x = i;
		if (x % 3 == 0) {
			cout << " " << i;
			continue;
		}
		bool f = true;
		do {
			if (x % 10 == 3) {
				cout << " " << i;
				f = false;
				continue;
			}
			x /= 10;
		} while (x && f);

	} while (++i <= n);
	cout << endl;
	
}

int main(){
	int n;
	cin >> n;
	call(n);

	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
#include <map>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

const int mod = 1e9 + 7;
const int M = 100000;

typedef long long ll;

char s[100100];
int n;

bool isValid() {
  if(s[n] == '1' || s[1] == '0') return 0;
  for(int i = 2; i < n; ++i) {
    if(s[i] != s[n - i]) return 0;
  }
  return 1;
}

void edge(int u, int v) {
  cout << u << " " << v << "\n";
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  cin >> (s + 1);
  n = strlen(s + 1);
  
  if(!isValid()) {
    cout << "-1\n";
    return 0;
  }
  
  int root = 1;
  for(int i = 2; i <= n; ++i) {
    edge(root, i);
    if(s[i-1] == '1') root = i;
  }
}


Measured memory_bytes: 1536
n, a, b =map(int, input().split())
#整数w, x, y, z
sum=0
for i in range(1, n+1):
    z=i%10
    y=(i//10)%10
    x=(i//100)%10
    w=(i//1000)%10
    v=(i//10000)
    if a<=v+w+x+y+z<=b:
        sum+=i
print(sum)

Measured memory_bytes: 3064
N = gets.to_i
As = gets.split.map(&:to_i).sort.reverse

i, cnt, res = 0, 0, []
while i < N - 1
  if As[i] == As[i + 1]
    res << As[i]
    cnt += 1
    break if cnt == 2
    i += 1
  end
  i += 1
end
puts cnt < 2 ? 0 : res.inject(:*)

Measured memory_bytes: 10112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(j, m) for (int j = 0; j < (int)(m); j++)
#define rep2(i, l, n) for (int i = l; i < (int)(n); i++)


int main() {
    ll N,A,B;
    cin >> N >> A >> B;
    ll ans = 0;
    rep2(i, 1, N + 1) {
        ll j = i%10 + (i/10)%10 + (i/100)%10 + (i/1000)%10 + (i/10000)%10;
        if (A <= j && j <= B) {
            ans += i;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3552
n=int(input())
maxp=55555
primes = set(range(2, maxp+1))
for i in range(2, int(maxp**0.5+1)):
    primes.difference_update(range(i*2, maxp+1, i))
primes=list(primes)
p5=[i for i in primes if i%5==1]
ans=p5[:n]
print(*ans)

Measured memory_bytes: 49388
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Apolloliu
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

void get() {

}

class APair {
public:
	void solve(std::istream& in, std::ostream& out) {
		int k;
		in >> k;
		if(k%2 == 0)out << (k/2)*(k/2);
		else
		out << (k+1)/2*(k/2);
	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	APair solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256