akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define INFTY 1<<30
using namespace std;
int h,heap[2000001];
void maxHeapify(int i){
    int left,right,largest;
    left=i*2;
    right=left+1;
    if(left<=h&&heap[i]<heap[left]) largest=left;
    else largest=i;
    if(right<=h&&heap[largest]<heap[right]) largest=right;
    if(largest!=i){
        swap(heap[i],heap[largest]);
        maxHeapify(largest);
    }
}
void push(int key){
    h++;
    int i=h;
    heap[i]=-INFTY;
    if(key<heap[i]) return;
    heap[i]=key;
    while(i>1&&heap[i/2]<heap[i]){
        swap(heap[i/2],heap[i]);
        i=i/2;
    }
}
int pop(){
    int maxv;
    if(h<1) return -INFTY;
    maxv=heap[1];
    heap[1]=heap[h];
    h--;
    maxHeapify(1);
    return maxv;
}
int main(){
    scanf("%d",&h);
    string com;
    int k;
    while(cin>>com){
        if(com=="insert"){
            scanf("%d",&k);
            push(k);
        }else if(com=="extract"){
            printf("%d\n",pop());
        }
    }
    return 0;
}

Measured memory_bytes: 7196
N,M=map(int,input().split())
Boxes=[1]*N
R=[False]*N
R[0]=True
for i in range(M):
  x,y=map(int,input().split())
  Boxes[x-1]-=1
  Boxes[y-1]+=1
  if R[x-1]:
    R[y-1]=True
  if Boxes[x-1]==0:
    R[x-1]=False
ans=0
for i in range(N):
  if R[i]:
    ans+=1
print(ans)
    


Measured memory_bytes: 51672
#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(){
    int N,M; cin >> N >> M;
    vector<int> nodes(N);
    rep(i,N) nodes[i] = i+1;

    vector<P> vec(M);
    rep(i,M){
        int a,b; cin >> a >> b;
        vec[i] = P(a,b);
    }
    int ans = 0;    
    do{
        bool ok = true;
        rep(i, N-1){
            bool exists = false;
            rep(j, M){
                if(vec[j] == P(nodes[i], nodes[i+1]) || vec[j] == P(nodes[i+1], nodes[i])){
                    exists = true;
                }
            }
            if(!exists) ok = false;
        }
        if(ok) ++ans;
    }while(next_permutation(nodes.begin() + 1, nodes.end()));
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>

int main() {
  int n, k, d;
  bool is_safe[10] = {};
  std::cin >> n >> k;
  std::fill(is_safe, is_safe + 10, true);
  for (int ki = 0 ; ki < k; ++ki) {
    std::cin >> d;
    is_safe[d] = false;
  }
  while (true) {
    int r = n;
    while (r > 0) {
      if (not is_safe[r % 10]) {
        goto fail;
      }
      r /= 10;
    }
    std::cout << n << std::endl;
    return 0;
fail:
    ++n;
  }
}

Measured memory_bytes: 256
using System;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var p = Console.ReadLine();

            var s2 = s + s;

            var result = "No";
            if (s2.Contains(p))
            {
                result = "Yes";
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 17836
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  int count = 0;
  for(int i = 0; i < S.size(); i++){
    if(S.at(i) == 'o')count++;
  }
  if(15 - S.size() + count >= 8)cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 10007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //------------------------------
    int n;cin>>n;
    V<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    sort(all(a));
    ll sum=0;
    for(int i=0;i<n;i++)sum+=a[i];
    cout<<a[0]<<" "<<a[n-1]<<" "<<sum<<Endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------

































Measured memory_bytes: 3236
def number_list(A):
    number_list = set()
    for bit in range(1 << len(A)):
        sum_a = 0
        for i in range(len(A)):
            if bit & (1 << i):
                sum_a += A[i]
                number_list.add(sum_a)
    return number_list


if __name__ == "__main__":
    n = int(input())
    A = list(map(int, input().split()))
    q = int(input())
    M = list(map(int, input().split()))

    number_list = number_list(A)

    for m in M:
        if m in number_list:
            print('yes')
        else:
            print('no')



Measured memory_bytes: 5652
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(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 debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int a, b; cin >> a >> b;
    cout << (a + b) % 24 << endl;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < n; i++)

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

    string s;
    cin >> s;

    set<char> st;
    rep(i, s.size()) {
        if (st.count(s[i]) == 0) {
            st.insert(s[i]);
        } else {
            cout << "no" << endl;
            return 0;
        }
    }

    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

using System.Linq;
//using System.Collections;
//using System.Collections.Generic;
class Program
  
{
	static void Main(string[] args)
	{
		// 整数の入力
		int a = int.Parse(Console.ReadLine());
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
        int[] b = new int [a];
        for (int i = 0; i < a; i++){
    		b[i] = int.Parse(input[i]);
		}
		//出力
      int     intMax      = b.Max();
      
      if((b.Sum()-intMax)-intMax <=0){
      Console.WriteLine("No");
      }else{
       Console.WriteLine("Yes");
      }
       //for (int i = 0; i < a; i++){
	//	Console.WriteLine(b[i]);
      // }
	}
}

Measured memory_bytes: 13268
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define ll long long
#define ull unsigned long long
//#define int long long
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000009;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
                                                                    
typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 2e5 + 5;
int n ;
string s;
set < int > pos[30];
main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n;
	cin >> s;
	for(int i = 0 ; i < n ; i++)
		pos[s[i] - '0'].insert(i);
	int ans = 0;
	rep(i , 0 , 9)
		rep(j , 0 , 9)
			rep(k , 0 , 9){
				auto it = pos[i].begin();
				if(it == pos[i].end()) continue;
				it = pos[j].upper_bound(*it);
				if(it == pos[j].end()) continue;
				it = pos[k].upper_bound(*it);
				if(it == pos[k].end()) continue;
			    ans++;	
			}
	ret(ans);						
}

Measured memory_bytes: 1664
N = gets.to_i
L = gets.split.map(&:to_i).sort

ans = 0
1.step(N-1) do |b|
  b.times do |a|
    ab = L[a] + L[b]
    ans += L[(b+1)..-1].bsearch_index {|c| ab <= c } || N-b-1
  end
end
puts ans


Measured memory_bytes: 3836
fn main() {
    let v = read_vec::<u32>();
    let n = v[0];
    let m = v[1];
    if m == 0 {
        println!("{}", n * 100);
        return;
    }
    let pow2m = {
        let mut mm = m;
        let mut a = 1;
        while mm > 0 {
            a *= 2;
            mm -= 1;
        }
        a
    };
    let ans = (1900 * m + 100 * (n - m)) * pow2m;
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
/*input
10 10 1
1 10 9 1
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int n, m, q;
ll ans;
vector<int> a;
vector<int> b;
vector<int> c;
vector<ll> d;

void brute(int sz, int last, vector<int> v)
{
	if(sz == n)
	{
		ll score = 0;
		for(int i = 0; i < q; i++) if(v[b[i] - 1] - v[a[i] - 1] == c[i]) score += d[i];
		ans = max(ans, score);
	}
	else
	{
		for(int i = last; i <= m; i++)
		{
			v[sz] = i;
			brute(sz + 1, i, v);
		}
	}
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m >> q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    for(int i = 0; i < q; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
	vector<int> v(n, -1);
    for(int i = 1; i <= m; i++)
    {
    	v[0] = i;
    	brute(1, i, v);
    }
    cout << ans;

    return 0;
}

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

int main() {
	
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> a(n);
	rep(i, m){
		int tmp;
		cin >> tmp;
		a[tmp]++;
	}
	int cnt1 = 0;
	for(int i = x; i >= 0; i--){
		if(a[i]) cnt1++;
	}
	int cnt2 = 0;
	for(int i = x; i < n; i++){
		if(a[i]) cnt2++;
	}
	cout << min(cnt1, cnt2) << endl;
	return 0;
}

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

int main() {
  int N ;
  cin >> N ;
  
  if ( N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 
      || N % 10 == 9 ) {
    cout << "hon" << endl;
  }
  else if ( N % 10 == 0  || N % 10 == 1  || N % 10 == 6  || N % 10 == 8 ) {
    cout << " pon " << endl;
  }
  else {
    cout << " bon " << endl;
  }
}



Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;
  string d,e,f;
  cin >>d>>e>>f;
  if(d[d.size()-1]==e[0]&&e[e.size()-1]==f[0]) cout <<"YES\n";
  else cout <<"NO\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


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 nlcm(vector<ll> numbers) {
	ll l;
	l = numbers[0];
	for (ll i = 1; i < numbers.size(); i++) {
		l = lcm(l, numbers[i]);
	}
	return l;
}

int main(void) {
    
    int n;
    cin>>n;
    vll v(n);
    rep(i,n){
        cin>>v[i];
    }
    fin(nlcm(v));
}


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

int main() {
    int N, H; cin >> N >> H;
    vector<int> a(N);
    vector<int> b(N);
    rep(i, N){
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    int amax = a[N-1];
    int ans = 0;
    int bnow = N-1;
    bool ok = true;
    while(H > 0){
        if(ok && amax < b[bnow]){
            H -= b[bnow];
            if(bnow == 0){
                ok = false;
            } else {
                bnow--;
            }
            ans++;
        } else {
            ans += ((H-1) / amax) + 1;
            break;
        }
    }

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 4040
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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; }

const long long INF = 1000000000000000;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n, m,k,l; string s;
char maze[60][60];
int dis[101][101];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main() {
	cin >> n >> s;
	int res = 0; int kp = 0;
	rep(i, n) {
		if (s[i] == 'I') { kp++; chmax(res, kp); }
		else { kp--; chmax(res, kp); }
	}
	cout << res << endl;
}

Measured memory_bytes: 256
def some_sum(num):
    string = str(num)
    s = 0
    for i in range(len(string)):
        s += int(string[i])
    return s


N, A, B = map(int, input().split())

s = []
for n in range(N + 1):
    if A <= some_sum(n) and some_sum(n) <= B:
        s.append(n)

print(sum(s))


Measured memory_bytes: 3396
#include <iostream>
#include <fstream>

using namespace std;

ifstream f("1.in");

long long a, b, ans;
//4, 3
//1
int biti_unu(long long x, int poz)
{
   if ((x >> (poz))%2 == 1 && x%2 == 0) return 1;
   return 0;
}

int main()
{
    cin >> a >> b;
    for (int bit = 63; bit >= 1; bit--)
    {
        int x1=biti_unu(a-1, bit);
        int x2=biti_unu(b, bit);

        ans+= ((1LL*(x1^x2)) << bit);
        //cout << x1 << " " << x2 << " ";cout << bit << " " << ans << '\n';
    }
    long long bitiA=a/2;
    long long bitiB=(b+1)/2;
    long long bitiBA=bitiB-bitiA;
    if (bitiBA%2 == 1) ans++;
//// 10101010101

    cout << ans;
    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	k := nextInt()
	s := nextLine()

	if len(s) > k {
		fmt.Println(s[:k] + "...")
		return
	}

	fmt.Println(s)
}

// =================================
// I/O util
// =================================

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 1756
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	map<string, int> mx;
	int n,mak=0,nom=0;
	cin >> n;
	int i,j,k;
	for(i = 0; i < n; ++i) {
		string s;
		cin >> s;
		++mx[s];
	}
	for(auto j : mx) {
		mak = max(mak, j.second);
	}
	for(auto k : mx) {
		if(k.second == mak)
			cout << k.first << endl;
	}
}

Measured memory_bytes: 25216
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	ll a , b ;
	cin>> a >> b ;
	if(a>=10 || b>=10){
		cout<<-1<<endl;
	}
	else{
		cout<<a*b<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
#define MOD 1000000007
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	vector <int> A(3);
	cin >> A[0] >> A[1] >> A[2];
	cout << A[0] + A[1] + A[2] - max({ A[0],A[1],A[2] });
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

int main(){
	int w, h;
	scanf("%d%d", &w, &h);
	vector<pair<int, int>> p;
	for(int i = 0; i < w; i++){
		int x;
		scanf("%d", &x);
		p.push_back(make_pair(x, 0));
	}
	for(int i = 0; i < h; i++){
		int x;
		scanf("%d", &x);
		p.push_back(make_pair(x, 1));
	}
	sort(p.begin(), p.end());
	int a = w + 1, b = h + 1;
	long long ans = 0;
	for(int i = 0; i < p.size(); i++){
		if(p[i].second == 0){
			ans += (long long)p[i].first * b;
			a--;
		}else{
			ans += (long long)p[i].first * a;
			b--;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2420
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 1987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 1000000009;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[]={-1,-2,1,-2,2,-1,2,1},ddy[]={-2,-1,-2,1,-1,2,1,2};

int n,k;
char s[100005];
int main(){
	scanf("%d%d%s",&n,&k,s);
	Vi v,ans;
	fup(i,0,n,1)if(s[i]=='0')v.pb(i);
	int now=n;
	while(now>0)
	{
		int t=*lower_bound(ALL(v),now-k);
		if(t==now)return !printf("-1");
		ans.pb(now-t);
		now=t;
	}
	fdn(i,(int)ans.size()-1,0,1)printf("%d ",ans[i]);
}

Measured memory_bytes: 1528
#include <stdio.h>
#include <algorithm>
#include <climits>

using namespace std;

#define FOR(i,a,b) for(int i=a;i<b;++i)
#define REP(i,b) FOR(i,0,b)

int a[100000];
int b[100000];
int amn=INT_MAX;
int amx=INT_MIN;
int bmn=INT_MAX;
int bmx=INT_MIN;
int n;
int c,d;
int ow = INT_MIN;
int oh = INT_MIN;

int main(){
	scanf("%d",&n);
	REP(i,n){
		scanf("%d %d",&c,&d);
		a[i] = c+d;
		b[i] = c-d;
		amn = min(amn,a[i]);
		amx = max(amx,a[i]);
		bmn = min(bmn,b[i]);
		bmx = max(bmx,b[i]);
	}
	REP(i,n){
		ow = max(ow,min(max(a[i]-amn,b[i]-bmn),max(amx-a[i],bmx-b[i])));
		oh = max(oh,min(max(a[i]-amn,bmx-b[i]),max(amx-a[i],b[i]-bmn)));
	}
	printf("%d\n",min(ow,oh));
}

Measured memory_bytes: 1808
#include<iostream>
using namespace std;
int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  while(A>0&&B>0){
    C-=B;
    A-=D;
  }
  if(C<=0){
    cout<<"Yes"<<endl;
  }else if(A<=0){
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>

constexpr int kN = int(1E3 + 10);

long long int gcd(long long int a, long long int b) {return b == 0 ? a : gcd(b, a % b);}

long long int a[kN], b[kN];

int main() {
	int n;
	long long int l = 1, r = 1, tmp, nl, nr, nnl, nnr;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%lld%lld", &a[i], &b[i]);
	for (int i = 1; i <= n; i++) {
		tmp = gcd(l, r);
		if (l / tmp == a[i] && r / tmp == b[i]) continue;
			nl = ((l - 1) / a[i] + 1) * a[i];
			nr = nl / a[i] * b[i];
			nnr = ((r - 1) / b[i] + 1) * b[i];
			nnl = nnr / b[i] * a[i];
			if (nl >= l && nr >= r) {
				if (nnl >= l && nnr >= r) {
					if (nl < nnl) {
						l = nl;
						r = nr;
					}
					else {
						l = nnl;
						r = nnr;
					}
				}
				else {
					l = nl;
					r = nr;
				}
			}
			else {
				l = nnl;
				r = nnr;
			}
	}
	printf("%lld\n", l + r);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

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(){
    ll N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    N--;
    ll dif=abs(A-B);
    bool ans=false;
    rep(i,N+1){
        ll c=i*(C+D)-N*D;
        ll d=i*(C+D)-N*C;
        if (c<=dif&&dif<=d){
            ans=true;
        }
    }
    if (ans){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

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

int main(void) {

	int n, m;
	cin >> n >> m;

	int A[n][m];
	int b[m];

	for(int i=0;i<n;i++) {
		for(int j=0;j<m;j++) {
			cin >> A[i][j];
		}
	}
	for(int i=0;i<m;i++) {
		cin >> b[i];
	}

	for(int i=0;i<n;i++) {
		int tmp = 0;
		for(int j=0;j<m;j++) {
			tmp += A[i][j] * b[j];
		}
		cout << tmp << endl;
	}

	return 0;
}

Measured memory_bytes: 1196
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] p = new int[N];

		for (int i = 0; i < N; i++) {
			p[i] = sc.nextInt();
		}

		int temp_max = p[0];
		int cnt = 1;
		for (int i = 1; i < N; i++) {
			if (temp_max > p[i]) {
				temp_max = p[i];
				cnt++;
			}
		}

		System.out.print(cnt);

		sc.close();

	}
}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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

vector<int>h(N);
REP(i, N) cin >> h[i];

int ans = 0;
while(true){
if (*max_element(h.begin(), h.end()) == 0) break;

int i = 0;
while(i < N){
    if(h[i] == 0) i++;
    else{
        ans++;
        while(i < N && h[i] > 0){
            h[i]--;
            i++;
        }
    }
}

}
print(ans);

}


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

import static java.lang.Integer.parseInt;

/**
 * Affine Cipher
 */
public class Main {

	static final char[][] hint = {{'t', 'h', 'i', 's'}, {'t', 'h', 'a', 't'}};

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = parseInt(br.readLine());

		for (int i = 0; i < n; i++) {
			String s = br.readLine();
			int[] c = cipher(s);
			char[] d = new char['z' + 1];
			for (int j = 0; j < 26; j++) {
				d[(char) (((c[0] * j + c[1]) % 26) + 'a')] = (char) (j + 'a');
			}
			StringBuilder sb = new StringBuilder();
			for (int j = 0; j < s.length(); j++) {
				if (s.charAt(j) == ' ') {
					sb.append(' ');
				} else {
					sb.append(d[s.charAt(j)]);
				}
			}
			System.out.println(sb.toString());
		}
	}

	static int[] cipher(String s) {

		int[] ret = new int[2];

		StringTokenizer st = new StringTokenizer(s);

		while (st.hasMoreTokens()) {

			String w = st.nextToken();

			if (w.length() == 4) {
				for (int a = 0; a < 26; a++) {
					if (a % 2 != 0 && a % 13 != 0) {
						for (int b = 0; b < 26; b++) {
							String h1 = "";
							String h2 = "";
							for (int i = 0; i < hint[0].length; i++) {
								h1 += (char) (((a * (hint[0][i] - 'a') + b) % 26) + 'a');
								h2 += (char) (((a * (hint[1][i] - 'a') + b) % 26) + 'a');
							}
							if (w.equals(h1) || w.equals(h2)) {
								ret[0] = a;
								ret[1] = b;
								return ret;
							}
						}
					}
				}
			}
		}

		return ret;
	}
}

Measured memory_bytes: 41024
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  cin >> N ;
  
  string S;
  
  for (int i = 0; i < N; i++){
    cin >> S;
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
  }
  if (S != "Y") cout << "Three" << endl;
}

Measured memory_bytes: 256
dp = [[-1 for i in range(6005)] for j in range(6005)]


def f(idx, time):
    if time >= T:
        return 0
    if idx >= N:
        return 0
    if dp[idx][time] != -1:
        return dp[idx][time]
    dp[idx][time] = max(f(idx+1, time), B[idx]+f(idx+1, time+A[idx]))
    return dp[idx][time]

N, T = [int(i) for i in input().split()]
data = []
A, B = [], []

for i in range(N):
    a, b = [int(j) for j in input().split()]
    data.append([a,b])
    A.append(a)
    B.append(b)

data.sort()
A, B = [], []
for i, j in data:
    A.append(i)
    B.append(j)

for idx in range(N, -1, -1):
    for time in range(T, -1, -1):
        if time == T:
            dp[idx][time] = 0
            continue
        if idx == N:
            dp[idx][time] = 0
            continue
        if A[idx]+time >= T:
            fval = 0
        else:
            fval = dp[idx+1][time+A[idx]]
        dp[idx][time] = max(dp[idx+1][time], B[idx] + fval)

print(dp[0][0])



Measured memory_bytes: 322056
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var nab = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var n = nab[0];
            var a = nab[1];
            var b = nab[2];
            var min = Math.Min(n * a, b);
            Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
int main(){
  char a,b;
  cin >> a >> b;
  puts((a==b)?"H":"D");
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dbl;
#define sqr(int) (int * int)
#define sqr3(int) (int * int * int)
#define pi M_PI
#define nl "\n"


int a;
int main() {
    cin >> a;
    cout << a + sqr(a) + sqr3(a);
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
// ----------------------R00TDADA------------------------------
#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada ios_base::sync_with_stdio(false)
#define int long long
#define M 1000000007
#define MAX 100005
int A[MAX], tree[4 * MAX];
int power(int x, int p)
{
    if (p == 0)
        return 1;
    int y = power(x, p / 2);
    y *= y;
    y %= M;
    if (p % 2 == 0)
        return y;
    y *= x;
    y %= M;
    return y;
}
void build(int node, int start, int end)
{
    if (start == end)
        //Leaf node will have a single element
        tree[node] = start;
    else
    {
        int mid = (start + end) / 2;
        //Recurse on the left child
        build(2 * node, start, mid);
        //Recurse on the right child
        build(2 * node + 1, mid + 1, end);
        // Internal node will have the sum of both of its children
        tree[node] = tree[2 * node] + tree[2 * node + 1];
    }
}
void update(int node, int start, int end, int idx, int val)
{
    if (start == end)
    {
        //Leaf Node
        A[idx] = val;
        tree[node] += val;
    }
    else
    {
        int mid = (start - end) / 2 + end;
        if (start <= idx && idx <= mid)
        {
            // If idx is in the left child, recurse on the left child
            update(2 * node, start, mid, idx, val);
        }
        else
        {
            // if idx is in the right child, recurse on the right child
            update(2 * node + 1, mid + 1, end, idx, val);
        }
        // Internal node will have the sum of both of its children
        tree[node] = tree[2 * node] + tree[2 * node + 1];
    }
}
int query(int node, int start, int end, int l, int r)
{
    if (r < start || l > end)
    {
        // range represented by a node is completely outside the given range
        return 0;
    }
    if (l <= start && end <= r)
    {
        // range represented by a node is completely inside the given range
        return tree[node];
    }
    // range represented by a node is partially inside and partially outside the given range
    int mid = (start + end) / 2;
    int p1 = query(2 * node, start, mid, l, r);
    int p2 = query(2 * node + 1, mid + 1, end, l, r);
    return p1 + p2;
}

signed main()
{

    rootdada;
    int n;
    cin >> n;
    int a[101];
    int x;
    int l = 0;
    rep(i, 1, 10)
    {
        rep(j, 1, 10)
        {
            x = i * j;
            a[l] = x;
            l++;
        }
    }
    int flag = 0;
    rep(i, 0, 101)
    {
        if (a[i] == n)
        {
            flag = 1;
        }
    }
    if (flag)
        cout << "Yes" << endl;
    else
    {
        /* code */
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef unsigned long long ll;

ll N, n, M, K;

int common_num(vector<int> v, vector<int> u){
    sort(v.begin(), v.end()); 
    sort(u.begin(), u.end()); 
    vector<int> w; 
    set_intersection(v.begin(), v.end(), u.begin(),u.end(), back_inserter(w));
    return w.size();
}

int main(){
    cin >> N >> M;
    vector<vector<int>> v(M);
    REP(i,M){
        int k ; cin >> k;
        REP(j,k) {
            int c; cin >> c;
            v[i].push_back(c-1);
        }
    }
    vector<int> p(M);
    REP(i,M){
         cin >> p[i];
    }

    int count =0;
        for (int bit = 0; bit < (1<<N); ++bit) {
          	vector<int> key;
            int num = 0;
            for (int i = 0; i < N; ++i) {
                if (bit & (1<<i) ) {
                    key.push_back(i);
                }
            }
            REP(j,M){
                if(common_num(key, v[j])%2 == p[j]) ++num;
            }
            if(num == M) ++count;
        }
    cout << count;
}

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

using namespace std;
using ll = long long;


int main()
{
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int cnt = 0;
    for(int i = 0; i < n; i+=2)if(a[i] & 1)cnt++;
    cout << cnt << endl;    
}

Measured memory_bytes: 3616
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
	char numder[100];
	int a,b,i;
	bool flg=true;
	
	cin>>a>>b;
	cin>>numder;
	for(i=0;i<a;i++){
		if(numder[i]<'0'||numder[i]>'9'){
			flg=false;
		}
	}
	if(numder[a]!='-'){
		flg=false;
	}
	for(i=a+1;i<a+b+1;i++){
		if(numder[i]<'0'||numder[i]>'9'){
			flg=false;
		}
	}
	cout<<((flg)?"Yes":"No")<<endl;
	return 0;
}

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

int main()
{
    long long n,m,i,j,k,a,b;
    cin>>n>>a>>b;
    m=abs(a-b);
   if(m%2==0){
        k=m/2;
        cout<<k<<endl;
        //long long x=abs(1-max(a,b));
        //long long y=abs(n-min(a,b));
        //cout<<min(k,min(x,y))<<endl;
    }
    else{
        long long x=abs(1-a);
        long long y=abs(n-b);
        long long z=min(x,y);
        if(z==x){
            j=x+1;
            b=b-1-x;
            i=b-1;
            j=j+(i/2);
            cout<<j<<endl;
            return 0;
        }
        j=y+1;
        a=a+y+1;
        i=(n-a);
        j=j+(i/2);
        cout<<j<<endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>A>>B;
    K = B - A;
    cout<<(K + 1)*K/2 - B<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

    if(s=="ABC") {
        cout<<"ARC"<<endl;
    }
    else {
        cout<<"ABC"<<endl;
    }
    
 return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
//	freopen("text.out","w",stdout);
	int b[50],a[50];
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&b[i]);
		a[i]=b[i];
	}
	sort(b,b+n);
	int m=0;
	for(int i=0;i<n;i++){
		if(a[i]!=b[i])
		m++;
		if(m>2){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val n: Int = io.StdIn.readInt()
  val d: Array[Int] = Array.ofDim(n)
  val f: Array[Int] = Array.ofDim(n)
  val adjacencyMatrix: Seq[Array[Int]] =
    for (_ <- (0 until n).toVector)
      yield io.StdIn.readLine().split(" ").drop(2).map(_.toInt - 1)
  (0 until n).foldLeft[Int](0)((acc, p) => if (d(p) == 0) loop(p, acc) else acc)
  for (i <- 0 until n) println(s"${i+1} ${d(i)} ${f(i)}")

  def loop(current: Int, time: Int): Int = {
    d(current) = time + 1
    f(current) =
      adjacencyMatrix(current).foldLeft[Int](d(current))(
        (acc, p) => if (d(p) == 0) loop(p, acc) else acc
      ) + 1
    f(current)
  }
}


Measured memory_bytes: 44264
import java.util.Scanner;

public class Main {
	
	static class Vec{
		int x, y;
		Vec(int x, int y){
			this.x=x;
			this.y=y;
		}
	}
	
	static double value(Vec v) {
		return Math.sqrt(v.x*v.x+v.y*v.y);
	}
	static double scalar(Vec v1, Vec v2) {
		return v1.x*v2.x+v1.y*v2.y;
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int x1=sc.nextInt();
			int y1=sc.nextInt();
			int x2=sc.nextInt();
			int y2=sc.nextInt();
			Vec p1=new Vec(x1, y1);
			Vec p2=new Vec(x2, y2);
			Vec a=new Vec(x2-x1, y2-y1);
			int q=sc.nextInt();
			for(int i=0; i<q; i++) {
				int xp=sc.nextInt();
				int yp=sc.nextInt();
				Vec b=new Vec(xp-x1, yp-y1);
				double k=scalar(a, b)/(value(a)*value(a));
				double ansx=k*a.x+p1.x;
				double ansy=k*a.y+p1.y;
				System.out.printf("%.9f %.9f\n", ansx, ansy);
			}

		}
	}
}


Measured memory_bytes: 38408
let x = require('fs').readFileSync('/dev/stdin', 'UTF-8');
x = parseInt(x);


let surplus1 = x%3600;
let hour = (x-surplus1)/3600;
var surplus2 = surplus1%60;
let minite = (surplus1-surplus2)/60;

let second = surplus2;

console.log(hour + ":" + minite + ":" + second);



Measured memory_bytes: 15132
/*
負の閉路が存在しない場合に使える
O(FElogV)

参考:
蟻本p202
https://ei1333.github.io/luzhiled/snippets/graph/primal-dual.html

verify:
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_B&lang=jp
*/

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

template<typename flow_t,typename cost_t>
struct PrimalDual{
    struct edge{
        int to;
        flow_t cap;
        cost_t cost;
        int rev;
        bool isrev;
    };
    const cost_t inf;

    vector<vector<edge>> g;
    vector<cost_t> h,dist;
    vector<int> prevv,preve;

    PrimalDual(int N,cost_t inf_):g(N),inf(inf_){}

    void add_edge(int from,int to,flow_t cap,cost_t cost){
        g[from].emplace_back((edge){to,cap,cost,(int)g[to].size(),false});
        g[to].emplace_back((edge){from,0,-cost,(int)g[from].size()-1,true});
    }

    //fを流すのが不可能だったらinfを返す
    cost_t query(int s,int t,flow_t f){
        int N=g.size();
        cost_t ret=0;
        using pci=pair<cost_t,int>;
        priority_queue<pci,vector<pci>,greater<pci>> que;
        h.assign(N,0);
        preve.assign(N,-1);
        prevv.assign(N,-1);

        while(f>0){
            dist.assign(N,inf);
            que.emplace(0,s);
            dist[s]=0;
            while(!que.empty()){
                pci now=que.top(); que.pop();
                if(dist[now.second]<now.first) continue;
                for(int i=0;i<g[now.second].size();i++){
                    const edge &e=g[now.second][i];
                    cost_t nextCost=dist[now.second]+e.cost+h[now.second]-h[e.to];
                    if(e.cap>0 and dist[e.to]>nextCost){
                        dist[e.to]=nextCost;
                        prevv[e.to]=now.second; preve[e.to]=i;
                        que.emplace(nextCost,e.to);
                    }
                }
            }
        
            if(dist[t]==inf) return inf;
            for(int v=0;v<N;v++) h[v]+=dist[v];
            
            flow_t addflow=f;
            for(int v=t;v!=s;v=prevv[v]){
                addflow=min(addflow,g[prevv[v]][preve[v]].cap);
            }
            f-=addflow;
            ret+=addflow*h[t];
            for(int v=t;v!=s;v=prevv[v]){
                edge &e=g[prevv[v]][preve[v]];
                e.cap-=addflow;
                g[v][e.rev].cap+=addflow;
            }
        }
        return ret;
    }
};

int main(){
    int N,E,F;
    cin>>N>>E>>F;
    PrimalDual<int,int> flow(N,1<<30);
    for(int i=0;i<E;i++){
        int s,t,cap,cost;
        cin>>s>>t>>cap>>cost;
        flow.add_edge(s,t,cap,cost);
    }
    int x=flow.query(0,N-1,F);
    if(x==(1<<30)) x=-1;
    cout<<x<<"\n";
}


Measured memory_bytes: 3236
def resolve():
    n, x = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    for i in range(n):
        if x >= a[i]:
            x -= a[i]
            a[i] = 0
    ans = a.count(0)
    if x and all(ai == 0 for ai in a):
        ans -= 1
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 38384
#include <iostream> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <cmath> 
#include <algorithm>
#include <map> 
using namespace std; 
inline int gi() { 
    int data = 0, w = 1; 
    char ch = 0; 
    while (!isdigit(ch) && ch != '-') ch = getchar(); 
    if (ch == '-') w = -1, ch = getchar(); 
    while (isdigit(ch)) data = 10 * data + ch - '0', ch = getchar();
    return w * data; 
} 
const int MAX_N = 2e5 + 5; 
int N, a[MAX_N]; 
map<int, int> mp;
long long ans = 0; 
int main () { 
	N = gi(); 
	for (int i = 1; i <= N; i++) a[i] = gi(); 
	for (int i = 1; i <= N; i++) {
		int x = a[i] - i; 
		if (mp.find(x) != mp.end()) ans += mp[x]; 
		mp[-a[i] - i]++; 
	} 
	cout << ans << endl; 
    return 0; 
} 

Measured memory_bytes: 13344
/*
    A - Five Variables
    https://atcoder.jp/contests/abc170/tasks/abc170_a
*/

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define ll long long // 10 ^ 18
#define forn(i, s, n) for (int i = s; i < n; i++)
#define whilen(val, n) while(n-- && cin >> val)
#define r_1(v) cin >> v
#define r_2(v1, v2) cin >> v1 >> v2

int main() {
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    int xs[5];
    int x, n = 5;

    forn(i, 0, n) {
        r_1(x);
        if (x == 0) {
            cout << i + 1;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
#define pi 3.14159265358979323846
#define int ll
#define IL inline
#define RG register
#define rep(i,a,b) for(RG int i=(a);i<(b);++i)
#define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
#define Dep(i,a,b) for(RG int i=(a);i>=(b);--i)
#define pc putchar
#define gc getchar
IL ll read(){
    RG ll x=0;char f=0;RG char c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return f?-x:x;
}
IL double readdb(){
    RG double x=0,p=0.1;RG char f=0,c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=x*10+(c^48);
    if(c=='.')for(c=gc();isdigit(c);c=gc(),p/=10)x=x+(c^48)*p;
    return f?-x:x;
}
IL void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);pc(x%10+'0');}
IL void writeln(ll x){write(x);puts("");}
IL void writeln(ll x,char c,ll y){write(x);pc(c);writeln(y);}
IL void writeln(ll x,char c,ll y,char d,ll z){write(x);pc(c);write(y);pc(d);writeln(z);}
#define debug(x) printf(#x" = %d\n",x);
#define rd() read()
#define rdb() readdb()
#define mem(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define fin(x) freopen(#x".in","r",stdin)
#define fout(x) freopen(#x".out","w",stdout)
#define y1 ____y1
#define hash __hash
#define union _union
const int Mod = 998244353;
const int maxn = 3e5+233;
int fac[maxn],inv[maxn];
int qpow(int a,int b){
	int ans = 1;
	for(;b;b>>=1,a=1ll*a*a%Mod)
		if(b&1) ans=1ll*ans*a%Mod;
	return ans;
}
int C(int n,int m){
	return 1ll * fac[n] * inv[m] % Mod * inv[n-m] % Mod;
}
int n,ans=0,A,B,k;
signed main(){
	n = rd(),A = rd(),B = rd(),k = rd();
	fac[0] = 1;
	Rep(i,1,n) fac[i] = 1ll * fac[i-1] * i % Mod;
	inv[n] = qpow(fac[n],Mod-2);
	Dep(i,n-1,0) inv[i] = 1ll * inv[i+1] * (i+1) % Mod;
	for(int i = 0;i*A <= k;i ++){
		if((k-i*A)%B) continue;
		int j = (k-i*A) / B;
		if(i>n || j>n) continue;
		//i个，或者j个
	//	printf("(%d %d)\n",i,j);
		(ans += 1ll * C(n,i) * C(n,j) % Mod)%=Mod;
	}
	writeln(ans);
	return 0;
}

Measured memory_bytes: 4992