akhauriyash/Code-Regression huggingface dataset:
import heapq
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
q = []
heapq.heapify(q)
heapq.heappush(q,(-(A[0] + B[0] + C[0]),0,0,0))
for _ in range(K):
    m, i, j, k = heapq.heappop(q) #mに和、ijkにインデックス
    print(-m) #親から取り出すが、親は子よりも小さい、大きい順にするために-を入れている
    if i + 1 < X: #最初にiには０が挿入されている,pythonではインデックスが０から始まるから<xでいい
        s = (-(A[i+1] + B[j] + C[k]), i+1, j, k)
        if s not in q:
            heapq.heappush(q,s)
    if j + 1 < Y:
        s = (-(A[i] + B[j+1] + C[k]), i, j+1, k)
        if s not in q:
            heapq.heappush(q, s)
    if k + 1 < Z:
        s = (-(A[i] + B[j] + C[k+1]), i, j, k+1)
        if s not in q:
            heapq.heappush(q,s)
    


Measured memory_bytes: 3828
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
int max_deep;

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

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
	int n;
	cin >> n;
	max_deep = n;
	vector<int> vec_t(n + 1), vec_x(n + 1), vec_y(n + 1);
	for (int i = 1; i < n + 1; ++i) {
		cin >> vec_t[i] >> vec_x[i] >> vec_y[i];
	}
	bool result = true;
	for (int i = 1; i < n + 1; ++i) {
		int t = vec_t[i] - vec_t[i - 1];
		int d = abs(vec_x[i] - vec_x[i - 1]) + abs(vec_y[i] - vec_y[i - 1]);
		//移動毎に偶奇を変わることを利用する
		//xとyの増分がtを超えた場合、tと(x + y)の偶奇が一致しない場合は不可能な移動
		if (t < d || (t % 2) != (d % 2)) {
			result = false;
			break;
		}
	}
	string ans = (result == true) ? "Yes" : "No";
	cout << ans << endl;
    return;
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 1408
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define pi 3.14159265358979323846
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

int main()
{

  int x; cin >> x;
  if (x==3 || x==5 || x==7){cout << "YES" << endl;}
  else {cout << "NO" << endl;}

  return 0;
}


Measured memory_bytes: 256
///
// File:  c.cpp
// Author: ymiyamoto
//
// Created on Thu Sep 28 21:30:26 2017
//

#include <cstdint>
#include <iostream>
#include <string>

using namespace std;
static string str;

int32_t main()
{
  cin >> str;

  uint32_t count = 0;
  if (str[0] != str[str.size() - 1]) {
    uint32_t i = str.size() - 1;
    while (str[0] != str[i] && i > 0) {
      str[i] = str[0];
      i--;
    }
    count++;
  }

  char current = str[0];
  for (uint32_t i = 0; i < str.size(); i++) {
    if (current != str[i]) {
      count++;
      current = str[i];
    }
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 512
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()
min = 1
max = N-1
ans = [0 for _ in range(2*N+10)]
ans[len(ans)//2] = A[0]
l = len(ans) // 2
r = l
for i in range(1, N):
    left = False
    minS = False
    maxx = -1
    if abs(ans[l]-A[min]) > maxx:
        left = True
        minS = True
        maxx = abs(ans[l]-A[min])
    if abs(ans[l]-A[max]) > maxx:
        left = True
        minS = False
        maxx = abs(ans[l]-A[max])
    if abs(ans[r]-A[min]) > maxx:
        left = False
        minS = True
        maxx = abs(ans[r]-A[min])
    if abs(ans[r]-A[max]) > maxx:
        left = False
        minS = False
        maxx = abs(ans[r]-A[max])

    if left and minS:
        l -= 1
        ans[l] = A[min]
        min += 1
    elif left and not minS:
        l -= 1
        ans[l] = A[max]
        max -= 1
    elif not left and minS:
        r += 1
        ans[r] = A[min]
        min += 1
    else:
        r += 1
        ans[r] = A[max]
        max -= 1
an = 0
for i in range(l+1, r+1):
    an += abs(ans[i]-ans[i-1])
#print(ans)
print(an)


Measured memory_bytes: 8932
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll a,b,n;
  cin>>a>>b>>n;
  if(n>=b){
    ll n=b;
    ll max=0;
    for(ll i=n;i>n-10;i--){
      if(n<0){
        break;
      }
      chmax(max,(a*i/b)-a*(i/b));
    }
    cout<<max<<'\n';
  }
  else{
    cout<<(a*n/b)-a*(n/b)<<'\n';
  }
  return(0);
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    int64_t m = numeric_limits<int64_t>::max();
    int64_t ans = 0;
    for (auto i : irange(0L, n)) {
        int64_t p;
        cin >> p;

        if (p < m) {
            ++ans;
        }

        m = min(m, p);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 26


typedef struct{
  int left;
  int right;
  int parent;
  int sibling;
  int deg;
  int depth;
  int height;
}Node;

Node node[MAX];

int Height(int i){
  int left=0,right=0; 

  if( node[i].left != -1 ) left = Height(node[i].left) + 1;

  if( node[i].right != -1 ) right = Height(node[i].right) + 1;

  if( right <= left ) return left;

  else if( right > left ) return right;
}

int main(){
  int n,id,right,left,i;

  scanf("%d",&n);

  for( i = 0 ; i < n ; i++ )
    {
      node[i].left = node[i].right = node[i].parent = node[i].sibling = -1;
      node[i].deg = node[i].depth = node[i].height = 0;
    }
  
  for( i = 0 ; i < n ; i++ )
    {
      scanf("%d%d%d",&id,&right,&left);
      if(right != -1 && left != -1){
	node[right].sibling = left;
	node[left].sibling = right;
	node[id].right = right;
	node[id].left = left;
	node[right].parent = node[left].parent = id;
	node[id].deg = 2;
      }
      else if( right == -1 && left != -1 ){
	node[id].left = left;
	node[left].parent = id;
	node[id].deg++;
      }
      else if( left == -1 && right != -1 ) {
	node[id].right = right;
	node[right].parent = id;
	node[id].deg++;
      }
    }
  int x;

  for( i = 0 ; i < n ; i++ )
    {
      x = i;
      while( node[x].parent != -1 )
	{
	  x = node[x].parent;
          node[i].depth++;
	}
      node[i].height =  Height(i);
    }

  for( i = 0 ; i < n ; i++ )
    {
      printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,node[i].parent,node[i].sibling,node[i].deg,node[i].depth,node[i].height);
      if(node[i].parent == -1 ) printf("root\n");
      else if(node[i].deg == 0 ) printf("leaf\n");
      else printf("internal node\n");
    }

  return 0;
}

Measured memory_bytes: 612
//57
#include<iostream>
#include<string>
#include<sstream>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    string s;
    cin>>s;
    while(n--){
      char p=0;
      int c;
      stringstream ss;
      for(int i=0;i<s.size();i++){
	if(s[i]!=p){
	  if(i!=0){
	    ss<<c<<p;
	  }
	  p=s[i];
	  c=1;
	}else{
	  c++;
	}
      }
      ss<<c<<p;
      s=ss.str();
    }
    cout<<s<<endl;
  }
  return 0;
}

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

int main() {
  int N,K,i,j;
  cin>>N>>K;
  vector<int> h(N), dp(N,1e9+1);
  for (i=0;i<N;i++) cin>>h[i];
  dp[0]=0;
  for (i=1;i<N;i++) {
    for (j=1;j<=i && j<=K;j++) {
      dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
    }
  }
  cout<<dp[N-1]<<endl;
  return 0;
}


Measured memory_bytes: 3628
package main

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

const (
	maxBufferSize     = 2000000 // check
	initialBufferSize = 20000
)

func Reverse(a []int) {
	n := len(a)
	for i := 0; i < n/2; i++ {
		a[i], a[n-i-1] = a[n-i-1], a[i]
	}
}

func BinarySearch(a []int, begin, end, target int) (int, int) {
	lb, ub := begin-1, end
	for ub-lb > 1 {
		mid := (lb + ub) / 2
		if a[mid] <= target {
			lb = mid
		} else {
			ub = mid
		}
	}
	return lb, ub
}

func Fill(a []int, value int) {
	for i := 0; i < len(a); i++ {
		a[i] = value
	}
}

func solve() {
	sc := bufio.NewScanner(os.Stdin)
	buffer := make([]byte, initialBufferSize)
	sc.Buffer(buffer, maxBufferSize)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	a := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}

	Reverse(a)

	b := make([]int, n)
	Fill(b, 1010101010)
	b[0] = a[0]
	for i := 1; i < n; i++ {
		_, ub := BinarySearch(b, 0, n, a[i])
		b[ub] = a[i]
	}

	var ans int
	for i := 0; i < n; i++ {
		if b[i] != 1010101010 {
			ans = i + 1
		}
	}

	fmt.Println(ans)
}

func main() {
	solve()
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, p;
  cin >> a >> p;
  p += a*3;
  cout << p/2 << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
ans = 0
for i in range(3,N+1,2):
    num = i
    count = 1
    #yaku = []
    for j in range(1,N//2 +1):
            if num % j == 0:
                count += 1
                #yaku.append(j)
    if count == 8:
        ans += 1
        #print(i,yaku)
print(ans)

Measured memory_bytes: 9184
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int M = in.nextInt();
		int[] itemVotes = new int[N];
		int sum = 0;
		int count = 0;
		for (int i = 0; i < N; i++) {
			itemVotes[i] = in.nextInt();
			sum = sum + itemVotes[i];
		}
		
		float cutoff = (1/(4* (float) M))*(float) sum;
		Arrays.sort(itemVotes);
		
		for(int i = 0; i<N; i++) {
			if(itemVotes[i] >= cutoff) {
				count++;
			}
		}
		
		if(count >= M) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	}
	
}


Measured memory_bytes: 21716
from sys import stdin
input = stdin.readline

H,W,M = map(int, input().split())

sum_row = [0]*H; sum_col = [0]*W
bomb_row = [0]*M; bomb_col = [0]*M
for i in range(M):
    h,w = map(int, input().split())
    sum_row[h-1] += 1
    sum_col[w-1] += 1
    
    bomb_row[i] = h-1
    bomb_col[i] = w-1

maxcol = max(sum_col)
maxcollist = [False]*W
for col in range(W):
    if sum_col[col] == maxcol:
        maxcollist[col] = True

maxrow = max(sum_row)
maxrowlist = [False]*H
for row in range(H):
    if sum_row[row] == maxrow:
        maxrowlist[row] = True

#最高行または最高列上にあり、
#かつ最高行と最高列の交点にない爆弾があるかをチェック
cross_cnt = sum(maxrowlist) * sum(maxcollist)
for i in range(M):
    h,w = bomb_row[i], bomb_col[i]
    if maxrowlist[h] and maxcollist[w]:
        cross_cnt -= 1

if cross_cnt > 0:
    print(maxcol + maxrow)
else:
    print(maxcol + maxrow - 1)

Measured memory_bytes: 88468
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;

int Q, N[100];

int main(void) {
  cin >> Q;
  REP(i, 0, Q) cin >> N[i];

  REP(i, 0, Q) {
    bool visited[2000000];
    REP(i, 0, 2000000) visited[i] = false;
    int n = N[i];
    int ans = 0;
    visited[n] = true;
    while(n >= 10) {
      vector<int> v;
      int d = 10;
      while(1) {
        int a = n / d;
        int b = n % d;
        if(a == 0) break;
        v.push_back(a * b);
        d *= 10;
      }
      sort(v.begin(), v.end());
      reverse(v.begin(), v.end());
      n = v[0];
      if(visited[n]) {
        ans = -1;
        break;
      }
      visited[n] = true;
      ans++;
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 5068
n = int(input())
b = list(map(int, input().split()))
a = []
while b:
    m = len(b)
    ok = False
    for i in range(m)[::-1]:
        # print(m, i)
        if b[i] == i+1:
            a.append(b.pop(b[i]-1))
            ok = True
            break
    
    if not ok:
        print(-1)
        exit()

for i in range(n)[::-1]:
    print(a[i])

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long int
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 1e9+7
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp);
void ipgraph(int m);
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
const int mod = 1e9 + 7;
//const int N = 2e5+5, M = N;
//=========================================

const int MAXN = 3005;
int N, a[MAXN];
int dp[MAXN][MAXN];

int solve(int i, int j){

    if(dp[i][j] != -1)
        return dp[i][j];

    if(i == j)
        return dp[i][j] = a[i];

    return dp[i][j] = max(a[i] - solve(i + 1, j), a[j] - solve(i, j - 1));
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  
    cin >> N;
    for(int i = 1; i <= N; ++i)
        cin >> a[i];

    memset(dp, -1, sizeof(dp));
    int answer = solve(1, N);
    cout << answer << "\n";

    return 0;
}


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

int main(){
  int a,k;
  string s;
  cin>>a>>s;
  long long color , l=0, r=0,g=0,b=0;
  for(int i=0;i<a;i++){
    if(s.at(i)=='R')r++;
    else if(s.at(i)=='G')g++;
    else b++;
  }
  color=r*g*b;
  for(int i=0;i<a;i++){
    for(int j=i+1;j<a;j++){
      k=2*j-i;
      if(k>=a || s.at(i)==s.at(k) || s.at(j)==s.at(k) || s.at(i)==s.at(j))continue;
      l++;      
    }
  }
  cout <<color - l<<endl;
}

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

using namespace std;

int main(int argc, char *argv[]) {
    int N;
    cin >> N;

    vector<int64_t> arr;
    int64_t cur;
    for (int64_t i = 0; i < N; i++) {
        cin >> cur;
        arr.push_back(cur);
    }

    vector<int64_t> arr1 = arr;
    sort(arr1.begin(), arr1.end());

    vector<int64_t> cur_arr;
    for (int j = 0; j < N; j++) {
        int64_t one = arr[j];
        auto it = lower_bound(arr1.begin(), arr1.end(), one);
        int idx = it - arr1.begin();
        if (idx + 1 <= (N / 2)) {
            cout << arr1[N / 2] << endl; 
        } else {
            cout << arr1[(N / 2) - 1] << endl; 
        }
    }
    return 0;
}


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

int main(){
 long long N,u,c;
  cin>>N;
    for(long long h=1;h<=3500;h++){
      for(long long n=1;n<=3500;n++){
        u=h*n*N;
        c=h*(4*n-N)-n*N;
        if(c!=0){
   if(u%c==0&&u/c>0){
     cout<<h<<" "<<n<<" "<<u/c<<endl;
   return 0;
   }
    }
      }
    }
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100

void Ssort(int a[], int n);

int main(void) {
  int A[MAX];
  int N;
  scanf("%d", &N);

  for(int i=0; i<N; ++i) {
    scanf("%d", &A[i]);
  }

  Ssort(A, N);

  return 0;
}

void Ssort(int a[], int n) {
  int i, j, count = 0;
  int tmp, minj;

  for(i=0; i<=n-1; ++i) {
    minj = i;
    for(j=i; j<=n-1; ++j) {
      if(a[j] < a[minj]) minj = j;
    }
    tmp = a[i];
    a[i] = a[minj];
    a[minj] = tmp;
    if(i != minj) ++count;
  }

  for(i=0; i<n; ++i) {
    if(i != n-1) {
      printf("%d ", a[i]);
    }
    else printf("%d\n", a[i]);
  }
  printf("%d\n", count);
  
}



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

int S[100001];

int main() {
    int N, K, Q;
    cin >> N >> K >> Q;

    memset(S, 0, sizeof(S));

    for (int i = 1; i <= Q; ++i) {
        int a;
        cin >> a;
        ++S[a];
    }

    for (int i = 1; i <= N; ++i) {
        if (S[i] - Q + K <= 0) {
            cout << "No" << endl;
        }
        else {
            cout << "Yes" << endl;
        }
    }

    return 0;
}


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

int main(){
    long long INF = 1LL << 60;
    int n,k;
    cin >> n >> k;
    vector<long long> dp(n);
    vector<long long> h(n);
    for(int i = 0;i < n;i++) cin >> h[i];
    dp[0] = 0;
    for(int i = 1;i < n;i++) dp[i] = INF;

    for(int i = 0;i< n-1;i++){
        for(int j = 1;j < k+1;j++){
            if(i+j <= n-1){
                dp[i+j] = min(dp[i] + abs(h[i] - h[i+j]), dp[i+j]);
            }
        }
    } 
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
main(){
  char op[1000200];
  int memory[100],cnt=0;
  while(scanf("%s",op)!=EOF){
    if(op[0]=='+'){
      memory[cnt-2]+=memory[cnt-1];
      cnt--;
    }else if(op[0]=='-'){
      memory[cnt-2]-=memory[cnt-1];
      cnt--;
    }else if(op[0]=='*'){
      memory[cnt-2]*=memory[cnt-1];
      cnt--;
    }else{
      memory[cnt]=atoi(op);
      cnt++;
    }
  }
  printf("%d\n",memory[0]);
}

Measured memory_bytes: 984
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main() { 
  int n;
  cin>>n;
  
  vector<int> A(n);
  rep(i,n) cin>>A[i];
  
  sort(ALL(A));
  int sum=0;
  rep(i,n){
    if(i!=n-1) sum+=A[i];
    else sum+=A[i]/2;
  }
  
  cout<<sum<<endl;
  
  return 0;
}

Measured memory_bytes: 3568
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        function(0,0,0,0);
        System.out.println(count);
    }
    static int count = 0;
    static int n;
    static void function(long num, int a, int b, int c){
        if (a>0&&b>0&&c>0&&(num<=n)){
            count++;
        }
        if (num>n){
        }else{
            if (num*10<n){
                function(num*10+3,a+1,b,c);
                function(num*10+5,a,b+1,c);
                function(num*10+7,a,b,c+1);
            }
        }
    }
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
#define int ll
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 998244353;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

struct BIT {
  int sz;
  vi node;
  BIT(int n): sz(n+1), node(vi(n+1)) {}

  void add(int idx, int val) {
    idx++;
    while(idx < sz) {
      node[idx] += val;
      idx += idx & -idx;
    }
  }

  int sum(int idx) {
    idx++;
    int res = 0;
    while(idx) {
      res += node[idx];
      idx -= idx & -idx;
    }
    return res;
  }

};

template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}



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

  int n; cin >> n;
  vi x(n), y(n);
  set<int> stx, sty;
  map<int, int> ztx, zty;
  for(int i=0;i<n;++i) {
    cin >> x[i] >> y[i];
    stx.insert(x[i]);
    sty.insert(y[i]);
  }
  sty.insert(INF+1);

  int idx = 0;
  for(auto &e: stx) {
    ztx[e] = idx;
    idx++;
  }

  int idy = 0;
  for(auto &e: sty) {
    zty[e] = idy;
    idy++;
  }

  vector<P> v1;
  for(int i=0;i<n;++i) {
    v1.push_back({ztx[x[i]], zty[y[i]]});
    //cout << v1[i].first << " " << v1[i].second << endl;
  }
  sort(v1.begin(), v1.end());


  vi a1(n), a2(n), a3(n), a4(n);
  BIT bit1(n+2), bit2(n+2);
  for(int i=0;i<n;++i) {
    
    a2[i] = bit1.sum(v1[i].second);
    a1[i] = bit1.sum(zty[INF+1]) - bit1.sum(v1[i].second);
    bit1.add(v1[i].second, 1);
    //printv(bit1.node);
  }
  for(int i=n-1;i>=0;--i) {
    a4[i] = bit2.sum(v1[i].second);
    a3[i] = bit2.sum(zty[INF+1]) - bit2.sum(v1[i].second);
    bit2.add(v1[i].second, 1);
  }
/*   printv(a1);
  printv(a2);
  printv(a3);
  printv(a4); */
  
  map<int, bool> ok;
  ok[6] = true;
  ok[7] = true;
  ok[9] = true;
  ok[11] = true;
  ok[13] = true;
  ok[14] = true;
  ok[15] = true;

  ll ans = 0;
  for(int i=0;i<n;++i) {
    ans += mod_pow<ll>(2, n-1, MOD);
    ans %= MOD;
    for(int j=0;j<(1<<4);++j) {
      if(!ok[j]) continue;
      ll tmp = 1;
      if((j>>0)&1) {
        tmp *= (mod_pow<ll>(2, a1[i], MOD) + MOD - 1) % MOD;
        tmp %= MOD;
      }
      if((j>>1)&1) {
        tmp *= (mod_pow<ll>(2, a2[i], MOD) + MOD - 1) % MOD;
        tmp %= MOD;
      }
      if((j>>2)&1) {
        tmp *= (mod_pow<ll>(2, a3[i], MOD) + MOD - 1) % MOD;
        tmp %= MOD;
      }
      if((j>>3)&1) {
        tmp *= (mod_pow<ll>(2, a4[i], MOD) + MOD - 1) % MOD;
        tmp %= MOD;
      }
      ans += tmp;
      ans %= MOD;
    }
    
  }
  cout << ans << endl;

}


Measured memory_bytes: 61420
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int M, K;

int main() {
    ios_base::sync_with_stdio(false);
    cin >> M >> K;
    if(K >= (1 << M)) {
        cout << -1 << endl;
        return 0;
    } else if(M == 0) {
        if(K == 0) cout << "0 0";
        else cout << -1;
        return 0;
    } else if(M == 1) {
        if(K == 1) cout << -1;
        else cout << "0 0 1 1" << endl;
        return 0;
    }

    for(int i = 0; i < (1 << M); i++) {
        if(i != K) cout << i << " ";
    }
    cout << K << " ";
    for(int i = (1 << M) - 1; i >= 0; i--)
        if(i != K) cout << i << " ";
    cout << K << " ";

}

Measured memory_bytes: 1920
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,k,a[55],i,ans;
  cin >> n >>k;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n,greater<int>());
  for(i=0;i<k;i++){
    ans=ans+a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val even = sc.nextLine.split(" ").map(_.toInt).filter(_ % 2 == 0)
    if (even.length == 0) println("Yes")
    else println("No")
  }
}


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

typedef long long ll;
ll S;
const ll up=1000000000;
int main(){
	scanf("%lld",&S);
	ll x0,y0,x1,y1;
	x0=up;
	y1=(S+up-1)/up;
	S=x0*y1-S;
	x1=1;
	y0=S;
	printf("0 0 %lld %lld %lld %lld\n",x0,y0,x1,y1);
	return 0;
}

Measured memory_bytes: 764
import java.io.{BufferedReader, InputStreamReader}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val n = in.readLine.toLong

    System.out.println(
      if (n % 2L == 1) {
        0
      } else {
        BigInt(n / 2L).toString(5).reverse.map(_.toInt - '0').foldLeft((0L, 0L)) {
          case ((acc, base), i) =>
            (acc + base * i, base * 5L + 1L)
        }._1
      }
    )
  }
}


Measured memory_bytes: 25408
#include <iostream>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb emplace_back
#define mp make_pair
#define MOD (int) 1e9+7
#define for0(i, n) for (int i = 0; i < n; i++)
#define ff first
#define ss second
#define endl "\n"
#define bits(n) __builtin_popcount(n)
#define ini(a, i) memset(a, i, sizeof(a))

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	// cin >> t;
	t  = 1;
	while (t--)
	{
		ll n, k;
		cin >> n >> k;
		ll arr[n];
		for (ll i = 0; i < n; i++)
			cin >> arr[i];
		sort(arr, arr + n);
		ll ans = 0;
		for (ll i = 0; i < k; i++)
			ans += arr[i];
		cout << ans << endl;
		// char s;
		// cin >> s;
		// if (isupper(s))
		// 	cout << "A" << endl;
		// else
		// 	cout << "a" << endl;
	}
	return 0;
}


Measured memory_bytes: 3664
import sys
input = lambda : sys.stdin.readline().strip()

n = int(input())
wsv = [list(map(int, input().split())) for i in range(n)]
wsv.sort(key=lambda x: x[0]+x[1])

max_s = 10**4
DP = [-float("inf")]*(2*max_s+1)

DP[0] = 0

for i in range(n):
    w,s,v = wsv[i]
    nxt = DP[:]
    for j in range(s+1):
        nxt[j+w] = max(DP[j]+v, nxt[j+w])
    DP = nxt

ans = max(DP)
print(ans)

Measured memory_bytes: 119276
#include<stdio.h>
int main(void)
{
	char ch[100];
	int i, j;
	scanf("%s", ch);
	for(i = 0;ch[i];i++){}
	for(j = i-1;ch[j];j--){
		printf("%c",ch[j]);
	}
	printf("\n");

	return 0;

}

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

#ifdef DEBUG
#include "../.inc/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

long long N, K;

vector<int> calc_to(vector<int> &A, int l) {
    vector<int> to((int)A.size(), -1);
    map<int, int> prev;
    for (int i=l; i<2*N; ++i) {
        if (prev.count(A[i%N])) {
            int k = prev[A[i%N]];
            to[k] = i%N;
        }
        prev[A[i%N]] = i%N;
    }
    return to;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");
    // wtfile("_output.txt");

    cin >> N >> K;

    vector<int> A(N);
    for (int i=0; i<N; ++i) cin >> A[i];

    if (N == 1) {
        if (K % 2 == 0) return 0;
        cout << A[0] << endl;
        return 0;
    }

    vector<int> to = calc_to(A, 0);
    vector<int> pos;
    int k = 0;
    while (1) {
        while (k < to[k] % N && to[k]+1 < N) {
            k = to[k]+1;
        }
        pos.push_back(k);
        if (k == N-1 && to[k] == N-1) pos.push_back(N);
        k = (to[k]+1) % N;
        if (k == 0) break;
    }

    int M = pos.size();
    K = K % M;
    if (K == 0) return 0;

    int s = pos[K-1];
    vector<int> ans;
    while (s < N) {
        if (s < to[s]) {
            s = to[s];
        } else {
            ans.push_back(A[s]);
        }
        s ++;
    }

    for (int i=0; i<(int)ans.size(); ++i) {
        cout << (i == 0 ? "" : " ") << ans[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 11264
#include<bits/stdc++.h>
#define N 25
using namespace std;
int n,m,K;
int in[N][N];
bool ck(int x,int y){
	long long res=0;
	for(int i=1;i<=m;i++){
		res+=(in[x][i]-in[y][i])*(in[x][i]-in[y][i]);
	}
	if(sqrt(res)==floor(sqrt(res)))return 1;
	else return 0;
}
void solve(){
	int ans=0;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			scanf("%d",&in[i][j]);
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(ck(i,j))ans++;
		}
	}
	printf("%d\n",ans);
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 256
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

a, b, c, d = map(int,input().split())
ans = 0
a = a-1
 
x = b - (b//c + b//d - b//lcm(c,d)) #1~bまでの該当する数
y = a - (a//c + a//d - a//lcm(c,d)) #1~a-1までの該当する数
    
print(x-y)

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

int main() {
  int n;cin>>n;
  int ans=0;
  rep(i,n){
    int a;cin>>a;a--;
    ans+=a;
  }
  cout<<ans<<endl;
}

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

int main() {
	int D;

	cin >> D;
	string res = "";

	if (D == 25) res = "Christmas";
	if (D == 24) res = "Christmas Eve";
	if (D == 23) res = "Christmas Eve Eve";
	if (D == 22) res = "Christmas Eve Eve Eve";
	cout << res << endl;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

typedef bitset<4000>bs;

bs in(){
    string s;cin>>s;
    reverse(all(s));
    bs ret;
    rep(i,s.size())ret[i]=s[i]-'0';
    return ret;
}

bs mo(bs &a,bs &b){
    bs c=a;


    int k=0;
    rep(i,4000)if(b[i])k=i;
    for(int i=4000-1;i>=k;i--){
        if(c[i]){
            c^=(b<<(i-k));
        }
    }
    return c;
}

bs gcd(bs a,bs b){
    if(b.count()==0)return a;
    bs c=mo(a,b);
    return gcd(b,c);
}

const int mod=998244353;

int N;
int po[4444];
signed main(){
    po[0]=1;
    for(int i=1;i<4444;i++)po[i]=po[i-1]*2%mod;
    cin>>N;
    bs X=in();

    bs g;
    rep(i,N){
        bs A=in();
        g=gcd(A,g);
    }

    bs x;
    int k=0;
    rep(i,4000)if(g[i])k=i;

    int ans=0;
    for(int i=4000-1;i>=k;i--){
        if(X[i]){
            ans=(ans+po[i-k])%mod;
            if(x[i]==0){
                x^=g<<(i-k);
            }
        }
        else{
            if(x[i]==1){
                x^=g<<(i-k);
            }
        }
    }
    ans++;
    for(int i=4000-1;i>=0;i--){
        if(X[i]==x[i])continue;
        if(X[i]<x[i])ans--;
        break;
    }
    ans%=mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3456
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N,K,Q = inputlist()
A = [0]*Q
for i in range(Q):
    A[i] = int(input())
from collections import Counter
c = Counter(A)
for i in range(1,N+1):
    if K - Q + c[i] <= 0:
        print("No")
        continue
    print("Yes")


Measured memory_bytes: 11888
def main():
    N, M = map(int, input().split())
    A = [int(i) for i in input().split()]
    count = 0
    ok = 0
    for i in range(N):
        count += A[i]
    for i in range(N):
        if A[i] / count >= 1 / (4 * M):
            ok += 1
    if ok >= M:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<iomanip>
#include<algorithm>
using namespace std;

int main(void){
    int n;
    double x[100], y[100], d = 0;
    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    for(int i = 0; i < n; i++){
        cin >> y[i];
    }
    
    for(int i = 0; i < n; i++){
        d += abs(x[i] - y[i]);
    }
    cout << fixed << setprecision(6) << d << endl;
    d = 0;

    for(int i = 0; i < n; i++){
        d += (x[i]- y[i]) * (x[i]- y[i]);
    }
    cout << fixed << setprecision(6) << sqrt(d) << endl;
    d = 0;
    
    for(int i = 0; i < n; i++){
        d += abs((x[i]- y[i]) * (x[i]- y[i])* (x[i]- y[i]));
    }
    cout << fixed << setprecision(6) << cbrt(d) << endl;
    d = 0;

    for(int i = 0; i < n; i++){
        d = max(d, abs(x[i] - y[i]));
    }
    cout << fixed << setprecision(6) << d << endl;
    return 0;
}


Measured memory_bytes: 3468
#include <stdio.h>

int main(void){
  int N,M,a,b=0;
  scanf("%d %d",&N,&M);
  int K[N+1][M+1];
  for(int i=1;i<=M;i++){
    for(int j=1;j<=N;j++){
      K[j][i]=0;
    }
  }
  for(int i=1;i<=N;i++){
    scanf("%d",&K[i][0]);
    for(int j=1;j<=K[i][0];j++){
      scanf("%d",&a);
      K[i][a]++;
    }
  }

  for(int j=1;j<=M;j++){
    int c=1;
    for(int i=1;i<=N;i++){
      c*=K[i][j];
    }
    if(c==1){
      b++;
    }
  }
  printf("%d\n",b);
  return 0;
}



Measured memory_bytes: 128
from sys import stdin


def main():
    N = int(stdin.readline())
    s = [stdin.readline().rstrip().split() for _ in range(N)]

    s_flat = [flatten for inner in s for flatten in inner]

    s_dict = {}
    sum = 0

    for S in s_flat:
        new_S = ''.join(sorted(S))
        if not s_dict.get(new_S):
            s_dict[new_S] = 1
        else:
            sum += s_dict[new_S]
            s_dict[new_S] = s_dict[new_S] + 1

    print(sum)


if __name__ == "__main__":
    main()


Measured memory_bytes: 43040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const ll INF = numeric_limits<ll>::max();
int main()
{
    int n; cin >> n;
    int a, c = 0;
    rep(i, n) {
        cin >> a;
        if (a%2==1 && i%2==0) ++c;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#define int long long
using namespace std;

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

Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	vector<ll> a(n+1);
	vector<ll> b(n);
	for( auto &k : a ) cin >> k;
	for( auto &k : b ) cin >> k;
	ll ans = 0;
	ll a_, b_;
	for( int i = 0; i < n; ++i ){
		a_ = max(a[i]-b[i], 0ll);
		b_ = max(b[i]-a[i], 0ll);
		ans += (a[i]-a_);
		a[i] = a_; b[i] = b_;
		if( b[i] > 0 ){
			a_ = max(a[i+1]-b[i], 0ll);
			b_ = max(b[i]-a[i+1], 0ll);
			ans += (a[i+1]-a_);
			a[i+1] = a_; b[i] = b_;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
use std::cmp;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($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, ( $($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);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        a: usize,
        b: usize
    }

    // x * 0.08 = a      x * 0.1 = b
    // x = a * 12.5   x = 10b

    let min_x = b * 10;
    let mut x = min_x;
    let mut not_exist = false;

    while f64::floor((x as f64 * 0.08)) as usize != a && !not_exist {
        x += 1;

        if f64::floor((x as f64 * 0.1)) as usize > b {
            not_exist = true;
        }
    }

    if not_exist {
        println!("-1");
    } else {
        println!("{}", x);
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 8572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin >> s;
    if(s=="zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 << endl;
        return 0;
    }
    set<int> st;
    int n=s.size();
    REP(i,n){
        st.insert(s[i]-'a');
    }
    if(st.size()==26){
        string t=s;
        next_permutation(ALL(s));
        REP(i,n){
            if(s[i]==t[i]){
                cout << s[i];
            }
            else{
                cout << s[i] << endl;
                return 0;
            }
        }
        cout << endl;
    }
    else{
        REP(i,26){
            if(!st.count(i)){
                cout << s << char(i+'a') << endl;
                return 0;
            }
        }
    }
}


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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define DIVUP(x, y) (((x) + ((y) - 1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

int main() {
  int N, Y; scanf("%d%d", &N, &Y);

  bool result{false};
  for (int i{0}; i <= N; ++i) {
    for (int j{0}; j <= N - i; ++j) {
      if (i * 10000 + j * 5000 + (N - i - j) * 1000 == Y) {
        printf("%d %d %d\n", i, j, N - i - j);
        return 0;
      }
    }
  }
  printf("-1 -1 -1\n");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <tuple>
using namespace std;
typedef tuple<int, int, char, long long, string> item;
int main()
{
    int n;
    cin >> n;
    vector<item> A;
    A.reserve(n); //要素数を予約
    for (int i = 0; i < n; i++)
    {
        int v, w;
        long long d;
        char t;
        string s;
        cin >> v >> w >> t >> d >> s;
        A.push_back(make_tuple(v, w, t, d, s));
    }
    sort(A.begin(), A.end());

    for (auto it = A.begin(); it != A.end(); it++)
    {
        item T = *it;
        const int &v = get<0>(T);
        const int &w = get<1>(T);
        const char &t = get<2>(T);
        const long long &d = get<3>(T);
        const string &s = get<4>(T);
        cout << v << ' ' << w << ' ' << t << ' ' << d << ' ' << s << endl;
    }
}


Measured memory_bytes: 12212
#include <cstdio>

int par[100005];

int main(){
  int N,M;
  scanf("%d %d",&N,&M);
  for(int i=0;i<M;i++){
    int A,B;
    scanf("%d %d",&A,&B);
    A--,B--;
    par[A]^=1;
    par[B]^=1;
  }
  for(int i=0;i<N;i++){
    if(par[i]){
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
  return 0;
}


Measured memory_bytes: 512
using System;

namespace magic
{
    class Program
    {
        static void Main(string[] args)
        {
            int A, B,C,K;

            string inD0 = Console.ReadLine();
            string[] cngD0 = inD0.Split(' ');

            A = int.Parse(cngD0[0]);
            B = int.Parse(cngD0[1]);
            C = int.Parse(cngD0[2]);

            string inD1 = Console.ReadLine();

            K = int.Parse(inD1);

            for (int i = 1; i <= K; i++)
            {
                if(A < B)
                {
                    if(B < C)
                    {
                        continue;
                    }
                    else
                    {
                        C *= 2;
                    }
                }
                else
                {
                    B *= 2;

                }
            }

            if(A<B & B < C)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");

            }

        }
    }
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll X, A;
    cin >> X >> A;

    cout << ((X<A)? 0 : 10) << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl '\n'
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld pi=3.141592653589793238;

vector<long long> divisor(long long n) {
vector<long long> ret;
for (long long i = 1; i * i <= n; ++i) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n) ret.push_back(n / i);
}
}
sort(ret.begin(), ret.end()); // 昇順に並べる
return ret;
}

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll ans=0;
    for(ll i=1;i<=N;i+=2){
        if(divisor(i).size()==8)ans++;
    }
    prt(ans)

    return 0;
}


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

int main() {
  int n, p;
  bool isOdd = false;
  cin >> n >> p;
  vector<int> a(n);
  for (int i = 0; i < n; i ++) {
    cin >> a.at(i);
    if (a.at(i) % 2 == 1) {
      isOdd = true;
    }
  }

  LL ans;
  if (!isOdd && p == 0) {
    ans = pow(2, n);
  } else if (!isOdd && p == 1) {
    ans = 0;
  } else {
    ans = pow(2, n - 1);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a,b,c,k;
	
	scanf("%d %d %d %d",&a,&b,&c,&k);
	int left = k;
	int sum = 0;
	if(a >= k){
		sum = k;
	}else{
		left -= a;
		sum += a;
		if(b >= left){
			sum += 0;
		}else{ 
			left -= b;
			
			sum = sum - left; 
		}
	}
	
	printf("%d",sum);
	
	return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll //9223372036854775807
#define pi acos(-1.0)
#define ms(a,b) memset(a,b,sizeof(a))
#define nl "\n"
#define FAST_IO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef long long ll;
const int mod = 998244353;
ll qpow(ll x, ll y){ll s=1;while(y){if(y&1)s=s*x%mod;x=x*x%mod;y>>=1;}return s;}
//ll qpow(ll a, ll b){ll s=1;while(b>0){if(b%2==1)s=s*a;a=a*a;b=b>>1;}return s;
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();return x*f;}
ll inve(ll x){return x==1?1:(mod-mod/x)*inve(mod%x)%mod;}

int main()
{
    FAST_IO;
    int a[4] = {0};
    for(int i=0;i<4;i++)
        cin>>a[i];
    sort(a,a+4);
    if(a[0] == 1 && a[1]==4 && a[2]==7 && a[3]==9) cout<<"YES"<<nl;
    else cout<<"NO"<<nl;
    return 0;
}


Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N = int(input())
A = list(map(int, input().split()))

d = [0] * N
for i in range(1, N):
    d[i] = A[i] - A[i - 1]

l = 0
r1 = 1
r2 = 1
ans = 0
while l < N:
    while r1 < N and d[r1] >= 0:
        r1 += 1
    while r2 < N and d[r2] <= 0:
        r2 += 1
    r = max(r1, r2)
    l = r
    ans += 1
    r1 = l + 1
    r2 = l + 1
print(ans)


Measured memory_bytes: 20520
#include<bits/stdc++.h>
#include<cmath>
#define PB push_back
#define REP(i,a,b) for(int i=a;i<b;i++)
typedef long long int ll;
using namespace std;
int main()
 {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll prak,prat,vid=0;
    cin>>prak>>prat;
    prat*=prat;
    for(ll i=0;i<prak;i++)
    {
      ll koul,chand;
      cin>>koul>>chand;
      if(koul*koul+chand*chand<=prat)
        vid++;
    }
  	cout<<vid;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstring>

using namespace std;

typedef long long LL;

const int N=2e5+10;
const int mod=1e9+7;

int n;
int a[N];
int s[N];

int main(){
    cin>>n;
    for(int i=1;i<=n;++i) cin>>a[i];
    s[0]=0;
    for(int i=1;i<=n;++i){
        LL tmp=(LL)s[i-1]+a[i];
        tmp%=mod;
        s[i]=tmp;
    }
    LL res=0;
    for(int i=1;i<n;++i){
        LL k=(s[n]-s[i]);
        if(k<0) k+=mod;
        LL tmp=(LL)a[i]*k;
        tmp%=mod;
        res+=tmp;
        res%=mod;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 5132