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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int k;
  cin >> k;
  
  vector<ll> a(k);
  for (int i = 0; i < k; i++) cin >> a.at(i);
  
  ll l = 0, r = 1e18;
  while (r - l > 1) {
    ll mid = (l + r) / 2, now = mid;
    for (int i = 0; i < k; i++) {
      now -= now % a.at(i);
    }
    if (now >= 2) r = mid;
    else l = mid;
  }
  ll x = r;
  
  l = 0;
  r = 1e18;
  while (r - l > 1) {
    ll mid = (l + r) / 2, now = mid;
    for (int i = 0; i < k; i++) {
      now -= now % a.at(i);
    }
    if (now > 2) r = mid;
    else l = mid;
  }
  ll y = l;
  
  if (x > y) cout << "-1\n";
  else cout << x << " " << y << '\n';
}

Measured memory_bytes: 1024
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto nab = readln.split.to!(int[]);
    auto N = nab[0];
    auto A = nab[1];
    auto B = nab[2];

    if (A == 1 && B == N) {
        writeln(1.iota(N+1).array.reverse.to!(string[]).join(" "));
        return;
    } else if (A == N && B == 1) {
        writeln(1.iota(N+1).array.to!(string[]).join(" "));
        return;
    }

    bool rev;
    if (N-A >= B-1 && (N+A-1)/A <= B) {
        rev = false;
    } else if (N-B >= A-1 && (N+B-1)/B <= A) {
        rev = true;
        swap(A, B);
    } else {
        writeln(-1);
        return;
    }
    auto r = N-A;
    int x;
    while (r-A + x+1 > B-1) {
        r -= A;
        x += 1;
    }
    int d;
    if (r+x > B-1) {
        d = r + x+1 - (B-1);
        r -= d;
    }
    int[] res;
    int i = N;
    if (r) {
        res ~= (N-r+1).iota(N+1).array.reverse;
        i -= r;
    }
    if (d) {
        foreach_reverse (j; 0..d) res ~= i-j;
        i -= d;
    }
    foreach (_x; 0..x+1) {
        foreach_reverse (j; 0..A) res ~= i-j;
        i -= A;
    }
    if (rev) res = res.reverse.array;
    writeln(res.to!(string[]).join(" "));
}

Measured memory_bytes: 16108
// 

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  int n;
  vector<int> v;
  long long sum = 0;
  long long ans = 0;

  cin >> n;
  for(int i = 0; i < n; i++){
    int work;
    cin >> work;
    v.push_back(work);
  }
  // sum = v[0];

  int r = 0;
  for(int l = 0; l < n; l++){
    while(r < n){
      if((sum ^ v[r]) != (sum + v[r])) break;
      // cout << "L:" << l << " R:" << r << endl;
      sum += v[r];
      r++;
    }
    ans += r - l;
    if(r != l) sum -= v[l];
    else r++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <type_traits>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std;
using namespace placeholders;

using LL = long long;
using ULL = unsigned long long;
using VI = vector< int >;
using VVI = vector< vector< int > >;
using VS = vector< string >;
using ISS = istringstream;
using OSS = ostringstream;
using PII = pair< int, int >;
using VPII = vector< pair< int, int > >;
template < typename T = int > using VT = vector< T >;
template < typename T = int > using VVT = vector< vector< T > >;
template < typename T = int > using LIM = numeric_limits< T >;

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define NUMBERED( name, number ) NUMBERED2( name, number )
#define NUMBERED2( name, number ) name ## _ ## number
#define REP1( n ) REP2( NUMBERED( REP_COUNTER, __LINE__ ), n )
#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2, REP1 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &&e : c )
#define ALL( c ) begin( c ), end( c )
#define AALL( a ) ( remove_all_extents< decltype( a ) >::type * )a, ( remove_all_extents< decltype( a ) >::type * )a + sizeof( a ) / sizeof( remove_all_extents< decltype( a ) >::type )
#define DRANGE( c, p ) begin( c ), begin( c ) + ( p ), end( c )

#define SZ( v ) ( (int)( v ).size() )
#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

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

#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

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

	int N;
	scanf( "%d", &N );

	static int A[ 1 << 17 ];
	REP( i, N )
	{
		scanf( "%d", A + i );
	}

	puts( count_if( ALL( A ), bind( modulus< int >(), _1, 2 ) ) % 2 ? "NO" : "YES" );

	return 0;
}


Measured memory_bytes: 640
from collections import defaultdict

n, m = map(int, input().split())
ps = [list(input().split()) for _ in range(m)]

cnt = defaultdict(int)
d = defaultdict()

for p, s in ps:
    if s == "AC":
        if d.get(p) is None:
            d[p] = cnt[p]
    else:
        cnt[p] += 1

correct = 0
pena = 0
for k, v in d.items():
    correct += 1
    pena += v

print(correct, pena)


Measured memory_bytes: 41936
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		ArrayDeque<Long> deq = new ArrayDeque<>();
		for(long i=1;i<10;i++) {
			deq.offer(i);
		}
		long cnt = 9;
		while(cnt <=K) {
			long n = deq.poll();
			if (n%10!=0) {
				deq.offer(n*10+n%10-1);
				cnt++;
				if(cnt==K) {
					break;
				}
			} 
			deq.offer(n*10+n%10);
			cnt++;
			if(cnt==K) {
				break;
			}
			if (n%10!=9) {
				deq.offer(n*10+n%10+1);
				cnt++;
				if(cnt==K) {
					break;
				}
			} 
			
		}
		if(K<=9) {
			System.out.println(K);
		}else {
			System.out.println(deq.pollLast());	
		}
	}

}

Measured memory_bytes: 25940
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		String s = sc.next();
		String c[] = s.split("");


		// 計算
		int happy = 0;
		int lr = 0;
		int rl = 0;
		for(int i = 0; i < n; i++){
		    /*
		    if(i == 0 && c[i].equals("L")){
		        rl++;
		    }
		    if(i == n - 1 && c[i].equals("R")){
		        rl++;
		    }*/
		    
		    if(i > 0){
		        if(c[i - 1].equals(c[i])){
		            happy++;
		        }else{
		            if(c[i].equals("R")){
		                lr++;
		            }else{
		                rl++;
		            }
		        }
		    }
		}
		int result = happy + min(min(lr, rl), k)*2;
		if(abs(lr - rl) > 0 && k - min(lr, rl) > 0) result++;

		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 33456
using System.Collections.Generic;
using System.Linq;
using static System.Console;
class K
{
	static void Main()
	{
		var I = ReadLine().Split().Select(int.Parse).ToArray();
		int N = I[0], A = I[1], B = I[2];
		if (BitCount(A ^ B) % 2 == 0) { WriteLine("NO"); return; }
		WriteLine("YES");
		WriteLine(string.Join(" ", Generate(N, A, B)));
	}
	static IEnumerable<int> Generate(int N, int A, int B)
	{
		if (N == 1) return new[] { A, B };
		B ^= A;
		var c = BitCount(B);
		int[] p = new int[N], q = new int[N];
		int o = N - 1, z = 0;
		for (var i = 0; i < N; i++) q[p[i] = (B & (1u << i)) != 0 ? o-- : z++] = i;
		B = ((1 << c) - 1) << (N - c);
		var l = new List<int>();
		var M = 1 << (N - 1);
		for (var i = 0; i < M; i++) l.Add(i ^ (i >> 1));
		foreach (var i in Generate(N - 1, 1 << (N - 2), B ^ M)) l.Add(i ^ M);
		return l.Select(x =>
		{
			var s = 0;
			for (var j = 0; j < N; j++) if ((x & (1u << j)) != 0) s |= 1 << q[j];
			return s ^ A;
		});
	}
	static int BitCount(int n)
	{
		n = (n & 0x55555555) + ((n >> 1) & 0x55555555);
		n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
		n = (n & 0x0f0f0f0f) + ((n >> 4) & 0x0f0f0f0f);
		n = (n & 0x00ff00ff) + ((n >> 8) & 0x00ff00ff);
		return (n & 0x0000ffff) + ((n >> 16) & 0x0000ffff);
	}
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n, a;
  cin >> n;
  int ans = 0;
  for(int i = 0; i < n; ++i)
  {
    cin >> a;
    while(a % 2 == 0)
    {
      a /= 2;
      ans++;
    }
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3624
#include<string>
#include<iostream>
class Cube{	
public:
	long long plane[6];
	void North(){
		int buf = plane[1-1];
		plane[1-1] = plane[6-1];
		plane[6-1] = plane[3-1];
		plane[3-1] = plane[5-1];
		plane[5-1] = buf;
	}
	void East(){
		int buf = plane[2-1];
		plane[2-1] = plane[5-1];
		plane[5-1] = plane[4-1];
		plane[4-1] = plane[6-1];
		plane[6-1] = buf;
	}
	void West(){
		int buf = plane[2-1];
		plane[2-1] = plane[6-1];
		plane[6-1] = plane[4-1];
		plane[4-1] = plane[5-1];
		plane[5-1] = buf;
	}
	void South(){
		int buf = plane[1-1];
		plane[1-1] = plane[5-1];
		plane[5-1] = plane[3-1];
		plane[3-1] = plane[6-1];
		plane[6-1] = buf;
	}
	void Right(){
		int buf = plane[1-1];
		plane[1-1] = plane[2-1];
		plane[2-1] = plane[3-1];
		plane[3-1] = plane[4-1];
		plane[4-1] = buf;
	}
	void Left(){
		int buf = plane[1-1];
		plane[1-1] = plane[4-1];
		plane[4-1] = plane[3-1];
		plane[3-1] = plane[2-1];
		plane[2-1] = buf;
	}
};
using namespace std;
int main(){
	Cube dice;
	int n,num;
	string trend;
	while(1){

		dice.plane[1-1]=2;
		dice.plane[2-1]=3;
		dice.plane[3-1]=5;
		dice.plane[4-1]=4;
		dice.plane[5-1]=1;
		dice.plane[6-1]=6;

		num=0;
		num+=dice.plane[4];
		
		cin >> n;
		
		if(n==0)break;
		
		for(int i=0;i<n;i++){
			cin >> trend;
		
			if(trend=="North"){
				dice.North();
			}else if(trend=="East"){
				dice.East();
			}else if(trend=="West"){
				dice.West();
			}else if(trend=="South"){
				dice.South();
			}else if(trend=="Right"){
				dice.Right();
			}else if(trend=="Left"){
				dice.Left();
			}
			num+=dice.plane[4];
		}
		cout << num << endl;
	}
	cin >> n;
}

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

/*
,,,,
　　　　　　　　　　　　　　　　　　　　　　　　　　,.斗*''“i:i:{
　　　　　　　　　　　　　,.　｡. . . * : : : ''' : : : :” :”“ ''ｰ - 弋,,_
　　　　　 　 　 ,.斗*''“ : : : : : : : : : : : : : ' ' ' ' ' ' : : : : : : : : : : :”: '':* ｡ ,
　　　 ,.斗*''“ ” ＼：　　 ”・・． ' ' ' '　　　　　　　　 ' ' ' ' : : : : : : : : : : : : ”ミ*｡,,,,,,　　　　　　 　 　 　 ＿
　　く.　 ◎　 ﾞ:.ﾞ:..　ﾟ:,　:　───────────　　　--　　,,,,,,__ ' ' ' :.:.:.:.:.”≧s｡.　　＿,,,｡s*i:i:i:i:<
　　ﾏ*s｡ :,　 }　ﾟ:,　 :}　　　　　　　　　　　　　　　　　　　　　　　　　　　　”　''　-　”””：：”：：`*｡i:i:i:i:i:i:i;:’
　　　` .｡`　 ,　,ノ ／｡ ,,,_　　　　　　　　　　　　　　　　　　　　　　　　　　　　　＿＿`　　} }　　ﾉi:i:i:i:i:ﾂ
　　　　　 `　*　｡　　`*｡i:i:i::*=-　　　　　　　　　　　＿＿　　　　　　,,,....｡s*'i,:’　　　”`*｡＿,*’i:i:i:i:r’
　　　　　　　　　　　”　─ --　　　　｡｡｡｡｡　　 -　－`''''''''ヽ ─ '''”　　　｀ｰ“　　　　　　　`*｡i:i:i:i:i:i:
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*｡i:i:::
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*ﾟ:,
         fozubaoyou    no BUGs alive!
*/

typedef long long ll;
//{
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define dumo dump
#define sysp system("pause")
//}

#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cout<<endl;}
template<class...A> inline void debug_rest() {cout<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cout<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cout<<first,debug_rest(rest...);}
inline long long digitsum(long long v){long long d=0;while(v){d+=v%10;v/=10;}return d;};
//}

int n,ans;

int main(){
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=n-1;i>=0;i-=2){
		cout<<a[i]<<' ';
	}
	if(n%2==1){
		for(int i=1;i<n;i+=2){
			cout<<a[i]<<' ';
		}
	}else{
		for(int i=0;i<n;i+=2){
			cout<<a[i]<<' ';
		}
	}
	cout<<endl;
	sysp;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n,k;
	string s;
	cin >> n >> s >> k;
	char c = s[k-1];
	for (int i = 0; i < n; i++) {
		if (s[i] != c) {
			s[i] = '*';
		}
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int N,X,T,x,y;
  cin>>N>>X>>T;
  if(N>X)
  {
    x=N/X;
    y=N%X;
    if(y>0)
      x++;
    cout<<x*T;
  }
  else
  {
    cout<<T;
  }
}

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

int main(){
  int n;
  cin >> n;
  vector<int> h(n), dp(n);
  for(int i=0; i<n; i++){
    cin >> h[i];
    dp[i] = 0;
  }
  
  for(int i=0; i<n; i++){
    if(i==0){
      dp[i] = 0;
      continue;
    }
    if(i==1){
      dp[i] = abs(h[i-1] - h[i]);
      continue;
    }
    int c1, c2;
    c1 = dp[i-1] + abs(h[i-1] - h[i]);
    c2 = dp[i-2] + abs(h[i-2] - h[i]);
    dp[i] = min(c1, c2);
  }
  cout << dp[n-1] << endl;
  
  return 0;
}

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

#define ll long long

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;

    int a[n+1];

    int count = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        if (a[i] >= k) count++;
    }

    cout << count << endl;

    return 0;
}



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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> h(n, 0);
  for (int i = 0; i < n; i++) {
    int h_;
    cin >> h_;
    h[i] = h_;
  }
  vector<int> dp(n);
  dp[0] = 0;
  for (int i = 1; i < n; i++) {
    int minv = 1e9;
    for (int j = 1; j <= min(k, i); j++) {
      minv = min(minv, dp[i - j] + abs(h[i] - h[i - j]));
    }
    dp[i] = minv;
  }
  cout << dp[n - 1] << '\n';
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define INS(x) (x).begin(),(x).end()
#define gcd(x,y) __gcd((x),(y))


struct Edge
{
    int v;
    int next;
}edge[1000005];

int head[200005];
int cnt;
bool vis[200005];    //有无访问
unsigned int f[200005];    //存最短路

void add(int u,int v)
{
    cnt++;
    edge[cnt].v=v;
    edge[cnt].next=head[u];
    head[u]=cnt;
}


int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,m;
    cin>>n>>m;

    for (int i=1;i<=n;i++)
        cin>>f[i];
    
    int cnt=0;
    for (int i=1;i<=m;i++)
    {
        int u,v;
        cin>>u>>v;
        add(u,v);
        add(v,u);
    }

    int ans=0;
    for (int i=1;i<=n;i++)
    {
        int pd=0;
        for (int j=head[i];j;j=edge[j].next)
        {
            if (f[edge[j].v]>=f[i]) {pd=1; break;}
        }
        if (!pd) ans++;
    }

    cout<<ans<<'\n';

    return 0;
}

Measured memory_bytes: 5964
#include <iostream>
#include <climits>
#include <memory.h>
#include <random>
#include <ctime>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <bitset>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
#ifdef LOCAL
    #define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
    #define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*++++++++++++++++++++++++++++++++++++coding area start+++++++++++++++++++++++++++++++++++++++++*/
const int mod = 998244353;
const int MAXN = 3e5 + 10;
LL pw[MAXN], inv[MAXN], fact[MAXN];
LL pwer(LL base, int p) {
    LL ret = 1;
    while (p) {
        if (p&1) ret = ret * base % mod;
        p >>= 1;
        base = base * base % mod;
    }
    return ret;
}

LL combine(int n, int k) {
    LL ret = fact[n];
    ret = ret * inv[k] % mod;
    ret = ret * inv[n-k] % mod;
    return ret;
}
LL combine(int n, int a, int b) {
    LL ret = fact[n];
    ret = ret * inv[a] % mod;
    ret = ret * inv[b] % mod;
    ret = ret * inv[n-a-b] % mod;
    return ret;
}



/*-------------------------------------coding area end------------------------------------------*/
int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.precision(10); cout << fixed;
    #ifdef LOCAL
        freopen("../test.txt", "r", stdin);
//        freopen("../output.txt", "w", stdout);
    #endif
/*++++++++++++++++++++++++++++++++++++coding area start+++++++++++++++++++++++++++++++++++++++++*/
    LL n, a, b, k;
    cin >> n >> a >> b >> k;
    LL ret = 0;
    pw[0] = fact[0] = 1;
    for (int i = 1; i < MAXN; i++) {
        fact[i] = fact[i-1] * i % mod;
        pw[i] = pw[i-1] * 2 % mod;
    }
    inv[MAXN-1] = pwer(fact[MAXN-1], mod-2);
    for (int i = MAXN - 2; i >= 0; i--) {
        inv[i] = inv[i+1] * (i+1) % mod;
    }
    if (a == b) {
        if (k % a != 0) {
            cout << 0 << endl;
            return 0;
        }
        LL tot = k / a;
        for (int i = 0; i <= n && 2*i <= tot; i++) {
            if (tot - i > n) continue;
            LL tmp = combine(n, i, tot-2*i) * pw[tot-2*i] % mod;
            ret = (ret + tmp) % mod;
        }
        cout << ret << endl;
        return 0;

    }
    for (LL x = 0; x <= 2*n; x++) {
        LL delta = x * a - k;
        if (delta % (a-b) != 0) continue;
        LL d = delta / (a-b);
        if (d > n || d < 0) continue;
        LL c = x - d;
        if (c > n || c < 0) continue;
        LL tmp = (combine(n, c) * combine(n, d)) % mod;
        ret = (ret + tmp) % mod;
    }
    cout << ret << endl;




/*-------------------------------------coding area end------------------------------------------*/

    #ifdef LOCAL
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
    #endif
    return 0;
}
/* author:  txingml */


Measured memory_bytes: 7424
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>
#include <numeric>
using namespace std;


int main()
{
	unsigned int n, k;
	cin >> n >> k;
	int* h;
	h = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	if (n <= k) {
		cout << 0;
		return 0;
	}

	sort(h, h + n);
	unsigned long a = 0;
	for (int i = 0; i < n - k; i++) {
		a += h[i];
	}
	cout << a;
}


Measured memory_bytes: 1024
import copy
n = int(input())
lst =[]
for i in range(n):
    x = int(input())
    lst.append(x)

lst2 = copy.deepcopy(lst)
lst2.sort()
max = max(lst2)
for x in lst:
    if x == max:
        print(lst2[-2])
    else:
        print(max)

Measured memory_bytes: 19248
#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>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
  if (n == 0) return 1;
  mint x = f(n/2);
  x *= x;
  if (n%2 == 1) x *= 2;
  return x;
}

mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,a) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  mint ans = f(n);
  ans -= 1;
  ans -= choose(n,a);
  ans -= choose(n,b);
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 3600
#Python Template

from sys import stdin, stdout

dp = {0:1, 1:0, 2:0, 3:1}
prime = 10**9 + 7

def q(n):
	if n in dp:
		return dp[n]
	else:
		total = 0
		for i in range(3, n+1):
			total += q(n-i)
			total %= prime
		dp[n] = total
		return total

def main():
	s = int(stdin.readline())
	print(q(s))
	

main()

Measured memory_bytes: 9508
#include <bits/stdc++.h>
typedef long long LL;
#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)

using namespace std;
int main(void)
{
  for(;;){
    int d,e;
    cin >> d >> e;
    if(!d) return 0;
    double answer=1e+5;
    REP(i,d) answer=min(answer,abs(e-sqrt(i*i+(d-i)*(d-i))));
    cout << answer << endl;
  }
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll MOD = pow(10,9)+7;

int main()
{
  int n;
  cin >> n;
  int h;
  cin >> h;
  int cnt=1,tmp=h;
  for(int i=1; i<n; i++)
  {
    cin >> h;
    if(h>=tmp){
      cnt++;
      tmp = h;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
using namespace std;
int main(){
  int n,t,ans=100000;
  cin>>n>>t;
  vector<pair<int,int>>value(n);
  for(auto& e:value)cin>>e.first>>e.second;
  for(auto& e:value)if(e.first<ans&&e.second<=t)ans=e.first;
  if(ans!=100000)cout<<ans<<endl;
  else cout<<"TLE"<<endl;
}

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

int main()
{
    int n,m,i,j;
    cin >> n >> m;
    vector<int> k(m);
    vector<vector<int>> s(m,vector<int>(n));
    for(i = 0;i < m;++i){
        cin >> k.at(i);
        for(j = 0;j < k.at(i);++j){
            cin >> s.at(i).at(j);
        }
    }
    vector<int> p(m);
    for(i = 0;i < m;++i){
        cin >> p.at(i);
    }
    int bit;
    int ans = 0;
    vector<int> t(n);
    int l,x;
    int temp = 0;
    bool bitflag;
    for(bit = 0;bit < (1 << n);++bit){
        for(i = 0;i < n;++i){
            if(bit & (1 << i)){
                t.at(i) = 1;
            }else{
                t.at(i) = 0;
            }
        }
        for(l = 0;l < m;++l){
            temp = 0;
            for(x = 0; x < k.at(l);++x){
                if(t.at(s.at(l).at(x)-1) == 1){
                    ++temp;
                }
            }
            if(temp%2 == p.at(l)){
                bitflag = true;
                continue;
            }else{
                bitflag = false;
                break;
            }
        }
        if(bitflag){
            ++ans;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>

using namespace std;

class Edge{
public:
	int p, q; double cost;
	Edge(int p, int q, double cost) : p(p), q(q), cost(cost) {}
	bool operator < (const Edge &e) const { return cost > e.cost; }
};

const int INF = 10000000;
int cap[202][202];
double cost[202][202];

int maximumFlow(int s, int t, int n, double upper){
	int res = 0;
	while(true){
		vector<int> prev(n,-1); prev[s] = 0;
		queue<int> qu; qu.push(s);
		while(!qu.empty()){
			int e = qu.front(); qu.pop();
			for(int i=0;i<n;i++){
				if(cost[e][i] > upper) continue;
				if(cap[e][i]>0&&prev[i]<0){
					prev[i] = e;
					qu.push(i);
				}
			}
		}
		if(prev[t]<0) return res;
		for(int i=t;i!=prev[i];i=prev[i]) cap[prev[i]][i]--, cap[i][prev[i]]++;
		res++;
	}
	return res;
}

int main(){
	int n, m;
	while(cin >> n >> m, n){
		int x[100], y[100], v[100], xx[100], yy[100];
		vector<double> dst;
		int capa[202][202];
		memset(capa, 0, sizeof(capa));
		for(int i=0;i<n;i++) cin >> x[i] >> y[i] >> v[i];
		for(int i=0;i<m;i++) cin >> xx[i] >> yy[i];
		for(int i=1;i<=n;i++) capa[0][i] = 1;
		for(int i=1;i<=n;i++){
			for(int j=n+1;j<=n+m;j++) capa[i][j] = 1;
		}
		for(int j=n+1;j<=n+m;j++) capa[j][n+m+1] = 1;
		for(int i=0;i<n+m+2;i++)
			for(int j=0;j<n+m+2;j++) cost[i][j] = 0;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				double dx = x[i]-xx[j];
				double dy = y[i]-yy[j];
				cost[i+1][n+j+1] = sqrt(dx*dx+dy*dy)/v[i];
				dst.push_back(cost[i+1][n+j+1]);
				cost[n+j+2][i+1] = -cost[i+1][i+j+2];
			}
		}
		sort(dst.begin(), dst.end());
		int L = 0, R = dst.size()-1;
		while(L!=R){
			int mid = (L+R)/2;
			memcpy(cap, capa, sizeof(capa));
			if(maximumFlow(0, n+m+1, n+m+2, dst[mid])==m) R = mid;
			else L = mid + 1;
		}
		printf("%.8lf\n",dst[L]); 
	}
}

Measured memory_bytes: 1796
#include <iostream>
#include <stdlib.h>
#include <string>
#include <cstdlib> 
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    //cout << s[6]  +0<< endl;
    int a,b;
    if(s[5] >= 49 || s[6] >= 53 )
    {
    cout << "TBD"<<endl;
    }
    else
    {
        cout << "Heisei" << endl;
    }
}

Measured memory_bytes: 256
program main
integer :: n,i
real :: ans
real,allocatable :: a(:)
read *,n
allocate(a(n))
read *,a

call quicksort(a,1,n)

do i = 1,n-1
	a(i+1) = (a(i) + a(i+1))/2
end do

print *,a(n)
contains
recursive subroutine quicksort(a, first, last)
  implicit none
  real  a(*)
  integer first, last
  integer i, j
  real*8  x, t
  
  x = a( (first+last) / 2 )
  i = first
  j = last
  do
     do while (a(i) < x)
        i=i+1
     end do
     do while (x < a(j))
        j=j-1
     end do
     if (i >= j) exit
     t = a(i);  a(i) = a(j);  a(j) = t
     i=i+1
     j=j-1
  end do
  if (first < i - 1) call quicksort(a, first, i - 1)
  if (j + 1 < last)  call quicksort(a, j + 1, last)
end subroutine quicksort
end program

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

int dp1[5000][5000], dp2[5000][5000];

signed main() {
  int N, T;
  cin >> N >> T;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < T; j++) {
      dp1[i + 1][j] = max(dp1[i + 1][j], dp1[i][j]);
      if (j + A[i] < T) {
        dp1[i + 1][j + A[i]] = max(dp1[i + 1][j + A[i]], dp1[i][j] + B[i]);
      }
    }
  }

  reverse(A.begin(), A.end());
  reverse(B.begin(), B.end());

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < T; j++) {
      dp2[i + 1][j] = max(dp2[i + 1][j], dp2[i][j]);
      if (j + A[i] < T) {
        dp2[i + 1][j + A[i]] = max(dp2[i + 1][j + A[i]], dp2[i][j] + B[i]);
      }
    }
  }

  reverse(A.begin(), A.end());
  reverse(B.begin(), B.end());

  int ans = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j < T; j++) {
      ans = max(ans, dp1[i - 1][j] + dp2[N - i][T - 1 - j] + B[i - 1]);
    }
  }

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

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

signed main()
{   
    gearup;
    int n; cin >> n;
    vector<int> a(n),b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    ll res = 0;
    rep(i,n){
        if(a[i] > b[i]){
            res += a[i] - b[i];
        }
    }
    cout << res << endl;
    

}

Measured memory_bytes: 384
h,w=map(int,input().split())
a,c=[],[]
for i in range(h):
    a.append(input())
for i in range(w):
    b=0
    for j in range(h):
        if a[j][i]=='#':
            b=1
    c.append(b)
for i in range(h):
    if a[i]=='.'*w:
        continue
    for j in range(w):
        if c[j]==1:
            print(a[i][j],end='')
    print('')

Measured memory_bytes: 4468
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{BufWriter, Write};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! { s: chars }
    let n = s.len();
    //xxかxyxという文字列のみで構成されなければいけない
    for i in 0..(n - 1) {
        if s[i] == s[i + 1] {
            puts!("{} {}\n", i + 1, i + 2);
            return;
        }
    }
    for i in 0..(n - 2) {
        if s[i] == s[i + 2] {
            puts!("{} {}\n", i + 1, i + 3);
            return;
        }
    }
    puts!("-1 -1");
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2404
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

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

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////
LL f(vector<LL> A) {
	LL ans = abs(A[0]) + abs(A[1]) + abs(A[2]);
	return ans;
}

LL fn(vector<LL> A,int K) {
	LL ans = 0;
	for (int  k= 0; k < 3; ++k) {
		if (K & (1 << k)) {
			ans -= A[k];
		}
		else {
			ans += A[k];
		}
	}
	
	return ans;
}
vector<LL> V(vector<LL>& A, vector<LL>& B) {
	vector<LL> ans(3);
	for (int i = 0; i < 3; ++i) {
		ans[i] = A[i] + B[i];
	}
	return ans;
}
void solve() {
	int N, M;
	cin >> N >> M;
	vector<vector<LL>> X(N,vector<LL>(3));
	for (int i = 0; i < N; ++i) {
		cin >> X[i][0] >> X[i][1] >> X[i][2];
	}
	///N個中M個食べる。
	//合計の絶対値
	vector<LL> AAA = { LINF,LINF,LINF };
	vector<vector<vector<vector<LL>>>> dp(N+1,
		vector<vector<vector<LL>>>(M+1, vector<vector<LL>>(8,
			vector<LL>(AAA))));
	for (int k = 0; k < (1 << 3); ++k) {
		dp[0][0][k] = { 0,0,0 };
	}
	
	for (int i = 1; i <=N; ++i) {
		for (int m = 0; m <=M; ++m) {
			for (int k = 0; k < (1 << 3); ++k) {
				if (dp[i-1][m][k] != AAA) {
					dp[i][m][k] = dp[i-1][m][k];
				}

				if (m > 0 && dp[i - 1][m - 1][k] != AAA) {
					vector<LL> temp;
					temp = V(dp[i-1][m-1][k], X[i-1]);
					if (dp[i][m][k] == AAA) {
						dp[i][m][k] = temp;
					}
					else if(fn(dp[i][m][k],k)<fn(temp,k)){
						dp[i][m][k] = temp;
					}
				}
			}
		}
	}
	//f
	LL ans = 0;
	for (int k = 0; k < (1 << 3); ++k) {
		if (dp[N][M][k] != AAA) {
			chmax(ans, f(dp[N][M][k]));
		}
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 478336
#include <algorithm>
#include <iostream>
#include <memory>
#include <stdio.h>

#define MOD 1'000'000'007
#define MAX_N 100'001

typedef long long ll;

using namespace std;

bool B[MAX_N]{};
ll D[MAX_N]{};

int main() {
  int N, M;
  cin >> N >> M;
  memset(B, 1, N + 1);
  for (int i = 0; i < M; ++i) {
    int a;
    cin >> a;
    B[a] = false;
  }
  D[0] = 1;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j <= min(N, i + 2); ++j) {
      if (B[j]) {
        D[j] = (D[j] + D[i]) % MOD;
      }
    }
  }
  printf("%lld\n", D[N]);
}


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

int ans[200005];
int n, x, m;

int main(){
    cin >> n >> x; m = 2 * n - 1;
    if(n == 1){
        puts("Yes\n1");
        return 0;
    }
    if(x == 1 || x == 2 * n - 1){
        puts("No");
        return 0;
    }
    puts("Yes");
    if(n == 2){
        puts("1\n2\n3");
        return 0;
    }
    if(x - 2 > 0){
        ans[n-1] = x-1;
        ans[n  ] = x;
        ans[n+1] = x+1;
        ans[n+2] = x-2;
        int c = 1;
        for(int i = 1; i <= m; i++){
            if(c == x-2) c = x+2;
            if(!ans[i]) ans[i] = c++;
        }
    }else{ //x + 2 <= n
        ans[n-2] = x+1;
        ans[n-1] = x-1;
        ans[n] = x;
        ans[n+1] = x+2;
        int c = 1;
        for(int i = 1; i <= m; i++){
            if(c == x-1) c = x+3;
            if(!ans[i]) ans[i] = c++;
        }
    }
    for(int i = 1; i <= m; i++){
        printf("%d\n",ans[i]);
    }
}


Measured memory_bytes: 2304
// :)
// "Khodaya, be man "Tagwaye setiz" biamooz ta
//  dar anbuh masuliat nalaghzam ..." -Shariati
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define F first
#define S second
#define MP make_pair
using namespace std;
using namespace __gnu_pbds;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64,int64> pii64;
const int maxn = 1e5+9;
const int64 M = 1e9+7;
const int64 I = 4e5;

vector <int> v;
int a[maxn], b[maxn];
bool vis[maxn];
int64 sum = 0;
int n, ans = 0;

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];
    for (int i = 0; i < n; i++)
        if (a[i] > b[i])
            v.push_back(a[i] - b[i]);
    for (int i = 0; i < n; i++)
        if (a[i] < b[i]) {
            ans++;
            sum += b[i] - a[i];
        }
    sort(v.rbegin(), v.rend());
    if (sum)
    for (auto x : v) {
        ans++;
        sum -= x;
        if (sum <= 0)
            break;
    }
    if (sum > 0)
        return cout << "-1\n", 0;
    cout << ans << "\n";
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define iinf 2000000000
#define linf 1000000000000000000LL
#define ulinf 10000000000000000000ull
#define MOD1 1000000007
#define lson(v) ((v)<<1)
#define rson(v) (((v)<<1)^1)
#define mpr make_pair
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef unsigned short US;
typedef pair < int , int > pii;
clock_t __stt;
inline void TStart(){__stt=clock();}
inline void TReport(){printf("\nTaken Time : %.3lf sec\n",(double)(clock()-__stt)/CLOCKS_PER_SEC);}
template < typename T > T MIN(T a,T b){return a<b?a:b;}
template < typename T > T MAX(T a,T b){return a>b?a:b;}
template < typename T > T ABS(T a){return a>0?a:(-a);}
template < typename T > void UMIN(T &a,T b){if(b<a) a=b;}
template < typename T > void UMAX(T &a,T b){if(b>a) a=b;}
int n,m,a[200005],cnt[200005];
set < int > tt;
int main(){
    // inputing start
    scanf("%d%d",&n,&m);
	int xb,x2;
	for(xb=0;xb<n;++xb) {
		scanf("%d",a+xb);
		tt.insert(a[xb]);
		cnt[a[xb]]++;
	}
	sort(cnt,cnt+n+3);
    #ifdef LOCAL
        TStart();
    #endif
    // calculation start
    int res=0,xxx=0;
	for(xb=0;xb<200003;++xb){
		if(cnt[xb])++xxx;
		res+=cnt[xb];
		if(tt.size()-xxx<=m) break;
	}
	printf("%d\n",res);
    #ifdef LOCAL
        TReport();
    #endif
    return 0;
}

Measured memory_bytes: 11136
/*
██████╗  ███████╗  
██╔══██╗ ██╔════╝ 
██████╔╝ ███████╗ 
██╔══██╗ ╚════██║  
██║  ██║ ███████║      
╚═╝  ╚═╝ ╚══════╝                                                                                                             
*/

#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define haha(j,a,n) for(int j=a;j<n;j++)
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define endl "\n"
#define bc(v) v.begin(),v.end()
#define vl vector<ll>
#define vi vector<int>
#define why 1000000007
#define NUM 100005
#define F first
#define S second
#define bhar(a) rep(i,a.size()) cin>>a[i];
#define show(a) rep(i,a.size()) cout<<a[i]<<" ";
#define sott(a) sort(bc(a))
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define mapp map<ll,ll>
#define dkac cout<<fixed<<setprecision(15);
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define yeah(n) while(n--)
ll gcd(int a, int b){if(b==0) return a; else return gcd(b,a%b);}
ll bitfun(ll x){
    return (x&(-x));
}
void solve(){
    int n; cin>>n;
    int a[n][3];
    rep(i,n){
        rep(j,3) cin>>a[i][j];
    }
    int dp[n][3],mx;
    rep(j,3) dp[0][j]=a[0][j];
    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            mx=0;
            for(int k=0;k<3;k++)
                if(j!=k) 
                    mx = max(mx,dp[i-1][k]);
            dp[i][j] = mx+a[i][j];
        }
    }
    cout<<Max(dp[n-1][0],dp[n-1][1],dp[n-1][2]);
}
int main(){
    ios
    int t=1; 
    //cin>>t;
    yeah(t){
        solve();
    }
}

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

void call(int n)
{
    for (int i = 1; i <= n; i++)
    {
        if (i % 3 == 0)
        {
            cout << ' ' << i;
            continue;
        }
        for (int x = i; x; x /= 10)
        {
            if (x % 10 == 3)
            {
                cout << ' ' << i;
                break;
            }
        }
    }
    cout << endl;
}

int main(void)
{
    int n;
    cin >> n;
    call(n);
    return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
/*int dx[4]={1,0,-1,0};
  int dy[4]={0,1,0,-1};*/
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

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

  vector<int> A(N), B(N), C(N);
  rep(i, N) cin >> A[i]; sort(all(A));
  rep(i, N) cin >> B[i]; sort(all(B));
  rep(i, N) cin >> C[i]; sort(all(C));

  ll ans = 0;
  for(int i = 0; i < N; i++) {
    ll low  = lower_bound(all(A), B[i]) - A.begin();
    ll high = C.end() - upper_bound(all(C), B[i]);
    ans += low * high;
  }

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


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <list>

using namespace std;


int A[25];
int n;

int add(int m,int i) {
	if (i > n) return 0;
	if (m == 0)return 1;
	if (m < 0)return 0;
	int res = add(m, i + 1) || add(m - A[i], i + 1);
	return res;
}

int main() {
	
	int q, m;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> A[i];

	cin >> q;
	for (int i = 0; i < q; i++){
		cin >> m;
		if (add(m, 0)) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint H, A; cin >> H >> A;
    cout << (H / A + (H % A > 0)) << '\n';
}

Measured memory_bytes: 256
import numpy as np

N, M, X = map(int, input().split())

hon = []
for _ in range(N):
    hon.append(np.array(list(map(int, input().split()))))

ans = 10**10
flag = 1
for i in range(1, 2**N):
    tmp = np.zeros(M)
    tmp_m = 0
    for j in range(N):
        if (i >> j) & 1:
            tmp = tmp + hon[j][1:]
            tmp_m += hon[j][0]
    if (tmp >= X).sum() == M:
        if tmp_m < ans:
            ans = tmp_m
            flag = 0
if flag:
    print(-1)
else:
    print(ans)



Measured memory_bytes: 27296