akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

void YN(bool ans){
    if(ans)cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
    return;
}

int main(){
    string S;
    cin>>S;
    bool ans =true;
    if(S[2] != S[3])ans = false;
    if(S[4] != S[5])ans = false;
    YN(ans);
        return 0;
}

Measured memory_bytes: 256
N, h = gets.split(' ').map(&:to_i)
a = Array.new(N)
b = Array.new(N)
N.times do |i|
  a[i], b[i] = gets.split(' ').map(&:to_i)
end
b.sort!
b.reverse!
t = a.max
ans = 0
N.times do |i|
  break if h <= 0
  break if b[i] <= t
  h -= b[i]
  ans += 1
end
if h > 0
  ans += (h + t - 1) / t
end
puts ans

Measured memory_bytes: 4104
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var AB = Sarray();

            var ans = 0L;
            for (var i = AB[0]; i <= AB[1]; ++i)
            {
                var s = i.ToString();
                var kaibun = true;
                for (var j = 0; j < s.Length / 2; ++j)
                {
                    if (s[j] != s[s.Length - 1 - j])
                    {
                        kaibun = false;
                        break;
                    }
                }
                if (kaibun) ++ans;
            }
            Console.WriteLine(ans);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 15316
#define REP(i, t, n)  for (int i = t; i < n; i++)
#define ALL(n)        (n).begin(),(n).end()
#include <limits.h>
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <functional>
#include <algorithm>
#include <cstring>
#include <unordered_map>
#include <numeric>

using namespace std;

typedef bool               BOOL;
typedef short              WORD;
typedef unsigned short     U_WORD;
typedef long               DWORD;
typedef unsigned long      U_DWORD;
typedef long long          QWORD;
typedef unsigned long long U_QWORD;

#define N_MAX (100000)


typedef struct edge {
	DWORD	dwTo;
} EDGE;

vector <EDGE> vGraph[N_MAX + 1];
//vector <DWORD> vSortList;
queue  <DWORD> queNoInEdge;
DWORD  adwInEdgeNum[N_MAX + 1];
DWORD  adwNodeParent[N_MAX + 1];


void TopologicalSort()
{
	while (!queNoInEdge.empty()) {
		DWORD dwNode = queNoInEdge.front(); queNoInEdge.pop();
		//vSortList.push_back(dwNode);

		for (auto iter : vGraph[dwNode]) {
			adwInEdgeNum[iter.dwTo] -= 1;
			
			if (adwInEdgeNum[iter.dwTo] == 0) {
				queNoInEdge.push(iter.dwTo);
				adwNodeParent[iter.dwTo] = dwNode;
			}
		}
	}

}

void solve_main()
{
	DWORD N , M;
	cin >> N >> M;


	REP(i, 0, (N - 1 + M)) {
		DWORD dwFrom, dwTo;

		cin >> dwFrom >> dwTo;

		vGraph[dwFrom].push_back(EDGE{ dwTo });
		adwInEdgeNum[dwTo] += 1;
	}

	REP(i, 1, N + 1) {
		if (adwInEdgeNum[i] == 0) {
			queNoInEdge.push(i);
			adwNodeParent[i] = 0;
			break;			//最初に一つも流入量がないエッジは必ず根になる。他はすべて流入量が1以上のためここでbreak
		}
	}

	TopologicalSort();


	REP(i, 1, N + 1) {
		cout << adwNodeParent[i] << endl;
	}

}

int main()
{
#ifdef FOR_IDE
	ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
#endif

	solve_main();
	return 0;
}


Measured memory_bytes: 7808
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

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

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

const ll mod = 1e9 + 7;
const ll IMF = 1LL << 60;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//


ll val[1000];

int main(){
        ll n,m;
        cin >> n >> m;
        vector<ll> x(n),y(n),z(n);
        for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i];

        //8パターンを試す。
        ll ans = -ll(1e18);
        for(int mask = 0; mask < 8; mask++){
                int a = (mask & 1) ? -1 : 1;
                int b = (mask & 2) ? -1 : 1;
                int c = (mask & 4) ? -1 : 1;

                //そのパターンの時の絶対値を記録する。
                //こいつは再利用する。
                for(int i = 0; i < n; i++){
                        val[i] = a * x[i] + b * y[i] + c * z[i];
                }

                //ソートして降順にする。
                sort(val,val + n);
                reverse(val, val + n);
                //値が大きかったら更新する。
                ll cur = 0;
                for(int i = 0; i < m; i++){
                        cur += val[i];
                }
                ans = max(ans, cur);
        }

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


































Measured memory_bytes: 256
n=int(input())
s=input()
ss=s
x=0
while x<len(ss)-1:
    if ss[x]=='(' and ss[x+1]==')':
        ss=ss[:x]+ss[x+2:]
        x=0
    else:
        x+=1
left=0
right=0
for i in ss:
    if i=='(':
        right+=1
    elif i==')':
        left+=1
q='('*left
w=')'*right
print(q+s+w)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int pi[]=new int[n];
		for(int i=0;i<n;i++) {
			pi[i]=sc.nextInt();
		}
		int c=0;
		for(int i=1;i<n-1;i++) {
			int p[] = new int[] {pi[i-1],pi[i],pi[i+1]};
			int min= Math.min(Math.min(p[0], p[1]), p[2]);
			if(min==p[1]) {
				continue;
			}
			if(p[0]==min)p[0]=Integer.MAX_VALUE;
			if(p[2]==min)p[2]=Integer.MAX_VALUE;

			int min2= Math.min(Math.min(p[0], p[1]), p[2]);
			if(min2==p[1])c++;
		}
		System.out.println(c);


	}
}

Measured memory_bytes: 21840
#include<stdio.h>
#include<string.h>
typedef struct {
	int s;
}DATA;
int main() {
	int point[31] = { 0 },p,s,cnt,i;
	DATA data[101] = { 0 };
	while (fscanf(stdin, "%d,%d", &p, &s)&&(p||s)) point[s]++, data[p].s = s;
	while (~fscanf(stdin, "%d", &p)) {
		cnt = 0;
		for (i = 30; i > data[p].s; --i) if(point[i]!=0) cnt++;
		fprintf(stdout, "%d\n", cnt + 1);
	}
	return 0;
}

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

// zero-based numbering
template<class T> struct Fenwick {
    vector<T> bit; int N;
    Fenwick(int n) : N(n) { bit.assign(n+1, 0); }
    // add w to a
    void add(int a, T w) {
        for (int x = ++a; x <= N; x += x & -x) bit[x] += w;
    }
    // sum [0, a)
    T sum(int a) {
        T ret = 0;
        for (int x = a; x > 0; x -= x & -x) ret += bit[x];
        return ret;
    }
    // sum [a, b)
    T sum(int a, int b) { return sum(b) - sum(a); }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    Fenwick<int> f(m+2);
    vector<pair<int, pair<int, int>>> v;
    for (int i = 0; i < n; i++) {
        int l, r; cin >> l >> r;
        v.push_back({r-l+1, {l, r}});
    }
    sort(v.rbegin(), v.rend());
    vector<int> ans(m+1, 0);
    for (int d = 1; d <= m; d++) {
        while (!v.empty() && v.back().first < d) {
            f.add(v.back().second.first, 1);
            f.add(v.back().second.second+1, -1);
            v.pop_back();
        }
        ans[d] = v.size();
        for (int i = d; i <= m; i += d) {
            ans[d] += f.sum(i+1);
        }
        cout << ans[d] << "\n";
    }
    return 0;
}

Measured memory_bytes: 8944
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
using namespace std;
int main(){
    string s;
    cin>>s;
    ll total=0;
    rep(i,s.size()){
        total+=int(s[i])-48;
     
    }
    if(total%9==0)cout<<"Yes";
    else cout<<"No";
    
   
    
    }


Measured memory_bytes: 3692
#include<bits/stdc++.h>
#define re register
using namespace std;
const int MAXN=1e5+5;
int N,swtch[2],matrix[5][MAXN],temp[MAXN];
int main(){
    cin>>N;
    for(re int i=1;i<=3;i++) for(re int j=1;j<=N;j++) cin>>matrix[i][j];
    for(re int i=1;i<=N;i++){
        temp[i]=matrix[2][i]/3+1;
        if(!((matrix[1][i]-matrix[2][i]==-1 && matrix[2][i]-matrix[3][i]==-1 
		&& matrix[1][i]%3==1) || (matrix[1][i]-matrix[2][i]==1 && matrix[2][i]-matrix[3][i]==1 
		&& !(matrix[1][i]%3))) || (abs(i-temp[i])&1)){cout<<"No"<<endl; return 0;}
        swtch[i&1]^=(matrix[1][i]>matrix[2][i]);
    }
    for(re int i=1;i<=N;i++){while(temp[i]!=i){swtch[i&1^1]^=1; swap(temp[i],temp[temp[i]]);}}
   	if(swtch[0]||swtch[1]) cout<<"No"<<endl;
   	else cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-

if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    
    # 踏み台の高さを決める
    B = [0] * N
    
    B[0] = 0
    sum = 0
    for i in range(1, N):
        if A[i-1] + B[i-1] > A[i]:
            B[i] = A[i-1] + B[i-1] - A[i]
        else:
            B[i] = 0
            
        sum = sum + B[i]

    print(sum)


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

const int maxn=1e5+4;
int p[maxn];
int ans[maxn];
int ld[maxn];
int id[maxn];
int n,m,k;

int fleader(int x){
	return (x==p[x]? x:p[x]=fleader(p[x]));	
}

void unite(int x,int y){
	int px=fleader(x);
	int py=fleader(y);
	p[px]=py;
	return;	
}

bool cmp(int i,int j){
	return ld[i]<ld[j];	
}

int main(){
	vector<int> q;
	cin >> n >> m >> k;
	for (int i=1;i<=n;i++){
		p[i]=i;	
	}
	for (int i=1,x,y;i<=m;i++){
		cin >> x >> y;
		unite(x,y);
		ans[x]--;
		ans[y]--;
	}	
	for (int i=1,x,y;i<=k;i++){
		cin >> x >> y;
		if (fleader(x)!=fleader(y))continue;
		ans[x]--;
		ans[y]--;	
	}
	for (int i=1;i<=n;i++){
		id[i]=i;
		ld[i]=fleader(i);
	}
	sort(id+1,id+n+1,cmp);
	int tot=1,len=1;
	for (int i=2;i<=n+1;i++){
		if (i!=n+1 && ld[id[i]]==ld[id[i-1]]){len++;continue;}
		for (int j=tot;j<=i-1;j++){
			ans[id[j]]+=(len-1);	
		}
		len=1;
		tot=i;
	}
	cout << endl;
	for (int i=1;i<=n;i++){
		cout << ans[i] << ' ';
	}
	return 0;
}	

Measured memory_bytes: 2944
/*{{{*/
#include<bits/stdc++.h>

typedef long long ll;

#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORR(i,a,b) for(ll i=b-1;i>=a;i--)

#define vl vector<ll>
#define pll pair<ll,ll>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;
/*}}}*/

ll MOD = 1e9+7;
int main() {
  ll n,m;
  cin >> n >> m;
  ll singleAns = 0;
  vl modinv(m+1);
  modinv[1] = 1;
  FOR(i,2,m+1){
    modinv[i] = modinv[MOD%i]*(MOD-MOD/i) %MOD;
  }
  bool isPositive = true;
  ll perm  = 1;
  ll comb = 1;
  FOR(i,m-n+1,m){
    perm *= i;
    perm %= MOD;
  }
  ll allperm = perm*m%MOD; // mPn
  REP(i,n){
    comb *= n-i;
    comb %= MOD;
    comb *= modinv[i+1];
    comb %= MOD;
    //DEBUG(isPositive);
    //DEBUG(comb);
    //DEBUG(perm);
    ll diff = perm * comb % MOD;
    if(!isPositive) diff = MOD-diff;
    singleAns += diff;
    singleAns %= MOD;
    //DEBUG(singleAns);

    perm *= modinv[m-i-1];
    perm %= MOD;
    isPositive = !isPositive;
  }
  singleAns = allperm - singleAns + MOD;
  singleAns %= MOD;
  //DEBUG(singleAns);
  ll ans = singleAns * allperm % MOD;

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


Measured memory_bytes: 7224
import java.util.*;
 class Main{
  public static void main(String [] args){
    Scanner sc = new Scanner(System.in);
    int HP = sc.nextInt();
    int N = sc.nextInt();
    int total = 0;
    for(int i=0; i < N; i++){
      total += sc.nextInt();
    }
    if(HP <= total ){ System.out.println("Yes");}
    else{ System.out.println("No");}
    
  }
 
 
 
}

Measured memory_bytes: 47008
//#define DEBUG
#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 BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) ((a) & (1ll << (p)))
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))

#define fi first
#define sc second 
#define pb push_back


#ifdef DEBUG
    #define dbg(s) {s;}
    #define PRELUDE
#endif

#ifndef DEBUG 
    #define PRELUDE { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
    #define dbg(s)
    #define endl "\n"
#endif

#define int ll
#define i32 int32_t

#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 
// Ordered set docs:
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).

#define all(v) (v).begin(),(v).end()

typedef long long ll;
typedef long double ld;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;

// To remove randomization use 0 below:
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int ri(int x) { // from [0, n-1]
    return uniform_int_distribution<int>(0, x - 1)(rng);
}

inline ld rf() { // from [0, 1]
    return uniform_real_distribution<ld>(0, 1)(rng);
}

ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 

const ll mod = 1e9 + 7;

ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % mod;
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
}

const int maxn = 1e6 + 7;

const ll inf = 1e9 + 7;

void solve()
{
    int a,b,m;
    cin>>a>>b>>m;

    vector<int> wash;
    vector<int> micro;

    int x;
    int minia = inf;
    for (int i = 0; i < a; ++i) {
        cin>>x;
        minia = min(minia,x);
        wash.pb(x);
    }

    int minib = inf;
    for (int i = 0; i < b; ++i) {
        cin>>x;
        minib = min(minib,x);
        micro.pb(x);
    }

    int ans = minia + minib;

    int y,c,val;
    for(int i=0;i<m;i++)
    {
        cin>>x>>y>>c;
        x--;
        y--;
        val = wash[x] + micro[y] - c;
        ans = min(val,ans);
    }

    cout<<ans<<endl;
}

i32 main() {
    //freopen("<file>.in", "r", stdin);
    //freopen("<file>.out", "w", stdout);
    
    PRELUDE;
    int t = 1;
    //cin>>t;
    while(t--)
        solve();
}


Measured memory_bytes: 2548
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;

public class Main {
    public static void main(String[] args) throws IOException {
        for (int b=1; b<=4; b++){
            for (int f=1; f<=3; f++){
                for (int r=1; r<=10; r++){
                    Dom.allRes.add(new Dom(b, f, r, 0));
                }
            }
        }
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        int n = Integer.parseInt(br.readLine());
        String hashs =  HashMarks(20).toString();
        for (int i=0; i<n; i++){
            String[] line = br.readLine().split(" ");
            int bb = Integer.parseInt(line[0]);
            int ff = Integer.parseInt(line[1]);
            int rr = Integer.parseInt(line[2]);
            int vv = Integer.parseInt(line[3]);
            
            for (Dom dom: Dom.allRes){
                if (dom.b != bb || dom.f != ff || dom.r != rr){
                    continue;
                }else{
                    dom.v += vv;
                }
            }
        }
        int cnt = 0;
        for (Iterator<Dom> d = Dom.allRes.iterator(); d.hasNext();){
            Dom dom = d.next();
            cnt += 1;
            System.out.print(" " + dom.v);
            if (cnt%10==0){
                System.out.println();
            }
            if (!d.hasNext()){
                break;
            }
            if (cnt%30==0){
                System.out.println(hashs);
            }
        }
    }
    private static StringBuilder HashMarks(int n){
        StringBuilder sb = new StringBuilder();
        for (int i=0; i<n; i++){
            sb.append("#");
        }
        return sb;
    }
}
class Dom {
    final int b; //?£?
    final int f; //???
    final int r; //??????
    int v; //???
    static List<Dom> allRes = new ArrayList<Dom>();
    
    Dom (int b, int f, int r, int v){
        this.b = b;
        this.f = f;
        this.r = r;
        this.v = v;
    }
}

Measured memory_bytes: 21276
#include<bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
 
#define PII pair<LL,LL>
#define mem(v, x) memset(v, x, sizeof v)
 
#define si(x) scanf("%d", &x)
#define sii(x, y) scanf("%d %d", &x, &y)
#define siii(x, y, z) scanf("%d %d %d", &x, &y, &z)
 
#define sf(x) scanf("%lf", &x)
#define endl '\n'

#define FOR(i , N) for(int i = 0  ; i < N ; i++)
#define FOR1(i , N) for(int i = 1  ; i <= N ; i++)

template <typename T> T six(T &n){n = 0;bool neg = false;char c = getchar();while( c < '0' || c > '9'){if(c == '-') neg = true;c = getchar();}while(c >= '0' && c <= '9'){n = n*10 + c-48;c = getchar();}if(neg) n = ~(n-1);return n;}

using namespace std;
 
typedef long long LL;
 
int SET(int N,int pos){return N=N | (1<<pos);}
int RESET(int N,int pos){return N= N & ~(1<<pos);}
bool CHECK(int N,int pos){return (bool)(N & (1<<pos));}


/*
   D er iterative parlam na
   D te First WA Why???

*/

int main()
{

#ifndef ONLINE_JUDGE // dont use this in toph/codemarshal
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
#endif
   string str1, str2;
   cin >> str1 >> str2;
   int len1 = (int) str1.size();
   int len2 = (int) str2.size();
   int dp[len1 + 1][len2 + 1];
   for(int i = 0 ; i <= len1 ; i++) {
      for(int j = 0 ; j <= len2 ; j++) {
         if(i == 0 || j == 0) dp[i][j] = 0;
         else if(str1[i - 1] == str2[j - 1]) dp[i][j] = 1 + dp[i - 1][j - 1];
         else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      }
   }

   int i = len1, j = len2;
   string ans = "";
   while(i != 0 || j != 0) {
      if(i > 0 && j > 0 && str1[i - 1] == str2[j - 1]) ans += str1[i - 1], i--, j--;
      else if(i > 0 && dp[i][j] == dp[i - 1][j]) i--;
      else if(j > 0 && dp[i][j] == dp[i][j - 1]) j--;
   }
   reverse(all(ans));
   cout << ans << endl;
}  

// Iterative ta parlam na :( 

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string S;
    cin >> S;
    cout << "ABC" << S << '\n';
}

Measured memory_bytes: 3576
#include <iostream>//cout
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <functional>
#include <list>
#include <utility>//swap
using namespace std;
static const int MAX = 200000;
#define rep(i,n) for(int i=0;i<n;i++)
#define GET_ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
 
int main() {
  long long int n, y;
  cin >> n >> y;
  int i, g, s;
  i = y / 10000;

  while (i >= 0) { 
    int g = (y - 10000*i) / 5000;
    while (g >= 0) {
      int s = (y - 10000*i - 5000*g) / 1000;
      if (s + g + i == n) {
	cout << i <<' '<< g <<' '<< s << endl;
	return 0;
      }
      g--;
    }
    i--;
  } 
  cout << "-1 -1 -1" << endl;
  return 0;
}


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int N, M;
	vector<string> A,B;

	cin >> N >> M;
	A.resize(N), B.resize(M);
	for(int i = 0; i < N; i++)
		cin >> A[i];
	for(int i = 0; i < M; i++)
		cin >> B[i];


	bool ans = false;
	for(int i = 0; i < N-M+1; i++){
		for(int j = 0; j < N-M+1; j++){
			bool check = true;
			for(int k = 0; k < M; k++)
				if(A[i+k].substr(j,M) != B[k])
					check = false;
			if(check)
				ans = true;
		}
	}

	if(ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int count = 0;
        int PjMin = Integer.MAX_VALUE;
      
        for (int i = 0; i < N; i++) {
            int Pi = sc.nextInt();
            if (Pi <= PjMin) {
                count++;
            }
            if (PjMin >= Pi) {
                PjMin = Pi;
            }
        }
		System.out.println(count);
	}
}

Measured memory_bytes: 64900
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n,a,b;
  cin >> n >> a >> b;
  int x[n];
  int y[n];
  int z[n];
  rep(i,n)cin >> x[i] >> y[i] >> z[i];
  int dp[n+1][401][401];
  rep(i,n+1)rep(j,401)rep(o,401)dp[i][j][o]=1000000000;
  dp[0][0][0]=0;
  rep(i,n){
    rep(j,401)rep(o,401)dp[i+1][j][o]=dp[i][j][o];
    rep(j,401){
      rep(o,401){
        if(j-x[i]<0||o-y[i]<0)continue;
        dp[i+1][j][o]=min(dp[i+1][j][o],dp[i][j-x[i]][o-y[i]]+z[i]);
      }
    }
  }
  int ans=1000000000;
  rep(i,400){
    rep(j,400){
      int u=ans;
      if((i+1)/(gcd(i+1,j+1))==a&&(j+1)/(gcd(i+1,j+1))==b)ans=min(ans,dp[n][i+1][j+1]);
      //if(u!=ans)cout << i << " " << j << " " << ans << endl;
    }
  }
  if(ans==1000000000){
    cout << -1 << endl;
  }
  else cout << ans << endl;
}


Measured memory_bytes: 29368
N, K = map(int, input().split())
*X, = map(int, input().split())

k = 0
while k < N and X[k] < 0:
    k += 1
P = X[:k]; Q = X[k:]
ans = 10**30
if len(P) >= K:
    ans = min(ans, -P[-K])
if len(Q) >= K:
    ans = min(ans, Q[K-1])
for i in range(1, K):
    if len(P) < i or len(Q) < K-i:
        continue
    p = -P[-i]; q = Q[K-i-1]
    ans = min(ans, min(2*p+q, p+2*q))
print(ans)

Measured memory_bytes: 14480
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args) {
            string[] Nums = Console.ReadLine().Split(' ');
            int[] Cost = new int[3];
            for (int i = 0; i < 3; i++) {
                Cost[i] = int.Parse(Nums[i]);
            }
            Array.Sort(Cost);
            int Sum = 0;
            for(int i = 1; i < 3; i++) {
                Sum += Cost[i] - Cost[i - 1];
            }
            Console.WriteLine(Sum);
        }
    }
}


Measured memory_bytes: 11220
// C++ includes
#include <bits/stdc++.h>
// 俳句
using namespace std;

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

int main(void){
    ll n,m;
    cin >> n >> m;
    vll a(n);
    REP(i,n){
        cin >> a[i];
    }
    ll asum = accumulate(a.begin(), a.end(), 0);
    sort(a.begin(), a.end(), greater<ll>());
    if((a[m-1] * 4 * m) < asum){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>

#include<vector>

using namespace std;


int main()
{
	int N;
	int d[100];

	cin >> N;


	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}

	int num[110] = { 0 };


	for (int i = 0; i < N; i++) {
		num[d[i]]++;
	}

	int ans = 0;


	for (int i = 0; i <=100; i++) {

		if (num[i] > 0) {
			++ans;
		}
	}


	cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int cnt[26];
    for(int i=0;i<26;i++){
        cnt[i]=0;
    }
    char ch;
    while((ch=cin.get())!=EOF){
        if(0<=ch-'A'&&ch-'A'<=25){
            ch=ch-'A'+'a';
        }
        int num;
        num=ch-'a';
        if(0<=num&&num<=25) cnt[num]++;
    }
    
    for(int i=0;i<26;i++){
        char t='a'+i;
        cout<<t<<" : "<<cnt[i]<<endl;
    }
}


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

using namespace std;

set<int> s;

int main()
{
  ios_base::sync_with_stdio(false);
  int q;
  cin >> q;
  while(q--) {
    int a, x;
    cin >> a;
    if (a == 0) {
      cin >> x;
      s.insert(x);
      cout << s.size() << endl;
    }
    else if (a == 1) {
      cin >> x;
      cout << s.count(x) << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 12356
#include<bits/stdc++.h>
	#define ll long long
	#define f   first
	#define s   second
	#define pb          push_back
	#define mod         1000000007
	#define hell        998244353
	#define inf         1000000000000000000LL
	using namespace std;
	ll n,k,m,l,mx,sum;
	//ll dp[15][1005]
	ll power(ll x,ll y)
	{
		ll res=1;
		while(y>0)
		{
			if(y%2) res=(x*res)%mod;
			x=(x*x)%mod;
			y/=2;
		}
		return res;
	}
	void solve()
	{   ll a,b;
		cin>>n>>k;
		vector<ll> dp(k+1);
		for(int i=k;i>=1;i--)
		{
			dp[i]=power(k/i,n);
			for(int j=2;j<=k;j++)
			{
				if(j*i<=k) dp[i]=(dp[i]-dp[j*i]+mod)%mod;
				else break;
			}
		}
		ll ans=0;
		for(int i=1;i<=k;i++) ans=(ans+(i*dp[i])%mod)%mod;
		cout<<ans;


	}    
	int main()
	{  
	    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	    //cout<<primes.size();
	    ll t=1;
	    //cin>>t;
	    while(t--)
	        solve();

	}

Measured memory_bytes: 3972
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

fn main() {
    let n: usize = input();
    let q: usize = input();
    let s: Vec<char> = input::<String>().chars().collect();
    let lr: Vec<(usize, usize)> = (0..q).map(|_| (input(), input())).collect();

    let mut sum = vec![0; n + 1];
    for i in 0..n {
        sum[i + 1] = sum[i];
        if i > 0 && s[i - 1] == 'A' && s[i] == 'C' {
            sum[i + 1] += 1;
        }
    }

    let mut ans = vec![0; q];
    for i in 0..q {
        let (l, r) = lr[i];
        ans[i] = sum[r] - sum[l - 1];
        if l >= 2 && s[l - 1] == 'C' && s[l - 2] == 'A' {
            ans[i] -= 1;
        }
    }

    with_stdout_lock(|mut w| {
        for a in ans {
            writeln!(w, "{}", a).unwrap();
        }
    });
}


Measured memory_bytes: 6908
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstdlib>
#define INF 100000000
#define _INF -100000000
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;

int main() {
	int a, b;
	cin >> a >> b;
	int ret;
	if (a <= 0 && 0 <= b) {
		ret = 0;
	}
	else {
		if (a < 0) {
			if ((b - a) % 2 == 0) ret = -1;
			else ret = 1;
		}
		else {
			ret = 1;
		}
	}
	//output
	if (ret == 1) cout << "Positive" << endl;
	else if (ret == 0) cout << "Zero" << endl;
	else if (ret == -1) cout << "Negative" << endl;
	return 0;
}

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

int main(){
	int n;
	scanf("%d", &n);
	char a[n+5];
	scanf("%s", &a);
	if(n%2==1) printf("No\n");
	else{
		if(!strncmp(a, a+n/2, n/2)) printf("Yes\n");
		else printf("No\n");
	}
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) ((int)(x).size())

typedef	long long ll;

int main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	int cnt_refri, cnt_micro, m;
	cin >> cnt_refri >> cnt_micro >> m;

	vector<int> refri(cnt_refri), micro(cnt_micro);
	for (auto &v : refri) cin >> v;
	for (auto &v : micro) cin >> v;

	int best(1e9);
	for (int i(0); i < m; ++i)
	{
		int x, y, c;
		cin >> x >> y >> c;
		best = min(refri[x-1] + micro[y-1] - c, best);
	}
	int best_micro(1e9);
	for (auto v : micro) best_micro = min(best_micro, v);
	int best_refri(1e9);
	for (auto v : refri) best_refri = min(best_refri, v);
	cout << min(best, best_refri + best_micro) << endl;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll rui[111111][5];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  string s;cin>>s;
  for(int i=0;i<5555;i++)s.pb('!');
  for(int i=0;i<n;i++){
    if(s[i] == 'R'){
      rui[i+1][0] += rui[i][0]+1;
      rui[i+1][1] += rui[i][1];
      rui[i+1][2] += rui[i][2];
    }else if(s[i] == 'G'){
      rui[i+1][0] += rui[i][0];
      rui[i+1][1] += rui[i][1]+1;
      rui[i+1][2] += rui[i][2];
    }else{
      rui[i+1][0] += rui[i][0];
      rui[i+1][1] += rui[i][1];
      rui[i+1][2] += rui[i][2]+1;
    }
  }
  ll ans = 0;
  for(int i=0;i<n;i++){
    if(s[i] == 'G'){
      for(int j=0;j<i;j++){
	if(s[j] == 'R'){
	  ans += rui[n][2]-rui[i][2];
	  if(s[i+(i-j)] == 'B')ans--;
	}
      }
    }
  }
  for(int i=0;i<n;i++){
    if(s[i] == 'B'){
      for(int j=0;j<i;j++){
	if(s[j] == 'R'){
	  ans += rui[n][1]-rui[i][1];
	  if(s[i+(i-j)] == 'G')ans--;
	}
      }
    }
  }
  for(int i=0;i<n;i++){
    if(s[i] == 'R'){
      for(int j=0;j<i;j++){
	if(s[j] == 'G'){
	  ans += rui[n][2]-rui[i][2];
	  if(s[i+(i-j)] == 'B')ans--;
	}
      }
    }
  }
  for(int i=0;i<n;i++){
    if(s[i] == 'B'){
      for(int j=0;j<i;j++){
	if(s[j] == 'G'){
	  ans += rui[n][0]-rui[i][0];
	  if(s[i+(i-j)] == 'R')ans--;
	}
      }
    }
  }
  for(int i=0;i<n;i++){
    if(s[i] == 'G'){
      for(int j=0;j<i;j++){
	if(s[j] == 'B'){
	  ans += rui[n][0]-rui[i][0];
	  if(s[i+(i-j)] == 'R')ans--;
	}
      }
    }
  }
  for(int i=0;i<n;i++){
    if(s[i] == 'R'){
      for(int j=0;j<i;j++){
	if(s[j] == 'B'){
	  ans += rui[n][1]-rui[i][1];
	  if(s[i+(i-j)] == 'G')ans--;
	}
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3800
import javax.xml.crypto.Data;
    import java.math.BigDecimal;
    import java.util.*;
    import java.io.*;

    public class Main {
        public static int N = 1000;
        public static int[][] A = new int[N][N], dp = new int[N][N];

        public static void main(String[] args) throws IOException {

            //入力
            //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            FastScanner sc = new FastScanner();
            int n = sc.nextInt();

            //出力
            int a = (int) Math.floor(Math.sqrt(n));
            System.out.println(a * a);

        }


    }


    class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }


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

int func(float n) {
	float f = (float)((int)n);
	if (n - f < 0.5)return (int)f;
	return (int)f + 1;
}
int main() {
	float sum = 0, cnt = 0;
	float i, j;
	float C = 0;
	while (scanf("%f,%f", &i, &j) != EOF) {
		sum += i*j; cnt += j;
		C++;
	}
	cout << sum << endl << func(cnt / C) << endl;
	return 0;
}

Measured memory_bytes: 3280
a = 1
b = 1
c = 1
p = 10**9+7
N = int(input())
i = 0
while i < N:
  a = (a*10)%p
  b = (b*9)%p
  c = (c*8)%p
  i += 1
print((a-2*b+c)%p)

Measured memory_bytes: 9120
// Submitted By Subhash Yadav
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;

public class Main {

	static long m = (long) 1e9 + 7;

	static long power(long a, long b) {
		long x = 1, y = a;
		while (b > 0) {
			if (b % 2 == 1) {
				x = (x * y) % m; // multiplying with base
			}
			y = (y * y) % m; // squaring the base
			b /= 2;
		}
		return x % m;
	}

	public static void main(String[] args) throws IOException {

		FastScanner sc = new FastScanner();
		long n = sc.nextLong();

		
		long ans = (power(10, n) + power(8, n) - power(9, n) * 2 + m) % m;
		ans=(ans + 3L * m) % m;
		System.out.println(ans);

	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

}

Measured memory_bytes: 32584
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prarr(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.s<<')';return out;}
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
const int inf = 1e9+10;
const ll INF = 1e18+10;
const int MOD = 1e9+7;
const int MAXN = 2e5+10;

void solve()
{
	int n;
	// int l[MAXN];
	// cin>>a>>b;
	cin>>n;
	vector<int> l(n);
	rep(i,n) cin>>l[i];
	sort(all(l));
	ll ans = 0;
	int i = n-1;
	while(i>=0){
		int a = l[i];
		int b ;
		int c;
		for(int j = i-1; j>=0 ; j--){
			b = l[j];
			c = upper_bound(all(l),a-b)-l.begin();
			if(c<j) ans+=j-c;
		// tr(ans,i,j);
		}
		i--;
	}
	// cin
	// int i = 0,ans = 0;
	// while(i<n){
	// 	while(i<n && s[i]==s[i+1]) i++;
	// 	if(i<n)
	// 	ans++;
	// 	i++;
	// }

	cout<<ans<<endl;
}
int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin>>t;
	while(t--){
		solve();
	}
	return 0;

}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  string s;
  int k;
  cin >> s >> k;
  int no1 = 0;
  int no1wh = 0;
  if(count(ALL(s), '1')==s.size()) {
    cout << 1 << endl; 
    return 0;
  }
  
  rep(i,0,s.size()){
    if(s[i]!='1') {
      no1 = i;
      no1wh = s[i] - '0';
      break;
    }
  }
  
  if(k <= no1) cout << 1 << endl;
  else cout << no1wh << endl;
}


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

int main(){

  int N,K,num=1,i,j,uum;
  double ans=0.0,a=1.0,b;
  bool last=true;
  cin >> N >> K;

  if(K<=N){
    ans += N+1-K;
  }

  i=K;
  b=N;

  while(last){
    a = pow(0.5, num);
    if(i%2!=0){
      j = (i+1)/2;
    }else{
      j = i/2;
    }
    if(j<=N){
      uum = min(i-1,N);
      for(int k=j; k<=uum; k++) ans += a;
    }
    if(j==1){
      last=false;
    }
    num++;
    i = j;
  }

  ans /= b;
  cout << std::setprecision(12) << ans << endl;

  return 0;
}


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

int main()
{
    ll N, M;
    cin >> N >> M;

    vector<ll> A(N);
    ll sum = 0;
    for (size_t i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
    }

    ll count = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (4 * M * A[i] < sum)
        {
            count++;
        }
    }

    if (N - count >= M)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(X: int, Y: int):
    print("Brown" if -1 <= X - Y <= 1 else "Alice")


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)


if __name__ == '__main__':
    main()


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

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

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

  switch (X) {
    case 7:
    case 5:
    case 3:
      cout << "YES" << endl;
      break;

    default:
      cout << "NO" << endl;
      break;
  }
  return 0;
}


Measured memory_bytes: 256
def solve(X):
    items = [100, 101, 102, 103, 104, 105]
    dp = [0] * (X+1)

    dp[0] = 1
    for item in items:
        if X < item:
            continue
        dp[item] = 1
    for x in range(100, X+1):
        for item in items:
            if x >= item:
                if dp[x-item]:
                    #print(X,x)
                    dp[x] = dp[x - item]
                    break
    return dp[X]

def check(X):
    print(X, solve(X))

#check(100)
#check(615)
#check(217)
X = int(input())
print(solve(X))




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

int main() {
	string s, t;
	cin >> s >> t;
    int n = s.size(), m = t.size();
    vector<vector<int>> is(26);
    rep(i, n) is[s[i] - 'a'].push_back(i);
    rep(i, n) is[s[i] - 'a'].push_back(i+n);

    ll ans = 0;
    int p = 0;
    rep(i, m) {
        int c = t[i] - 'a';
        if (is[c].size() == 0) {
        	cout << "-1" << endl;
            return 0;
        }
        p = *lower_bound(is[c].begin(), is[c].end(), p) + 1;
        if (p >= n) {
            p -= n;
            ans += n;
        }
    }
    ans += p;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1724
/*-----lusar98-----*/
#include<bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define mod 1000000007
#define eps 1e-9
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
using namespace std;
int main()
{
    //fast();
    string a,b;
    cin >> a>> b;
    pair<ll,pair<ll,ll> > dp[a.length() +1 ][ b.length() +1 ];
    dp[0][0].ff=0;
    for(ll i=0;i<a.length() ; i++)
    {
    	for( ll j =0 ; j< b.length() ; j++)
    	{
    		if(b[j] == a[i])
			{
				dp[i+1][j+1].ff = dp[i][j].ff + 1 ;
				dp[i+1][j+1].ss = {i,j};
			}
			if(dp[i+1][j+1].ff < dp[i][j+1].ff)
			{
				dp[i+1][j+1].ff=dp[i][j+1].ff;
				dp[i+1][j+1].ss = {i, j +1 };
			}
			if(dp[i+1][j+1].ff < dp[i+1][j].ff)
			{
				dp[i+1][j+1].ff=dp[i+1][j].ff;
				dp[i+1][j+1].ss = { i + 1 , j};
			}
    	}
    }
    string s="";
    pair<ll,ll> k = {a.length(), b.length() };
    while(k.ff != 0 && k.ss!=0)
    {
    	if(a[k.ff-1] == b[k.ss-1])
    	s+=a[k.ff-1];
    	k = dp[k.ff][k.ss].ss;
    }
    reverse(s.begin() , s.end() );
    cout<<s;
}


Measured memory_bytes: 211328
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
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 sum = 0;
		List<Integer> list = new ArrayList<Integer>();
		for(int i = 0; i < n; i++) {
			list.add(sc.nextInt());
		}
		Collections.sort(list);
		Collections.reverse(list);
		for(int i = 0; i < k; i++) {
			sum += list.get(i);
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 1000000007

using namespace std;

typedef long long int lli;

const int MAXN = 200005;
vector <vector <lli>> adj(N, vector <lli>());
lli n;
lli dp[MAXN][2];

// dp[i][0] -> the number of ways to paint ith vertex to black?
// dp[i][1] -> white ??

void dfs(lli i, lli par){
	for(lli chi: adj[i]){
		if(chi == par) continue;
		dfs(chi, i);
		dp[i][0] = (dp[i][0] * dp[chi][1]) % MOD;
		dp[i][1] = (dp[i][1] * ((dp[chi][1] + dp[chi][0])%MOD)) % MOD;
	}
	dp[i][0] %= MOD;
	dp[i][1] %= MOD;
	//dbg(i);
	//dbg(dp[i][0]);
	//dbg(dp[i][1]);
}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin >> n;
	for(lli i=0; i<MAXN; i++)
		for(lli j: {0, 1})
			dp[i][j] = 1LL;

	for(lli i=0; i<n-1; i++){
		lli x, y;
		cin >> x >> y;
		adj[x].pb(y);
		adj[y].pb(x);
	}

	dfs(1, -1);
	cout << (dp[1][0] + dp[1][1]) % MOD;
	return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define    endl        '\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repp(i,a,b)    for(ll int i=b-1;i>=a;i--)
#define tr(container,it) for(__typeof__(container.begin()) it = container.begin(); it != container.end(); it++)
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define mpi         map<pair<ll int,ll int>,ll int>
#define vii         vector<pair<ll,pair<ll,ll> > >
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        998244353
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;
#define N  10000
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";



void solve(){
	ll a,b,n;
	cin>>a>>b>>n;
	if(b>n){
		// cout<<b;
		cout<<(ll)((a*n)/b);
		return;
	}
	cout<<(ll)((a*(b-1))/b);
		

}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll TESTS=1,an=1,f;
    // cin>>TESTS;
    while(TESTS--){
        // cout<<"Case #"<<an<<": ";
        an++;
        solve();

    }
    return 0;
}

Measured memory_bytes: 3600