akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
		#include <ext/pb_ds/assoc_container.hpp>
		#include <ext/pb_ds/tree_policy.hpp>
		using namespace __gnu_pbds;
		using namespace std;
		typedef long long ll;
		typedef unsigned long long int ull;
		// PB-DS
		#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
 
		#define ff first
		#define ss second
		#define pb push_back
		#define Inf  1000000000000000000
		#define inf -1000000000000000000
		#define mod 1000000007
 
		ll mulmod(ll x,ll y){
			  return (x%mod*y%mod)%mod;
		}
 
		ll addmod(ll x,ll y){
			  return (x%mod+y%mod)%mod;
		}
 
		long long  power(long long  x,long long  y) {
				long long  res = 1;
				x = x%mod;
				while (y > 0)
				{
					if (y & 1)
						res = (res*x)%mod;
					y = y>>1;
					x = (x*x)%mod;
				}
				return res;
		}
	
 
void testcases(int cases){
		int N , D;
		cin >> N >> D;
		int ans = 0;
		while(N--){
			long double X,Y;
			cin >> X >> Y;
			long double Dis = sqrtl(X*X+Y*Y);
			if(Dis<=D)
				ans++;
		}
		cout << ans << "\n";
}
	
		 
int main()
{
		
	//sieve();
		ios_base::sync_with_stdio(false);
		cin.tie(0);
		cout.tie(0);
		ll t;
		t = 1;
				//cin >> t;
		ll Case =1 ;
		while(t--)
		{
		 testcases(Case++);
		}
}


Measured memory_bytes: 3832
#include<iostream>
#include<string>
#include<vector>

using namespace std;

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


int const MAX_N = 100000;
vector<int> G[MAX_N];
int taka[MAX_N];
int ao[MAX_N];

void dfs(int e, int num, int per[]){
    rep(i, G[e].size()){
        int edge = G[e][i];
        if (per[edge] != -1) continue;
        else {
            per[edge] = num;
            dfs(edge, num + 1, per);
        }
    }
}

int main(){
    int n, u , v;
    cin >> n >> u >> v;
    u--;
    v--;
    rep(i, n - 1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    fill(taka, taka + n, -1);
    fill(ao, ao + n, -1);

    taka[u] = 0;
    dfs(u, 1, taka);
    ao[v] = 0;
    dfs(v, 1, ao);
    // rep(i, n) cout << taka[i] << " ";
    // cout << endl;
    int ans = 0;
    int idx;
    rep(i, n){
        if (taka[i] < ao[i] && ans < ao[i]){
            ans = ao[i];
            idx = i;
        }
    }
    cout << ans - 1 << endl;
    // if ((ao[idx] - taka[idx]) % 2 == 0){
    //     cout << ans - 1 << endl;
    // }else{
    //     cout << ans << endl;
    // }
    
}

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

ll arr[200005] ;
map <ll, ll> mp, mpX ;

int main()
{
    ll n, val, kVal, ans = 0, prevAns ;
    cin >> n ;
    for (int i = 0; i < n; i++) {
        cin >> arr[i] ;
        mp[arr[i]]++ ;
    }
    for (auto it = mp.begin(); it != mp.end(); it++) {
        val = (it->second * (it->second - 1) ) / 2 ;
        ans += val ;
        mpX[it->first] = val ;
    }

    for (int i = 0; i < n; i++) {
        prevAns = ans ;
        prevAns -= mpX[arr[i]] ;
        val = ((mp[arr[i]] - 1) * (mp[arr[i]] - 2)) / 2 ;
        prevAns += val ;
        cout << prevAns << endl ;
    }
}


Measured memory_bytes: 18944
#include<iostream>
#include<stdio.h>
#include<cstdlib>
#include <cstring>
using namespace std;
struct Node {
	int key;
	Node* pre;
	Node* next;
};
Node* nil;
void init() {
	nil = new Node;
	nil->pre = nil;
	nil->next = nil;
}
void insert(int x) {
	Node* add = new Node;
	add->key = x;
	add->next = nil->next;
	nil->next->pre = add;
	nil->next = add;
	add->pre = nil;
	add->next;
}
void deleteNode(Node* d) {
	if (d == nil)return;
	Node* p = d->pre;
	Node* n = d->next;
	p->next = n;
	n->pre = p;
	free(d);
}
void deleteOne(int x) {
	Node* i = nil->next;
	while (i!=nil&&i->key != x)
		i = i->next;
	deleteNode(i);
}
void deleteFirst() {
	deleteNode(nil->next);
}
void deleteLast() {
	deleteNode(nil->pre);
}
int main() {
	init();
	int len;
	cin >> len;
	for (int i = 0; i < len; i++) {
		char op[20];
		int x;
		scanf("%s", op);
		if (op[0] == 'i') {
			scanf("%d", &x);
			insert(x);
		}
		else if (op[0] == 'd') {
			if (strlen(op) <= 6) {
				scanf("%d", &x);
				deleteOne(x);
			}
			else if (op[6] == 'F')
				deleteFirst();
			else
				deleteLast();
		}
	}
	Node* item = nil->next;
	while (nil->pre != item) {
		printf("%d ", item->key);
		item = item->next ;
	}
	printf("%d\n", item->key);
	return 0;
}


Measured memory_bytes: 34436
a, b, c, x, y = [int(c) for c in input().split(' ')]
max_num_ab = 2 * max(x, y)
min_price = a * x + b * y
for num_ab in range(0, max_num_ab + 2, 2):
    price_ab = c * num_ab
    count_a = int(num_ab / 2)
    count_b = int(num_ab / 2)
    if count_a >= x:
        price_a = 0
    else:
        price_a = (x - count_a) * a

    if count_b >= y:
        price_b = 0
    else:
        price_b = (y -count_b) * b

    min_price = min(min_price, price_ab + price_a + price_b)
print(min_price)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, x: int, a: "List[int]"):
    # 左から貪欲
    counter = 0
    for i in range(N-1):
        # i, i+1について
        if a[i] + a[i+1] <= x:
            continue
        if a[i] > x:
            counter += a[i] - x
            a[i] = x
            if a[i+1] != 0:
                counter += a[i+1]
                a[i+1] = 0
        else:
            counter += a[i]+a[i+1]-x
            a[i+1] = x-a[i]

    print(counter)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, x, a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 15476
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define INF_MAX INT_MAX
#define INF_MIN ((int)1<<31)-1
using namespace std;
class Segtree{
    vector<int> tree;
    int n=1,m,Inf;
    void Set(vector<int> vec){
        rep(i,n*2-2)tree[i+1]=Inf;
        rep(i,vec.size())tree[i+n]=vec.at(i);
        update(0,n-1);
    }
    int sum(int a,int b){
        if(m==0)return max(a,b);
        else if(m==1)return min(a,b);
        else if(m==2)return a+b;
        else return a*b;
    }
    int query(int a,int b,int x,int l,int r){
        if(r<a||b<l)return Inf;
        if(a<=l&&b>=r)return tree[x];
        return sum(query(a,b,x*2,l,(l+r)/2),query(a,b,x*2+1,(l+r)/2+1,r));
    }
    void update(int l,int r){
        l+=n,r+=n;
        l/=2,r/=2;
        while(1){
            if(l==0)break;
            int xl=l;
            for(;xl<=r;xl+=2){
                tree[xl]=sum(tree[xl*2],tree[xl*2+1]);
            }
            l/=2,r/=2;
        }
    }
public:
    void Max(vector<int> vec){
        m=0;
        Inf=INF_MAX;
        Set(vec);
    }
    void Min(vector<int> vec){
        m=1;
        Inf=INF_MIN;
        Set(vec);
    }
    void Add(vector<int> vec){
        m=2;
        Inf=0;
        Set(vec);
    }
    void Multiply(vector<int> vec){
        m=3;
        Inf=1;
        Set(vec);
    }
    Segtree(int in){
        for(;in>n;n*=2);
        tree.resize(n*2);
    }
    void Set(int a,int b){
        tree[a+n]=b;
        update(a,a);
    }
    int query(int a,int b){
        return query(a,b,1,0,n-1);
    }
};
class Union_Find{
private:
    vector<int> t,s;
public:
    Union_Find(int max_length){
        rep(i,max_length+1){
            t.push_back(i);
            s.push_back(1);
        }
    }
    void Union(int x,int y){
        if(same(x,y))return;
        int tx=Find(x),ty=Find(y);
        if(s[tx]<s[ty]){
            s[ty]+=s[tx];
            t[tx]=ty;
        }
        else if(s[tx]>s[ty]){
            s[tx]+=s[ty];
            t[ty]=tx;
        }
        else if(tx>ty){
            t[tx]=ty;
            s[ty]+=s[tx];
        }
        else{
            t[ty]=tx;
            s[tx]+=s[ty];
        }
    }
    int Find(int n){
        if(t[n]==n)return n;
        else return t[n]=Find(t[n]);
    }
    bool same(int x,int y){
        return Find(x)==Find(y);
    }
};
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m,x[100000],ans=0,memo[100000];
    cin>>n>>m;
    rep(i,m){
        cin>>x[i];
    }
    sort(x,x+m);
    if(m==1)cout<<0<<endl;
    else{
        rep(i,m-1){
            memo[i]=x[i+1]-x[i];
            ans+=x[i+1]-x[i];
        }
        sort(memo,memo+m-1);
        rep(i,n-1){
            ans-=memo[m-i-2];
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i< (n); i++)
using namespace std;
 
int main() {
  int N, M;
  cin >> N >>M;
  
  
  vector<int> A(M);
  vector<int> B(M);
  vector<int> count(N + 1, 0);
  
  for (int i = 0; i<M; i++){
  	cin>>A[i]>>B[i];
  }
  
  for (int i = 0; i<M; i++){
  	count[A[i]] ++;
    count[B[i]] ++;
  }
  
  for(int i = 1; i<N + 1;i++){
  	cout<<count[i]<<endl;
  }
}

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

int main()
{
    int n, p;
    string s;
    cin >> n >> p >> s;
    ll ans = 0;
    if (p == 2)
    {
        for (int i = 0; i < n; i++)
        {
            if ((s[i] - '0') % 2 == 0)
                ans += i + 1;
        }
    }
    else if (p == 5)
    {
        for (int i = 0; i < n; i++)
        {
            if (s[i] == '0' || s[i] == '5')
                ans += i + 1;
        }
    }
    else
    {
        map<int, int> mp;
        mp[0]++;
        int t = 0, power = 1;
        for (int i = n - 1; i >= 0; i--)
        {
            t = (t + (s[i] - '0') * power) % p;
            ans += mp[t];
            mp[t]++;
            power = power * 10 % p;
        }
    }
    cout << ans << endl;
}


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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

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

const int A_MAX = 3e5;

int op(int a, int b) { return max(a, b); }
int e() { return 0; }

int main(){
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    segtree<int, op, e> dp(A_MAX+5);
    rep(i, n) {
        int l = max(0,a[i]-k), r = min(A_MAX,a[i]+k)+1;
        int now = dp.prod(l, r);
        dp.set(a[i], now+1);
    }
    cout << dp.all_prod() << endl;
    return 0;
}


Measured memory_bytes: 9620
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
#define fil(x) memset(x, 0, sizeof(x))
#define fillb(x) memset(x,false,sizeof(x))
#define fillm(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define pll pair<int, int>
#define pf printf
#define sf scanf
#define all(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<n;i++)
#define fof(i,a,b) for(int i=a;i<=b;i++)
#define off(i,a,b) for(int i=a;i>=b;i--)
#define of(i,n) for(int i=n-1;i>=0;i--)
#define stl(i,x) for(auto i=x.begin(); i!=x.end();i++)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define nl endl

typedef unsigned long long lll;
typedef long long ll;
int knigtx8[] = {2, 2, -2, -2, 1, 1, -1, -1}; ///knight move in chess
int knigty8[] = {1, -1, 1, -1, 2, -2, 2, -2}; ///knight move in chess
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; ///for 8 directions
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1}; ///for 8 directions
int dx4[] = {0, 0, 1, -1}; ///for 4 directions
int dy4[] = {1, -1, 0, 0}; ///for 4 directions
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}
ll pw(ll a, ll b)
{
    ll ans = 1;
    for(ll i = 1; i <= b; ++i)
        ans = (ans * a);
    return ans;
}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

int n;
int a[100005][4];
int dp[100005][4];

int func(int day, int flag)
{
    if(day==n) return 0;
    if(dp[day][flag]!=-1) return dp[day][flag];
    int mx=0;
    if(flag==0)
    {
        mx = max(mx, a[day][1] + func(day+1, 1));
        mx = max(mx, a[day][2] + func(day+1, 2));
        mx = max(mx, a[day][3] + func(day+1, 3));
    }
    else if(flag==1)
    {
        mx = max(mx, a[day][2] + func(day+1, 2));
        mx = max(mx, a[day][3] + func(day+1, 3));
    }
    else if(flag==2)
    {
        mx = max(mx, a[day][1] + func(day+1, 1));
        mx = max(mx, a[day][3] + func(day+1, 3));
    }
    else
    {
        mx = max(mx, a[day][1] + func(day+1, 1));
        mx = max(mx, a[day][2] + func(day+1, 2));
    }

    return dp[day][flag] = mx;
}

int main()
{
    IOS;
    fillm(dp);
    cin>>n;
    fo(i,n)
    {
        fof(j,1,3)
        {
            cin>>a[i][j];
        }
    }
    cout<<func(0,0);
    return 0;
}

///Alhamdulillah


Measured memory_bytes: 14500
#include <stdio.h>

double  calcIndex(int n, int k, int val)
{
	int tmp = 1;
	double probability = (double) 1 / n;
	while ( 1 ) {
		if ( val * tmp  >= k ) break;
		tmp *= 2;
	}
	return (double) probability / tmp;
}

int main()
{
	int n,k;
	double probability = 0;
	scanf("%d %d", &n, &k);
	for ( int val = 1; val <= n; val++ ) {
		probability += calcIndex(n, k, val);
	}
	printf("%.10f\n", probability);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    if(s[0]=='S'){
        if(s[1]=='U'){
            cout << 7<<endl;
        }
        else{
            cout << 1<<endl;
        }
    }
    else if(s[0]=='M'){
        cout << 6<<endl;
    }
    else if(s[0]=='T'){
        if(s[1]=='U'){
            cout << 5<<endl;
        }else{
            cout<<3<<endl;
        }
    }
    else if(s[0]=='W'){
        cout << 4<<endl;
    }
    else if(s[0]=='F'){
        cout << 2<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}
int sigma(int n){
    int sum=0;
    for (int i=1; i<=(n); i++){
        sum+=i;
    }
    return sum;
}
int distance(int yo,int xo,int yi,int xi){
    return (yo-yi)*(yo-yi)+(xo-xi)*(xo-xi);
}
signed main(){
    string S;
    
    cin >> S;
    if(S=="MON"){
        cout << 6 << endl;
        return 0;
    }
    if(S=="MON"){
        cout << 6 << endl;
        return 0;
    }
    if(S=="TUE"){
        cout << 5 << endl;
        return 0;
    }
    if(S=="WED"){
        cout << 4 << endl;
        return 0;
    }
    if(S=="THU"){
        cout << 3 << endl;
        return 0;
    }
    if(S=="FRI"){
        cout << 2 << endl;
        return 0;
    }
    if(S=="SAT"){
        cout << 1 << endl;
        return 0;
    }
    if(S=="SUN"){
        cout << 7 << endl;
        return 0;
    }
}


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

namespace ConsoleApplication14
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int a = int.Parse(Console.ReadLine());
                if (a == 0)
                    break;
                int[] b = new int[a / 4];
                int d = 0;
                for (int c = 0; c < a / 4; c++)
                    b[c] = int.Parse(Console.ReadLine());
                for (int e = 0; e < a / 4; e++)
                    d += b[e];
                Console.WriteLine(d);
            }
        }
    }
}

Measured memory_bytes: 9104
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long res = 1L;
		for (int i=1; i<=N; i++) {
			res = (i*res)%((long)Math.pow(10,9)+7);
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 21332
N=int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

count=0
for i in range(N):
    c=B[i]-A[i]
    if c>=0:
        count+=A[i]
#        print("1",i,A[i],B[i],c,count)
    if c>0 and A[i+1]>c:
        A[i+1]=A[i+1]-c
        count+=c
#        print("2",i,A[i],B[i],c,count)

    elif c>0 and A[i+1]<=c:
        count+=A[i+1]
        A[i+1]=0
#        print("3",i,A[i],B[i],c,count)

    if c<0:
        count+=B[i]
#        print("4",i,A[i],B[i],c,count)
    # if i ==N and A[i+1]>c:
    #     count+=A[i+1]
    #     print(N,i,"aaa")
    # if i ==N and A[i+1]>=c:
    #     count+=c
    #     print("bbb",i,N,c)

# if  A[i+1]>c:
#     count+=A[i+1]
#     print(N,i,"aaa")
# if  A[i+1]>=c:
#     count+=c
#     print("bbb",i,N,c)

print(count)

Measured memory_bytes: 82020
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdint>
#include<cstdlib>

template<typename T>
void fin(T const& v){ std::cout << v << std::endl; exit(0); }
int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int64_t N; std::cin >> N;
  std::vector<int64_t> A(N);
  for(auto& v: A) std::cin >> v;
  int64_t sum = 0, n2 = N*(N+1)/2;
  for(auto v: A) sum += v;
  if(sum%n2 != 0) fin("NO");
  int64_t d = sum/n2;
  for(int i = 0; i < N; ++i) A[i] -= d*(i+1);
  std::vector<int64_t> ix(N, 0);
  ix[0] = d;
  for(int i = 0; i < N-1; ++i) {
    int64_t diff = A.back() - A[i];
    if(diff%N != 0) fin("NO");
    diff /= N;
    ix[i] += diff;
    if(ix[i] < 0) fin("NO");
    ix[i+1] -= diff;
  }
  if(ix.back() < 0) fin("NO");
  fin("YES");
  return 0;
}

Measured memory_bytes: 1792
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        L:Chars,
    }
    let n = L.len();
    let mut dp = vec![vec![0; 2]; n + 1];

    dp[0][0] = 0;
    dp[0][1] = 1;
    for i in 0..n {
        dp[i][0] %= MOD;
        dp[i][1] %= MOD;
        if L[i] == '0' {
            dp[i + 1][0] += dp[i][0] * 3;
            dp[i + 1][1] += dp[i][1];
        } else {
            dp[i + 1][0] += dp[i][0] * 3;
            dp[i + 1][1] += dp[i][1] * 2;
            dp[i + 1][0] += dp[i][1];
        }
    }
    println!("{}", (dp[n][0] + dp[n][1]) % MOD);
}

const MOD: i64 = 1000000007;


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

int main() {
    int64_t h, w;
    cin >> h >> w;

    if ( h == 1 || w == 1){
        cout << 1 << endl;

    }
    else{
        cout << (h * w + 1) / 2 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int clz(int x) { return 31 - __builtin_clz(x); }
int clz(ll x) { return 63 - __builtin_clzll(x); }
int ctz(int x) { return __builtin_ctz(x); }
int ctz(ll x) { return __builtin_ctzll(x); }

class compare {
public:
	bool operator()(tuple<ll, ll> a, tuple<ll, ll> b) {
		return (get<1>(a) > get<1>(b));
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	string s;
	cin>>n;
	cout<<0<<endl;
	cin>>s;
	map<int,bool> mp;
	if(s=="Vacant")return 0;
	mp[0]=((s=="Male")^(0%2==1));
	cout<<n-1<<endl;
	cin>>s;
	if(s=="Vacant")return 0;
	mp[n-1]=((s=="Male")^((n-1)%2==1));
	int l=0,r=n-1;
	rep(i,18){
		int t=(l+r)/2;
		cout<<t<<endl;
		cin>>s;
		if(s=="Vacant")return 0;
		bool m=((s=="Male")^(t%2==1));
		mp[t]=m;
		if(mp[l]==mp[t])l=t;
		else r=t;
	}
}


Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
const ll MX=1e18+7;
int main()
{
	int n;
	cin>>n;
	ll tcnt=0,acnt=0;
	for(int i=1;i<=n;i++)
	{
		ll t,a;
		cin>>t>>a;
		int g=__gcd(t,a);
		t/=g;a/=g;
		ll L=1,R=MX,j=-1;
		while(L<=R)
		{
			ll mid=L+R>>1;
			if((__int128)t*mid>=tcnt&&(__int128)a*mid>=acnt)
			{
				R=mid-1;
				j=mid;
			}
			else L=mid+1;
		}
		tcnt=t*j;
		acnt=a*j;
		assert(j!=-1);
	}
	cout<<tcnt+acnt<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

int main(){
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n; cin >> n;
    string s; cin >> s;

    int i=0, cnt=0;

    while(i<n){
        if(s[i]!=s[i-1]) cnt++;
        i++;
    }

    cout << cnt << endl;

    

    return 0;
}

Measured memory_bytes: 512
/*

साहिल पे पहुंचने से इनकार किसे है लेकिन,
तूफ़ानो से लड़ने का मज़ा ही कुछ और है,
कहते है, कि किस्मत खुदा लिखता है लेकिन,
उसे मिटा के खुद गढ़ने का मजा ही कुछ और है।

*/


#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
using namespace std;
 
#define int                 long long int
#define ull					unsigned int
#define ld                  long double
#define pb                  push_back
#define ff                  first
#define ss                  second
#define S(arr)              sort(arr.begin(),arr.end());
#define RS(arr)              sort(arr.rbegin(),arr.rend());
#define R(arr)              reverse(arr.begin(),arr.end());
#define si                  set <int>
#define vi                  vector <int>
#define vvi                 vector <vector <int>>
#define vs                  vector <string>
#define pii                 pair <int, int>
#define vpi                 vector <pii>
#define vpp                 vector <pair<int, pii>>
#define mii                 map <int, int>
#define mci                 map<char, int>
#define mpi                 map <pii, int>
#define spi                 set <pii>
#define speed               ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl                "\n"
#define all(p)              p.begin(), p.end()
#define T                   int tcf;cin>>tcf;while(tcf--)
#define que_max(t)             priority_queue <t>
#define que_min(t)             priority_queue <t, vector<t>, greater<t>>
#define debuga(a, l, r)     for(auto x:a)cout<<x<<" ";cout<<endl;
#define debug1(x)           cout << #x " = " << x << endl;
#define debug2(x,y)         cout << #x " = " << x << " " << #y " = " << y << endl;
#define debug3(x,y,z)       cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define debug4(x,y,z,w)     cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << " " << #w " = " << w << endl;
#define debug5(x,y,z,w,v)   cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << " " << #w " = " << w << " " << #v " = " << v << endl;
#define debug6(x,y,z,w,v,a) debug3(a, y, x)debug3(w, v, a)
#define p2d(v)     	    for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)      	    for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppi(v)	for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;

 
void read(int n=10){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<setprecision(n)<<fixed;
    #ifndef ONLINE_JUDGE
         freopen("input.txt",  "r",  stdin);
         freopen("output.txt", "w", stdout);
    #endif
}

int M = 1e9 + 7;
int M1 = 998244353;
#define qqq 4000005



int32_t main(){
//	read();
	int a,b;
	cin>>a>>b;
	cout<<(a*b)/__gcd(a,b);
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  char c[2][3];
  for (size_t i = 0; i < 2; i++) {
    for (size_t j = 0; j < 3; j++) cin >> c[i][j];
  }

  if (c[0][0]==c[1][2] and c[0][1]==c[1][1] and c[0][2]==c[1][0]) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  vector<int> b(N);
  int cnt=0;
  bool can=false;
  for(int i=0;i<N;i++){
    cin >> a[i] >> b[i];
    if(a[i]==b[i]){
      cnt++;
    }
    else{
      cnt=0;
    }
    if(cnt>=3){
      can=true;
      break;
    }
  }
  if(can){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" <<endl;
  }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,a[200010]={},tmp,cnt=0;
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> tmp;
    if(a[tmp]==0){
      cnt++;
    }
    a[tmp]++;
  }
  sort(a,a+200010);
  if(cnt<=k){
    cout << 0 << endl;
    return 0;
  }
  int sum=0;
  int i=0;
  while(cnt>k){
    if(a[i]!=0){
      sum+=a[i];
      cnt--;
    }
    i++;
  }
  cout << sum << endl;
  return 0;
}	

Measured memory_bytes: 1024
n=int(input())
w=list(map(int, input().split()))

mn=10**9
for t in range(1,101):
        sm1=0
        sm2=0
        for i in range(len(w)):
                if i<=t:
                        sm1+=w[i]
                else:
                        sm2+=w[i]
        if mn > abs(sm1-sm2):
                 mn = abs(sm1-sm2)
print(mn)

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

//.define
// #define FILE_IN_OUT
#define RET(_x)    return cout << (_x) << '\n', 0;
#define all(_obj)  (_obj).begin(), (_obj).end()
#define loop(_n)   for (int i = 0; i < (_n); ++i)
#define sz(_obj)   static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)  std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)  {}
#endif
#define endl "\n"
template<typename P, typename Q>
P CeilDiv(P _dividend, Q _divider) {
    return static_cast<P>((_dividend - 1LL + _divider) / _divider);
}
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n;
    ll d;
    cin >> n >> d;
    d *= d;
    int ans = 0;
    loop(n) {
        ll x, y;
        cin >> x >> y;
        if (x * x + y * y <= d) {
            ++ans;
        }
    }
    cout << ans << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;

//

#define RESIDUE(u,v) (capacity[u][v] - flow[u][v])
#define RCOST(u,v) (cost[u][v] + h[u] - h[v])
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

int n;
string w[100];

int main(){
  cin>>n;
  REP(i,n){
    cin>>w[i];
  }
  
  REP(i,n){
    REP(j,i){
      if(w[i]==w[j]){
	cout<<"No"<<endl;
	return 0;
      }
    }
  }

  REP(i,n-1){
    if(w[i][w[i].size()-1] != w[i+1][0]){
      cout<<"No"<<endl;
      return 0;
    }
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <limits.h>

class MaximumProfit
{
private:
    enum CheckType {CHECK_N, CHECK_R};
    int size;
    int* currency;

public:
    MaximumProfit();

    ~MaximumProfit();

public:
    bool Run();

private:
    bool Read();

    void Execute();

    void Write(int ans);

    bool isValid(CheckType type, int target);

};

MaximumProfit::MaximumProfit()
    : currency(NULL)
    , size(0)
{
}

MaximumProfit::~MaximumProfit()
{
    delete[] currency;
}

bool MaximumProfit::Run()
{
    if (!Read()) {
        return false;
    }

    Execute();

    return true;
}

bool MaximumProfit::Read()
{
    std::cin >> size;
    if (!isValid(CHECK_N, size))
        return false;

    currency = new int[size];

    for (int i = 0; i < size; i++) {
        std::cin >> currency[i];
        if (!isValid(CHECK_R, currency[i]))
            return false;
    }

    return true;
}

void MaximumProfit::Execute()
{
    int max = INT_MIN;
    int min = currency[0];

    for (int i = 1; i < size; i++) {
        max = std::max(max, currency[i] - min);
        min = std::min(min, currency[i]);
    }

    Write(max);
}

void MaximumProfit::Write(int ans)
{
    std::cout << ans << std::endl;
}

bool MaximumProfit::isValid(CheckType type, int target)
{
    const int MinN = 2;
    const int MaxN = 200000;
    const int MinR = 1;
    const int MaxR = 1000000000;

    if (CHECK_N == type) {

        if (MinN > target || MaxN < target)
            return false;
    }
    
    if (CHECK_R == type) {
        if (MinR > target || MaxR < target)
            return false;
    }

    return true;
}

int main()
{
    if (!MaximumProfit().Run())
        return 1;

    return 0;
}



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

int main(){
  int N,M;
  cin >> N >> M;
  
  vector<int> c(N,0);
  int a,b;
  for(int i=0;i<M;i++){
    cin >> a >> b;
    c.at(a-1)++;
    c.at(b-1)++;
  }
  for(int i=0;i<N;i++)
    cout << c.at(i) << endl;
}

Measured memory_bytes: 256
import collections

n, m = map(int, input().split())
a = list(map(int, input().split()))

b = [0] * (n + 1)
for i in range(n):
    b[i + 1] = b[i] + a[i]

d = collections.Counter(x % m for x in b)
ans = sum(v * (v - 1) // 2 for v in d.values())
print(ans)

Measured memory_bytes: 62576
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    let mut s: Vec<isize> = Vec::with_capacity(n);
    for _i in 0..n {
        s.push(iterator.next().unwrap().parse().unwrap());
    }

    let mut ans: usize = 0;

    let q: usize = iterator.next().unwrap().parse().unwrap();
    for _i in 0..q {
        let t: isize = iterator.next().unwrap().parse().unwrap();

        if binary_search(&s, t) {
            ans += 1;
        }
    }

    return ans.to_string();
}

fn binary_search(s: &Vec<isize>, t: isize) -> bool {
    let mut l = 0;
    let mut r = s.len();

    while l < r {
        let i = (l + r) / 2;

        if s[i] == t {
            return true;
        } else if s[i] < t {
            l = i + 1;
        } else {
            r = i;
        }
    }

    false
}



Measured memory_bytes: 7080
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
int H, W;
int c[10][10];
int main() {
	cin >> H >> W;
	for (int i = 0; i < 10; ++i) {
		for (int j = 0; j < 10; ++j) {
			cin >> c[i][j];
		}
	}
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			for (int k = 0; k < 10; k++) {
				if (c[j][k] > c[j][i] + c[i][k]) c[j][k] = c[j][i] + c[i][k];
			}
		}
	}
	int sum = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			int a; cin >> a;
			if (a >= 0) sum += c[a][1];
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<stdlib.h>

typedef long long int lli;
using namespace std;

void yespr(){cout<<"Yes\n"<<endl;}
void nopr(){cout<<"No\n"<<endl;}

int main(void){
    int n;

    cin>>n;
    cout<<2.0*(double)n*3.14159265<<endl;

    return 0;
}

Measured memory_bytes: 3788
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N	= sc.nextInt();
		int K	= sc.nextInt();
		int p[]	= new int[N];
		int ans = 0;
		for(int i = 0; i < p.length; i++) {
			p[i] = sc.nextInt();
		}
		Arrays.sort(p);
		for (int i = 0; i < K; i++) {
			ans += p[i];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 38828
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    
    int n;
    cin >> n;
    string s[n];
    inrep(n,s);
    
    map<char,int> m[n];
    rep(i,0,n){
	rep(j,0,sz(s[i]))m[i][s[i][j]]++;
    }
    
    
    rep(i,0,56){
	char c = 'a'+i;
	int num = inf;
	rep(j,0,n){
	    num = min(num,m[j][c]);
	}
	rep(i,0,num)cout << c;
    }
    cout << endl;
    return  0;
}


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

using namespace std;

int n,t,ans=0,visit[15],cnt=0,num[]={3,5,7};

void dfs(int i,int sum)
{
    if(i==n)
    {
       // cout<<sum<<" "<<t<<" "<<visit[3]<<" "<<visit[5]<<" "<<visit[7]<<endl;
        if(visit[3]&&visit[5]&&visit[7]&&sum<=t){
            //cout<<sum<<" "<<t<<" "<<visit[3]<<" "<<visit[5]<<" "<<visit[7]<<endl;
            cnt++;
        }

        return ;
    }
    for(int j=0;j<3;j++)
    {
        int t=num[j];
        visit[t]++;
        dfs(i+1,sum*10+t);
        visit[t]--;
    }
}

int main()
{
    scanf("%d",&t);
    n=0;
    int tmp=t;
    while(tmp)
    {
        n++;
        tmp/=10;
    }
    //cout<<n<<endl;
    for(;n>=3;n--)
        dfs(0,0);
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::*;
 
fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}
 
fn main() {
    let n: isize = read().unwrap();
    let y: isize = read().unwrap();
    let y = y / 1000;
    let mut res: Vec<isize> = vec![-1, -1, -1];
 
    for b in 0..n + 1 {
        for c in 0..n - b + 1 {
            let x = 10 * n - y - 5 * b - 9 * c;
            if x == 0 {
                let a = n - b - c;
                res = vec![a, b, c];
                break;
            }
        }
        if res[2] != -1 {
            break;
        }
    }
    println!("{} {} {}", res[0], res[1], res[2]);
}

Measured memory_bytes: 4352
import numpy as np
n = int(input())
h = [int(i) for i in input().split()]
h = np.array(h)

def dfs(a):
    if len(a) == 1:
        return a[0]
    elif len(a) == 0:
        return 0

    water = 0
    pack = []
    mins = min(a)
    water += mins
    a = a - mins
    if a.sum() == 0:
        return mins
    for i in a:
        if i == 0:
            water += dfs(np.array(pack))
            pack = []
        else:
            pack.append(i)
    water += dfs(np.array(pack))
    return water

print(dfs(h))

Measured memory_bytes: 12640
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

count = 0

for i in range(0, N):
    left = min(a[i], b[i])
    a[i] -= left
    b[i] -= left
    count += left

    if b[i] > 0:
        right = min(a[i+1], b[i])
        a[i+1] -= right
        b[i] -= right
        count += right

print(count)

Measured memory_bytes: 18624
import java.util.Scanner;

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

		int ans = 0;
		while (n != 0) {
			ans += n % 10;
			n /= 10;
		}

		System.out.println(ans == 1 ? 10 : ans);

		sc.close();
	}

}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
int a[100010];
set<char>se;
int main()
{
int n,x,ans=0;
cin>>n;
for(int i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n);
  if(n%2!=0)
    cout<<0<<endl;
  else
  {
      if(a[n/2]==a[n/2-1])
      ans=0;
      else
        ans=a[n/2]-a[n/2-1];
      cout<<ans<<endl;


  }

    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("O3")
#pragma GCC target("arch=corei7-avx")

#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <queue>
#include <ctime>

using namespace std;

#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define SZ(a) (int)(a).size()
#define ALL(a) (a).begin(), (a).end()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    long long k;
    cin >> s >> k;
    int ones = 0;
    REP(i, SZ(s)) {
        if (s[i] == '1') ++ones;
        else break;
    }
    if (k <= ones) {
        cout << "1" << endl;
        return 0;
    }
    cout << s[ones] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long int n,m,i,s;
    scanf("%lld%lld",&n,&m);
    s=m-n*2;
    if(s<0)
    {
        printf("%lld\n",m/2);
    }
    else
    {
        i=n+s/4;
        printf("%lld\n",i);
    }
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    int a,b;
    cin >> a>> b;
    int maxx=max(a,b);
    int minn=min(a,b);
    if (maxx-1<=minn)cout << maxx+minn<<endl;
    else cout << maxx+maxx-1<<endl;
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int[,] G = new int[n + 1, n + 1];

            for (int i = 0; i < n; i++)
            {
                int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

                for (int j = 0; j < input[1]; j++)
                {
                    G[input[0], input[2 + j]] = 1;
                }
            }

            StringBuilder sb = new StringBuilder();
            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j < n; j++)
                {
                    sb.Append(G[i, j] + " ");
                }
                sb.AppendLine(G[i, n].ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9404
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def ap(a) a.each{|u| p u} end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end

h,w = inp
a = []
h.times{a << gets.chomp.split.map(&:to_i)}
f = false
ans = []
a.size.times do |i|
  if(f)
    (a[0].size-1).times do |j|
      if(a[i][j].odd?)
        ans.push("#{i+1} #{j+1} #{i+1} #{j+1+1}")
        a[i][j+1] += 1
      end
    end
    j = a[0].size-1
    if(a[i][j].odd? and i < (h-1))
      ans.push("#{i+1} #{j+1} #{i+1+1} #{j+1}")
      a[i+1][j] += 1
    end
  else
  (a[0].size-1).times do |j|
    j = w-1-j
    if(a[i][j].odd? and i != h)
      ans.push("#{i+1} #{j+1} #{i+1} #{j+1-1}")
      a[i][j-1] += 1
    end
  end
  j = 0
  if(a[i][j].odd? and i < (h-1))
    ans.push("#{i+1} #{j+1} #{i+1+1} #{j+1}")
    a[i+1][j] += 1
    end
  end
  f = !f
end
puts ans.size
puts ans

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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	int a , b , c ;
	cin>>a>>b>>c ;
	swap(a , b) ;
	swap(a , c) ;
	return cout<<a<<" "<<b<<" "<<c<<"\n" , 0 ;
}		

Measured memory_bytes: 892
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int INF = 1e9 + 5;

int main() {
    int n;
    scanf("%d", &n);
    vector<int> h(n);
    for(int& x : h) {
        scanf("%d", &x);
    }
    vector<int> dp(n, INF);
    dp[0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j : {i + 1, i + 2}) {
            if(j < n) {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }
    printf("%d\n", dp[n-1]);
}

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

int f(int n){
  if(n%2==0) return n/2;
  else return 3*n+1;
}

int main(){
  int N;
  cin >> N;
  if(N==1 || N==4 || N==2){
    cout << 4 << endl;
  }else{
    int cnt=1;
    while (N>1) {
      N=f(N);
      cnt++;
    }
    cnt++;
    cout << cnt << endl;
  }
}


Measured memory_bytes: 256