akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>

int main(){
    long long a,b,c,d;

    scanf("%lld%lld%lld",&a,&b,&c);

    d = c - a - b;
    if(d > 0 && d*d > 4*a*b)printf("Yes\n");
    else printf("No\n");

    return 0;
}

Measured memory_bytes: 128
# Tree walk 木の巡回


class Node():
    
    def __init__(self):
        self.parent = -1
        self.left = -1
        self.right = -1


def preordertreewalk(u):
    print(" ", u, end="", sep="")
    if T[u].left != -1:
        preordertreewalk(T[u].left)
    if T[u].right != -1:
        preordertreewalk(T[u].right)


def inordertreewalk(u):
    if T[u].left != -1:
        inordertreewalk(T[u].left)
    print(" ", u, end="", sep="")
    if T[u].right != -1:
        inordertreewalk(T[u].right)


def postordertreewalk(u):
    if T[u].left != -1:
        postordertreewalk(T[u].left)
    if T[u].right != -1:
        postordertreewalk(T[u].right)
    print(" ", u, end="", sep="")


n = int(input())
T = [Node() for i in range(n)]
for i in range(n):
    id, left, right = (int(d) for d in input().split())
    if left != -1:
        T[id].left = left
        T[left].parent = id
    if right != -1:
        T[id].right = right
        T[right].parent = id

rootid = -1
for id in range(n):
    if T[id].parent == -1:
        rootid = id

print("Preorder")
preordertreewalk(rootid)

print("\nInorder")
inordertreewalk(rootid)

print("\nPostorder")
postordertreewalk(rootid)
print()



Measured memory_bytes: 5628
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc= new Scanner(System.in);
      int a= sc.nextInt();
      int b=sc.nextInt();
      int c = sc.nextInt();
      
      if(a+b+c ==17) {
        System.out.println("YES");
      } else {
        System.out.println("NO");
      }
    }
  }


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

using namespace std;

int main()
{
    char line[7];
    for(int i=0;i<6;i++)
    {
        cin>>line[i];
        if(i==3)
        {
            if(line[i]!=line[i-1])
            {
               cout<<"No";
               return 0;
            }
        }
        else if(i==5)
        {
            if(line[i]!=line[i-1])
            {
               cout<<"No";
               return 0;
            }
        }
    }
    cout<<"Yes";
    return 0;
}



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

#define MorsheD ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
typedef long long ll;

bool mew(int n) {
    while (n) {
        if (n%10 == 7) {
            return true;
        }
        n /= 10;
    }
    return false;
}

int main(){
    // ===================
    MorsheD;
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // ===================

    int n;
    cin >> n;

    if (mew(n)) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }

    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>

using namespace std;

struct dice{
  int surface[6];

  void numReplace(int num[6], int n0, int n1, int n2, int n3, int n4, int n5){
    num[0] = n0;
    num[1] = n1;
    num[2] = n2;
    num[3] = n3;
    num[4] = n4;
    num[5] = n5;
  }
  
  void rotation(struct dice *self, char c){
    int num[6];
    for(int i = 0; i < 6; i++){
      num[i] = self->surface[i];
    }

    if(c == 'N'){
      numReplace(self->surface, num[1], num[5], num[2], num[3], num[0], num[4]);
    }
    else if(c == 'E'){
      numReplace(self->surface, num[3], num[1], num[0], num[5], num[4], num[2]);
    }
    else if(c == 'S'){
      numReplace(self->surface, num[4], num[0], num[2], num[3], num[5], num[1]);
    }
    else if(c == 'W'){
      numReplace(self->surface, num[2], num[1], num[5], num[0], num[4], num[3]);
    }
  }

  void spin(struct dice *self, string s){
    int num[6];
    for(int i = 0; i< 6; i++){
      num[i] = self->surface[i];
    }

    if(s == "CW"){
      numReplace(self->surface, num[0], num[2], num[4], num[1], num[3], num[5]);
    }
    else if(s == "CCW"){
      numReplace(self->surface, num[0], num[3], num[1], num[4], num[2], num[5]);
    }
  }
};

bool checkDiceSurface(struct dice *d1, struct dice *d2){
  for(int i = 0; i < 6; i++){
    if(d1->surface[i] != d2->surface[i]){
      return false;
    }
    else if(i == 5 && d1->surface[i] == d2->surface[i]){
      return true;
    }
    else{
      continue;
    }
  }
}

int main(){
  struct dice d1{{0}};
  struct dice d2{{0}};
  bool check = false;
  
  for(int i = 0; i < 6; i++){
    cin >> d1.surface[i];
  }
  for(int i = 0; i < 6; i++){
    cin >> d2.surface[i];
  }

  for(int j = 0; j < 6; j++){
    for(int k = 0; k < 4; k++){
      if(checkDiceSurface(&d1, &d2)){
	check = true;
	break;
      }
      d1.spin(&d1, "CW");
    }
    if(check){ break; }

    if(j%2){ d1.rotation(&d1, 'E'); }
    else{ d1.rotation(&d1, 'S'); }
  }

  if(check){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3228
N = int(input())
T = list(map(int, input().split()))
M = int(input())
PX = [list(map(int, input().split())) for i in range(M)]

for i in range(M):
    test = []
    for j in range(N):
        test.append(T[j])
    test[PX[i][0]-1] = PX[i][1]
    print(sum(test))


Measured memory_bytes: 3060
def check_p(p):
    global k, ws
    lt, nt = 0, 1  # loadage_of_current_truck, num_of_truck
    for w in ws:
        lt += w
        if lt > p:
            nt += 1
            if nt > k:
                return False
            lt = w
    return True


n, k = map(int, input().split())

ws = [int(input()) for _ in range(n)]
l, r, p = max(ws), sum(ws), 0

while l < r:
    p = (l + r) // 2
    if check_p(p):
        r = p
    else:
        l = p = p + 1

print(p)

Measured memory_bytes: 11664
n = int(input())
 
ans = [0] * (n+1)
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            tmp = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if tmp <= n:
                ans[tmp] += 1
 
for i in ans[1:]:
    print(i)

Measured memory_bytes: 69332
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cassert>

using namespace std;

const double EPS = 1e-8;

int dcmp(double d) {
    if (fabs(d) < EPS) {
        return 0;
    } else {
        return d < 0 ? -1 : 1;
    }
}

struct Vector {
    double x, y;

    Vector(double x = 0, double y = 0) : x(x), y(y) {
    }

    bool operator<(const Vector& other) const {
        return dcmp(x - other.x) < 0 || (dcmp(x - other.x) == 0 && dcmp(y - other.y) < 0);
    }
};

typedef Vector Point;

double dot(const Vector& a, const Vector& b) {
    return a.x * b.x + a.y * b.y;
}

double cross(const Vector& a, const Vector& b) {
    return a.x * b.y - a.y * b.x;
}

Vector operator+(const Vector& a, const Vector& b) {
    return Vector(a.x + b.x, a.y + b.y);
}

Vector operator-(const Vector& a, const Vector& b) {
    return Vector(a.x - b.x, a.y - b.y);
}

Vector operator*(const Vector& a, const double& p) {
    return Vector(a.x * p, a.y * p);
}

double angle(const Vector& a) {
    return atan2(a.y, a.x);
}

double length(const Vector& a) {
    return sqrt(dot(a, a));
}

struct Circle {
    Point c;
    double r;

    Circle(double x = 0, double y = 0, double r = 0) : c(Point(x, y)), r(r) {
    }

    Point point(double rad) const {
        return Point(c.x + r * cos(rad), c.y + r * sin(rad));
    }
};

vector<Point> intersect(const Circle& a, const Circle& b) {
    int count = 0;
    Vector v = b.c - a.c;
    
    double d = length(v);   
    double rad = angle(v);
 
    vector<Point> results;
    
    double x = acos((a.r - b.r)/d);
    double y = acos((a.r + b.r)/d);
    
    if (dcmp(d - a.r - b.r) > 0) {
        results.push_back(a.point(rad + x));
        results.push_back(a.point(rad - x));
        results.push_back(a.point(rad + y));
        results.push_back(a.point(rad - y));
    } 
    else if (dcmp(d - a.r - b.r) == 0) {
        results.push_back(a.point(rad));
        results.push_back(a.point(rad + x));
        results.push_back(a.point(rad - x));
    } 
    else if (dcmp(d - fabs(a.r - b.r)) < 0) {
    } 
    else if (dcmp(d - fabs(a.r - b.r)) == 0) {
        if (a.r > b.r) {
            results.push_back(a.point(rad));
        }
        else {
            results.push_back(a.point(rad + acos(-1)));
        }
    } 
    else {
        results.push_back(a.point(rad + x));
        results.push_back(a.point(rad - x));
    }
    sort(results.begin(), results.end());
    
    return results;
}

int main() {
    double x, y, r;
    cin >> x >> y >> r;
    Circle c1(x, y, r);

    cin >> x >> y >> r;
    Circle c2(x, y, r);

    vector<Point> ans = intersect(c1, c2);

    cout << fixed << setprecision(8);

    for (Point p: ans) {
        cout << p.x << " " << p.y << endl;
    }
    return 0;
}

Measured memory_bytes: 3692
from itertools import accumulate
MOD = 10 ** 9 + 7
N = int(input())
Xs = list(map(int, input().split()))
Ds = []
for i in range(1, N):
    Ds.append(Xs[i] - Xs[i-1])
S = list(accumulate(Xs))

factorials = [1]
for i in range(1, N):
    factorials.append(factorials[-1]*i % MOD)

def div(a, b):
    return a * pow(b, MOD-2, MOD)

ans = 0
prev = 0
fact = factorials[N-1]
for i, d in enumerate(Ds):
    n = i+1
    tmp = prev + div(fact, n)
    prev = tmp
    ans += tmp * Ds[i]
    ans %= MOD

print(ans)

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

int main(){
  int n,m;
  
  cin>>n;
  vector<string> blue(n);
  for(int i=0;i<n;i++)cin>>blue.at(i);
  cin>>m;
  vector<string> red(m);
  for(int i=0;i<m;i++)cin>>red.at(i);
  int ans=0;
  
  //[]の中で範囲外の変数をキャプチャ
  //参照：https://www.xlsoft.com/jp/products/intel/compilers/ccl/12/ug/cref_cls/common/cppref_lambda_lambdacapt.htm
  auto calc=[blue,red](string s){
    int buf=0;
    for (string t:blue) 
      if (t==s) buf++;
    for (string t:red)
      if(t==s) buf--;
    return buf;
  };
  //上セミコロン忘れない
  for (string t:blue)
    ans=max(ans,calc(t));
  
  cout<<ans<<endl;  
}

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

int main() {
  string S, T;
  cin >> S >> T;
  cout << (S == T.substr(0, S.size()) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>

int ball[11], ch;

void solve(int i, int b, int c){
	
	if (i >= 1){
		
		if (b < ball[i]){
			solve(i + 1, ball[i], c);
		}
		
		if (c < ball[i]){
			solve(i + 1, b, ball[i]);
		}
		else if (b > ball[i]){
			return;
		}
		
		if (i == 9){
			ch = 1;
			return;
		}
	}
	
	if (i == 0){
		solve(i + 1, ball[i], c);
		solve(i + 1, b, ball[i]);
	}
}

int main(void)
{
	int n, i, i2;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		for (i2 = 0; i2 < 10; i2++){
			scanf("%d", &ball[i2]);
		}
		ch = 0;
		solve (0, 0, 0);
		if (ch == 1){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return (0);
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

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

  stack<char> st;

  for (int i = 0; i < s.size(); i++){
    if (s[i] == 'B'){
      if (!st.empty())
        st.pop();
    }
    else 
      st.push(s[i]);
  }

  string t = "";

  while (!st.empty()){
    t += st.top();
    st.pop();
  }
  reverse(t.begin(), t.end());

  for (auto c : t)
    cout << c;
  cout << endl;

  return 0;
}


Measured memory_bytes: 3628
import java.lang.Math.floor
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    val a = sc.nextDouble() // 8
    val b = sc.nextDouble() // 10

    for(i in 1..1250){
        if( floor(i*0.08)==a && floor(i*0.1)==b) {
            println(i)
            return
        }
    }
    println(-1)
}

Measured memory_bytes: 31396
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let n = nextInt()
    let p = nextIntArray()
    let ans = 0
    for(let i = 1; i<p.length-1; i++){
        let tmp = p.slice(i-1, i+2)
        tmp.sort((a,b)=> a-b)
        if(tmp[1] == p[i]) ans++
    }
    console.log(ans)
}
Main()


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

#define vi vector<int>
#define INFTY 2000000000

struct Card {
    char c;
    int x;
};

#define vc vector<Card>

void merge(vc& A, int left, int mid, int right) {

  int n1 = mid - left;
  int n2 = right - mid;
  vc L, R;
  for (int i = 0; i < n1; i++) {
      L.push_back(A[left + i]);
  }
  for (int i = 0; i < n2; i++) {
      R.push_back(A[mid + i]);
  }
  Card t;
  t.c = 'X';
  t.x = INFTY;
  L.push_back(t);
  R.push_back(t);
  int i = 0;
  int j = 0;
  for (int k = left; k < right; k++) {
      if (L[i].x <= R[j].x) {
          A[k] = L[i];
          i++;
      }
      else {
          A[k] = R[j];
          j++;
      }
  }
}

void mergeSort(vc& A, int left, int right) {
    if (left+1 < right) {
        int mid = (left + right)/2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int partition(vc& A, int p, int r) {
    int x = A[r].x;
    int i = p - 1;
    for (int j = p; j < r; j++) {
        if (A[j].x <= x) {
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i+1], A[r]);

    return i + 1;
}

void printArray(vc& A) {
    for (int i = 0; i < A.size(); i++) {
        cout << A[i].c << " " << A[i].x << endl;;
    }
}

void quickSort(vc& A, int p, int r) {
    if (p < r) {
        int q = partition(A, p, r);
        quickSort(A, p, q - 1);
        quickSort(A, q + 1, r);
    }
}

void compareArray(vc& A, vc& B) {
    for (int i = 0; i < A.size(); i++) {
        if (A[i].c != B[i].c) {
            cout << "Not stable" << endl;
            return;
        }
    }
    cout << "Stable" << endl;
    return;
}

int main() {

    int n;
    vc A, B;
    char tmp_c;
    int tmp_x;
    Card t;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> tmp_c >> tmp_x;
        t.c = tmp_c;
        t.x = tmp_x;
        A.push_back(t);
    }
    B = A;

    quickSort(A, 0, n-1);
    mergeSort(B, 0, n);

    compareArray(A, B);
    printArray(A);

    return 0;
}



Measured memory_bytes: 5644
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
double ans;
ll N;
 
 
 
int main(){
    cin >> N;
    ans = M_PI * N * 2;
    cout << ans << endl;
}


Measured memory_bytes: 3796
#include <cstdio>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

typedef long long LL;
int n;
LL pow10[20],ans;

void dfs(int n,int k,LL sum,int cnt)
{
    if (sum%pow10[k])
        return;
    if (k>(n-1)/2)
    {
        if (!sum)
            ans+=n&1?cnt:cnt*10;
        return;
    }
    dfs(n,k+1,sum,k?cnt*10:cnt*9);
    repu(i,1,9)
    {
        dfs(n,k+1,sum+i*(pow10[n-k]-pow10[k]),cnt*(k?10-i:9-i));
        dfs(n,k+1,sum-i*(pow10[n-k]-pow10[k]),cnt*(k?10-i:9-i));
    }
}

int main()
{
    scanf("%d",&n),pow10[0]=1;
    repu(i,1,17)
        pow10[i]=pow10[i-1]*10;
    repu(i,1,17)
        dfs(i,0,n,1);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 128
//Compile: g++ -g -Wshadow -Wall main.cpp -o a.exe -Ofast -Wno-unused-result
//Build: g++ -g -Wshadow -Wall -o "%e" "%f" -g -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG
//Compile and run: g++ -g -Wshadow -Wall main.cpp -o a.exe -Ofast -Wno-unused-result && a.exe

#pragma GCC optimize("Ofast")

#include <algorithm>
#include <bitset>
#include <chrono>
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

typedef long long ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::pair<long, long> pl;
typedef std::vector<int> vi;
typedef std::vector<ll> vl;
typedef std::vector<pii> vpii;
typedef std::vector<pl> vpl;
typedef std::vector<vi> vvi;
typedef std::vector<vl> vll;
typedef std::map<int, int> mii;
typedef std::priority_queue<int> pqd;
typedef std::priority_queue<int, vi, std::greater<int>> pqi;

#define gc getchar_unlocked
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265358979323846264
#define MOD 1e9 + 7
#define INF INT64_MAX;

#define fo(i, n) for (ll i = 0; i < n; ++i)
#define Fo(i, k, n) for (ll i = k; k < n ? i < n : i > n; k < n ? ++i : --i)
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define deb(x) cout << #x << "=" << x << endl
#define sortall(x) sort(x.begin(), x.end())
#define tr(it, a) for (auto it = a.begin(); it != a.end(); ++it)
#define ps(x, y) std::fixed << setprecision(y) << x
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mk(arr, n, type) type* arr = new type[n]

std::mt19937_64 rng(std::chrono::high_resolution_clock::now().time_since_epoch().count());

inline void setup() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

#ifdef LOCAL_PROJECT  //run with -DLOCAL_PROJECT drung compilation
    freopen("input.txt", "r", stdin);
#else
#ifndef ONLINE_JUDGE  //runs automatically for supported online judges
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
#endif
}

inline void solve();

int main() {
    setup();

    ll t = 1;

    // std::cin >> t;

    while (t--) {
        solve();
    }
    return 0;
}

using namespace std;

inline void solve() {
    ll n;
    cin >> n;

    mk(a, n, ll);

    fo(i, n) {
        cin >> a[i];
    }

    sort(a, a + n, greater<ll>());

    ll comfort = 0;

    ll id = 0;

    fo(i, n - 1) {
        comfort += a[id];
        if (!(i & 1))
            ++id;
    }

    cout << comfort;
}

Measured memory_bytes: 5152
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 2e5 + 5, mo = 1e9 + 7 ;
using namespace std ;

int n, m, A, B, fac[N], inv[N], f[N] ;

inline int mul(int a, int b) {
	int ans = 1, w = a % mo ;
	for ( ; b; b /= 2) {
		if (b & 1) ans = (ll) ans * w % mo ;
		w = (ll) w * w % mo ;
	}
	return ans ;
}

inline int calc(int x1, int y1, int x2, int y2) {
	int x = x2 - x1, y = y2 - y1 ;
	return (ll) fac[x + y] * inv[x] % mo * inv[y] % mo ;
}

int main() {
	scanf("%d%d%d%d", &n, &m, &A, &B) ;
	fac[0] = 1 ;
	rep(i, 1, n + m) fac[i] = (ll) fac[i - 1] * i % mo ;
	inv[n + m] = mul(fac[n + m], mo - 2) ;
	for (int i = n + m - 1 ; i >= 0 ; -- i) inv[i] = (ll) inv[i + 1] * (i + 1) % mo ;
	rep(i, 1, n - A) f[i] = calc(1, 1, i, B + 1) ;
	for (int i = n - A ; i; -- i) f[i] -= f[i - 1], f[i] %= mo ;
	int ans = 0 ;
	rep(i, 1, n - A) ans += (ll) f[i] * calc(i, B + 1, n, m) % mo, ans %= mo ;
	printf("%d\n", (ans + mo) % mo) ;
	return 0 ; 
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
#define endl '\n'
#define pb push_back
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main()
{
  cin.tie(0); ios::sync_with_stdio(false);

  int n, l; cin >> n >> l;

  string s;
  vector<string> str;

  rep(i, n) {
    cin >> s;
    str.pb(s);
  }

  sort( all(str) );

  string ans;

  rep(i, n) {
    ans += str[i];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
n,y=map(int,input().split())
A,B,C=[-1,-1,-1]
f=True
for a in range(n+1):
	for b in range(n+1):
		if 10000*a+5000*b+1000*(n-a-b)==y and 0<=n-a-b<=n:
			A,B,C=[a,b,n-a-b]
			f=False
			break
	if f==False:
		break
print(A,B,C)

Measured memory_bytes: 40684
n=input()
k=int(input())
dp=[[(k+1)*[0]for _ in range(2)]for _ in range(len(n))]
#dp[i][flag][j]...i文字目までみて0以外がj個あるパターン数
#flag...True(n[])
dp[0][0][0]=1
dp[0][1][1]=1
dp[0][0][1]=int(n[0])-1
for i in range(1,len(n)):
  for j in range(k+1):dp[i][1][j]=dp[i-1][1][j]
  if n[i]!="0":dp[i][1]=[0]+dp[i][1][:k]
  for j in range(k+1):dp[i][0][j]=dp[i-1][0][j]
  for j in range(k):
    dp[i][0][j+1]+=dp[i-1][0][j]*9
    if n[i]!="0":
      dp[i][0][j+1]+=dp[i-1][1][j]*(int(n[i])-1)
      dp[i][0][j+1]+=dp[i-1][1][j+1]
print(dp[-1][0][-1]+dp[-1][1][-1])
#for i in dp:print(*i)

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

using namespace std;

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

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

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

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    string s;
    cin>>n>>k>>s;
    Vec v;
    v.pb(0);
    ll tmp = 0;
    rep(i,n){
        if(i==0){
            if(s[i]=='1'){
                tmp++;
            }else{
                tmp--;
            }
        }else{
            if(s[i]!=s[i-1]){
//                if(tmp<0){
//                    tmp *= -1;
//                }
                v.pb(tmp);
                tmp=0;
            }
            if(s[i]=='1'){
                tmp++;
            }else{
                tmp--;
            }
        }
    }
//    if(tmp<0){
//        tmp *= -1;
//    }
    v.pb(tmp);
    v.pb(0);
    ll lim;
    lim = min(2*k+1,(ll)v.size());
    ll ans=0;
    rep(i,lim){
        ans += abs(v[i]);
    }
    dbg(v);
    ll sumv = ans;
    ll ind = 0;
    while(ind+lim<v.size()){
        sumv = sumv+abs(v[ind+lim])-abs(v[ind]);
        if(v[ind+1]>=0){
            ans = max(sumv,ans);
        }
        dbg(ind);
        dbg(v[ind+lim]);
        dbg(v[ind]);
        dbg(sumv);
        dbg(ans);
        ind++;
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 1528
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
using namespace std;
#define vel vector<long long>
#define vvel vector<vel>
#define int long long
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
long long p = 1000003;
vel kai(1000007, 1);
vel ink(1000007, 1);
template<typename T>
V<T> uni(V<T> &list) {
	if (list.size() == 0) { return list; }
	sort(list.begin(), list.end());
	V<T> ql(1, list[0]);
	rep(i, list.size() - 1) {
		if (list[i] != list[i + 1]) { ql.push_back(list[i + 1]); }
	}
	return ql;
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; ans %= p; }
	return ans;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, 1000006) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, 1000007) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p;
	return ans;
}
signed main() {
	string s; cin >> s;
	int n = s.size();
	int pla = -1;
	vel pl(0);
	rep(i, n) {
		if (s[i] == 'A') { pl.push_back(i); }
	}
	int sz = pl.size();
	pl.push_back(n);
	int co = 0;
	int ans = co;
	for (int i = sz - 1; i >= 0; i--) {
		int pl0 = pl[i] + 1;
		int nco = 0;
		while (pl0 + 2 <= pl[i + 1]) {
			if (s[pl0] == 'B' and s[pl0 + 1] == 'C') { nco++; pl0 += 2; }
			else { break; }
		}
		if (pl0 == pl[i + 1]) { co += nco; }
		else { co = nco; }
		ans += co;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 18296
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<set>
#include<map>
#include<ctime>
#include<iostream>
using namespace std;

int a,b,c,x,vis = 0;

int main()
{
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&x);
	if(x > a*500+b*100+c*50) printf("0\n");
	else{
		for(int i = 0;i <= a;i++){
			for(int j = 0;j <= b;j++){
				for(int l = 0;l <= c;l++){
					if(x == i * 500 + j*100 + l*50) vis+=1;
					else continue;
				}
			}
		}
		printf("%d",vis);
	}
	return 0;
}


Measured memory_bytes: 256
<?php
	fscanf(STDIN, "%d %d %d", $X, $A, $B);
	$expiration_date = $A*2;
	$eat_day = $A + $B;
	$check_day = $eat_day - $expiration_date;

	if($check_day < 0 || $check_day === 0){
		echo 'delicious';
	}else if($check_day > 0){
		if($X >= $check_day){
			echo 'safe';
		}else{
			echo 'dangerous';
		}
	}
?>

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
using ld = long double;

ld dp[3002];
int n;

int main() {
	cin>>n;
	dp[0] = 1;
	for(int i = 0; i < n; ++i){
        ld x; cin>>x;
        for(int j = i+1; j >= 0; --j){
            dp[j] = (j == 0 ? 0 : dp[j-1] * x) + (1 - x) * dp[j]; 
        }
	}
	ld ans = 0;
	for(int i = n/2+1; i <= n; i++){
	    ans += dp[i];
	}
	cout.precision(10);
	cout<<ans<<fixed;
	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE BangPatterns #-}

module Main where

import Debug.Trace
import Control.Monad

import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM

main :: IO ()
main = do
  getLine
  s <- map read . words <$> getLine 
  --a `traceShow`
  print $ solve s

solve :: [Int] -> Int
solve s = length . filter (\ss -> t U.! ss == 1) $ s
  where
    mx = (maximum s) + 1
    t = build mx s

build :: Int -> [Int] -> U.Vector Int
build mx ss = U.create $ do
  vec <- UM.replicate (mx + 1) 0
  forM_ ss $ \s -> do
    c <- UM.read vec s
    UM.modify vec (+ 1) s
    when (c < 1) $ do
      forM_ [s*2, s*3 .. mx] $ \t -> do
        UM.modify vec (+ 1) t
  return vec


Measured memory_bytes: 64488
//chessboard.cpp
#include<iostream>
using namespace std;

int main()
{
    int h,w,flag,i,j;
    flag=0;
    while (flag==0)
    {
        cin>>h>>w;
        if (h==0 && w==0)
        {
            flag=1;
        }
        else
        {
            for ( i = 0; i < h; i++)
            {
                for ( j = 0; j < w; j++) 
                {
                    if ((i+j)%2==0) cout<<"#";
                    else cout<<".";
                }
                cout<<endl;
            }
            cout<<endl;
        }
    }
}


Measured memory_bytes: 3092
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int A, B;
    io.read(A, B);
    cout << A * B - A - B + 1;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    string s;
    cin >> s;
    reverse(ALL(s));
    int n = s.size();
    int mod = 2019, r = 0, ten = 1;
    ll ans = 0;
    VI cnt(mod);
    cnt[0] = 1;
    REP(i,n){
        r = (r + (s[i] - '0') * ten) % mod;
        ten = (10 * ten) % mod;
        ans += cnt[r];
        cnt[r]++;
    }
    cout << ans << endl;
    return 0;
}


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

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



int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll ans = 0;
  ans += min(a,k);
  if(k >= a) {
    k -= a;
  }
  else {
    cout << ans << endl;
    return 0;
  }
  if(k >= b) k -= b;
  else {
    cout << ans << endl;
    return 0;
  }
  ans -= min(c,k);
  cout << ans << endl;
} 

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REP_S(i, n, s) for(int i = s; i < (int)(n); i++)
int main()
{
   	ios::sync_with_stdio(false);
	cin.tie(0);
     
	int num;
	cin >> num;

    vector<int> a(num);
    vector<int> colorList;
    REP(i, num)   
    {
        cin >> a[i];
    }

    int maxNo = a[num - 1];
    colorList.push_back(a[num - 1]);
    for(int i = num - 2; i >= 0; --i)
    {
        if(maxNo <= a[i])
        {
            colorList.push_back(a[i]);
            maxNo = a[i];
        }
        else
        {
            
            bool test = false;
            for(int j = 0; j < colorList.size(); ++j)
            {
                if(colorList[j] > a[i])
                {
                    colorList[j] = a[i];
                    test = true;
                    break;
                }
            }
            maxNo = colorList[colorList.size() - 1];
        }
    }

    cout << colorList.size() << endl;
	return 0;
}

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

using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> B(N);
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> B[i];
    A[0] = B[0];
    A[N - 1] = B[N - 2];
    for(int i = 1; i < N - 1; i++){
      A[i] = min(B[i],B[i - 1]);
    }
    int ans = 0;
    for(int i = 0; i < N; i++) ans += A[i];
    cout << ans;
 return 0;
}

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

char a[50], b[50];
int main() {
	int n, r;
	while (scanf("%d%d", &n, &r), n) {
		for (int i = n - 1; i >= 0; i--)a[i] = n - i;
		rep(i, r) {
			int p, c; scanf("%d%d", &p, &c);
			memcpy(b, a, p - 1);
			memmove(a, a + p - 1, c);
			memcpy(a + c, b, p - 1);
		}
		printf("%d\n", (int)a[0]);
	}
}

Measured memory_bytes: 3220
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair

int main(void)
{
    cin.sync_with_stdio(false);
    string str;
    while(cin >> str){
        reverse(ALL(str));
        cout << str << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1176
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>

#define ll long long

using namespace std;
int N, A, B;
int sum = 0;

int digit_sum(int i)
{
    int s = 0;

    while (i > 0) {
        s += i % 10;
        i /= 10;
    }

    return s;

}

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

    for (int i=1; i<=N; i++) {
        int s = digit_sum(i);
        if (s >= A && s <= B) {
            sum += i;
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    A = list(map(int, rl().split()))
    
    d = defaultdict(int)
    ans = 0
    for i in range(N)[::-1]:
        ans += d[-A[i] - i]
        d[A[i] - i] += 1
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 135652
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;

	vector< pair<int, int> > cities[n];
	for (int i = 0; i < m; i++) {
		int prefecture, year;
		cin >> prefecture >> year;

		cities[prefecture - 1].push_back(pair<int, int> (year, i));
	}

	pair<int, int> ans[m];
	for (int i = 0; i < n; i++) {
		sort(cities[i].begin(), cities[i].end());
		for (int j = 0; j < cities[i].size(); j++) {
			int index = cities[i][j].second;
			ans[index] = make_pair(i, j);
		}
	}

	for (int i = 0; i < m; i++) {
		cout << setfill('0') << setw(6) << right << (ans[i].first + 1);
		cout << setfill('0') << setw(6) << right << (ans[i].second + 1) << endl;
	}

}


Measured memory_bytes: 7808
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>

#define EPS (1e-8)

using namespace std;

int main() {
  int w, n;
  while(cin >> w >> n, w) {
    int a[n][2];
    int r[w];
    int t;
    for (int i = 0; i < n; i++) {
      cin >> a[i][0];
      cin.ignore();
      cin >> a[i][1];
    }
    for (int i = 0; i < w; i++) {
      r[i] = i + 1;
    }
    for (int i = 0; i < n; i++) {
      t = r[a[i][1] - 1];
      r[a[i][1] - 1] = r[a[i][0] - 1];
      r[a[i][0] - 1] = t;
    }
    for (int i = 0; i < w; i++) {
      cout << r[i] << endl;
    }
    w = 0;
  }
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  string s; cin >> s;
  i64 ans = 0;
  i64 sum = 0;
  i64 acc = s[0] - '0';
  function<void(int)> dfs = [&](int x) {
    if (x == s.size()) {
      ans += sum + acc;
      return;
    }
    // 付け加える
    {
      acc *= 10;
      acc += s[x] - '0';
      dfs(x + 1);
      acc -= s[x] - '0';
      acc /= 10;
    }
    // +を入れる
    {
      i64 tmp = acc;
      sum += tmp;
      acc = s[x] - '0';
      dfs(x + 1);
      acc = tmp;
      sum -= tmp;
    }
  };
  dfs(1);
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <tuple>
#include <set>
using namespace std;

#define INF 100000000;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
#define eps 1.0e-14;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main(){
    ll N;
    ll ans = 0;
    set<ll> st;
    cin >> N;
    ll originN = N;
    bool isFinished = false;
    if (N == 1){
        cout << 0 << endl;
        return 0;
    }
    ll begin = sqrtl(N);
    // while(!isFinished){
    //     ll X = yakusuu( originN, begin);
    //     st.insert(X);
    //     N /= X;
    //     begin = X;
    //     cout << X << endl;
    //     if(N == 1 || X == 1){
    //         isFinished = true;
    //         break;
    //     }
    // }
    vector<pair<long long, long long> > pair;
    pair = prime_factorize(N);
    for(auto&& x : pair){
        //cout << x.second << endl;
        for(int i = 1; i <= x.second; i++){
            // N /= powl(x.first,i);
            x.second -= i;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3700
import Data.Char
main = do
  text<- getContents
  putStr $ unlines $ zipWith (\c x -> [c]++" : "++show x) ['a'..'z'] (count text)
    where
      lower txt = map (\c-> length $ filter (== c) txt) ['a'..'z']
      upper txt = map (\c-> length $ filter (== c) txt) ['A'..'Z']
      count txt = zipWith (+) (lower txt) (upper txt)

Measured memory_bytes: 3604
//package solution;

import java.io.*;
import java.util.*;
import java.math.*;
import java.text.*;
import java.awt.Point;

public final class Main {
    BufferedReader br;
    StringTokenizer stk;

    public static void main(String[] args) throws Exception {
        //new Thread(null, new Runnable() {
            //@Override
            //public void run() {
                //try {
                    new Main().run();
                //} catch(Exception ex) {ex.printStackTrace();}
            //}
        //}, "solution", 1<<26).start();
    }
    
    {
        stk = null;
        br = new BufferedReader(new InputStreamReader(System.in));
    }
    
    //long mod = 1000000007L;
    void run() throws Exception {
        long n = ni();
        long total = (n / 500) * 1000;
        n %= 500;
        total += (n / 5) * 5;
        pl(total);
    }
    
    //Reader & Writer
    String nextToken() throws Exception {
        if (stk == null || !stk.hasMoreTokens()) {
            stk = new StringTokenizer(br.readLine(), " ");
        }
        return stk.nextToken();
    }

    String nt() throws Exception {
        return nextToken();
    }

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

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

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

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

    void p(Object o) {
        System.out.print(o);
    }

    void pl(Object o) {
        System.out.println(o);
    }
}

Measured memory_bytes: 21204
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int a, b, c, k;
int main() {
	scanf("%d %d %d %d", &a, &b, &c, &k);
	int sum = min(a, k);
	k = max(0, k - a);
	k = max(0, k - b);
	sum -= min(c, k);
	printf("%d\n", sum);
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, x;
    cin >> n >> x;
    n = 2 * n - 1;
    --x;
    if (x == 0 || x == n - 1)
    {
        cout << "No";
        return 0;
    }
    cout << "Yes" << endl;
    if (n == 3 && x == 1)
    {
        cout << "1\n2\n3";
        return 0;
    }
    vector<int> odp(n, -1);
    vector<bool> bylo(n, false);
    int s = n / 2;
    if (x == 1)
    {
        odp[s - 1] = 0;
        odp[s] = 1;
        odp[s + 1] = 2;
        odp[s - 2] = 3;
        bylo[0] = bylo[1] = bylo[2] = bylo[3] = true;
    }
    if (x == n - 2)
    {
        odp[s + 1] = n - 1;
        odp[s] = n - 2;
        odp[s - 1] = n - 3;
        odp[s + 2] = n - 4;
        bylo[n - 1] = bylo[n - 2] = bylo[n - 3] = bylo[n - 4] = true;
    }
    if (x != 1 && x != n - 2)
    {
        odp[s] = x;
        odp[s - 1] = x - 1;
        odp[s - 2] = x + 2;
        odp[s + 1] = x + 1;
        bylo[x] = bylo[x - 1] = bylo[x + 2] = bylo[x + 1] = true;
    }
    for (int i = 0, j = 0; i < n; ++i)
    {
        if (odp[i] == -1)
        {
            while (bylo[j])
                ++j;
            odp[i] = j;
            bylo[j] = true;
        }
    }
    for (int i = 0; i < n; ++i)
        cout << odp[i] + 1 << endl;
    return 0;
}


Measured memory_bytes: 2304
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = 0;
            while ((n = int.Parse(Console.ReadLine())) != 0)
            {
                var table = new Dictionary<string, string>();
                while (n-- != 0)
                {
                    var t = Console.ReadLine().Split(' ');
                    table.Add(t[0], t[1]);
                }

                var m = int.Parse(Console.ReadLine());
                var s = new List<char>();
                while (m-- != 0)
                {
                    var c = Console.ReadLine();
                    s.Add(table.ContainsKey(c) ? table[c][0] : c[0]);
                }
                Console.WriteLine(new string(s.ToArray()));
            }
        }
    }
}

Measured memory_bytes: 6508
#include <bits/stdc++.h>
using namespace std;
template<typename T>
inline T read(T&x){
	x=0;int f=0;char ch=getchar();
	while (ch<'0' || ch>'9') f|=(ch=='-'),ch=getchar();
	while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x=f?-x:x;
}
const int N=(1<<18)+10;
int n,i,j,status,a[N];
pair<int,int> f[N];
inline void up(pair<int,int> &a,pair<int,int> b){
	if (b.second>=a.first){
		a=b;
	}
	else if (b.first>=a.first){
		a.second=a.first;
		a.first=b.first;
	}
	else if (b.first<a.first && b.first>=a.second){
		a.second=b.first;
	}
}
int main(){
	read(n);
	for (i=0;i<(1<<n);++i){
		read(a[i]);
		f[i].first=a[i];
	}
	for (i=0;i<n;++i){
		for (status=0;status<(1<<n);++status){
			if (status&(1<<i)) up(f[status],f[status^(1<<i)]);
		}
	}
	int res=0;
	for (i=1;i<(1<<n);++i){
		res=max(res,f[i].first+f[i].second);
		printf("%d\n",res);
	}
	return 0;
}

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


typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#define pb push_back
#define popb pop_back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second

#define forz(i,n) for( int i=0;i<n;i++)
#define forl(i, n) for(int i = 0; i<= n; i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
// #define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)

using namespace std;

void cpc()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w" , stdout);
#endif
}
lli power(lli x, lli y)
{
	lli res = 1;     // Initialize result
	// lli p = mod;
	x = x ; // Update x if it is more than or
	// equal to p

	if (x == 0) return 0; // In case x is divisible by p;

	while (y > 0)
	{
		// If y is odd, multiply x with result
		if (y & 1)
			res = (res * x);

		// y must be even now
		y = y >> 1; // y = y/2
		x = (x * x);
	}
	return res;
}

// lli mod(lli x)
// {
// 	if (x < 0)
// 		x = -x;
// 	return x;
// }



int main()
{
	// cpc();
	// kira;
	lli n , k, ct = 0;
	cin >> n >> k;
	lli arr[n + 1] = {0};
	forz(i, k)
	{
		lli d;
		cin >> d;
		forz(j, d)
		{
			lli s;
			cin >> s;
			arr[s]++;
		}
	}
	for (int i = 1; i <= n; i ++)
	{
		if (arr[i] == 0)
		{
			ct ++;
		}
	}
	cout << ct << endl;
	return 0;
}

Measured memory_bytes: 3676