akhauriyash/Code-Regression huggingface dataset:
import sys

def checkCol(A, i):
    for j in range(len(A[i])):
        if A[i][j] == "#":
            return False
    return True

def checkLow(A, j):
    for i in range(len(A)):
        if A[i][j] == "#":
            return False
    return True

H, W = map(int, sys.stdin.readline().strip().split(" "))

A = []
for line in sys.stdin:
    A.append(list(line.strip()))

col = []
low = []
for i in range(len(A)):
    if checkCol(A, i):
        col.append(i)

for i in range(len(A[0])):
    if checkLow(A, i):
        low.append(i)

for i, al in enumerate(A):
    if i in col:
        continue
    for j, a in enumerate(A[i]):
        if j in low:
            continue
        sys.stdout.write(a)
    sys.stdout.write("\n")



Measured memory_bytes: 3828
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int[] b = new int[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }
    for(int i = 0; i < n; i++){
      b[i] = sc.nextInt();
    }
    int[] difA = dif(n, a);
    int[] difB = dif(n, b);
    int output = 0;
    for(int i = 0; i < n; i++){
      output += (difA[i] - difB[i]) * fac(n - i - 1);
    }
    System.out.println(Math.abs(output));
  }
  public static int[] dif(int n, int[] seq){
    List<Integer> ideal = new ArrayList<>();
    int[] dif = new int[n];
    for(int i = 1; i <= n; i++){
      ideal.add(i);
    }
    for(int i = 0; i < n; i++){
      int index = ideal.indexOf(seq[i]);
      dif[i] = index;
      ideal.remove(index);
    }
    return dif;
  }
  public static int fac(int n){
    int fac = 1;
    if(n == 0){
      return 1;
    }
      for(int i = n; i >= 1; i--){
        fac *=  i;
      }
      return fac;
  }
}

Measured memory_bytes: 21844
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//                       _oo0oo_                         //
//                      o8888888o                        //
//                      88" . "88      ------ hzt1       //
//                      (| -_- |)                        //
//                      0\  =  /0                        //
//                    ___/`---'\___                      //
//                  .' \|     |// '.                     //
//                 / \|||  :  |||// \                    //
//                / _||||| -:- |||||- \                  //
//               |   | \  -  /// |     |                 //
//               | \_|  ''\---/''  |_/ |                 //
//               \  .-\__  '-'  ___/-. /                 //
//             ___'. .'  /--.--\  `. .'___               //
//          ."" '<  `.___\_<|>_/___.' >' "".             //
//         | | :  `- \`.;`\ _ /`;.`/ - ` : | |           //
//         \  \ `_.   \_ __\ /__ _/   .-` /  /           //
//     =====`-.____`.___ \_____/___.-`___.-'=====        //
//                       `=---='                         //
//                                                       //
//                                                       //
//     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       //
//                                                       //
//                 God-He Bless All.                     //
//           This Code Will Never Explode.               //
//                                                       //
//                                                       //
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
const int Size=1<<16;
char buffer[Size],*head,*tail;
inline char Getchar() {
    if(head==tail) {
        int l=fread(buffer,1,Size,stdin);
        tail=(head=buffer)+l;
    }
    if(head==tail) return -1;
    return *head++;
}
inline int read() {
    int x=0,f=1;char c=Getchar();
    for(;!isdigit(c);c=Getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=Getchar()) x=x*10+c-'0';
    return x*f;
}
typedef long long ll;
const int mod=1000000007;
int qpow(int n,int m) {
	int ans=1;
	for(;m;m>>=1,n=(ll)n*n%mod) if(m&1) ans=(ll)ans*n%mod;
	return ans;
}
const int maxn=2100;
int n,m,A[maxn],f[maxn],cnt;
int main() {
	n=read();m=read();
	for(int i=1;i*i<=n;i++) if(n%i==0) {
		A[++cnt]=i;
		if(i*i!=n) A[++cnt]=n/i;
	}
	sort(A+1,A+cnt+1);
	int ans=0;
	rep(i,1,cnt) {
		f[i]=qpow(m,A[i]+1>>1);
		rep(j,1,i-1) if(A[i]%A[j]==0) (f[i]+=mod-f[j])%=mod;
		(ans+=(ll)f[i]*((A[i]&1)?A[i]:A[i]/2)%mod)%=mod;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std; 
#define rep(i, n) for (int i = 0; i < (n); ++i)
int p[15];
int c[15];

int main() {
	
	
	int d,g;cin>>d>>g;
	
	rep(i,d) cin>>p[i]>>c[i];
	
	int ans = 123456789;
	
	rep(i,(1<<d))
	{
		int score = 0;
		int num = 0;
		rep(j,d)if(i&(1<<j))
		{
			score += (j+1)*100*p[j] + c[j];
			num += p[j];
		}
		
		int ma;
		for(int j=d-1;j>=0;j--)if(!(i&(1<<j))) {ma=j;break;}
		if(score + (p[ma]-1)*100*(ma+1) < g)continue;
		
		int yozyo = score>=g?0:(g-score + 100*(ma+1) - 1) / (100*(ma+1));
	
		ans = min(ans,num+yozyo);
	}
	
	cout << ans << endl;
	
	
	
}

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

int main(){
    int n,num;
    char mark;
    bool cards[4][14];
    for (int i=0; i<4; i++)
        for (int j=1; j<14; j++)
            cards[i][j]=0;
    cin >> n;        
    for (int i=0; i<n; i++){
        cin >> mark >> num;
        if (mark=='S') cards[0][num]=1;
        if (mark=='H') cards[1][num]=1;
        if (mark=='C') cards[2][num]=1;
        if (mark=='D') cards[3][num]=1;
    }
    
    for (int i=0; i<4; i++){
        for (int j=1; j<14; j++){
            if (cards[i][j]==0) {
                if (i==0) cout << "S" << " " << j << endl;
                else if (i==1) cout << "H" << " " << j << endl;
                else if (i==2) cout << "C" << " " << j << endl;
                else cout << "D" << " " << j << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void){

  int N = 4;
  int num = 0;
  char s[N];
  
  for ( int i = 0; i < N; i++) {
    cin >> s[i];
  }

  for ( int i = 0; i < N; i++ ) {
    if (s[i] == '+') {
      num += 1;
    } else if (s[i] == '-') {
      num -= 1;
    }
  }

  cout << num;
}


Measured memory_bytes: 256
import Control.Monad
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as BS
main=do
  [n,m]<-map read.words<$>getLine
  edge<-replicateM m (BS.words<$>BS.getLine)
  print(f m edge edge)
   where f 0 _ _ = 0
         f m ([a,b]:ab) edge = (g b edge (h [a,b] edge [] S.empty))+(f (m-1) ab edge)
         h [a,_] [] l s = (l,S.insert a s)
         h [a,b] ([x,y]:edge) l s |[a,b]==[x,y] = h [a,b] edge l s
                                  |a==x         = h [a,b] edge (y:l) (S.insert y s)
                                  |a==y         = h [a,b] edge (x:l) (S.insert x s)
                                  |otherwise    = h [a,b] edge l s
         g _ _ ([],_) = 1
         g b edge ((v:l),s) |b==v = 0
                            |otherwise = g b edge (i v edge l s)
         i _ [] l s = (l,s)
         i v ([x,y]:edge) l s |v==x&&(not (S.member y s)) = i v edge (y:l) (S.insert y s)
                              |v==y&&(not (S.member x s)) = i v edge (x:l) (S.insert x s)
                              |otherwise = i v edge l s

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    int n;
    string s;
    cin >> n >> s;
    
    int ans = INF;
    string tmp = "#.";
    int right = 0;
    int left = 0;
    rep(i,n)
    {
        if(s[i] == tmp[1]) right++;
    }
    if(ans > left + right) ans = left + right;
    rep(i,n)
    {
        if(s[i] == tmp[0])
        {
            left++;
        }
        else
        {
            right--;
        }
        if(ans > left + right) ans = left + right;
    }
    cout << ans << endl;
}


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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
 
using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

signed main(){
    io();
    int n; cin >> n;
    string s1, s2; cin >> s1 >> s2;
    string ans = "";
    for(int i = 0; i < n; ++i){
        ans += s1[i];
        ans += s2[i];
    }
    cout << ans << '\n';
    return 0;
}

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

#define int long long

main()
{
  string s;
  int minv = 114514;
  
  cin >> s;
  for(int i = 0; i < 26; i++) {
    string t = s;
    int cnt = 0;
    while(true) {
      bool flag = false;
      string temp;
      for(int j = 0; j < t.size() - 1; j++) {
	if(t[j] != t[j + 1]) flag = true;
	if(t[j] == i + 'a' || t[j + 1] == i + 'a') {
	  temp += i + 'a';
	} else {
	  temp += t[j];
	}
      }
      if(!flag) break;
      cnt++;
      t = temp;
    }
    minv = min(minv, cnt);
  }
  cout << minv << endl;

  return (0);
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct node
{
    int x,y;
}arr[100010];

int a[100010],b[100010];

bool cmp(node a,node b)
{
    if(a.y==b.y) return a.x<b.x;
    return a.y<b.y;
}

int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m))
    {
        for(int i=0;i<m;i++)
        {
            scanf("%d%d",&a[i],&b[i]);
            arr[i].x=a[i];
            arr[i].y=b[i];
        }
        int minn=1000010;
        for(int i=0;i<m;i++)
        {
            if(b[i]<minn) minn=b[i];
        }
        sort(arr,arr+m,cmp);
        int res=minn,ans=1;
        for(int i=1;i<m;i++)
        {
            if(arr[i].x>=res)
            {
                res=arr[i].y;
                ans++;
            }
        }
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  int a[7][7],m,i,j,k,l,n,o,not,max,my,mx;
  scanf("%d",&m);
  for(i=0;i<m;i++){
    //syokika
    for(j=0;j<7;j++){
      for(k=0;k<7;k++){
    a[j][k]=0;
      }
    }
    max=0;
    //in
    for(j=0;j<5;j++){
      for(k=0;k<5;k++){
    scanf("%d",&a[j][k]);
      }
    }
    //syori
    for(j=0;j<5;j++){
      for(k=0;k<5;k++){
    if(a[j][k]==1){
      for(l=0;k+l<6;l++){
        if(a[j][k+l]==1){
          mx=l+1;
          for(n=0;j+n<6;n++){
        not=0;
        for(o=0;o<=l;o++){
          if(a[j+n][k+o]==0)not=1;
        }
        if(not==1){
          my=n;
              if(max<my*mx){
            max=my*mx;
          }
          break;
        }
          }
        }
        else{
          break;
        }
      }
 
    }
      }
    }
    printf("%d\n",max);
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, T;
    cin >> N >> T;
    long long ans = 0;
    vector<int> t(N); for(int i = 0; i < N; ++i) cin >> t[i];
    for(int i = 0; i < N-1; ++i){
        ans += min(T, t[i+1] - t[i]);
    }
    ans += T;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    class P
    {
        public int index;
        public List<int> ad;

        public P(int index)
        {
            this.index = index;
            ad = new List<int>();
        }
    }

    static void Main(string[] args)
    {
        var nm = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var ps = new P[nm[0]];
        var set = new HashSet<int>();
        for(var i = 0; i < nm[1]; i++)
        {
            var ab = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
            for(var j = 0; j <2; j++)
            {
                if (set.Contains(ab[j]))
                    ps[ab[j]-1].ad.Add(ab[1 - j]-1);
                else
                {
                    set.Add(ab[j]);
                    ps[ab[j]-1] = new P(ab[j]-1);
                    ps[ab[j]-1].ad.Add(ab[1 - j]-1);
                }
            }
        }
        set.Clear();
        var result = 0;
        get(ps, ref result, set,0);
        WriteLine(result);
    }

    private static void get(P[] ps,ref int result,HashSet<int> set,int i)
    {
        set.Add(i);
        for(var j = 0; j < ps[i].ad.Count; j++)
        {
            if (!set.Contains(ps[i].ad[j]))
                get(ps, ref result, set, ps[i].ad[j]);
        }
        if (set.Count == ps.Length) result++;
        set.Remove(i);
    }
}


Measured memory_bytes: 13396
#include <iostream>
using namespace std;
int main() {
    long N;
    cin>>N;
    long sum=0;
  
    for(int i= 1;i<=N;i++)
    {
      if(((i%3)==0)||((i%5)==0))
      {
        
      }
      else{
      	sum+=i;
      }
    }
    
    cout<<sum<<endl;
 
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define pb push_back
#define Scan(a) scanf("%I64d", &a);
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<int, int> II;
typedef vector<II> vi;

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    char ch;
    cin >> ch;
    if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') cout << "vowel";
    else cout << "consonant";
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
//#include <string.h>
#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define LL long long
#define pii pair<int,int>
#define pb push_back
using namespace std;
const LL MOD=1e9+7;
int main()
{
	int n,f=0;
	char s[300010];
	cin>>n;
	rep(i,n)
	{
		cin>>s[i];
		if(i>0&&s[i]=='E') f++;
	}
	int mn=f;
	for(int i=1;i<n;i++)
	{
		if(s[i]=='E') f--;
		if(s[i-1]=='W') f++;
		mn=min(f,mn);
	}
	cout<<mn;
    rt0;
}


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

using namespace std;

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define Get(t, i) get<(i)>((t))
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

const int inf = 1 << 25;
const ll INF = 1LL << 55;

struct BipartiteMatching
{
  vector< vector<int> > graph;
  vector<int> matched;
  vector<bool> used;
  BipartiteMatching(int V):graph(V), matched(V, -1), used(V, false){}
  void add_edge(int u, int v)
  {
    graph[u].emplace_back(v);
    graph[v].emplace_back(u);
  }
  bool dfs(int u)
  {
    used[u] = true;
    for(auto& v : graph[u]) {
      int w = matched[v];
      if(w < 0 || !used[w] && dfs(w)) {
	matched[u] = v;
	matched[v] = u;
	return true;
      }
    }
    return false;
  }
  int match()
  {
    int res = 0;
    for(int u = 0; u < graph.size(); u++) {
      if(matched[u] < 0) {
	used.clear(); used.resize(graph.size(), false);
	if(dfs(u)) res++;
      }
    }
    return res;
  }
};


int main()
{
  int X, Y, E;
  cin >> X >> Y >> E;
  BipartiteMatching bpm(X + Y);
  while(E--) {
    int x, y; cin >> x >> y;
    bpm.add_edge(x, y + X);
  }
  cout << bpm.match() << endl;
  return 0;
}

Measured memory_bytes: 3260
n,*a=open(0).read().split()
ba=xa=bx=ans=0
for i in a:
    if i[0]=="B" and i[-1]=="A":
        ba+=1
    elif i[0]=="B":
        bx+=1
    elif i[-1]=="A":
        xa+=1
    ans+=i.count("AB")    
print(ans+min(xa,bx)+ba-1*(ba>0 and xa==bx==0))

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

int main(){
  int n;
  cin >> n;
  vector<double> vec(n);
  for (int i = 0; i < n; i++){
  	cin >> vec.at(i);
  }
  double sum = 0;
  double inverse;
  for (int i = 0; i < n; i++){
    sum = sum + (1 / vec.at(i));
  }
  inverse = 1 / sum;
  cout << inverse << endl;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    ll dp[90]{};
    dp[0] = 1000;
    for (int i = 1; i < N; ++i) {
        dp[i] = dp[i-1];
        for (int j = 0; j < i; ++j) {
            ll v = dp[j] / A[j];
            ll w = dp[j] + (A[i] - A[j]) * v;
            dp[i] = max(dp[i], w);
        }
    }
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;


struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){
  ll N,M;cin>>N>>M;
  UnionFind uf(N+M);
  repeat(i,N){
    int K;cin>>K;
    repeat(j,K){
      int L;cin>>L;L--;
      uf.unionSet(i,N+L);
    }
  }
  bool isok=true;
  repeat(i,N){
    isok &= uf.findSet(0,i);
  }
  cout <<(isok? "YES":"NO") << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

void diceb(int[],int,int,int,int);

int main(void)
{
    int i,j,dice[10]={},dice2[10]={};
    for(i=0;i<6;i++){
        scanf("%d",&dice[i]);
    }
    for(i=0;i<6;i++){
        scanf("%d",&dice2[i]);
    }

    for(i=0;i<8;i++){

        if(memcmp(dice,dice2,sizeof(dice))==0)break;
        if(dice[0]==dice2[0]){
            for(j=0;j<4;j++){
              diceb(dice2,1,2,4,3);
              if(memcmp(dice,dice2,sizeof(dice))==0) goto OUT;
            }
        }
        if(i<4){

              diceb(dice2,0,1,5,4);
        }else{

              diceb(dice2,0,2,5,3);
        }
    }
    OUT:

    if(memcmp(dice,dice2,sizeof(dice))==0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

void diceb(int dice3[],int a,int b,int c,int d){
  int top;

  top=dice3[a];
  dice3[a]=dice3[b];
  dice3[b]=dice3[c];
  dice3[c]=dice3[d];
  dice3[d]=top;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n) cin>>a[i];
    sort(a.begin(),a.end());
    int l=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,j=0;
    REP(i,n){
    if(a[i]<400){
        l++;
    }if(a[i]<800&&a[i]>=400){
        b++;
    } if(a[i]<1200&&a[i]>=800){
        c++;
    } if(a[i]<1600&&a[i]>=1200){
        d++;
    } if(a[i]<2000&&a[i]>=1600){
        e++;
    } if(a[i]<2400&&a[i]>=2000){
        f++;
    } if(a[i]<2800&&a[i]>=2400){
        g++;
    } if(a[i]<3200&&a[i]>=2800){
        h++;
    }if(a[i]>=3200){
        j++;
    }
    }
    int k=0;
    if(l!=0){
        k++;
    }
    if(b!=0){
        k++;
    }
    if(c!=0){
        k++;
    }
    if(d!=0){
        k++;
    }
    if(e!=0){
        k++;
    }
    if(f!=0){
        k++;
    }
    if(g!=0){
        k++;
    }
    if(h!=0){
        k++;
    }
    if(j!=n){
    cout<<k<<' '<<k+j;
    }else{
        cout<<1<<' '<<k+j;
    }
    return 0;
}


Measured memory_bytes: 256
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

n = int(stdin.readline().rstrip())
li = [0]*1000000

for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            li[i**2+j**2+k**2+i*j+j*k+k*i] += 1

for i in range(1,n+1):
    print(li[i])

Measured memory_bytes: 76372
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()

using ll = long long;

const int INF = 2147483647;
//const ll LINF = ll();今度書く

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>

using namespace std;

int ggd(int number1, int number2) {
	int m = number1;
	int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}

	while (m != n) {
		int temp = n;
		n = m - n;
		m = temp;
	}

	return m;
}

int lcm(int number1, int number2) {
	return number1 * number2 / ggd(number1, number2);
}

bool is_prime(int64_t x) {
	for (int64_t i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

int main() {

	int a;
	char s[100];
	scanf("%d%*c%s", &a, s);
	if (a >= 3200)printf("%s\n", s);
	else printf("red\n");

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int aaaa;cin>>aaaa;
  for(int fdsaf=0;fdsaf<aaaa;fdsaf++){
    int a[10];
    for(int i=0;i<10;i++)
      cin>>a[i];
    int b[10]={};
    int c[10]={};
    b[0]=1;c[0]=0;
    int flag=1;
    int cnt=0;
    for(int i=0;i<2;i++){
      if(i==0){
	b[1]=1;c[1]=0;
      }else{
	b[1]=0;c[1]=1;
      }

      for(int j=0;j<2;j++){
	if(j==0){
	  b[2]=1;c[2]=0;
	}else{
	  b[2]=0;c[2]=1;
	}
	for(int k=0;k<2;k++){
	  if(k==0){
	    b[3]=1;c[3]=0;
	  }else{
	    b[3]=0;c[3]=1;
	  }
	  for(int l=0;l<2;l++){
	    if(l==0){
	      b[4]=1;c[4]=0;
	    }else{
	      b[4]=0;c[4]=1;
	    }
	    for(int m=0;m<2;m++){
	      if(m==0){
		b[5]=1;c[5]=0;
	      }else{
		b[5]=0;c[5]=1;
	      }
	      for(int n=0;n<2;n++){
		if(n==0){
		  b[6]=1;c[6]=0;
		}else{
		  b[6]=0;c[6]=1;
		}
		for(int o=0;o<2;o++){
		  if(o==0){
		    b[7]=1;c[7]=0;
		  }else{
		    b[7]=0;c[7]=1;
		  }
		  for(int p=0;p<2;p++){
		    if(p==0){
		      b[8]=1;c[8]=0;
		    }else{
		      b[8]=0;c[8]=1;
		    }
		    for(int q=0;q<2;q++){
		      if(q==0){
			b[9]=1;c[9]=0;
		      }else{
			b[9]=0;c[9]=1;
		      }
		      int bpointer=0;
		      int cpointer=0;
		      for(int r=0;r<10;r++){
			//cout<<a[r]<<" "<<b[r]<<" "<<c[r]<<endl;
			if(b[r]==1){
			  if(bpointer<a[r]){
			    bpointer=a[r];
			    if(r==9){
			      flag=0;
			      cout<<"YES"<<endl;
			      break;
			    }
			  }else{
			    break;
			  }
			}else if(c[r]==1){
			  //cout<<"!"<<endl;
			  if(cpointer<a[r]){
			    cpointer=a[r];
			    if(r==9){
			      flag=0;
			      cout<<"YES"<<endl;
			      break;
			    }
			  }else{
			    break;
			  }
			}
		      }
		      if(flag==0)break;
		    }
		    if(flag==0)break;
		  }
		  if(flag==0)break;
		}
		if(flag==0)break;
	      }
	      if(flag==0)break;
	    }
	    if(flag==0)break;
	  }
	  if(flag==0)break;
	}
	if(flag==0)break;
      }
      if(flag==0)break;
    }
    if(flag)
      cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3012
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const int INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;



void solve() {
    int n, k;
    cin >> n >> k;
    cout << n - k + 1 << endl;
    
    
}

//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
using namespace std;

int main() {
	int n, x, m, min=9999, sum = 0;
	scanf("%d%d", &n, &x);
	for (int i = 0; i < n; i++) {
		scanf("%d", &m);
		if (m < min)min = m;
		sum += m;
	}
	printf("%d\n", n + (x - sum) / min);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    String[] data;
    Scanner sc = new Scanner(System.in);
    while(sc.hasNext()){
      data = sc.nextLine().split(" ");
      int digit = Integer.parseInt(data[0]) + Integer.parseInt(data[1]);
      System.out.println("" + Integer.toString(digit).length());
    }
  }
}

Measured memory_bytes: 26360
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, x = map(int, input().split())
    n -= x
    res = 0
    while x != 0:
        q, r = divmod(n, x)
        res += q * x * 3
        n = x
        x = r
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9036
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int w;
    cin >> s >> w;
    for(int i = 0; i < s.size(); i+=w) {
        cout << s[i];
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

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

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N;
ll K;
P p[100000];

void solve(){
	sort(p, p +  N);
	rep(i, N){
		K -= p[i].second;
		if(K <= 0){
			cout << p[i].first << endl;
			return;
		}
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> K;
	rep(i, N) {
		cin >> p[i].first >> p[i].second;
	}
		solve();
	return 0;
}


Measured memory_bytes: 1792
s=input()
t=input()
sr = len(s)
tr = len(t)
cand = []
for i in range(sr-tr+1):
    flag = True
    for j in range(tr):
        if s[i+j] != '?' and s[i+j] != t[j]:
            flag = False
            break
    if flag:
        tmp = (s[:i] + t + s[(i+tr):]).replace("?", "a")
        cand.append(tmp)
        
cand.sort()

if cand:
    print(cand[0])
else:
    print("UNRESTORABLE")

Measured memory_bytes: 38256
#import copy
from collections import deque


def xnxn(n=0, flag="v"):
    """
    args:
        int n: a number of lows to read
    example:
        input   1
        retrun  1

        input   1 2 3
        return  [1,2,3]
        input   1 2 3
                4 
        return  [[1,2,3],
                [4]]
    """
    if n == 0:
        temp = list(map(int, input().split()))
        if len(temp) == 1:
            if flag == "l":
                return temp
            else:
                return temp[0]
        elif len(temp) > 1:
            return temp
    else:
        temp = [list(map(int, input().split())) for _ in range(n)]
        return temp


n, m = xnxn()
a = xnxn(m)

graph = [[] for _ in range(n+1)]
for g in a:
    graph[g[0]].append(g[1])
    graph[g[1]].append(g[0])

# print(graph)

d = deque([1])
rout = [0]*(n+1)
while d != deque([]):
    pos = d.popleft()
    for i in graph[pos]:
        if rout[i] == 0:
            rout[i] = pos
            d.append(i)


if rout != [0]*(n+1):
    print("Yes")
    for i in rout[2:]:
        print(i)
else:
    print("No")


Measured memory_bytes: 58768
# -*- coding: utf-8 -*-
from sys import stdin

s_in = lambda: stdin.readline()[:-1]  # s = s_in()


N = list(s_in())
if N[0] == N[1] and N[1] == N[2]:
    print(''.join(N))
else:
    if int(N[0]) > int(N[1]):
        x = int(N[0])
    elif int(N[0]) < int(N[1]):
        x = int(N[0]) + 1
    elif int(N[1]) >= int(N[2]):
        x = int(N[0])
    else:
        x = int(N[0]) + 1
    print(x * 111)


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

int dis[MAXN];

set<pii> st;

void solve(){
	int k;
	cin >> k;
	REP(i, 0, k) {
		dis[i] = INF;
	}
	REP(i, 1, 10) {
		dis[i % k] = min(dis[i % k], i);
	}
	REP(i, 0, k) {
		if (dis[i] < INF) {
			st.insert(mp(dis[i], i));
		}
	}
	while(true) {
		int cur = st.begin()->_2;
		st.erase(st.begin());
		if (cur == 0) {
			printf("%d\n", dis[cur]);
			return;
		}
		REP(i, 0, 10) {
			int nxt = (cur * 10 + i) % k;
			if (dis[nxt] > dis[cur] + i) {
				st.erase(mp(dis[nxt], nxt));
				dis[nxt] = dis[cur] + i;
				st.insert(mp(dis[nxt], nxt));
			}
		}
	}
}   

int main(){

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


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

using namespace std ;
typedef long long ll;
typedef string str;
typedef vector<int> vint;
typedef vector<double> vdou ;
typedef vector<ll> vll;
typedef vector<vint> vvint;
typedef vector<str> vstr;
typedef pair<int, int> pii;
typedef vector<pii> vpii ;

#define REP(i, n) for (ll (i) = 0; (i) < (ll)(n); i++) 
#define FOR(i, a, b) for(ll (i) = a; (i) < (ll)b; i++)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (ll)x.size()
#define SP(x)  setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n ;
  str s ;
  cin >> n >> s ;
  vint we(n,0) ;
  vint ea(n,0) ;
  for(int i=1;i<n;i++){
    if(s[i-1]=='W'){
      we[i] = we[i-1] + 1 ;
    }
    else{
      we[i] = we[i-1] ;
    }
  }
  reverse(ALL(s)) ;
  
  for(int i=1;i<n;i++){
    if(s[i-1]=='E'){
      ea[i] = ea[i-1] + 1 ;
    }
    else{
      ea[i] = ea[i-1] ;
    }
  }
  
  reverse(ALL(ea)) ;
  
  vint ans(n) ;
  
  
  REP(i,n){
    ans[i] = we[i] + ea[i] ;
    //cout << ans[i] <<endl ;
  }
  
  
  sort(ALL(ans)) ;
  
  cout << ans[0] <<endl ;
  /*
  REP(i,n){
    cout << we[i] <<endl ;
  }

  REP(i,n){
    cout << ea[i] <<endl ;
  }
  */
  
  
  
  return 0 ;
}

Measured memory_bytes: 4244
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
int main()
{
  ll H,W,D;
  cin>>W>>H>>D;
  vector<pair<ll,ll>> A(H*W+1);
  ll b;
  rep(i,W){
    rep(j,H){
      cin>>b;
      A.at(b).first=i;
      A.at(b).second=j;
    }
  }
  vector<ll> P(H*W+1);
  rep(i,H*W+1){
    if(i>D)P.at(i)=P.at(i-D)+abs(A.at(i).first-A.at(i-D).first)+abs(A.at(i).second-A.at(i-D).second);
  }
  ll Q,L,R;
  cin>>Q;
  rep(i,Q){
    cin>>L>>R;
    cout<<P.at(R)-P.at(L)<<endl;
  }
}

Measured memory_bytes: 3200
#include <iostream>
#define r(i,n) for(int i=0;i<n;i++)
int a[51000];
using namespace std;
int main(){
  for(int i=2;i<51000;i++){
    for(int j=i*2;j<51000;j+=i)a[j]++;
  }
  int n;
  while(cin>>n){
    for(int i=n-1;i>=2;i--)if(!a[i]){cout<<i<<' ';break;}
    for(int i=n+1;i<=51000;i++)if(!a[i]){cout<<i<<endl;break;}
  }
}

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

using namespace std;

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

    if(n % 2 == 0)
    {
        cout << n << endl;
    } else
    {
        cout << n*2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  val in2 = in.head
  //println(in2)
  
  val k = "keyence"
  
  private def func(s: String):Boolean = {
    if(s.startsWith(k) || s.endsWith(k)) return true
    if(k == s.take(1) + s.takeRight(6)) return true
    if(k == s.take(2) + s.takeRight(5)) return true
    if(k == s.take(3) + s.takeRight(4)) return true
    if(k == s.take(4) + s.takeRight(3)) return true
    if(k == s.take(5) + s.takeRight(2)) return true
    if(k == s.take(6) + s.takeRight(1)) return true
  	false
  }
  val ret = if(func(in2)) "YES" else "NO"
  println(ret)
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}
 
template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int MN = 60;

int N, K;
int a[MN];

int main() {
	cin >> N >> K;
	rep(i, N) {
		cin >> a[i];
		a[i] -= (K+1);
	}

	int la = -1;

	vi com;
	rep(i, K) {
		int p = -1;
		rep(j, N) if (j != la && (p == -1 || a[p] > a[j])) {
			p = j;
		}
		++a[p];
		com.pb(p);
		la = p;
	}

	rep(i, N) if (a[i] < 0) {
		puts("-1");
		return 0;
	}

	vi ans;

	rep(i, N) if (i != com[0]) {
		ans.pb(i);
	}

	rep(i, K) {
		ans.pb(com[i]);
		rep(j, N) if (j != com[i] && !(i < K-1 && j == com[i+1])) {
			ans.pb(j);
		}
	}
	cout << ans.size() << endl;
	rep(i, ans.size()) cout << ans[i] + 1 << (i + 1 == ans.size() ? '\n' : ' ');

	return 0;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line: Vec<usize> = read_as_vec();
    let (n, m) = (line[0], line[1]);

    let mut s: Vec<usize> = vec![0;m];
    for i in 0..m{
        let line: Vec<usize> = read_as_vec();
        let switches = line.into_iter().skip(1).collect::<Vec<usize>>();
        for switch in switches{
            s[i] |= 1 << (switch-1);
        }
    }

    let p: Vec<usize> = read_as_vec();
    let mut counter = 0;
        
    for cur_switch in 0..(2<<(n-1)){
        let mut is_on: Vec<bool> = vec![false;m];
        //println!("current switch status: {:b}", cur_switch);
        for i in 0..m{
            let filtered_switch = cur_switch & s[i];
            //println!("filtered switch: {:b}", filtered_switch);
            //let num_of_on = filtered_switch.to_string().chars().filter(|x| *x == '1').count();
            let num_of_on = format!("{:b}", filtered_switch).chars().filter(|x| *x == '1').count();
            //println!("num_of_on = {}", num_of_on);
            if num_of_on%2 == p[i]{
                is_on[i] = true;
            }
        }

        //println!("result; {:?}", is_on);
        if is_on.into_iter().all(|x| x){
            counter += 1;
        }
    }

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


Measured memory_bytes: 4352
bill_count, total_money = map(int, input().split())

def calc(total_money, bill_count):
  x_high_bound = int(total_money / 10000) if int(total_money / 10000) < bill_count else bill_count
  for x in range(x_high_bound + 1):
    hoge = bill_count - x
    if 10000 * x + 5000 * hoge < total_money: continue
    if 10000 * x + 1000 * hoge > total_money: continue
    for y in range(hoge + 1):
      for z in [bill_count - x - y]:
        if 10000 * x + 5000 * y + 1000 * z == total_money:
          return "{} {} {}".format(x, y, z)
  return '-1 -1 -1'

print(calc(total_money, bill_count))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <complex>
#include <cfloat>
using namespace std;

typedef complex<double> P;
typedef const P &rP;

#define EPS 1e-7

double eq(double a, double b){
	return abs(a - b) < EPS;
}

double dot(rP a, rP b){
	return a.real() * b.real() + a.imag() * b.imag();
}

double cross(rP a, rP b){
	return a.real() * b.imag() - b.real() * a.imag();
}


double distc2(rP v, rP p, double rp, rP q, double rq){
	P d = q - p;
	rp += rq;
	double a = norm(v);
	double b = dot(v, d);
	double c = norm(d) - rp * rp;

	double D = b * b - a * c;
	if( D < 0.0 ){
		return DBL_MAX;
	}
	double t = (b - sqrt(D)) / a;
	if(t > EPS){
		return abs(v) * t;
	}
	t = (b + sqrt(D)) / a;
	if(t > EPS){
		return abs(v) * t;
	}
	return DBL_MAX;
}


double intersectSS(rP pa1, rP pa2, rP pb1, rP pb2){
	P da12 = pa2 - pa1;
	P db21 = pb1 - pb2;
	P dab1 = pb1 - pa1;
	double D = cross(da12, db21);
	if( abs(D) > EPS ){
		double t = cross(dab1, db21) / D;
		double s = cross(da12, dab1) / D;
		if( EPS < t && (-EPS < s && s < 1.0 + EPS) ){
			return t;
		}
	}
	return DBL_MAX;
}

int n;
double w, h, r, vx, vy, x, y;
P ball[11], wall[5], v;

int solve(){
	wall[0] = wall[4] = P(r, r);
	wall[1] = P(w - r, r);
	wall[2] = P(w - r, h - r);
	wall[3] = P(r, h - r);

	double t[4];
	double w[4];

	double s = 1e4;
	while(s > 0.0){
		v = P(vx, vy);
		v /= abs(v);

		double wmin = DBL_MAX;
		int windex = -1;
		for(int i = 0; i < 4; ++i){
			t[i] = intersectSS(ball[0], ball[0] + v, wall[i], wall[i+1]);
			w[i] = abs(v) * t[i];
			if( wmin > w[i] ){
				wmin = w[i];
				windex = i;
			}
		}

		double dmin = DBL_MAX;
		int dindex = -1;
		for(int i = 1; i < n; ++i){
			double d = distc2(v, ball[0], r, ball[i], r);
			if( dmin > d ){
				dmin = d;
				dindex = i + 1;
			}
		}

		if( dmin < wmin ){
			s -= dmin;
			if( s < 0.0 ) return -1;
			return dindex;
		}
		else{
			s -= wmin;
			if( s < 0.0 ) return -1;

			P next = ball[0] + v * t[windex];

			int f = 0;
			for(int i = 0; i < 4; ++i){
				if( eq(wmin, w[i]) ){
					if( i & 1 ){
						vx = -vx;
					}
					else{
						vy = -vy;
					}
				}
			}

			ball[0] = next;
		}
	}

	return -1;
}


int main(){
	while( cin >> n >> w >> h >> r >> vx >> vy ){
		for(int i = 0; i < n; ++i){
			cin >> x >> y;
			ball[i] = P(x, y);
		}
		
		cout << solve() << '\n';
	}
}

Measured memory_bytes: 1248
program main
implicit none
integer :: n
integer , allocatable :: a(:), b(:)
integer :: i, j, s

read(*,*) n
allocate( a(n) )
allocate( b(n) )
do i = 1, n
   read(*,*) a(i), b(i)
end do
call quicksort2(n, b, a, 1, n)
s = 0.
do i = 1, n
   s = s + a(i)
   if(s .gt. b(i) ) then
      write(*,*) 'No'
      stop
   end if
end do
write(*,*) 'Yes'

stop
contains

recursive subroutine quicksort2(n, a, b, first, last)
  implicit none
  integer :: a(n), b(n)
  integer :: first, last
  integer ::  i, j, n
  integer ::  x, y, t, s
  
  x = a( (first+last) / 2 )
  i = first
  j = last
  do
     do while (a(i) < x)
        i=i+1
     end do
     do while (x < a(j))
        j=j-1
     end do
     if (i >= j) exit
     t = a(i)
    a(i) = a(j)
    a(j) = t
    s = b(i)
    b(i) = b(j)
    b(j) = s
    i=i+1
    j=j-1
  end do
  if (first < i - 1) call quicksort2(n, a, b, first, i - 1)
  if (j + 1 < last)  call quicksort2(n, a, b, j + 1, last)
end subroutine quicksort2

end program main


Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,a,sum=0;
    cin >> n;
    rep(i,n){
        cin >> a;
        sum+=a;
    }
    cout << (sum%2?"NO\n":"YES\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>//accumulate(v.begin(), v.end(), 0);
#include <algorithm>//sort(v.begin(),v.end());
#include <string>//
#include <cmath>
#include <iomanip> //setprecision(2)
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
        ll a,b;
        cin >> a >> b;
        if(b%a==0) cout << a+b <<endl;
        else cout <<b-a<<endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
//#include <tuple>
#include <cmath>
#include <string>
#include <vector>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
using namespace std;

int k;


int main() {
	cin >> k;
	if (k % 2) {
		cout << (k / 2)*(k / 2 + 1) <<"\n";
	}
	else cout << k * k / 4 << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[1000005];
int main() {
	long long sum=1;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]==0){
			cout<<0;
			return 0;
		} 
	} 
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(1000000000000000000ll/sum<a[i]){
			cout<<-1;
			return 0;
		}
		else{
			sum*=a[i];
		}
	} 
	cout<<sum;
	return 0;
}


Measured memory_bytes: 4412
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cassert>
#include <vector>
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
#define umax( x , y ) x = max( x , (y) )
#define umin( x , y ) x = min( x , (y) )
#define For( i , a ) for(int i=1;i<=a;i++)
#define ort (b+s)/2
#define y2 asrwjaelkf
#define y1 asseopirwjaelkf
#define set multiset

using namespace std;

inline int read() {
    int res = 0 ;int neg ;
    while(true){char ch = getchar();if(ch>='0' && ch<='9' || ch=='-'){if(ch=='-') neg = -1;else neg = 1 , res = ch-'0';break;} }
    while(true){char ch = getchar();if(ch>='0' && ch<='9') res*=10 , res+=ch-'0';else break;}
    return res*neg;
}


typedef long long Lint;
typedef double db;
typedef pair<int,int> ii;
typedef pair<db,db> dd;
typedef pair<ii,int> iii;
typedef pair<ii,ii> i4;

const int maxn = 100020;
const int maxm = 1000020;
const int MOd = 1e9 + 7;
const int K = 320;

struct node {
    Lint x[2][2][2];// bas-son bitisik, bas havada, son havada.
};

int a, ar[maxn], bs[maxn];

int main() {

    //freopen("asd.in.c","r",stdin);
    //freopen("asd.out.c","r",stdout);

    int a;
    scanf("%d",&a);
    a *= 2;
    for(int i=1;i<=a;i++)
        scanf("%d",&ar[i]);
    sort( ar+1, ar+1+a );
    Lint ans = 0;
    for(int i=1;i<=a;i+=2) ans += ar[i];
    cout << ans << endl;
    return 0;
}



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

int main() {
	string S, X = "";
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'B') {
			if (X != "") X.erase(X.end() - 1);
		}
		else X += S[i];
	}
	cout << X << endl;
}

Measured memory_bytes: 256