akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define aint(v) v.begin(),v.end()
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
/*
2d pointer array
int **dp;
in main function
int row,col;
dp=new int*[n];
rep(i,n)dp[i]=new int[m]
*/
int power(int x,int y);
bool isPrime(int n);
int modInv(int a,int b);
int gcdExtended(int a,int b,int *x,int* y);
int mpower(int a,int b,int p);
vector<int>v;
void getDiv(int n)
{
  for(int i=1;i*i<=n;i++)
  {
    if(n%i==0)
    {
      if(n/i==i)
      {
        v.pb(i);
      }
      else
      {
        v.pb(i);
        v.pb(n/i);
      }
    }
  }
}
int32_t main()
{
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  fastio
  int a,b;
  cin>>a>>b;
  int temp=__gcd(a,b);
  getDiv(temp);
  int ans=1;
  rep(i,v.size())
  {
    if(v[i]==1)continue;
    if(isPrime(v[i]))
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}

int modInv(int a, int m){
int x, y;
int g = gcdExtended(a, m, &x, &y);
int res = (x%m + m) % m;
return res;
}

int gcdExtended(int a, int b, int *x, int *y){
if (a == 0){
    *x = 0, *y = 1;
    return b;
}
int x1, y1;
int gcd = gcdExtended(b%a, a, &x1, &y1);
*x = y1 - (b/a) * x1;
*y = x1;
return gcd;
}

int mpower(int x, int y, int p){
int res = 1;
x = x % p;
while(y > 0){
    if(y & 1) res = (res*x) % p;
    y = y>>1;
    x = (x*x) % p;
}
return res;
}

int power(int x, int y){
int res = 1;
while (y > 0){
    if (y & 1) res = res*x;
    y = y>>1;
    x = x*x;
}
return res;
}

bool isPrime(int n){
if (n <= 1)  return false;
if (n <= 3)  return true;
if (n%2 == 0 || n%3 == 0) return false;
int p=sqrt(n);
for(int i=5;i<=p;i=i+6)
    if (n%i == 0 || n%(i+2) == 0)
        return false;
return true;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define MOD 1000000007
typedef long long LL;
template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

int main(void) {
	char a, b;
	cin >> a >> b;

	if (a == 'H') {
		cout << b << endl;
	}
	else if (a == 'D' and b == 'H') {
		cout << 'D' << endl;
	}
	else if (a == 'D' and b == 'D') {
		cout << 'H' << endl;
	}
	return 0;
}


Measured memory_bytes: 256
using System;

namespace abc153_c
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str01 = Console.ReadLine().Split(' ');
            int n = int.Parse(str01[0]);
            int k = int.Parse(str01[1]);
            string[] str02 = Console.ReadLine().Split(' ');
            long[] hp = new long[n];
            for(int i = 0; i < n; ++i)
            {
                hp[i] = long.Parse(str02[i]);
            }
            Array.Sort(hp);
            long sum = 0;
            for(int i = 0; i < n - k; ++i)
            {
                sum = hp[i] + sum;
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 31360
#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);
    cout.tie(0);
    ios::sync_with_stdio(false);
    char a;
    cin>>a;
    a++;
    cout << char(a)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
double y;
int n,m,o,t,x,z;
main(){
	cin>>n;
	while(n--){
		int ans=0;
		cin>>x>>t>>m;
		r(i,m){
			int s=0,p=x,a=0;
			cin>>o>>y>>z;
			r(i,t){
				if(o)p+=y*p;
				else a+=y*p;
				p-=z;
			}
			ans=max(ans,p+a);
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3076
#include<iostream>
#include<vector>
#include<deque>
#include<string>
using namespace std;

int main(){

    deque<char> S;

    while(true){
    string str;
    cin >> str;
    if(str[0]=='-') break;

    for(int i=0; i<str.size(); i++){
        S.push_back(str[i]);
    }

    int m;
    cin >> m;
    vector<int> v;
    for(int i=0; i<m; i++){
        int x;
        cin >> x;
        v.push_back(x);
    }

    for(int i=0; i<m; i++){
        for(int j=0; j<v[i]; j++){
            int tmp;
            tmp = S.front();
            S.pop_front();
            S.push_back(tmp);
        }
    }

    for(int i=0; i<S.size(); i++){
        cout << S[i];
    }
    cout << endl;
    S.clear();
    }

    return 0;
}


Measured memory_bytes: 3216
#include<stdio.h>
int main()
{
    int m,f,r,t;
    for(;;)
    {
        scanf("%d%d%d",&m,&f,&r);
        t=m+f;
        if(m+f+r==-3)return 0;
        if(m==-1||f==-1)puts("F");
        else if(t>=80)puts("A");
        else if(t>=65)puts("B");
        else if(t>=50||r>=50)puts("C");
        else if(t>=30)puts("D");
        else puts("F");
    }
    return 0;
}


Measured memory_bytes: 2104
import java.util.Scanner;

public 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){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 22100
#include<bits/stdc++.h>
#define MAX 100005
using namespace std;
 
int main(){
  int n;
  long long c, x[MAX], v[MAX], u[2] = {0, 0}, w[2] = {0, 0};
  scanf("%d%lld", &n, &c);
  v[0] = x[0] = 0;
  for(int i = 1; i <= n; i++){
    scanf("%lld%lld", &x[i], &v[i]);
    v[i] += v[i-1];
  }
  v[n+1] = v[n], x[n+1] = c;
  for(int i = 0; i < 2; i++){
    for(int j = 1; j <= n+1; j++){
      w[i] = max(w[i], (v[n] - v[j-1]) - (c - x[j])*(2-i) + u[i]);
      u[i] = max(u[i], (v[j] - x[j]*(i+1)));
    }
  }
  printf("%lld\n", max(w[0],w[1]));
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    long long int count=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n/i;j++)
        {
            if(n-(i*j)>0)
            {
                count++;

            }
        }
    }
    cout<<count<<endl;
}


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

int main(){
    int h,w,k;
    cin>>h>>w>>k;
    vector<string> v(h);
    for(int i=0;i<h;i++) cin>>v[i];

    int ans=0;
    for(int i=0;i<(1<<h);i++){
        for(int j=0;j<(1<<w);j++){
            int c=0;
            for(int k=0;k<h;k++){
                for(int l=0;l<w;l++){
                    if((i&(1<<k))&&(j&(1<<l))&&v[k][l]=='#') c++;
                }
            }
            if(c==k) ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <string>
#include <iostream>

int main() {
	int A, B, C, D, flag = 0;
	std::cin >> A;
	std::cin >> B;
	std::cin >> C;
	std::cin >> D;

	while (1) {
		C -= B;
		if (C <= 0)break;
		A -= D;
		if (A <= 0) {
			flag = 1;
			break;
		}
	}
	
	if (flag == 0) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
}

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

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

    int n;
    cin >> n;
    string s,t,ans;
    cin >> s >> t;
    rep(i,n){
        ans += s[i];
        ans += t[i];
    }
    cout << ans << endl;


    cout << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

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

cnt = defaultdict(int)
for a, b in ab:
    cnt[a] += 1
    cnt[b] += 1
ans = all(cnt[i] % 2 == 0 for i in cnt)
print('YES' if ans else 'NO')


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(n);
    rep(i, n)
    {
        int k;
        cin >> k;
        a[i].resize(k);
        rep(j, k) cin >> a[i][j];
    }

    map<int, int> mp;
    rep(i, n)
    {
        rep(j, a[i].size())
        {
            mp[a[i][j]]++;
        }
    }

    int ans = 0;
    for (auto itr = mp.begin(); itr != mp.end(); itr++)
    {
        if (itr->second == n)
        {
            ans++;
        }
    }

    cout << ans << '\n';
    return 0;
}


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct N001 {
   long n;
   std::vector<long> parents;
   std::vector<long> numbers;
   N001(long n_) : n(n_), parents(n+1, -1), numbers(n+1, -1) {
   }
};
long find(N001& s, long x) {
   if( s.parents[x] == -1 ) return x;
   return s.parents[x] = find(s, s.parents[x]);
}
bool same(N001& s, long x, long y) {
   return find(s, x) == find(s, y);
}
void unite(N001& s, long x, long y) {
   long x2 = find(s, x);
   long y2 = find(s, y);
   if( x2 == y2 ) return;
   if( not ( s.numbers[x2] <= s.numbers[y2] ) )
      std::swap(x2, y2);
   s.parents[x2] = y2;
   s.numbers[y2] += s.numbers[x2];
}

template<typename W>
struct N003 {
   typedef std::vector<long> LI;
   typedef std::vector<W>    LW;
   long n, e;
   LI ss, ds;
   LW ws;
   std::vector<LI> iss;
   N003(long n_, const LI& ss_, const LI& ds_, const LW& ws_)
      : n(n_), e(ss_.size()), ss(ss_), ds(ds_), ws(ws_) {
      iss.resize(n+1);
      for(long i = 0; i < e; ++i) {
         iss[ss[i]].push_back(i);
      }
   }
};

template<typename W>
struct N007 {
   std::vector<long> xs;
   N007(const N003<W>& g) {
      std::vector<std::pair<W, long>> ys;
      for(long i = 0; i < g.e; ++i) {
         ys.emplace_back(std::make_pair(g.ws[i], i));
      }
      std::sort(ys.begin(), ys.end());
      N001 uf(g.n+1);
      for(auto y : ys) {
         long i = y.second;
         if( not same(uf, g.ss[i], g.ds[i]) ) {
            unite(uf, g.ss[i], g.ds[i]);
            xs.emplace_back(i);
         }
      }
   }
};

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      typedef std::vector<long> LI;
      long v, e;
      scan(v, e);
      LI ss(e+1), ds(e+1);
      LI ws(e+1);
      for(long i = 0; i < e; ++i) {
         scan(ss[i], ds[i], ws[i]);
      }
      N003<long> g(v, ss, ds, ws);
      N007<long> kruskal(g);
      long res = 0;
      for(auto x : kruskal.xs) {
         res += g.ws[x];
      }
      printf("%ld\n", res);
   }
};

int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
}

Measured memory_bytes: 11308
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
//#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

struct edge{ ll to,cost; };
ll V;
vector<edge> G[500010];
ll d[500010];

void dijkstra(ll s){
    fill(d,d+500010,inf);
    d[s]=0;
    priority_queue<l_l,vector<l_l>,greater<l_l>> que;
    que.push(l_l(0,s));
    while(!que.empty()){
        l_l p=que.top();que.pop();
        ll v=p.second;
        if(d[v]<p.first)continue;
        if(G[v].size()>0){
            rep(i,0,G[v].size()-1){
                edge e=G[v][i];
                if(d[e.to]>d[v]+e.cost){
                    d[e.to]=d[v]+e.cost;
                    que.push(l_l(d[e.to],e.to));
                }
            }
        }
    }
}

int main(){
    ll n;cin>>n;
    ll x,y;cin>>x>>y;
    edge e;
    rep(i,1,n){
        e.to=i+1;
        e.cost=1;
        G[i].pb(e);
        e.to=i;
        G[i+1].pb(e);
    }
    e.to=x;
    e.cost=1;
    G[y].pb(e);
    e.to=y;
    G[x].pb(e);
    ll ans[n];rep(i,0,n-1)ans[i]=0;
    rep(i,1,n){
        dijkstra(i);
        rep(j,1,n){
            ans[d[j]]++;
        }
    }
    rep(i,1,n-1){
        cout<<ans[i]/2<<endl;
    }
    
    return 0;
}






Measured memory_bytes: 16000
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll n;

	cin >> n;

	vector<ll> v(n, 0);
	ll sum = 0;

	REP(i, n) {
		cin >> v[i];
		sum += v[i];
	}

	vector<ll> ans;
	ll x = 0;

	REP(i, (n - 1) / 2) {
		x += 2 * v[i * 2 + 1];
	}

	ans.push_back(sum - x);

	FOR(i, 1, n) {
		ans.push_back(2 * v[i - 1] - ans[i - 1]);
	}

	REP(i, n - 1) {
		cout << ans[i] << " ";
	}

	cout << ans[n - 1] << endl;
}

Measured memory_bytes: 3060
import math
mod = int(1e9+7)

N = int(input())
n = math.factorial(N)

count_of_prime_factors = {}
while True:
    if n > 1:
        count = 0
        while n % 2 == 0:
            n //= 2
            count += 1
        if count != 0:
            count_of_prime_factors.update({2: count})
        if n == 1: 
            break 

        for i in range(3, N+1, 2):
            count = 0
            while n % i == 0:
                n //= i 
                count += 1
            if count != 0:
                count_of_prime_factors.update({i: count})
            if n == 1: 
                break
        else:        
            count_of_prime_factors.update({n: 1})
        break 
    else:
        print(1)
        exit()

ans = 1
for prime_factor, count in count_of_prime_factors.items():
    ans *= count + 1

print(ans % mod)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main()
{
  ll a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a==0)
    cout<<1<<"\n";
  if(b==0)
    cout<<2<<"\n";
  if(c==0)
    cout<<3<<"\n";
  if(d==0)
    cout<<4<<"\n";
  if(e==0)
    cout<<5<<"\n";
 
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <map>
#include <iomanip>

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

using namespace std;
using lli = long long int;
using ll = long long;

struct Point {
    lli x;
    lli y;

    bool operator<(const Point &another) const {
        if (x != another.x) {
            return x < another.x;
        } else {
            return y < another.y;
        }
    };
} ;

lli factorial(lli n){
    lli sum = 1;
    for (lli i = 1; i <= n; ++i)
    {
        sum *= i;
    }
    return sum;
}

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

    vector<Point> points(N);

    for (lli i = 0; i < N; ++i) {
        Point point{};
        cin >> point.x;
        cin >> point.y;
        points[i] = point;
    }
    sort(points.begin(), points.end());

    double answer = 0;
    do {
        for(unsigned long i = 0; i < points.size() - 1; ++i){
            lli dx = points[i].x - points[i + 1].x;
            lli dy = points[i].y - points[i + 1].y;
            answer += sqrt(dx * dx + dy * dy);
        }
    } while( next_permutation(points.begin(), points.end()));

    cout << setprecision(10) << answer / (double) factorial(N) << endl;
}


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

using namespace std;

typedef long long ll;

int main()
{
    ll X, Y, Z, K;
    vector<ll> A, B, C;
    cin >> X >> Y >> Z >> K;
    ll temp;
    for (ll x = 0; x < X; x++) {
        cin >> temp;
        A.push_back(temp);
    }
    for (ll y = 0; y < Y; y++) {
        cin >> temp;
        B.push_back(temp);
    }
    for (ll z = 0; z < Z; z++) {
        cin >> temp;
        C.push_back(temp);
    }

    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());
    vector<ll> cand;
    for (ll x = 0; x < X; x++) {
        for (ll y = 0; y < Y; y++) {
            for (ll z = 0; z < Z; z++) {
                if ((x + 1) * (y + 1) * (z + 1) <= K) {
                    cand.push_back(A[x] + B[y] + C[z]);
                } else {
                    break;
                }
            }
        }
    }
    sort(cand.begin(), cand.end(), greater<ll>());

    for(ll k = 0; k < K; k++) {
        cout << cand[k] << endl;
    }
    return 0;
}


Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b > c+d){
        cout<< "Left" <<endl;
    }
    else if(c+d > a+b){
        cout<< "Right" <<endl;
    }
    else{
        cout<< "Balanced" <<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<n;i++)
#define MOD 1e9+7
#define EPS 1e-8
#define INF 1e9+10
typedef long long ll;
using namespace std;
int main()
{
    string s;
    cin >> s;
    rep(i,0,s.length()){
        cout << s[i];
        if(i==3){cout << " ";}
    }
    cout << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}

signed main(){
    string s,t;
    int a,b;
    string u;
    cin>>s>>t>>a>>b>>u;
    if(u==s)cout<<a-1<<" "<<b<<endl;
    else cout<<a<<" "<<b-1<<endl;
    return 0;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    string r, g, b;
    cin >> r >> g >> b;

    int t = stoi(r+g+b);
    if(t%4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 3608
using namespace std;
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 1000000007
#define mod 998244353
#define sec setprecision
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return pow(x * x , n / 2);
	else
		return x * pow(x, n - 1);
}
int main() {
	ll n;
	cin >> n;
	int i = 0;
	ll m = n;
	ll mae=0;
	while (m > 0) {
		mae = m;
		i++;
		m -= pow(26, i);
	}
	mae--;
	vector<int>string(i,0);
	rip(j, i) {
		string[j] = (mae) % (26);
		mae -= string[j];
		mae /= 26;
	}
	vector<char>ans(i);
	rip(j, i) {
		ans[j] = string[j] + 97;
	}
	rip(j, i)cout << ans[i-1-j];
}

Measured memory_bytes: 4044
#include <math.h>
#include <bits/stdc++.h>//一括で読み込み
typedef long long ll;
using namespace std;

int n,a[25][25];
ll dp[70050];

int main()
{
	scanf("%d",&n);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++) scanf("%d",&a[i][j]);
    
	int lim = 1<<n;
  
	for (int i = 1; i < lim; i++)
  {
		for (int j = 1; j <= n; j++)
    {
      if((i&(1<<(j-1))))//j個目にbitがある時
      {
			  for (int k = j+1; k <= n; k++)//k個目にもbitがある時
        {
          if((i&(1<<(k-1))))
          {            
            dp[i] += a[j][k];
          }
        }
      }
    }
  }
      
	for (int i = 1; i < lim; i++)
  {//全ての集合に対し、全ての部分集合を調べるDP。O(3^集合の要素数)
		for (int j = i; j > 0; j = i&(j-1))
    {
      dp[i] = max(dp[i], dp[i-j]+dp[j]);
    }
  }
    
	printf("%lld\n",dp[lim-1]);
}


Measured memory_bytes: 768
n = int(input())
a,b = map(int,input().split())
l = 0
m = 0
u = 0
x = list(map(int,input().split()))
for i in range(n):
    if x[i]<=a:
        l+=1
    elif x[i]<=b:
        m+=1
    else:
        u += 1

print(min(l,m,u))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b=mod-2,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
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;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;



int res, a;

signed main() {
    while (1) {
        cin >> res;
        if (res==0) break;
        rep(i,9) {
            cin >> a;
            res -= a;
        }
        cout << res << endl;
    }
}



Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
ll n,m,x,y,cnt=0;
vector<ll> flag(9);
vector<vector<ll>> a(9),b(9);

bool judge(vector<ll> flag){
	ll ans=1;
	FOR(i,1,n+1){
		ans *=flag[i];		
	}
	return ans?true:false;
}

void dfs(int i){
	flag[i]=1;
	if(judge(flag)){
		cnt++;
		flag[i]=0;
		return;
	}
	rep(j,a[i].size()){
		if(flag[a[i][j]]==0){
			dfs(a[i][j]);
		}
	}
	rep(j,b[i].size()){
		if(flag[b[i][j]]==0){
			dfs(b[i][j]);
		}
	}
	flag[i]=0;
	return;
}



int main(){
	cin>>n>>m;
	rep(i,m){
		cin>>x>>y;
		a[x].pb(y);
		b[y].pb(x);
	}
	dfs(1);
	cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 256
object Main extends App {
  import scala.io.StdIn.{readLine}
  def change(price:Int, coins:List[Int] = List(500,100,50,10,5,1)):Int = {
    coins match{
      case c::t  ⇒ price / c + change(price % c, t)
      case Nil ⇒ 0
    }
  }
  var price = readLine().toInt
  while (price != 0){
    println(change(1000 - price))
    price = readLine().toInt
  }
}


Measured memory_bytes: 43696
const main = arg => {
  const [a, b, c, d] = arg.split(' ').map(BigInt);
  const ary = [a * c, a * d, b * c, b * d];
  const max = ary.reduce((x, y) => x > y ? x : y);
  console.log(max.toString());
};
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29536
#include <bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
using namespace std;
int n;
void dfs(string s,char max){
    if(s.length()==n)cout<<s<<endl;
    else{
        for(char c='a';c<=max;c++) dfs(s+c,((c==max)?((char)max+1):(max)));
    }    
}
int main(){
    cin>>n;
    dfs("",'a');
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d; cin >> a >> b >> c >> d;
  while(1){
    c-=b;
    if(c <=0){
      cout <<"Yes";
      return 0;
    }
    a-=d;
    if(a<=0){
      cout <<"No";
      return 0;
    }
  }
}


Measured memory_bytes: 3644
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <map>
#include <vector>

using namespace std;

vector<string> combination_s;

map<char, long long> ch_count;

long long get_count(string s)
{
	return ch_count[s[0]] * ch_count[s[1]] * ch_count[s[2]];
}

string BASE = "MARCH";

void make_combination(int depth, int last, string curr_s)
{
	if (depth == 3)
	{
		combination_s.push_back(curr_s);
		return;
	}

	for (int i = last + 1; i < BASE.size(); i++)
	{
		curr_s.push_back(BASE[i]);
		make_combination(depth + 1, i, curr_s);
		curr_s.pop_back();
	}
}

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

	int N;
	cin >> N;

	for (int i = 0; i < N; i++)
	{
		string s;
		cin >> s;

		ch_count[s[0]]++;
	}

	make_combination(0, -1, "");

	long long result = 0;
	for (int i = 0; i < combination_s.size(); i++)
	{
		result += get_count(combination_s[i]);
	}
	cout << result;

	return 0;
}


Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val A, B = ni()
    val ans = if (A * B % 2 == 1) "Yes" else "No"
    out.println(ans)
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int): Array[Int] = map(n)(_ => ni())
  def nm(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }
}

Measured memory_bytes: 25544
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
SH = []
SW = []

for h in range(H):
    SW.append([])
    c = 0
    for w in range(W):
        if S[h][w] == '#':
            if c != 0:
                for _ in range(c):
                    SW[h].append(c)
            SW[h].append(0)
            c = 0
        else:
            c += 1
    for _ in range(c):
        SW[h].append(c)

for w in range(W):
    SH.append([])
    c = 0
    for h in range(H):
        if S[h][w] == '#':
            if c != 0:
                for _ in range(c):
                    SH[w].append(c)
            SH[w].append(0)
            c = 0
        else:
            c += 1
    for _ in range(c):
        SH[w].append(c)

ans = -1
for h in range(H):
    for w in range(W):
        ans = max(ans, SW[h][w] + SH[w][h] - 1)

print(ans)


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

using namespace std;

#define bug(x) cerr << #x << " = " << x << '\n'
#define ll     long long
#define maxn

int main() {
        //freopen(".inp","r",stdin);

        ll x, k, d;
        cin >> x >> k >> d;

        x = abs(x);

        ll step = min(x / d, k);
        ll pos = x - step*d;
        k -= step;
        if(k % 2) pos = d - pos;

        cout << pos;
}



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

int counter(int x) {
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

int main()
{
  int N;
  int A[20];
  int x[20][20];
  int y[20][20];

  cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> A[i];
        for(int j = 1; j <= A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for(int bits = 1; bits < (1 << N); bits++) {
        bool ok = true;
        for(int i = 1; i <= N; i++) {
            if(!(bits & (1 << (i-1)))) continue;
            for(int j = 1; j <= A[i]; j++) {
                if(((bits >> (x[i][j]-1)) & 1) ^ y[i][j]) ok = false;
            }
        }
        if(ok) ans = max(ans, counter(bits));
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int N; cin >> N;
	map<int, int> m;
    rep(i, N) {
        int a; cin >> a;
        m[a]++;
    }
    bool flg = false;
    for (auto i : m) {
        if (i.first == 0 && i.second > 1) flg = true;
        else if (i.first != 0 && i.second != 2) flg = true;
    }

    ll ans = 1;
    if (flg) cout << 0 << endl;
    else {
        rep(i, N/2) {
            ans *= 2;
            ans %= MOD;
        }
        cout << ans << endl;
    }
}


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

using namespace std;

#define rep(i, a) for (int i = 0; i < a; i++)
#define reps(i, a, b) for (int i = a; i < b; i++)

string s;
int w;

int main()
{
	cin >> s >> w;
	for (int i = 0; s[i] != '\0'; i++) {
		if (i % w == 0) cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];
const int INF = 1e9;
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

vector<ll> dp(100010, INF);

void solve(long long N, std::vector<long long> h)
{
    dp[0] = 0;
    for (int i = 1; i < N; i++)
    {

        dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i >= 2)
        {
            dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
        }
    }
    cout << dp[N-1] << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> h(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &h[i]);
    }
    solve(N, std::move(h));
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll t1,t2,a1,a2,b1,b2;
	cin>>t1>>t2>>a1>>a2>>b1>>b2;
	if(a1<b1){
		swap(a1,b1);
		swap(a2,b2);
	}
	ll ma=(a1-b1)*t1;
	ll mi=ma+t2*(a2-b2);
	if(mi==0){
		cout<< "infinity";
	}
	else if(mi>0){
		cout << 0;
	}
	else{
		mi=abs(mi);
		if(ma%mi==0){
		//	cout << "k";
			cout << 2*(ma/mi);
		}
		else{
			cout << 1+2*(ma/mi);
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string ss,t;
int res,half;
bool EvenString(){
	if(t.size()%2==1)
		return false;
	half=(t.size()/2);
	for(int i=half;i<t.size();i++) 
		if(t[i]!=t[i-half]) 
			return false;
	return true;
}
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>ss;
	res=0;
	for(int i=0;i<ss.size()-1;i++){
		t+=ss[i];
		if(EvenString())
			res=i+1;
	}
	cout<<res<<endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

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

        int N = sc.nextInt();
        int Y = sc.nextInt();

        System.out.println(solve(N, Y));

        sc.close();
    }

    static String solve(int N, int Y) {
        for (int x = 0; x <= N; ++x) {
            for (int y = 0; x + y <= N; ++y) {
                int z = N - x - y;

                if (x * 10000 + y * 5000 + z * 1000 == Y) {
                    return String.format("%d %d %d", x, y, z);
                }
            }
        }

        return "-1 -1 -1";
    }
}

Measured memory_bytes: 22996
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from math import factorial
def C(n, m, P):
    c = 1
    for i in range(m):
        c *= n-i
        c %= P
    m = factorial(m)%P
    return c*pow(m, P-2, P)%P

def main():
    P = int(1e9)+7
    n, a, b = map(int, readline().split())
    print((pow(2, n, P)-1-C(n, a, P)-C(n, b, P))%P)
if __name__ == '__main__':
    main()


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<char> t(q), d(q);
  rep (i, q) {
    cin >> t[i] >> d[i];
  }

  int ok = -1, ng = n;
  while (ok + 1 < ng) {
    int mid = (ok + ng) / 2;
    int now = mid;
    rep (i, q) {
      if (s[now] == t[i]) {
        if (d[i] == 'L') now--;
        else now++;
      }
      if (now == -1 || now == n) break;
    }
    if (now == -1) ok = mid;
    else ng = mid;
  }

  int l = ok;

  ok = n; ng = -1;
  while (ng + 1 < ok) {
    int mid = (ok + ng) / 2;
    int now = mid;
    rep (i, q) {
      if (s[now] == t[i]) {
        if (d[i] == 'L') now--;
        else now++;
      }
      if (now == -1 || now == n) break;
    }
    if (now == n) ok = mid;
    else ng = mid;
  }

  int r = ok;
  //DEBUG(l); DEBUG(r);
  cout << r - (l + 1) << endl;
}


Measured memory_bytes: 900
a,b,c,x,y=map(int,input().split())
if a+b>c*2:
    if x>y:
        print(min(x*c*2,y*c*2+(x-y)*a))
    else:
        print(min(y*c*2,x*c*2+(y-x)*b))
else:
    print(a*x+b*y)

Measured memory_bytes: 3064
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

void printIntInLine(vector<int> &arr) {
	for(vector<int>::iterator itr=arr.begin(); itr!=--(arr.end()); ++itr) {
		printf("%d ", *itr);
	}
	printf("%d\n", *(--(arr.end())));
}

int main() {
	vector<int> arr;
	int n, tmp, nSwap;

	scanf("%d", &n);
	for(int i=0; i<n; ++i) {
		scanf("%d", &tmp);
		arr.push_back(tmp);
	}

	nSwap = 0;

	for(vector<int>::iterator itr1=arr.begin(); itr1!=arr.end(); ++itr1) {
		for(vector<int>::iterator itr2=--arr.end(); itr2!=itr1; --itr2) {
			if((*itr2)<(*(itr2-1))) {
				swap(*itr2, *(itr2-1));
				++nSwap;
			}
		}
	}

	printIntInLine(arr);
	printf("%d\n", nSwap);
}

Measured memory_bytes: 1052
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>

using namespace std;


int main()
{
	string str[100],str2[200000],strmemo="";
	long long int n, m, a, b, c, now[200][200] = {};
	const long long int mod = 1000000007;
	cin >>n ;
	for (int i = 1; i <= n; i++) {
		cin >> str[i];
		for (int j = 0; j < str[i].length(); j++) {
			now[i][str[i][j]]++;
		}
	}
	for (int j = 'a'; j <= 'z'; j++) {
		long long int ma = 999;
		for (int i = 1; i <= n; i++) {
			ma = min(ma, now[i][j]);
		}
		for (int i = 0; i < ma; i++) {
			cout << (char)j;
		}
	}
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define _fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define pb push_back
#define PI acos(-1)

int main()
{
     double r,ans;
     cin>>r;
     ans=2*PI*r;
     cout<<ans<<'\n';


    return 0;
}



Measured memory_bytes: 3764
n,k=map(int,input().split())
d=list(map(int,input().split()))

nmax=100000

for nn in range(n,nmax):
    ns=list(str(nn))
    yn="yes"
    for nsi in ns:
#        print(nn,nsi,(nsi in d))
        if int(nsi) in d:
            yn="no"
            break
    if yn=="no":
        continue
    else:
        break
if yn=="yes":
    print(nn)


Measured memory_bytes: 3060
#include <bits/stdc++.h> 
#define ll long long int
#define ld long double
#define ull unsigned long long
const double pi=3.14159265358979323846;
using namespace std;

bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 

ll ipow(ll base, ll exp)
{
    ll result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    ull n;
    cin>>n;
    ull a[n];
    ull sum=0;
    for(ull i=0;i<n;i++)
    {
        cin>>a[i];
        sum^=a[i];
    }
    for(ull i=0;i<n;i++)
    {
        a[i]^=sum;
        cout<<a[i]<<" ";
    }
    cout<<"\n";

    
}

Measured memory_bytes: 5156
n = gets.to_i
s = []
n.times do |i|
  s[i] = gets.to_i
end
s.sort!
sum = s.inject(:+)
if sum % 10 != 0
  puts sum
else
  s.each do |v|
    if v % 10 != 0
      sum -= v
      break
    end
  end
  puts (sum % 10 != 0) ? sum : 0
end


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

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

int main()
{
  int d, c;
  cin >> d >> c;
  cout << d * c << endl;
}

Measured memory_bytes: 1164
S = input().split()
A = int(S[0])
B = int(S[1])
K = int(S[2])
#print(A, B, K)

for k in range(K):
    if k % 2 == 0: #taka 
        if A % 2 == 1:
            A -= 1
        B_plus = A//2
        A -= B_plus
        B += B_plus
        #print(A, B)
    else:        
        if B % 2 == 1:
            B -= 1
        A_plus = B//2
        B -= A_plus
        A += A_plus
        #print(A, B)
        
print(A,B)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

string s;
int n,k;

int main(){
	cin>>n>>k>>s;
	s[k-1]=tolower(s[k-1]);
	cout<<s<<endl;
}

Measured memory_bytes: 256