akhauriyash/Code-Regression huggingface dataset:
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        int n = sc.nextInt();
        HashMap<Integer, Integer> map = new HashMap<>();
        int[] as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = sc.nextInt();
            int v = map.getOrDefault(as[i], 0);
            map.put(as[i], v + 1);
        }

        long ans = 0;
        for (Map.Entry<Integer, Integer> entry: map.entrySet()) {
            ans += (long) entry.getValue() * (entry.getValue() - 1) / 2;
        }

        for (int i = 0; i < n; i++) {
            long v = map.get(as[i]);
            out.println(ans - v * (v - 1) / 2 + (v - 1) * (v - 2) / 2);
        }

        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 99160
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n; cin >> n;
    if (n <= 999)
    {
        cout << "ABC" << endl;
    } else {
        cout << "ABD" << endl;
    }
    return 0;
}

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

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

const int CASES = 3;

void solve(){
    int N, A, B; cin >> N >> A >> B;
    int dist = B-A;
    if(dist % 2 == 0){
        cout << "Alice" << endl;
    }
    else{
        cout << "Borys" << endl;
    }
    return;
}

int main() {
    #ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
    #else

    solve();

    #endif
    return 0;
}



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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    map<int, int> mp;
    int a;
    for(int in=0;in<n;in++) {
        cin >> a;
        auto result = mp.insert(make_pair(a, 1));
        if(!result.second) mp[a]++;
    }

    int ans = 0;
    for(auto imp:mp) {
        if(imp.second%2==1) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

#define int int64_t
#define loop(i,s,e) for(int i=s;i<e;++i)
#define vi vector<int>
#define pb push_back
#define max(x,y) ((x>y)?x:y)
#define min(x,y) ((x>y)?y:x)

using namespace std;


int32_t main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	int x, n; cin >> x >> n;
	vector<bool> blocked(x+2*n, false);
	loop(i, 0, n){
		int pi; cin >> pi;
		blocked[pi] = true;
	}
	for(int i = 0; i < n+2; i++){
		if(!blocked[x-i]){
			cout << x-i << endl;
			return 0;
		}
		if(!blocked[x+i]){
			cout << x+i << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 111111;
struct UnionFind{
    vector<int> parent;
    vector<int> rank;

    UnionFind(int n) : parent(n),rank(n) {
        for(int i=0;i<n;i++){
            parent[i]=i;
            rank[i]=0;
        }
    }
    int root(int x){
        if(parent[x]==x)return x;
        return parent[x]=root(parent[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry)return ;

        if(rank[rx]<rank[ry])parent[rx]=ry;
        else {
            parent[ry]=rx;
            if(rank[rx]==rank[ry])rank[rx]++;
        }
    }
    bool same(int x,int y){
        int rx=root(x),ry=root(y);
        return rx==ry;
    }
};

signed main(){
    int N,m;
    cin>>N>>m;
    UnionFind uf(N);
    vector<int> p(N);
    for(int i=0;i<N;i++)cin>>p[i];
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        x--;y--;
        uf.unite(x,y);
    }

    int res=0;
    for(int i=0;i<N;i++){
        if(uf.same(i,p[i]-1))res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 2560
fn main() {
 let mut b=String::new();
 let s=std::io::stdin();
 s.read_line(&mut b).unwrap();
 let a = b.chars().map(|c|
  if c.is_lowercase(){
   c.to_uppercase().to_string()
  }else{
   c.to_lowercase().to_string()
  }
 ).collect::<String>();
 print!("{}", a);
}



Measured memory_bytes: 5056
#include "iostream"
#include "algorithm"
#include "string"
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int antiPoison = a + b;//Poisonはc
	int ans = 0;
	if (c > antiPoison) {
		ans += antiPoison + b + 1;
	}
	else {
		ans += b + c;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
int gcd(int x, int y) { return (y ? gcd(y, x%y) : x); }
/* main */
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    vector<int> gcdVec(N);
    gcdVec[N-1] = a[N-1];
    for (int i = N-2; i >= 0; i--) gcdVec[i] = gcd(gcdVec[i+1], a[i]);

    int ans = gcdVec[1];
    int g = a[0];
    for (int i = 1; i < N-1; i++) {
        ans = max(ans, gcd(g, gcdVec[i+1]));
        g = gcd(g, a[i]);
    }
    ans = max(ans, g);
    cout << ans << '\n';
}


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

int main()
{
	int H, N, A;

	cin >> H >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> A;
		H -= A;
	}
	if (H <= 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
	ll n,m;
	cin >> n >> m;
	n = n-1;
	m = m-1;
	ll sum = n*(n+1)/2;
	sum += m*(m+1)/2;
	cout<<sum<<endl; 
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
int main(int argc, char const *argv[]) {
    std::string A,B;
    std::cin >> A>>B;
    bool flag=false;
    if (A.size()>B.size()) {
        std::cout << "GREATER" << '\n';
    }else if (A.size()<B.size()) {
        std::cout << "LESS" << '\n';
    }else{
        for (size_t i = 0; i < A.size(); i++) {
            if (A[i] > B[i]) {
                std::cout << "GREATER" << '\n';
                flag=true;
                break;
            }else if (A[i]<B[i]) {
                std::cout << "LESS" << '\n';
                flag=true;
                break;
            }
        }
        if (!flag) {
            std::cout << "EQUAL" << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 100000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
ll add(ll a,ll b){
	return a+b;
}
struct P{
	ll x,y;
	int val;
	P() {}
	P(ll x,ll y):x(x),y(y){}
	P(ll x,ll y,int val):x(x),y(y),val(val){}
	P operator +(P p){
		return P(add(x,p.x),add(y,p.y));
	}
	P operator -(P p){
		return P(add(x,-p.x),add(y,-p.y));
	}
	P operator *(double d){
		return P(d*x,d*y);
	}
	ll dot(P p){
		return add(x*p.x,y*p.y);
	}
	ll det(P p){
		return add(x*p.y,-y*p.x);
	}
};

int R,C,N;
int M;
P ps[200100];
bool used[200100];
bool Xedge(int x){
	if(x==0||x==R)return true;
	else return false;
}
bool Yedge(int y){
	if(y==0||y==C)return true;
	else return false;
}
pair<ll,ll> idx(P a){
	pair<ll,ll> ret;
	if(a.y==0ll&&a.x<R){
		ret.fi=0;ret.sec=a.x;
	}else if(a.x==R&&a.y<C){
		ret.fi=1;ret.sec=a.y;
	}else if(a.y==C&&a.x>0ll){
		ret.fi=2;ret.sec=R-a.x;
	}else{
		ret.fi=3;ret.sec=C-a.y;
	}
	return ret;
}
bool comp(const P& p,const P& q){
	return idx(p)<idx(q);
}
int main(){
	cin >> R >> C >> N;
	for(int i=0;i<N;i++){
		int x1,y1,x2,y2;
		cin >> x1 >> y1 >> x2 >> y2;
		if((Xedge(x1)||Yedge(y1))&&(Xedge(x2)||Yedge(y2))){
			ps[2*M]=P(x1,y1,i+1);
			ps[2*M+1]=P(x2,y2,i+1);
			M++;
		}
	}
	M*=2;
	sort(ps,ps+M,comp);
	//vector<P> ch = convex_hull(ps,M);
	//assert(ch.size()==M);
	/*for(int i=0;i<M;i++){
		cout << ps[i].x << ' ' << ps[i].y << ' ' << ps[i].val << endl;
 	}*/
 	stack<int> s;
 	for(int i=0;i<M;i++){
 		int c = ps[i].val;
 		if(used[c]){
 			if(s.top()!=c){
 				printf("NO\n");
 				return 0;
 			}
 			s.pop();
 		}else{
 			s.push(c);
 			used[c]=true;
 		}
 	}
 	printf("YES\n");
	return 0;
}

Measured memory_bytes: 5248
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define INF 0x3f3f3f3f
#define MOD 998244353
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 10000005
ll n;
ll dp[MN];
ll fac[MN];

void modInvs(int n){
    dp[0] = dp[1] = 1; 
    for (int i=2; i<=n; i++){
        dp[i]=dp[MOD % i]*(MOD - MOD / i) % MOD;
    }
}

ll modExp(ll b, ll ex){
    ll prod = 1;
    while(ex > 0){
        if(ex % 2 == 0){
            b = (b * b) % MOD;
            ex /= 2;
        } else{
            prod = (prod*b) % MOD;
            ex--;
        }
    }
    
    return prod;
}


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

    cin >> n;
    
    modInvs(n);

    ll sm = 0;
    ll p2 = 1;
    ll ch = 1;
    FOR(i, 0, n/2-1){
        sm += (p2*ch)%MOD;
        sm %= MOD;
        p2 = (p2*2)%MOD;
        ch = ((ch*(n-i))%MOD)*dp[i+1];
        ch %= MOD;
    }

    sm = (sm*2)%MOD;
    ll pw = modExp(3, n);
    cout << (pw-sm+MOD)%MOD << "\n";

    return 0;
}


Measured memory_bytes: 78720
#include <stdio.h>

int main(){
	long long int n;
	int ac=0;
	int wa=0;
	int tle=0;
	int re=0;
	char testing[4];
	scanf("%lld", &n);
	for(int i=0 ; i<n ; i++){
		scanf("%s", &testing);
		switch (testing[0]){
		case 'A':
			ac++;
			break;
		case 'W':
			wa++;
			break;
		case 'T':
			tle++;
			break;
		case 'R':
			re++;
			break;
		}
	}
	printf("AC x %d\n", ac);
	printf("WA x %d\n", wa);
	printf("TLE x %d\n", tle);
	printf("RE x %d\n", re);
	return 0;
}

Measured memory_bytes: 1728
#pragma region

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
using vvb = vector<vector<bool>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16);
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int N;
void aa(int n, int rem, string head) {
  if (rem == 0) {
    out(head);
    return;
  }
  rep(i, n + 1) {
    aa(max(i + 1, n), rem - 1, head + (char)('a' + i));
  }
}

int main() {
  init();

  cin >> N;

  aa(1, N - 1, "a");
}


Measured memory_bytes: 1536
import scala.collection.mutable.ListBuffer
import scala.io.StdIn
object Main extends App {
  val n = StdIn.readLine().trim.toInt
  val result = (0 until n).foldLeft(ListBuffer.empty[String], Set.empty[String]){
      case ((acc, dict), _) =>
    val cmd = StdIn.readLine().split(' ')
    if(cmd(0) == "insert"){
      (acc, dict + cmd(1))
    } else {
      if(dict.contains(cmd(1))) {
        (acc += "yes", dict)
      } else {
        (acc += "no", dict)
      }
    }
  }
  println(result._1.mkString(f"%n"))

}


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a<=c){
        if(c<=b){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
string s,sr1,s2,s3,sr2,sr3;
sr1 = s2 = s3 = sr2 = sr3 = "";
cin>>s;
sr1 = s;
reverse(sr1.begin(),sr1.end());
int len=s.length();
for(int i=0;i<((len-1)/2);i++){
s2 += s[i];
}
for(int i=((len+3)/2)-1;i<len;i++){
s3 += s[i];
}
sr2 = s2; sr3 = s3;
reverse(sr2.begin(),sr2.end());
reverse(sr3.begin(),sr3.end());
//cout<<s<<endl<<sr1<<endl<<s2<<endl<<sr2<<endl<<s3<<endl<<sr3<<endl;
bool f=false;
if(s == sr1){
if(s2 == sr2){
if(s3 == sr3)f=true;

}
}
if(f)cout<<"Yes\n";
else cout<<"No\n";

}

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

int main(){
    char s, b;
    int counter[26] = {};
    int num, i, a;
    
    while( cin >> s ){
        s = tolower(s);
        if(isalpha(s)){
            num = s - 'a';
            counter[num]++;
        }
    }
    
    for(i = 0; i < 26; i++){
        a = i + 'a';
        b = char(a);
        cout << b ;
        cout << " : ";
        cout << counter[i];
        cout << endl;
    }
    
    return 0;
}


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

using namespace std;

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

  int n;
  cin >> n;

  int h, prev;
  cin >> prev;
  string res = "Yes";
  int sum = 0;

  for (int i = 1; i < n; ++i) {
    cin >> h;
    if (h-prev <= 0) {
      sum += h-prev;
      if (sum < -1) {
        res = "No";
        break;
      }
    } else {
      sum = 0;
    }
    prev = h;
  }
  cout << res << endl;


  return 0;
}



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

A.sort(reverse=True)

happiness = A.pop(0)
tree = [0] * N
tree[0] = A[0]

index = 0
appendIndex = 1
while(len(A)>appendIndex):
  happiness += tree[index]
  tree[appendIndex] = A[appendIndex]
  appendIndex += 1
  if(len(A)==appendIndex):
    break
  happiness += tree[index]
  tree[appendIndex] = A[appendIndex]
  appendIndex += 1
  index += 1

print(happiness)




Measured memory_bytes: 94180
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
typedef long long i64;
const int MAXN = 1e5 + 10;
 
i64 answer;
i64 totCnt;
i64 N, M;
i64 check[MAXN];
i64 cnt[3];
 
bool flag;
 
vector<pair<i64, i64> > Adj[MAXN];
 
inline void addEdge(i64 u, i64 v, i64 w)
{
	Adj[u].emplace_back(v, w);
}
 
void DFS(int cur)
{
	cnt[check[cur]] ++;
 
	for(auto x : Adj[cur])
	{
		totCnt += (x.second == 1);
 
		if(check[x.first] != -1)
		{
			if((check[cur] + x.second) % 3 != check[x.first])
				flag = true;
		}
		else
		{
			check[x.first] = (check[cur] + x.second) % 3;
			DFS(x.first);
		}
	}
}
 
int main()
{
	ios::sync_with_stdio(false), cin.tie(nullptr);
 
	cin >> N >> M;
	for (int i = 1; i <= M; i++)
	{
		i64 u, v;
		cin >> u >> v;
		addEdge(u, v, 1);
		addEdge(v, u, 2);
	}
 
	memset(check, -1, sizeof check);
 
	for(int i = 1; i <= N; i++)
	{
		if(check[i] != -1)
			continue;
 
		check[i] = 0, totCnt = 0;
		cnt[0] = cnt[1] = cnt[2] = 0;
		flag = false;
 
		DFS(i);
		if(flag)
			answer += (cnt[0] + cnt[1] + cnt[2]) * (cnt[0] + cnt[1] + cnt[2]);
		else if(!cnt[0] || !cnt[1] || !cnt[2])
			answer += totCnt;
		else
			answer += cnt[0] * cnt[1] + cnt[1] * cnt[2] + cnt[2] * cnt[0];
 
	}
 
	cout << answer << endl ;
 
	return 0;
}

Measured memory_bytes: 12800
package main

import (
	"fmt"
)

func main() {
	var today string
	fmt.Scan(&today)

	switch today {
	case "Sunny":
		fmt.Println("Cloudy")
	case "Cloudy":
		fmt.Println("Rainy")
	case "Rainy":
		fmt.Println("Sunny")
	}
}


Measured memory_bytes: 512
//https://atcoder.jp/contests/abc118/tasks/abc118_d
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class reverse_range {private:struct I {int x;int operator*() {return x-1;}bool operator!=(I& lhs) {return x>lhs.x;}void operator++() {--x;}};I i, n;public:reverse_range(int n) :i({ 0 }), n({ n }){}reverse_range(int i, int n) :i({ i }), n({ n }){}I& begin() {return n;}I& end() {return i;}};
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }reverse_range operator!(){return reverse_range(*i,*n);}};

int cost[]={0,2,5,5,4,5,6,3,7,6};
struct node{
    int val[10];
    int len;
    int& operator[](int i){return val[i];}
    bool operator<(const node& o)const{
        if(len<o.len)return true;
        if(len>o.len)return false;
        for(int i:!range(10)){
            if(val[i]<o.val[i])return true;
            if(val[i]>o.val[i])break;
        }
        return false;
    }
    node(int n=0){
        len=n;
        for(int i:range(10))val[i]=0;
    }
};
int main(){
    int N,M;
    cin>>N>>M;
    vector<int> A(M);
    cin>>A;
    vector<node> dp(N+10,node(-100000));
    dp[0]=node(0);
    for(int i:range(M)){
        for(int j:range(cost[A[i]],N+1)){
            node nxt = dp[j-cost[A[i]]];
            nxt.len++;
            nxt[A[i]]++;
            chmax(dp[j],nxt);
            //cout<<dp[j].len<<endl;
        }
    }
    for(int i:!range(10)){
        //cout<<i<<" "<<dp[N][i]<<endl;
        while(dp[N][i]>0){
            cout<<i;dp[N][i]--;
        }
    }
    cout<<endl;
    return 0;
}

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



int main(){
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  for(int i=0;i<n-1;++i){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<int> c(n);
  for(int i=0;i<n;++i) cin >> c[i];

  sort(c.rbegin(),c.rend());
  long long ans=0;
  queue<int> q;
  vector<int> d(n,-1);
  q.push(0);
  int index=0;
  while(!q.empty()){
    int v=q.front();
    q.pop();
    d[v]=c[index];
    index++;
    ans+=d[v];
    for(auto nv : g[v]){
      if(d[nv]==-1) q.push(nv);
    }
  }
  ans-=c[0];
  cout << ans << endl;
  for(int i=0;i<n;++i){
    if(i!=n-1) cout << d[i] << " ";
    else cout << d[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 4012
#include <stdio.h>
int main(void)
{
	int a,b;
	scanf("%d%d",&a,&b);
	if((a+b)%2==0){
		printf("%d\n",(a+b)/2);
	}else{
		printf("%d\n",(a+b+1)/2);
	}
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v, n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vvint(v, w, n) vector<int> v(n); vector<int> w(n); REP(i,n) cin >> v[i] >> w[i];
#define vlint(v, n) vector<ll int> v(n); REP(i,n) cin >> v[i];
#define vdouble(v, n) vector<double> v(n); REP(i,n) cin >> v[i];
#define vvdoube(v, n1, n2) vector<vector<double> > v(n1, vector<double>(n2, 0)); REP(i,n1) REP(j,n1) cin >> v[i][j];
#define string(x) string x; cin >> x;
#define vstring(v, n) vector<string> v(n); REP(i,n){string a; std::cin >> a; v.push_back(a); }

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).begin(), (v).end(), std::greater<int>()
#define len(v) (v).length()
#define FIND(s, n) (s.find(n) != s.end())
#define SORT(a) sort(all(a))

static const string abet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static const long long MOD = 1000000007;
static const double PI=3.1415926535897932;
static const int INF = 0x3f3f3f3f;
static const int INFTY = (1 << 29);
static const long long LINFTY = (1LL << 32);

static const int dy4[]={0, 0, 1, -1};
static const int dx4[]={1, -1, 0, 0};
static const int dx8[] = {1, 1, 1, 0, 0, -1, -1, -1};
static const int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};

int N, M, res;
int G[100][100];
int c[100], m[100];

int dfs(int b, int n) {
	c[n] = 1;
	for (int i = 0; i < N; i++) {
		if (b == i || n == i) continue;
		if (G[n][i]) {
			if (c[i] == 1) return 0;
			if (!dfs(n, i)) return 0;
		}
	}
	return 1;
}

int isPrime(int x){
  int i;
  if(x < 2) return 0;
  else if(x == 2) return 1;
  if( x%2 == 0) return 0;
  for(i = 3; i*i <= x; i += 2){
    if(x%i == 0) return 0;
  }
  return 1;
}

const int pmax = 1000000;
bool isPrime_table[pmax];
//const is necessary;
void eratos(void){
  int i, j;
  double sqrtmax=sqrt(pmax);

  REP(k, pmax) isPrime_table[k] = true; /* Initialization */

  /* Sieve process  */
  isPrime_table[0] = false;
  isPrime_table[1] = false;
          /* 0 and 1 are not prime. */
  for (i=2; i <= sqrtmax; i++){
    if (isPrime_table[i]==true){   /* i is prime. */
      for (j=i; i*j<pmax; j++){
        isPrime_table[i*j] = false; /* multiples of i are not prime. */
      }
    }
  }
}

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

	eratos();

	int N;
	cin >> N;

	vi v;
	REPS(i, 2, N+1){
		int N0 = N;
		if(isPrime(i)){
			int tot = 0;
			int k = 1;
			while(1){
				int i0 = 1;
				REP(j, k) i0 *= i;
				tot += N/i0;
				if(N/i0 == 0) break;
				k++;
			}
			v.push_back(tot);
		}
	}

	long long  ans = 1;
	REP(i, v.size()){
		ans *= v[i]+1;
		ans %= MOD;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1280
def rec(S,depth):
    if depth == 0:
        print(S)
        return
    else:
        list_mozi=list(dict.fromkeys(list(S)))
        list_mozi.sort()
        for j in range(len(list_mozi)):
            rec(S+list_mozi[j],depth-1)
        rec(S+chr(ord(list_mozi[len(list_mozi)-1])+1),depth-1)

N=int(input())
rec("a",N-1)


Measured memory_bytes: 4412
from bisect import bisect_left, bisect_right
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0
for b in B:
    ans += bisect_left(A, b) * (N - bisect_right(C,  b))

print(ans)


Measured memory_bytes: 107108
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#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 << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int nax = 1e5 + 10;
const ll inf = 1e18L;
int a[nax];
ll ogr[nax];
int n;

int main() {
	ios_base::sync_with_stdio(false);
	scanf("%d", &n);
	rep(i,0,n+1) {
		scanf("%d", &a[i]);
	}
	ll res = 0;
	if (n == 0) {
		printf("%d\n", a[0] == 1 ? 1 : -1);
		return 0;
	}
	ogr[0] = 1 - a[0];
	res = a[0];
	rep(i,1,n+1) {
		if (ogr[i-1] == inf) {
			ogr[i] = inf;
		}
		ogr[i] = 2*ogr[i - 1] - a[i];
		if (ogr[i] > inf) {
			ogr[i] = inf;
		}
		// printf("ogr[%d] = %lld\n", i, ogr[i]);
		if (ogr[i] < 0) {
			printf("-1\n");
			return 0;
		}
	}
	ll curVert = a[n];
	res = a[n];
	ford(i, n, 0) {
		ll maxMoge = 2 * ogr[i];
		if (curVert > maxMoge) {
			printf("-1\n");
			return 0;
		}
		curVert = min(curVert, ogr[i]) + a[i];
		// printf("lvl: %d, curVert: %lld\n", i, curVert);
		res += curVert;
	}
	printf("%lld\n", res);
}

Measured memory_bytes: 4988
N=int(input())
a=list(map(int,input().split()))
A=0
B=0
if N%2==0:
  for i in range(int(N/2)):
    A=A+max(a)
    a.remove(max(a))
    B=B+max(a)
    a.remove(max(a))
else:
  for i in range(int(N/2)+1):
    a.append(0)
    A=A+max(a)
    a.remove(max(a))
    B=B+max(a)
    a.remove(max(a))
  
print(A-B)

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI=3.14159265358979323846;

int main() {
    int H, W, h, w;
    cin >> H >> W;
    cin >> h >> w;

    cout << (H - h) * (W - w) << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int H = sc.nextInt();
    int W = sc.nextInt();
    String[] a = new String[H];

    for (int i = 0; i < H; i++) {
      a[i] = sc.next();
    }

    sc.close();

    for (int i = 0; i < W + 2; i++) {
      System.out.print("#");
    }

    System.out.println("");

    for (int i = 0; i < H; i++) {
      System.out.print("#");
      System.out.print(a[i]);
      System.out.println("#");
    }

    for (int i = 0; i < W + 2; i++) {
      System.out.print("#");
    }

    System.out.println("");

  }

}

Measured memory_bytes: 25236
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    string a, b;
    cin >> a >> b;
    string s = a + b;
    reverse(all(s));
    int n = s.size();

    int m = 0;

    int cur = 1;
    rep(i, n) {
        int nd = s[i] - '0';
        m += nd * cur;
        cur *= 10;
    }

    for (int i = 1; i * i <= m; i++) {
        if (i * i == m) {
            cout << "Yes" << endl;
            exit(0);
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string S; cin >> S;
	int n = S.length();

	
	int res1 = 0, res2 = 0;
	if (n != 1){
		for (int i = 1; i < n; ++i){
			res1 += (S[i-1] != S[i]);
		} // end for

		for (int i = n - 1; i > 0; --i){
			res2 += (S[i] != S[i-1]);
		} // end for
	} // end if
	int res = min(res1, res2);

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 512
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, T = MAP()
t = LIST()
t = [0] + t
t = [t[i]-t[i-1] for i in range(1, N+1)]
# print(t)

tmp = t[0]
ans = 0
for i in range(1, N):
	if t[i] < T:
		ans += t[i]
	else:
		ans += T
	tmp = t[i]
print(ans+T)


Measured memory_bytes: 27268
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int g = 0;
    while(n>=5){
        if(n>=500){
            g+=(n/500)*1000;
            n-=(n/500)*500;
        }
        else{
            g+=(n/5)*5;
            n-=(n/5)*5;
        }
    }
    cout << g << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int price, a, b, c, t, i, j, k, temp, m, n;
	int sum[60]={0};

	while (scanf("%d", &price) != EOF)
	{
		if(price == 0)
			break;
		else
		{
			a = 0;
			b = 0;
			c = 0;
			n = 0;
			m = 0;
			price = price / 100;
			for (i = 0; i < price; i++)
				for (j = 0; j < price - i; j++)
					for (k = 0; k < price - j - i; k++)
					{
						if (price == i * 2 + j * 3 + k * 5)
						{
							a = ((i - i % 5) * 0.8 + (i % 5)) * 380;
							b = ((j - j % 4) * 0.85 + (j % 4)) * 550;
							c = ((k - k % 3) * 0.88 + (k % 3)) * 850;
							if(i == 0)
								a = 0;
							if(j == 0)
								b = 0;
							if(k == 0)
								c = 0;
							t = a + b + c;
							sum[n] = t;
							n++;
						}
					}
					while(sum[m+1] != 0)
					{
						if(sum[m] > sum[m+1])
						{
							temp = sum[m];
							sum[m] = sum[m+1];
							sum[m+1] = temp;
							m=0;
						}
						else
							m++;
					}
					printf("%d\n", sum[0]);
		}
	}
	return 0;
}

Measured memory_bytes: 600
import numpy as np

N,D = [int(i) for i in input().split()]
cor = [[int(i) for i in input().split()] for i in range(N)]

count = 0
for i in range(N):
  for j in range(N):
    a = np.array(cor[i])
    b = np.array(cor[j])
    u = b-a
    leng = np.linalg.norm(u)
    
    if leng!=0:
      if leng.is_integer() == True:
      	count += 1
print(count//2)

Measured memory_bytes: 12400
import static java.util.Comparator.comparing;

import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==========================================================
    //　素数チェック					
    boolean isPrime(long n) {					
    	if(n <= 1)		return false;		
        	for(int i = 2; i * i <= n; i++){				
        		if(n % i == 0)		return false;	
    	}				
    	return true;				
    }					
    public void solve() {
    	long X = nl();
    	while(true) {
    		if(isPrime(X)) {
    			out.println(X);
    			return;
    		}
    		X++;
    	}
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define int long long
#define fo(i,n)   for(i=0;i<n;i++)
#define mod       1000000007
using namespace std;

int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("ati.txt", "r", stdin);
	freopen("ato.txt", "w", stdout);
#endif

	int n, i;
	cin >> n;

	int a[n];
	fo(i, n)
	cin >> a[i];

	sort(a, a + n);
	int x = n / 2;

	if (a[x] > a[x - 1])
		cout << a[x] - a[x - 1] << endl;
	else if (a[x] == a[x - 1])
		cout << "0" << endl;
}

Measured memory_bytes: 4360
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  vector<int> dp(n, 1e9);
  dp[0] = 0;
  for (int i = 1; i < n; i++) {
    for (int j = 1; j <= k; j++) {
      if (i - j < 0) break;
      dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
    }
  }
  cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#define mak(a,b) make_pair(a,b)
#define MM 1200005
#define MN 100005
using namespace std;
struct edge{int nex; pair <int,int> to; int wt;}e[MM];
vector <pair<int,int> > v[MN];
map <pair<int,int> , int> hr,dis;
map <pair<int,int> , bool> u;
int n,m,pin;

inline void ins(int ax,int bx,int ay,int by,int z) {e[++pin]=(edge){hr[mak(ax,bx)],mak(ay,by),z}; hr[mak(ax,bx)]=pin;}

inline int read()
{
	int n=0,f=1; char c=getchar();
	while (c<'0' || c>'9') {if(c=='-')f=-1; c=getchar();}
	while (c>='0' && c<='9') {n=n*10+c-'0'; c=getchar();}
	return n*f;
}

int main()
{
	register int i,j,k,x,y,z;
	n=read(); m=read();
	for (i=1;i<=m;++i)
		x=read(),y=read(),z=read(),
		ins(0,x,z,x,1),ins(0,y,z,y,1),
		ins(z,x,0,x,0),ins(z,y,0,y,0),
		ins(z,x,z,y,0),ins(z,y,z,x,0);
	dis[mak(0,1)]=1; v[1].push_back(mak(0,1));
	for (i=1;v[i].size();++i)
		for (j=0;j<v[i].size();++j)
		{
			pair <int,int> pr=v[i][j];
//			printf("ha=%d %d %d\n",pr.first,pr.second,dis[pr]);			
			if (u[pr]) continue;
			for (u[pr]=true,k=hr[pr];k;k=e[k].nex)
			{
				if (u[e[k].to]) continue;
				if (!dis[e[k].to] || dis[pr]+e[k].wt<dis[e[k].to])
				{
					dis[e[k].to]=dis[pr]+e[k].wt;
					v[dis[e[k].to]].push_back(e[k].to);
				}
			}
		}
	if (!dis[mak(0,n)]) printf("-1"); else printf("%d",dis[mak(0,n)]-1);
}

Measured memory_bytes: 119024
import java.util.*;

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

        sc.nextLine();
        String[] a = new String[N];
        String b = "";
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextLine();
        }
        for (int i = 0; i < M; i++) {
            b += sc.nextLine();
        }

        if (N == M) {
            if (a[0].equals(b)) {
                System.out.println("Yes");
                return;
            }
        }

        for (int i = 0; i < N-M; i++) {
            for (int j = 0; j < N-M; j++) {
                String l = "";
                for (int k = 0; k < M; k++) {
                    l += a[j+k].substring(i, i+M);
                }
                if (l.equals(b)) {
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 37332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN=2e3+5;
const ll MOD=1e9+7;
const ll INF=1e18;
ll n,k,c1[MAXN],c2[MAXN],inv[MAXN];
ll mul(ll x,ll y)
{
    return x*y%MOD;
}
ll add(ll x,ll y)
{
    ll ret=x+y;
    if(ret>=MOD)
    {
        return ret-MOD;
    }
    return ret;
}
void init()
{
    inv[1]=1;
    for(ll i=2;i<=MAXN;i++)
    {
        ll a=MOD/i,b=MOD%i;
        inv[i]=((ll)inv[b]*(-a)%MOD+MOD)%MOD;
    }
    ll d1=n-k+1;
    c1[0]=1;;
    for(ll i=1;i<=d1;i++)
    {
        c1[i]=mul(c1[i-1],mul((d1-(i-1)),inv[i]));
    }

    ll d2=k-1;
    c2[0]=1;
    for(ll i=1;i<=d2;i++)
    {
        c2[i]=mul(c2[i-1],mul((d2-(i-1)),inv[i]));
    }
}
void solve()
{
    init();
    for(ll i=1;i<=k;i++)
    {
        ll ans=mul(c1[i],c2[i-1]);
        printf("%lld\n",ans);
    }
}
int main()
{
//    freopen("c://duipai//data.txt","r",stdin);
//    freopen("c://duipai//wa.txt","w",stdout);
    while(~scanf("%lld %lld",&n,&k))
    {
//        string ss;
//        cin>>ss;
//        cout<<ss<<endl;
       // solve();
        solve();
    }
}
/*
5
76578820211343624  293297008968192 189152283861189120 324294649604739072 20266198324215808
*/


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <math.h>

using namespace std;

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

    vector<int> menu(5);
    for(int i = 0; i < 5; i++) cin >> menu[i];

    vector<int> menu_1_digit(5);
    for(int i = 0; i < 5; i++){
        menu_1_digit[i] = menu[i] - 10 * ((menu[i]-1) / 10);
    }

    int total_min;
    total_min = 0;

    vector<int>::iterator minIt = min_element(menu_1_digit.begin(), menu_1_digit.end());
    int minIndex = distance(menu_1_digit.begin(), minIt);

    for(int i = 0; i < 5; i++){
        if(i == minIndex){
            total_min += menu[i];
        }else{
            total_min += ((menu[i] - 1) / 10 + 1) * 10;
        }
    }

    cout << total_min << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * A - ∴ (Therefore)
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 入力された数
        int n = sc.nextInt();

        switch ( n % 10 ) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            System.out.println( "hon" );
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            System.out.println( "pon" );
            break;
        case 3:
            System.out.println( "bon" );
            break;
        }

        sc.close();
    }
}

Measured memory_bytes: 35604
n=int(input())
a=[int(x) for x in input().split()]
num_minus=0
a_modified=[]
for ai in a:
    if ai<0:
        num_minus+=1
        a_modified.append(-ai)
    else:
        a_modified.append(ai)
if num_minus%2==0:
    print(sum(a_modified))
else:
    print(sum(a_modified)-2*sorted(a_modified)[0])
# print(sorted(a_modified)[0])

Measured memory_bytes: 65184
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

const inf = 1 << 60
const mod int = 1e9 + 7

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()
	p := make([]int, n)
	for i := 0; i < n; i++ {
		p[i] = ri()
	}
	ct := 0
	for i, pp := range p {
		if i+1 != pp {
			ct++
		}
	}
	if ct <= 2 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef vector<ll> vll;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forn(s, e) for(int i=s; i<e; ++i)
#define pb push_back
#define INF 1000000000

int main(){
	IO
	int num;
	bool f = false;
	cin >> num;
	do{
		if(num%10 == 7){
			cout << "Yes" << endl;
			f = true;
			break;
		}
		num/=10;
	}while(num);
	if(!f)
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
//typedef pair<ll,ll> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

struct Doubling{
    vector< vector<int> > table;
    const int LOG;
    const int size;

    Doubling(int sz,ll lim_t) :LOG(64-__builtin_clzll(lim_t)),size(sz){
        table.resize(LOG,vector<int>(sz,-1));        
    }
    void set_next(int k,int x){
        table[0][k]=x;
    }
    void build(){
        for(int k=0;k+1<LOG;k++){
            for(int i=0;i<size;i++){
                if(table[k][i]==-1) table[k+1][i]=-1;
                else table[k+1][i]=table[k][table[k][i]];
            }
        }
    }
    int query(int k,ll t){
        for(int i=LOG-1;i>=0;i--){
            //cout<<k<<endl;
            if(bit(t,i)) k=table[i][k];
            if(k==-1) return size;
        }
        return k;
    }

};
signed main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin>>N;
    vector<ll> x(N);
    for(int i=0;i<N;i++){
        cin>>x[i];
    }
    ll L;
    cin>>L;
    Doubling db(N,N);
    x.push_back(INF);
    for(int i=0;i<N;i++){
        int t=(int) (lower_bound(x.begin(),x.end(),x[i]+L+1)-x.begin() );
        int next=t-1;
        if(next==i) next=-1;
        db.set_next(i,next);
    }
    db.build();
    int Q;
    cin>>Q;
    while(Q--){
        int a,b;
        cin>>a>>b;
        if(a==b){
            cout<<0<<endl;
            continue;
        }
        if(a>b) swap(a,b);
        a--; b--;
        int ok=N,ng=0;
        while(ok-ng!=1){
            int mid=(ok+ng)/2;
            if(db.query(a,mid)>=b) ok=mid;
            else ng=mid;
        }
        cout<<ok<<endl;
    }
}


Measured memory_bytes: 8440
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>
 
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>
 
#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;
 
template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

inline string bool_to_string(bool b, const string &tval, const string fval) { return b ? tval : fval; } 
string YESNO(bool b) { return bool_to_string(b, "YES", "NO"); }
string YesNo(bool b) { return bool_to_string(b, "Yes", "No"); }
string yesno(bool b) { return bool_to_string(b, "yes", "no"); }

int main() {
  int n; string s;
  while (cin >> n) {
    cin >> s;
    int op = 0, cl = 0;
    REP(i,n) {
      if (s[i] == '(') {
        op++;
      } else {
        if (op > 0) op--;
        else cl++;
      }
    }
    cout << string(cl, '(') << s << string(op, ')') << endl;
  }
}


Measured memory_bytes: 256