akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

vector<unsigned long> p(51, 0), l(51, 0);

unsigned long func(int n, unsigned long x){
    if(n == 0) return 1;
    if(x == 1){
        return 0;
    }else if(x <= 1 + l[n-1]){
        return func(n-1, x-1);
    }else if(x == 1 + l[n-1] + 1){
        return p[n-1] + 1;
    }else if(x <= 1 + l[n-1] + 1 + l[n-1]){
        return p[n-1] + 1 + func(n-1, x - 1 - l[n-1] - 1);
    }else if(x == 1 + l[n-1] + 1 + l[n-1] + 1){
        return p[n-1] + 1 + p[n-1];
    }
    return 0;
}

int main(){
    int N;
    unsigned long X;
    cin>>N>>X;

    p[0] = 1;
    for(int i=1; i<=N; ++i){
        p[i] = p[i-1] + 1 + p[i-1];
    }
    l[0] = 1;
    for(int i=1; i<=N; ++i){
        l[i] = 1 + l[i-1] + 1 + l[i-1] + 1;
    }

    unsigned long ans = func(N, X);
    cout<<ans<<endl;

    return 0;
}



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

int main(void){
  int N;
  string hon="hon";
  string pon="pon";
  string bon="bon";
  cin >> N;

  if (N%10==3)  printf("bon\n");
  else if(N%10==0 || N%10==1 || N%10==6 || N%10==8) printf("pon\n");
  else printf("hon\n");
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector>
#include <iomanip>
#include <cmath>
#include <string.h>
#include <stdio.h>

using namespace std;

int main(){

  int N;
  
  cin >> N;
  
  string answer = "No";
  for(int i=1; i<=9; i++){
	for(int j=1; j<=9; j++){
    	if(i*j == N)
          answer = "Yes";
    }
  }
  
  cout << answer << endl;
  

  
  return 0;
  
}


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

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			long K = scan.nextLong();
			int[]A = new int[N];
			int[]C = new int[N];
			Arrays.fill(C, -1);
			int count = 0;
			C[0]=count;;
			for(int i = 0;i<N;i++) {
				A[i] = scan.nextInt()-1;
			}
			int loop = 0;
			int loopcount = 0;
			int loopad = 0;
			
			int genzai = 0;
			
			while(true) {
				count++;
				
				if(C[A[genzai]]==-1) {
					C[A[genzai]]=count;
					genzai = A[genzai];
				}else {
					loop = C[genzai]-C[A[genzai]]+1;
					loopcount = C[A[genzai]];
					loopad = A[genzai];
					//System.out.println(genzai);
					//System.out.println(A[genzai]);
					//System.out.println(C[genzai]);
					//System.out.println(C[A[genzai]]);
					break;
				}

			}
			
			
			if(loopcount>K) {
				int gen  =0;
				
				while(K>0) {
					gen = A[gen];
					K--;
				}
				
				System.out.println(gen+1);
			}else {
				
				int gen  =loopad;
				
				K-=loopcount;
				
				K = K%loop;
				
				while(K>0) {
					gen=A[gen];
					K--;
				}
				
				System.out.println(gen+1);
				
				
				
			}
			
			/*
			for(int i = 0;i<N;i++) {
				System.out.print(C[i]);
				System.out.print(" ");
			}
			
			System.out.println();
			System.out.println(loop);
			System.out.println(loopcount);
			System.out.println(loopad);
			*/
			
			
			
			
			
			
			
			
		}
		
		
	}
		

}


Measured memory_bytes: 61308
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 1e9
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    vector<int> s(n);
    REP(i,n){
        cin>>s[i];
    }

    int sum=0,d=0;
    sort(ALL(s));
    REP(i,n){
        sum+=s[i];
        if(d==0 && s[i]%10!=0) d=s[i];
    }

    int ans;
    if(sum%10){
        ans=sum;
    }else{
        if(d) ans=sum-d;
        else ans=0;
    }

    cout<<ans<<endl;

	return 0; 
}


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

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int f(int a){
  int count = 0;
  int flag = 0;
  for(int i = 1; i <= pow(a,0.5); ++i){
    if(a % i == 0) count ++;
    if(i*i == a)flag = 1;
  }
  count *= 2;
  if(flag == 1) --count;
  return count;
}


int main(){

  int a,b,k;
  scanf("%d%d%d",&a,&b,&k);

  int count = 0;
  for(int i = 100; i > 0; --i){
    if(a % i == 0 && b % i == 0) count ++;
    if(count == k){
      printf("%d",i);
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 2144
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
s = 0

for i in range(N-1):
    s += B[A[i]-1]
    if A[i] == A[i+1]-1:
        s += C[A[i]-1]

s += B[A[N-1]-1]

print(s)


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

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
string G[701];
typedef pair<int,int>P;
typedef pair<P,int>PP;
int H,W;
//double eps=0.000005;
double eps=0.0000000000;
double eeps=0.00001;
bool cmp(const PP&a,const PP&b){
	if(a.first==b.first){
		return a.second<b.second;
	}
	if((H-a.first.first)*(b.first.second)==(a.first.second)*(H-b.first.first)){
		return a.second<b.second;
	}
	return (H-a.first.first)*(b.first.second)>(a.first.second)*(H-b.first.first);
}
int main(){
	cin>>H>>W;
	REP(i,H){
		cin>>G[i];
	}
	vector<PP>v;
	REP(i,H){
		REP(j,W){
			if(G[i][j]=='#'){
				/*//横
				if(i==0||G[i-1][j]=='.'){
					v.push_back(PP(P(i,j),1));
					v.push_back(PP(P(i,j+1),-1));
				}
				if(i!=H-1&&G[i+1][j]=='.'){
					v.push_back(PP(P(i+1,j),1));
					v.push_back(PP(P(i+1,j+1),-1));
				}
				//縦
				if((j+1)==W-1||G[i][j+1]=='.'){
					v.push_back(PP(P(i,j+1),1));
					v.push_back(PP(P(i+1,j+1),-1));
				}
				if(j!=0&&G[i][j-1]=='.'){
					v.push_back(PP(P(i,j),1));
					v.push_back(PP(P(i+1,j),-1));
				}*/
				
				//横
				if(i==0||G[i-1][j]=='.'){
					v.push_back(PP(P(i,j),1));
					v.push_back(PP(P(i,j+1),-1));
				}
				if(i+1!=H&&G[i+1][j]=='.'){
					v.push_back(PP(P(i+1,j),1));
					v.push_back(PP(P(i+1,j+1),-1));
				}
				//縦
				if((j+1)==W||G[i][j+1]=='.'){
					v.push_back(PP(P(i,j+1),1));
					v.push_back(PP(P(i+1,j+1),-1));
				}
				if(j!=0&&G[i][j-1]=='.'){
					v.push_back(PP(P(i,j),1));
					v.push_back(PP(P(i+1,j),-1));
				}
			}
		}
	}
	sort(v.begin(),v.end(),cmp);
	LL ans=2;
	LL ans2=0;
	LL now=0;
	REP(i,v.size()){
		//cout<<v[i].first.first<<" "<<v[i].first.second<<" "<<v[i].second<<endl;
		now+=v[i].second;
		ans=max(ans,(now+1)/2+1);
		ans2=max(ans2,now);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 15868
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		Queue<Integer> N=new ArrayDeque<>(),M=new ArrayDeque<>();
		int n=in.nextInt();
		for(int i=0;i<n;i++) N.add(in.nextInt()*100+in.nextInt());
		int m=in.nextInt();
		for(int i=0;i<m;i++) M.add(in.nextInt()*100+in.nextInt());
		
		Queue<Integer> res=merge(N,M);
		while(!res.isEmpty()) {
			int v=res.remove();
			int j=v/100,k=v-(j*100);
			if(res.isEmpty())System.out.printf("%d:%02d\n",j,k);
			else System.out.printf("%d:%02d ",j,k);
		}
	}
	
	static Queue<Integer> merge(Queue<Integer> n,Queue<Integer> m) {
		Queue<Integer> mg=new ArrayDeque<>();
		while(!n.isEmpty() && !m.isEmpty()) {
			int a=n.peek(),b=m.peek();
			if(a<b) mg.add(n.remove());
			else if(a>b)mg.add(m.remove());
			else {
				mg.add(n.remove()); m.remove();
			}
		}
		
		while(!n.isEmpty())mg.add(n.remove());
		while(!m.isEmpty())mg.add(m.remove());
		return mg;
	}

}



Measured memory_bytes: 28052
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int N = sc.nextInt();
        for (int i=1; i<=9; i++) {
            for (int j=1; j<=9; j++) {
                if (i*j==N) {
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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


using namespace std;

typedef long long ll;
const int Max_N = 50;
ll N,M;
std::vector<int> A(Max_N);
std::vector<int> B(Max_N);


int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A[i];
    B[i] = A[i];
  }
  int count =0;
  std::sort(A.begin(),A.begin()+N);
  for(int j=0;j<N;j++){
    if(A[j]!=B[j]) count++;
  }
  if(count<=2) cout <<"YES" <<endl;
  else cout << "NO" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int ami=1000, bmi=1000, ans=0;
    REP(i,4){
        int a;
        cin >> a;
        ans += a;
        ami = min(ami,a);
    }
    REP(i,2){
        int b;
        cin >> b;
        ans += b;
        bmi = min(bmi, b);
    }
    cout << ans - ami - bmi << endl;
    return 0;
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define all(v)    ((v.begin()),(v.end()))
#define sz(v)     ((int)(v.size()))
#define forv(i, v) for(int i = 0; i < sz(v); ++i)
#define forn(i,n)   for(int i = 0; i < (int)(n); i++)
using namespace std;

typedef long long       ll;
typedef long double     ld;
typedef vector<int>     vi;
typedef vector<double>  vd;
typedef vector< vi >    vii;
typedef vector< vd >    vdd;
typedef vector<string>  vs;


int main()
{
	fast;
	ll n, a, b;
	cin >> n >> a >> b;
	//cout << n << " " << a << " " << b << endl;
	ll ans = 0;
	if (a == 0) {
		cout << "0\n";
		return 0;
	}
	else if (n  < (a + b)) {
		if (n < a) cout << n << "\n";
		else cout << a << "\n";
	}
	else {
		ans = (n / (a + b)) * a;
		ll p;
		p  = (n % (a + b));
		if (p < a) ans += p;
		else ans += a;
		cout << ans << "\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
int main()
{
	int a,b,c;
	scanf("%d %d %d", &a, &b, &c);
if(a+b==c || b+c==a || a+c==b){
	if((a+b+c)%2==0){
		printf("Yes");
	}
}
else{
		printf("No");
	}
	
}

Measured memory_bytes: 128
s=input()
left,ans=0,0
word=["A","C","G","T"]
for i in range(len(s)):
    point=i
    while point!=len(s):
        if s[point] in word:
            point +=1
        else:break
    ans=max(ans,point-left)
    left +=1
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main()
{
    uint64_t n, k;

    cin >> n >> k;

    set<int> st;

    for (int i = 0; i < k; i++)
    {
        int d;
        cin >> d;

        for (int j = 0; j < d; j++)
        {
            int tmp;
            cin >> tmp;
            st.insert(tmp);
        }
    }

    cout << n - st.size() << endl;

    return 0;
}

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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

int main(){
  int k;
  cin >> k;
  cout << ((k+1)/2)*(k/2) << endl;
}



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

int main()
{
    string s,t;
    cin>>s>>t;
    string res="";
    int arr[s.size()+1][t.size()+1];
    for (int i=0;i<=s.size();i++)
    {
        arr[i][0]=0;
    }
    for (int i=0;i<=t.size();i++)
    {
        arr[0][i]=0;
    }
    for (int i=1;i<=s.size();i++)
    {
        for (int j=1;j<=t.size();j++)
        {
            if (s[i-1]==t[j-1])
            {
                arr[i][j]=1+arr[i-1][j-1];
            }
            else
            arr[i][j]=max (arr[i-1][j],arr[i][j-1]);
        }
    }

    int i=s.size(),j=t.size();
    while (i>0&&j>0)
    {
        if (arr[i][j]==arr[i-1][j])
        {
            i--;
        }
        else if (arr[i][j]==arr[i][j-1])
            j--;
        else
        {
            res+=s[i-1];
            i--;
            j--;
        }
    }
   reverse(res.begin(),res.end());
   cout<<res;
  //  cout<<arr[s.size()][t.size()];
    return 0;
}


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

typedef pair<int,int> P;

int main() {
    int N;
    while (cin >> N, N) {
        char s, t, b;
        cin >> s >> t >> b;

        int sx, sy;
        sx = (s - 'A') / 3;
        sy = (s - 'A') % 3;
        int tx, ty;
        tx = (t - 'A') / 3;
        ty = (t - 'A') % 3;
        int bx, by;
        bx = (b - 'A') / 3;
        by = (b - 'A') % 3;
        vector<vector<vector<int> > > dp(N+1, vector<vector<int> >(3, vector<int>(3, 0)));
        dp[0][sx][sy] = 1;
        int dx[] = {1,0,-1,0};
        int dy[] = {0,1,0,-1};
        for (int i = 0; i < N; i++) {
            for (int x = 0; x < 3; x++) {
                for (int y = 0; y < 3; y++) {
                    for (int j = 0; j < 4; j++) {
                        int nx = x + dx[j];
                        int ny = y + dy[j];
                        if (0 <= nx && nx < 3 && 0 <= ny && ny < 3) {
                            if (nx == bx && ny == by)
                                dp[i+1][x][y] += dp[i][x][y];
                            else
                                dp[i+1][nx][ny] += dp[i][x][y];
                        } else {
                            dp[i+1][x][y] += dp[i][x][y];
                        }
                    }
                }
            }
        }

        double ans = 0.;
        double p = 1.;
        for (int i = 1; i <= N; i++) {
            p /= 4.;
        }
        ans = p * dp[N][tx][ty];
        printf("%0.9f\n", ans);
    }

    return 0;
}

Measured memory_bytes: 3056
#include <iostream>
#include <vector>
using namespace std;
long long a[200001];
long long b[200001];
int main() {
	long long n;
	cin >> n;
	for(int i=0;i<n;i++){
		int t;
		cin >> t;
		a[i]=t;
		b[t]+=1;
	}
	long long total=0;
	for(int i=1;i<=n;i++){
		total+=b[i]*(b[i]-1)/2;		
	}
	
	for(int i=0;i<n;i++){
		cout << total-(b[a[i]]-1) << '\n';	
	}
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;typedef vector<ll> vll;
ll mod = 1000000007, INF = 10000000000000000;
ll gcd(ll a, ll b){if(b==0){return a;}return gcd(b, a%b);}
// for (ll i = 0; i < n; i++) {
// sort(.begin(),.end());
int main(){
  ll n, ans = 0;
  cin >> n;
  vll a(n), co(100001);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] <= 100000) {
      co[a[i]]++;
    }
    else {
      ans++;
    }
  }
  
  for (ll i = 1; i <= 100000; i++) {
    if (co[i] >= i) {
      ans += co[i] - i;
    }
    else {
      ans += co[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc119d
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var S = Console.ReadLine().ToCharArray();
            var ans = 1L;
            var mod = 1000000007L;
            for (char c = 'a'; c <= 'z'; c++)
            {
                ans *= (long)S.Count(x => x == c) + 1;
                ans %= mod;
            }
            ans += mod - 1;
            ans %= mod;
            Console.WriteLine(ans);
#if DEBUG
            Console.ReadKey();
#endif
        }
        private static int ReadInt() => int.Parse(Console.ReadLine());
    }
}


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

int main() {
  char s[5];
  for(int i = 0; i < 6; i++) {
    cin >> s[i];
  }
  if(s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
  std.range, std.container, std.bigint, std.ascii, std.typecons, std.format, std.bitmanip;

// }}}
// nep.scanner {{{
class Scanner {
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType)) {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0) {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }

  void scan()() {
  }

  void scan(T, S...)(ref T x, ref S args) {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType)) {
    str ~= s.to!(char[]).strip.split;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  long k, n;
  cin.scan(k, n);
  long[] a = cin.nextArray!long(n);


  long[] ar = a.dup;

  foreach (e; a) {
    ar ~= k + e;
  }

  long[] tmp;
  foreach (e; a) {
    tmp ~= k - e;
  }

  tmp ~= ar;

  long res = long.max;
  foreach (i; 0 .. n) {
    size_t cur = i + n;
    res = min(res, tmp[cur - (n - 1)] + tmp[cur], tmp[cur + n - 1] - tmp[cur]);
  }

  writeln(res);
}


Measured memory_bytes: 20920
using System; 

class Program {
    static void Main() {
        int[] in1 = new int[2];
        int[] in2 = new int[2];
        int result = 0;
        in1[0] = Int32.Parse(Console.ReadLine());
        in1[1] = Int32.Parse(Console.ReadLine());
        in2[0] = Int32.Parse(Console.ReadLine());
        in2[1] = Int32.Parse(Console.ReadLine());
        Array.Sort(in1);
        Array.Sort(in2);
        result = in1[0] + in2[0];
        Console.Write(result);
    }
}

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

const int WEIGHTS[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};

int main()
{
    int in_data;
    while(cin >> in_data)
    {
        int gram_num = 0;
        bool is_used[10] = {};
        stringstream ss;
        string ans;
        for(int i=9; i>=0; i--)
        {
            if(gram_num + WEIGHTS[i] <= in_data)
            {
                gram_num += WEIGHTS[i];
                is_used[i] = true;
            }
        }
        for(int i=0; i<10; i++)
        {
            if(is_used[i])
            {
                ss << std::to_string(WEIGHTS[i]) <<  " ";
            }
        }
        ans = ss.str();
        ans.pop_back();
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3180
#include <iostream>
//#include <bits/stdc++.h>
// a&1 check odd or not and a>>=1 halfs a
// for(int& i : vector) cin>>i input
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define pb(x) push_back(x)
#define F first
#define S second
using namespace std;
const int N=2e5+9;
int n;
int child[N];
void solve(){
	cin>>n;
	loop(i,2,n+1){
		int f;
		cin>>f;
		child[f]++;
	}
	loop(i,1,n+1){
		cout<<child[i]<<" ";
	}
	cout<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t=1;
	//~ cin>>t;
	while(t--){
		solve();
	}
	return 0;
}



Measured memory_bytes: 4380
import java.util.Scanner;

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

        String result = "";
        if (a > 0) {
            result = "Positive";
        } else if (a <= 0 && 0 <= b) {
            result = "Zero";
        } else {
            result = ((b - a + 1) % 2 == 0) ? "Positive" : "Negative";
        }
        System.out.println(result);
    }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int64_t abs(int64_t n) {
  if (n < 0) {
    n = -n;
  }
  return n;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
int64_t factorial(int64_t n) {
  if (n == 1) {
    return 1;
  }
  int64_t ans = factorial(n-1);
  return ans*n;
}

int main() {
  int n, l;
  cin >> n >> l;
  vector <string> v(n);
  rep(i, n) cin >> v.at(i);
  sort(v.begin(), v.end());
  string ans = v.at(0);
  rep(i, n-1) ans += v.at(i+1);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<vector>
#define ll long long
using namespace std;


int main() {
    
    
	ll count =0;
    ll  row;
    ll  col;
    cin>>row>>col;
    ll i,j,k;
    if(col==1 || row ==1)
    {
        cout<<1<<endl;
    }
    else{
    for(i=0;i<row;i++)
    {
        if(col&1)
        {
         if(i&1)
        {
            count+=col/2;
        }
        else{
            count+=col/2 + 1;
           }
        }
        else{
            if(i&1)
        {
            count+=col/2;
        }
        else{
            count+=col/2;
            }
        }
    }
    cout<<count<<endl;
    }
   
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
int main(void){
    string s,t;
    cin>>s>>t;
    int ans=1000000000;
    int c=0;
    for(int i=0;i<=(s.size()-t.size());i++){
        c=0;
        for(int j=0;j<t.size();j++){
            if(s[i+j]!=t[j]){
                c++;
            }
        }
        ans=min(ans,c);
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 3624
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdin = new Scanner( System.in);
		int N ,H,W;
            N=stdin.nextInt() ;
            H=stdin.nextInt() ;
            W=stdin.nextInt() ;
            
           
        System.out.println((N-H+1)*(N-W+1));
	}
}


Measured memory_bytes: 21460
input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
line = lines.shift().split(' ')
a = line[0] * 1
b = line[1] * 1 

_dividers = function(n) {
    var arr = []
    for (var i = 1; i*i <= n; i++) {
        if (n % i === 0) {
            arr.push(i)
            if ( i != n / i) {
                arr.push(n / i)
            }
        }
    }
    return arr.sort((a, b) => a - b)
}

_isPrime = function(n) {
    if (n < 2) {
        return false
    }
    for (var i = 2; i*i <= n; i++) {
        if (n % i === 0) {
            return false
        }
    }
    return true
}

_gcd = function(m, n, t) {
	while (m % n !== 0) {
		t = n;
		n = m % n;
		m = t;
	}
	return n;
}

a_div = _dividers(a)
b_div = _dividers(b)

c = []
ca = a_div.pop()
cb = b_div.pop()

while (ca != 1 || cb != 1) {
    if (ca == cb) {
        c.push(ca)
        ca = a_div.pop()
        cb = b_div.pop()
    } else {
        if (ca < cb) {
            cb = b_div.pop()
        } else {
            ca = a_div.pop()
        }
    }
}

ans = 1
for (i=0; i < c.length; i++) {
    if (_isPrime(c[i])) {
        ans++
    }
}

console.log(ans)

Measured memory_bytes: 10932
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int N;
int A[18], B[18];
int dp[1 << 18][51];
int keisan(int b, int k) {
	if (dp[b][k] != -1) return dp[b][k];
	if (b == (1 << N) - 1) return 0;

	int num = __builtin_popcount(b);
	int saishou = 2e9;
	int num2 = 0;
	rep(i, N) {
		if (!(b >> i & 1)) {
			if ((num + i) & 1) {
				if (B[i] >= k) {
					chmin(saishou, keisan(b + (1 << i), B[i]) + num2);
				}
			}
			else {
				if (A[i] >= k) {
					chmin(saishou, keisan(b + (1 << i), A[i]) + num2);
				}
			}
			num2++;
		}
	}
	return dp[b][k] = saishou;
}

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


	cin >> N;
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];
	rep(i, 1 << N) rep(j, 51) dp[i][j] = -1;

	int kotae = keisan(0, 0);
	if (kotae > 1e9 || kotae == -1) co(-1);
	else co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 52480
// import chie template :) {{{
import std.stdio,
       std.algorithm,
       std.array,
       std.string,
       std.math,
       std.conv,
       std.range,
       std.container,
       std.bigint,
       std.ascii;
// }}}
// tbh.scanner {{{
class Scanner {
  import std.stdio;
  import std.conv : to;
  import std.array : split;
  import std.string : chomp;

  private File file;
  private dchar[][] str;
  private uint idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  private dchar[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    dchar[] s;
    while (s.length == 0) {
      s = file.readln.chomp.to!(dchar[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(uint len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  int N = cin.next!int;
  int[] arr = cin.nextArray!int(N);
  int res;
  while (true) {
    foreach (ref i; arr) {
      if (i % 2 != 0) {
        writeln(res);
        return;
      }
      i /= 2;
    }
    ++res;
  }
}


Measured memory_bytes: 256
// "include" {{{
#include <deque>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <utility>
// }}}
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 all(x) (x).begin(),(x).end()
#define int long long 
#define pii pair<int,int> 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

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

vector<int> t;
vector<int> a;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c;
	cin >> a >> b >> c;
	cout << min({abs(a - b) + abs(b - c),abs(a - c) + abs(c - b),abs(b - a) + abs(a - c),abs(b - c) + abs(c - a)}) << '\n';
	return 0;
}


Measured memory_bytes: 256
N=int(input())
i=N
base=26
Ans=''
st='abcdefghijklmnopqrstuvwxyz'

while i!=0:
  if i>base:
    wkm=i%base
    wk=wkm//(base//26)
    Ans=st[wk-1]+Ans
    if wkm!=0:
      i-=wkm
    else: #余りがないときはbase分を引く
      i-=base
    base=base*26
#    print(i)
  else: #最後は商を頭につける
    base=base//26
    wk=i//base
    Ans=st[wk-1]+Ans
#    print(i)
    i=0
    
print(Ans)
    

Measured memory_bytes: 9176
#include <iostream>

using namespace std;

#define MAX 250

template<typename T>
class Heap
{
public:
	Heap(int maxSize = MAX)
	{
		m_maxSize = maxSize;
		m_currentSize = 0;
		m_pArray = new T[m_maxSize];
	}

	virtual ~Heap()
	{
		if (m_pArray)
			delete[] m_pArray;

		m_pArray = 0;
	}

	void Push(const T& data)
	{
		if (m_currentSize >= m_maxSize) return;

		m_pArray[m_currentSize++] = data;
	}

	T* GetParent(int index)
	{
		// 根节点
		if (0 == index) return 0;

		int parent = (index - 1) >> 1;
		return &m_pArray[parent];
	}

	T* GetLeftChild(int index)
	{
		int leftChild = (index << 1) + 1;
		if (leftChild >= m_currentSize) return 0;

		return &m_pArray[leftChild];
	}

	T* GetRightChild(int index)
	{
		int rightChild = (index << 1) + 2;
		if (rightChild >= m_currentSize) return 0;

		return &m_pArray[rightChild];
	}

	void Print()
	{
		for (int i = 0; i < m_currentSize; ++i)
		{
			cout << "node " << i + 1 << ": key = " << m_pArray[i] << ", ";
			if(GetParent(i))
				cout << "parent key = " << *GetParent(i) << ", ";
			if (GetLeftChild(i))
				cout << "left key = " << *GetLeftChild(i) << ", ";
			if (GetRightChild(i))
				cout << "right key = " << *GetRightChild(i) << ", ";
			cout << endl;
		}
	}

private:
	T* m_pArray;
	int m_maxSize;
	int m_currentSize;
};

int main()
{
	int n; cin >> n;
	Heap<int> heap;
	int v;
	for (int i = 0; i < n; ++i)
	{
		cin >> v;
		heap.Push(v);
	}

	heap.Print();

	return 0;
}


Measured memory_bytes: 3092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		long N=sc.nextLong();
		int ketasu=0;
		int raw=0;
		long tmp=N;
		int max=0;
		while(tmp>0) {
			raw+=tmp%10;
			if(tmp<10) {
				max=(int)tmp;
			}
			ketasu++;
			tmp/=10;
		}
		int tmpmax=(ketasu-1)*9+(max-1);
		pl(Math.max(raw, tmpmax));
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
}

Measured memory_bytes: 21076
#include<stdio.h>
#include<string.h>
#include<queue>
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second

 #define maxn 51
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
char mp[maxn][maxn];
int step[maxn][maxn];
bool vis[maxn][maxn];
int n,m;

bool check(int x,int y) {
    if(x < 0 || y < 0|| x >= n || y >= m || vis[x][y] || mp[x][y] == '#') return false;
    return true;
}

int BFS() {
    queue<pair<int ,int> > q;
    q.push(make_pair(0,0));
    step[0][0] = 1;
    vis[0][0] = true;
    while (!q.empty()) {
        pair<int ,int> t = q.front();
        q.pop();
        for(int i = 0;i < 4;i++) {
            int tox = t.fi + Move[i][0];
            int toy = t.se + Move[i][1];
            if(tox == n - 1 && toy == m - 1) return step[t.fi][t.se] + 1;
            if(check(tox,toy)) {
                vis[tox][toy] = true;
                step[tox][toy] = step[t.fi][t.se] + 1;
                q.push(make_pair(tox,toy));
            }
        }
    }
    return -1;
}


int main(){
    cin>>n>>m;
    int cnt = 0;
    for(int i = 0;i < n;i++)
        for(int j = 0;j < m;j++) {
            cin>>mp[i][j];
            if(mp[i][j] == '#') cnt++;
        }
    int res = BFS();
    if(res == -1) {
        cout<<"-1"<<endl;
    } else {
        cout<<n*m - res - cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <algorithm>

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
inline int gcd(int a,int b){return b?gcd(b,a%b):a;}
inline int lcm(int a,int b){return a*b/gcd(a,b);}
typedef long long ll;
typedef std::vector<int> VI;
typedef std::pair<int, int> PII;

using namespace std;

int main()
{
  int A, B;
  cin >> A >> B;
  if (B < A) {
    int tmp = B;
    B = A;
    A = tmp;
  }
  if((A-B)%2) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  cout << (A-B)/2+B << endl;
  return 0;
}


Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

void yesno(int ans) {
	if (ans == 1) {	printf("Yes\n");
	} else {		printf("No\n");	}
	return;
}

void okng(int ans) {
	if (ans == 1) { printf("OK\n");
	} else { 		printf("NG\n");	}
	return;
}

int ans[4] = {0};
int main()
{
	int N = 0;
	scanf("%d", &N);
	int i = 0;
	for (i = 0; i < N; i++) {
		char S[4] = {0};
		scanf("%s", S);
		if (S[0] == 'A') {
			ans[0]++;
		} else if (S[0] == 'W') {
			ans[1]++;
		} else if (S[0] == 'T') {
			ans[2]++;
		} else {
			ans[3]++;
		}
	}
	printf("AC x %d\n", ans[0]);
	printf("WA x %d\n", ans[1]);
	printf("TLE x %d\n", ans[2]);
	printf("RE x %d\n", ans[3]);

	//yesno(ans);
	//okng(ans);
	return 0;
}


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

using namespace std;

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

  if(400 <= x && x <=599){
    cout << 8 << endl;
  }else if(600 <= x && x <=799){
    cout << 7 << endl;
  }else if(800 <= x && x <=999){
    cout << 6 << endl;
  }else if(1000 <= x && x <=1199){
    cout << 5 << endl;
  }else if(1000 <= x && x <=1399){
    cout << 4 << endl;
  }else if(1400 <= x && x <=1599){
    cout << 3 << endl;
  }else if(1600 <= x && x <=1799){
    cout << 2 << endl;
  }else if(1800 <= x && x <=1999){
    cout << 1 << endl;
  }


}


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

//CHEKING

using ll = long long;

const int mod = 1e9 + 7;

// O(N * K^2)

void add_self(int& a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}
void sub_self(int& a, int b) {
    a -= b;
    if(a < 0) {
        a += mod;
    }
}

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    vector<int> dp(k + 1);
    // dp[i] - the number of ways such that we used i candies so far
    dp[0] = 1;
    for(int child = 0; child < n; ++child) {
        int up_to;
        scanf("%d", &up_to);
        vector<int> fake(k + 1);
        for(int used = k; used >= 0; --used) {
            int tmp = dp[used];
            int L = used + 1;
            int R = used + min(up_to, k - used);
            if(L <= R) {
                add_self(fake[L], tmp);
                if(R + 1 <= k) {
                    sub_self(fake[R+1], tmp);
                }
            }
            //~ for(int i = L; i <= R; ++i) {
                //~ add_self(dp[i], tmp);
            //~ }
        }
        int prefix_sum = 0;
        for(int i = 0; i <= k; ++i) {
            add_self(prefix_sum, fake[i]);
            add_self(dp[i], prefix_sum);
        }
    }
    printf("%d\n", dp[k]);
}


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

int main() {
	int n[3];
	for (int i = 0; i < 3; i++) {
		cin >> n[i];
	}

	int cnt[3] = {};
	for (int i = 0; i < 3-1; i++) {
		for (int j = i+1; j < 3; j++) {
			if (n[i] != n[j]) {
				cnt[i]++;
				cnt[j]++;
			}
		}
	}

	int ans;
	for (int i = 0; i < 3; i++) {
		if (cnt[i] == 2) {
			ans = n[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,M,X,Y; cin>>N>>M>>X>>Y;
    vi x(N + 1);
    x[0] = X; FOR(i, 1, N + 1) cin >> x[i];
    vi y(M + 1);
    y[0] = Y; FOR(i, 1, M + 1) cin >> y[i];

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    string ans = x[N] < y[0] ? "No War" : "War"; 
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long long int llint;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int,int>
#define pl pair<ll,ll>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T x,T y){
    return y ? GCD(y,x%y) : x;
}
const ll mod = 1e9+7;
long long fac[2010],finv[2010],inv[2010];
void init(){
    fac[0] = 1;
    fac[1] = 1;
    finv[0] = 1;
    finv[1] = 1;
    inv[1] = 1;
    for(ll i = 2; i < 2002; i++){
        fac[i] = fac[i-1]*i%mod;
        inv[i] = mod - inv[mod%i]*(mod/i)%mod;
        finv[i] = finv[i-1]*inv[i]%mod;
    }
}

long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return (ll)fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
ll N,K;
int main(){
    cin >> N >> K;
    init();

    for(int i = 1; i <= K; i++){
        //cout <<"1=" << (ll)COM(N-K-1,i) << ",2=" << (ll)COM(N-K+1,N-K-i) << endl;
        cout << COM(N-K+1,i)*COM(K-1,K-i)%mod << endl;
        //cout << COM(K-i,i)*fac[i]%MOD << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int n, m; cin >> n >> m;
  vi x(m); rep(i,m) cin>>x[i];
  sort(all(x));
  vi y(m-1);
  ll width = x[m-1] - x[0];
  rep(i,m-1){
    y[i] = x[i+1] - x[i];
  }
  sort(all(y));
  dump(x);
  dump(width,n,y);
  int ans;
  if(m<=n){ ans = 0; }
  else {
    ans = width;
    for(int i=0;i<n-1;++i){
      ans -= y[m-i-2];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
import fractions

def lcm(a,b):
    return (a*b)//fractions.gcd(a,b)

n=int(input())
a=list(map(int,input().split()))
for i in range(n-1):    
    if(i==0):
        m=lcm(a[0],a[1])
    else:
        m=lcm(m,a[i+1])
m-=1
f=0
for i in range(n):
    f+=m%a[i]
print(f)

Measured memory_bytes: 5472
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
int N, M;
vector<int> cnt;
vector<pair<int,int>> id;
typedef pair<int,pair<int, int>> tp;
vector<tp> P;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> M;
	REP(i, N) {
		cnt.push_back(1);
	}
	REP(i, M) {
		int p, y;
		cin >> p >> y;	
    id.push_back(make_pair(p,0));
	P.push_back(make_pair(y,make_pair(p, i)));

	}
	sort ( P.begin(), P.end());

	REP(i, M) {
		id[P[i].second.second].second = cnt[P[i].second.first - 1]++;
	}

	REP(i, M) {
		printf("%06d%06d\n", id[i].first, id[i].second);
	}
	return 0;
}


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

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;

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

  int N,M;
  while(true){
      cin>>N>>M;
      if(N==0) break;
      int r;cin>>r;
      VVI v(M,vector<int>(1000,0));
      for(int i=0;i<r;i++){
          int t,n,m,s;cin>>t>>n>>m>>s;
          t-=540;m--;
          if(s) v[m][t]++;
          else v[m][t]--;
      }
      for(int i=0;i<M;i++){
          for(int j=1;j<=720;j++){
              v[i][j]+=v[i][j-1];
          }
      }
      int q;cin>>q;
      for(int i=0;i<q;i++){
          int ts,te,m;cin>>ts>>te>>m;
          ts-=540;te-=540;m--;
          int res=0;
          for(int j=ts;j<te;j++)if(v[m][j])res++;
          cout<<res<<endl;
      }
  }
}

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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch) {
    if ( ch == 'A' ) return 1;
    else if ( ch == 'C' ) return 2;
    else if ( ch == 'G' ) return 3;
    else if ( ch == 'T' ) return 4;
    else return 0;
}

long long getKey(char str[]) {
    long long sum = 0, p = 1, i;
    for ( i = 0; i < strlen(str); i++ ) {
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M - 1)); }

//文字列を検索
int find(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for ( i = 0;; i++ ) {
        h = (h1(key) + i * h2(key)) % M;
        if ( strcmp(H[h],str) == 0 ) return 1;
        else if ( strlen(H[h]) == 0 ) return 0;
    }
    return 0;
}

//文字列を挿入
int insert(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for ( i = 0; ; i++) {
        h = (h1(key) + i * h2(key)) % M;           //同じ文字列だったらhの値も一緒になるはず
        if ( strcmp(H[h],str) == 0 ) return 1;     //文字列の比較、すでに同じ文字列があれば挿入しない
        else if ( strlen(H[h]) == 0 ) {
            strcpy(H[h], str);                     //文字列が無かったら挿入
            return 0;
        }
    }
    return 0;
}

int main() {
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    scanf("%d", &n);
    for ( i = 0; i < n; i++ ) {
        scanf("%s %s", com, str);
        
        if ( com[0] == 'i' ) {
            insert(str);
        } else {
            if( find(str) ) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 17064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int solve(int a, int b, int c)
{
    vector<int> ans(3);
    ans[0] = a;
    ans[1] = b;
    ans[2] = c;
    sort(ans.begin(), ans.end());
    return ans[1];
}

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    cout << p[n / 2] - p[n / 2 - 1] << endl;
}


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

const int MAXN = 1e2 + 5;
const int MAXK = 1e5 + 5;
const ll MOD = 1e9 + 7;
ll dp[MAXN][MAXK], a[MAXN];

int main() {
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++) {
        dp[i][0] = dp[i - 1][0];
        for(int w = 1; w <= k; w++) {
            dp[i][w] = dp[i][w - 1];
            dp[i][w] = (dp[i][w] + dp[i - 1][w]) % MOD;
            if(w - a[i] > 0)
                dp[i][w] = (dp[i][w] - dp[i - 1][w - a[i] - 1] + MOD)%MOD;
        }
    }
    cout << dp[n][k] << endl;
}


Measured memory_bytes: 79360