akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define rall(v) rbegin(v),rend(v)
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int dp[(int)1e4+7];

int main(){
  nimble;
  int tt=1;//cin>>tt;
  while(tt--){
    int h,n;
    cin>>h>>n;
    rep(i,0,h+4)dp[i]=inf;
    dp[0]=0;
    rep(i,0,n){
      int b,c;
      cin>>b>>c;
      rep(d,0,h+1)
        dp[d]=min(dp[d],d<b?c:dp[d-b]+c);
    }
    cout<<dp[h]<<nl;
  }
  return 0;
}


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

constexpr ll INF = 1LL << 60;

void cinv(lls& llVec, ll n, bool to_0_origin = false) {
	ll val;
	llVec.reserve((size_t)(n));
	for (ll i = 0; i < n; i++) {
		cin >> val;
		if (to_0_origin) val--;
		llVec.push_back(val);
	}
}


ll StateMake(lls& cLin) {
	ll state = 0;
	for (auto e : cLin) {
		state |= (1LL << e);
	}
	return state;
}


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

	lls a(M);
	lls b(M);
	std::vector<lls> c(M);

	for (ll i = 0; i < M; i++) {
		ll aOne, bOne;
		cin >> aOne >> bOne;
		a[i] = aOne;
		b[i] = bOne;
		cinv(c[i], bOne, true);
	}

	ll stateNum = 1LL << N;
	std::vector<lls> tblAll(M, lls(stateNum, INF));

	tblAll[0][0] = 0;
	ll state = StateMake(c[0]);
	tblAll[0][state] = a[0];

	for (ll m = 1; m < M; m++) {
		ll state_c = StateMake(c[m]);

		auto &preTblLin = tblAll[m-1];
		auto& curTblLin = tblAll[m];

		curTblLin[0] = 0;
		
		for (ll s = 0; s < stateNum; s++) {
			curTblLin[s] = std::min(preTblLin[s], curTblLin[s]);
		}
		for (ll s = 0; s < stateNum; s++) {
			ll newState = s | state_c;
			ll mon = preTblLin[s] + a[m];
			curTblLin[newState] = std::min(curTblLin[newState], mon);
		}
	}

	ll minMoney = tblAll[M - 1][stateNum - 1];

	if (minMoney == INF) minMoney = -1;

	cout << minMoney << '\n';

	return 0;
}



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


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

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

int main(void) {
	int data[3];
	scanf("%d %d %d", &data[0], &data[1], &data[2]);
	size_t len = sizeof(data) / sizeof(data[0]);
	qsort(data, len, sizeof(data[0]), cmp);
	int i;
	for (i = 0; i < len; i++) {
		if (i > 0) {
			printf(" ");
		}
		printf("%d", data[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int N, M, X;
    cin >> N >> M >> X;
    int l = 0, r = 0;
    FOR(i, 0, M) {
        int a;
        cin >> a;
        if (a < X)
            l++;
        else
            r++;
    }
    cout << min(l, r) << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 256
class Cube:
    def __init__(self, x, y, z, s):
        self.x, self.y, self.z = x, y, z
        self.s = s

    def is_in_cube(self, x, y, z):
        return self.x <= x <= self.x + self.s and self.y <= y <= self.y + self.s and self.z <= z <= self.z + self.s

    def intersect(self, C):
        dxyz = [(0, 0, 0),
                (C.s, 0, 0), (0, C.s, 0), (0, 0, C.s),
                (C.s, C.s, 0), (C.s, 0, C.s), (0, C.s, C.s),
                (C.s, C.s, C.s)]
        for dx1, dy1, dz1 in dxyz:
            nx1, ny1, nz1 = C.x + dx1, C.y + dy1, C.z + dz1
            if self.is_in_cube(nx1, ny1, nz1):
                for dx2, dy2, dz2 in dxyz:
                    nx2, ny2, nz2 = self.x + dx2, self.y + dy2, self.z + dz2
                    if C.is_in_cube(nx2, ny2, nz2):
                        a, b, c = abs(nx1 - nx2), abs(ny1 - ny2), abs(nz1 - nz2)
                        if a * b * c == 0:
                            continue
                        # print(a, b, c, end=':')
                        return 2 * (a * b + b * c + c * a)
        return 0


edges = list()
inters = dict()


def calc_overlap(vs):
    ret = sum(inters.get((vs[i], vs[i + 1]), 0) for i in range(len(vs) - 1))
    if len(vs) > 2:
        ret += inters.get((vs[-1], vs[0]), 0)
    return ret


def dfs(v, par, vs, res):
    if res == 0:
        return calc_overlap(vs)

    ret = -1

    for e in edges[v]:
        if e != par:
            vs.append(e)
            ret = max(ret, dfs(e, v, vs, res - 1))
            vs.pop()
    return ret


INF = 10 ** 9
while True:
    N, K, S = map(int, input().split())
    # print((N, K, S))
    if not (N | K | S):
        break
    cubes = []
    for _ in range(N):
        x, y, z = map(int, input().split())
        cubes.append(Cube(x, y, z, S))
    # cubes = [Cube(*map(int, input().split()), S) for _ in range(N)]
    edges = [[] for _ in range(N)]
    inters = dict()
    for i in range(N):
        for j in range(i + 1, N):
            sur = cubes[i].intersect(cubes[j])
            if sur > 0:
                # print(i, j, cubes[i].intersect(cubes[j]))
                inters[i, j] = inters[j, i] = sur
                edges[i].append(j)
                edges[j].append(i)
    # print(edges, inters)

    ans = -1
    for i in range(N):
        ans = max(ans, dfs(i, -1, [i], K - 1))

    print(-1 if ans == -1 else S * S * 6 * K - ans)

Measured memory_bytes: 8216
#include<stdio.h>

int main (){
	int num1, num2, num3;
	num1, num2, num3>=1;
	num1, num2, num3<=13;
	
	
	scanf("%d %d %d", &num1, &num2, &num3);
	if (num1+num2+num3<=21){
		printf("win");
		
	}else {
		printf("bust");
	    }
	
	return 0;
}

Measured memory_bytes: 3204
#include <stdio.h>

int main(){
	int j,s_length = 0;
	char s[101],p[101];
	scanf("%s",s);
	scanf("%s",p);

	for(int i = 0; s[i] != '\0';i++) s_length++;

	for(int left = 0;s[left] != '\0';left++){
		for(j = 0;p[j] != '\0' && p[j] == s[(left+j)%s_length];j++);
		if(p[j] == '\0'){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}



Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

vector<vector<pii>> a;

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

    int n; cin>>n;
    FOR(i,n) {
        int m; cin>>m;
        a.push_back(vector<pii>());
        FOR(j,m) {
            int x,y; cin>>x>>y; x--;
            a[i].push_back({x,y});
        }
    }

    int best=0;
    FOR(b, 1<<n) {
        bool ok = true;
        FOR(i,n) {
            if((b&(1<<i)) == 0)
                continue;

            for(auto p : a[i]) {
                if(p.second==1)
                    ok &= (b&(1<<p.first))>0;
                else
                    ok &= (b&(1<<p.first))==0;
            }
        }
        if(ok)
            best |= MAX(__builtin_popcount(b));
    }
    cout<<best<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int i,i0,n,m,ans;
int main()
{
    int a[55];
    scanf("%d",&n);
    int cnt=0;
    for(i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        cnt+=(x!=i);
    }
    if(cnt>2)printf("NO\n");
    else printf("YES\n");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

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


const int NMAX=50010;
int dp[NMAX];

int main(){
	int n,m;
	cin>>n>>m;
	fill_n(dp,50010,1<<30);
	vector<int>c(m);
	for(int i=0;i<m;i++){
		cin>>c[i];
	}
	sort(c.begin(),c.end());
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(i+c[j]>n)break;
			chmin(dp[i+c[j]],dp[i]+1);
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

const string YES = "yes";
const string NO = "no";

void solve(std::string S){
    REP(i, S.size()) REP2(j, i+1, S.size()) {
        if(S[i] == S[j]) {
            cout << NO << endl;
            return;
        }
    }

    cout << YES << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}



Measured memory_bytes: 256
#define _CRT_NONSTDC_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define NL << endl

using namespace std;
using ll = long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

using namespace std;

ll cost[201][201] = { 0 };

signed main() {
	int N, M, R;
	for (int i = 0; i < 201; i++) for (int j = 0; j < 201; j++) if (i != j) cost[i][j] = INTMAX;
	cin >> N >> M >> R;
	vector<ll> r(R);
	for (auto& t : r) cin >> t;
	sort(r.begin(), r.end());
	for (int i = 0; i < M; i++) {
		ll a, b, c;
		cin >> a >> b >> c;
		cost[a][b] = c;
		cost[b][a] = c;
	}
	for (int k = 1; k <= N; k++) {
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= N; j++) {
				if (cost[i][j] > cost[i][k] + cost[k][j]) {
					cost[i][j] = cost[i][k] + cost[k][j];
				}
			}
		}
	}

	ll ans = LLMAX;
	do {
		ll t = 0;
		for (int i = 0; i < R - 1; i++) {
			t += cost[r[i]][r[i + 1]];
		}
		ans = min(t, ans);
	} while (next_permutation(r.begin(), r.end()));
	
	cout << ans NL;

	return 0;
}



Measured memory_bytes: 512
let (a,b,c,d) = Scanf.scanf "%d %d %d %d\n" (fun x y z w -> (x,y,z,w))

let () = if a + b > c + d then print_endline "Left"
         else if a + b < c + d then print_endline "Right"
         else print_endline "Balanced"


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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

int main(){
    string T;
    cin>>T;
    for(int i=0;i<T.size();i++){
        if(T.at(i)=='?'){
            T.at(i) = 'D';
        }
    }

    cout <<T<<endl;


    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> w(n);
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> w[i];
        sum = sum + w[i];
    }
    int result = sum;
    int b = 0;
    for(int i = 0; i < n; i++){
        cin >> w[i];
        b = b + w[i];
        result = min(result, abs(b - (sum - b)));
    } 
    cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	long long n;

	std::cin >> n;

	long long ans = 0;
	long long count = 1;

	for (long long i = 0; i < n; i++)
	{
		long long val;
		std::cin >> val;

		if (val == count) {
			count++;
		}
		else {
			ans++;
		}
	}

	if (ans == n) ans = -1;

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  vector<bool> prime(100005,true);
  prime[0]=prime[1]=false;
  rep(i,100005)if(prime[i])
    for(j=2;i*j<100005;j++)prime[i*j]=false;
  vi p(100005,0);
  rep(i,100005)if(i%2==1 && prime[i] && prime[(i+1)/2])p[i]++;
  rep(i,100000)p[i+1]+=p[i];
  int n;
  cin>>n;
  rep(i,n){
    int l,r;
    cin>>l>>r;
    cout<<p[r]-p[l-1]<<endl;
  }
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

struct P {
  int p[31];
  P() {}
  P a() {
    P res;
    for (int i = 1; i <= 30; i++) res.p[i] = p[i];
    swap(res.p[1], res.p[28]);
    swap(res.p[2], res.p[29]);
    swap(res.p[3], res.p[30]);
    swap(res.p[15], res.p[16]);
    swap(res.p[19], res.p[21]);
    return res;
  }
  P b() {
    P res;    
    for (int i = 1; i <= 30; i++) res.p[i] = p[i];    
    swap(res.p[7], res.p[22]);
    swap(res.p[8], res.p[23]);
    swap(res.p[9], res.p[24]);
    swap(res.p[13], res.p[18]);
    swap(res.p[10], res.p[12]);
    return res;
  }
  P c() {
    P res;    
    for (int i = 1; i <= 30; i++) res.p[i] = p[i]; 
    swap(res.p[1], res.p[24]);
    swap(res.p[4], res.p[27]);
    swap(res.p[7], res.p[30]);
    swap(res.p[10], res.p[21]);
    swap(res.p[16], res.p[18]);
    return res;    
  }
  P d() {
    P res;    
    for (int i = 1; i <= 30; i++) res.p[i] = p[i]; 
    swap(res.p[3], res.p[22]);
    swap(res.p[6], res.p[25]);
    swap(res.p[9], res.p[28]);
    swap(res.p[12], res.p[19]);
    swap(res.p[13], res.p[15]);
    return res;    
  }
  bool check() {
    bool ok = true;
    for (int i = 1; i <= 9; i++) {
      ok &= p[i] == p[1];
    }
    for (int i = 10; i <= 19; i += 3) {
      for (int j = 0; j < 3; j++) {
        ok &= p[i + j] == p[i];
      }
    }
    for (int i = 22; i <= 30; i++) {
      ok &= p[i] == p[22];
    }
    return ok;
  }
  bool operator < (const P& other) const {
    for (int i = 1; i <= 30; i++) {
      if (p[i] == other.p[i]) continue;
      return p[i] < other.p[i];
    }
    return false;
  }
};

void solve() {
  P x;
  for (int i = 1; i <= 30; i++) {
    cin >> x.p[i];
  }
  queue<P> que;
  que.emplace(x);
  map<P, int> dis;
  dis[x] = 0;
  while (!que.empty()) {
    P y = que.front(); que.pop();
    if (y.check()) {
      cout << dis[y] << endl;
      break;
    }
    P z;
    z = y.a();
    if (dis.find(z) == dis.end()) {
      que.emplace(z);
      dis[z] = dis[y] + 1;
    }
    z = y.b();
    if (dis.find(z) == dis.end()) {
      que.emplace(z);
      dis[z] = dis[y] + 1;
    }
    z = y.c();
    if (dis.find(z) == dis.end()) {
      que.emplace(z);
      dis[z] = dis[y] + 1;
    }
    z = y.d();
    if (dis.find(z) == dis.end()) {
      que.emplace(z);
      dis[z] = dis[y] + 1;
    }
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    solve();
  }

  return 0;
}


Measured memory_bytes: 3276
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[100100];

#define N_MAX 100100

long long fact[N_MAX];
long long rfact[N_MAX];

long long modpow(long long a, long long b){ 
  long long r = 1LL;

  while(b){
    if(b & 1LL)r *= a;
    if(r >= MOD)r %= MOD;
    a *= a;
    if(a >= MOD)a %= MOD;
    b >>= 1LL;
  }
  return r;
}

long long nCr(long long n, long long r) {
	long long ret = 1LL;
	ret *= fact[n];
	ret %= MOD;
	ret *= rfact[r];
	ret %= MOD;
	ret *= rfact[n - r];
	ret %= MOD;
	return ret;
}

int main() {
	clr(fact, 0);
	fact[0] = 1;
	rep(i, 1, N_MAX) {
		fact[i] = fact[i - 1] * i;
		fact[i] %= MOD;
	}
	clr(rfact, 0);
	rfact[0] = 1;
	rep(i, 1, N_MAX) {
		rfact[i] = rfact[i - 1] * modpow(i, MOD - 2);
		rfact[i] %= MOD;
	}
	ll n;
	cin >> n;
	clr(d, 0);
	vector<ll> v;
	rep(i, 0, n + 1) {
		ll a;
		cin >> a;
		a--;
		d[a]++;
		v.pb(a);
	}
	if(n==1){
		cout << 1 << endl;
		cout << 1 << endl;
		return 0;
	}
	int b;
	rep(i, 0, n) {
		if (d[i] == 2) {
			b = i;
		}
	}
	int p0, p1;
	int c = 0;
	rep(i, 0, n + 1) {
		if (c == 0 && v[i] == b) {
			p0 = i;
			c++;
		}
		else if (c == 1 && v[i] == b) {
			p1 = i;
		}
	}
	cout << n << endl; 
	rep(i, 2, n + 2) {
		ll e = nCr(n+1,i);
		ll g = p1-p0-1;
		ll h = n+1-g-2;
		if(h>=i-1){
			ll m = nCr(h,i-1);
			e += MOD;
			e -= m;
		}
		e %= MOD;
		cout << e << endl;
	}
	return 0;
}

Measured memory_bytes: 4468
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,i,ta,tem,has;
unordered_map<ll,ll> me;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	me[0]=1;
	for(i=1;i<=n;i++)
	{
		cin>>ta;
		tem+=ta;
		has+=me[tem];
		me[tem]++;
	}
	cout<<has<<"\n";
}

Measured memory_bytes: 8520
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9
#define INFL 1e18
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

//cout<< fixed << setprecision(10)

int main(){

    fast;
    int T;
    T=1;
    //cin>>T;
    while(T--){
        long double x,y;
        cin>>x;
        long double z;
        cin>>z;
        z=z*x;
        ll n=z/1;
        cout<<n;
	

    }

}


Measured memory_bytes: 3804
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

n = input_n

ans = 0
(1..n).each do |i|
  num = n / i
  # 等差数列の公式 初項a, 公差d, 項数nとするとき、
  # n * (2 * a + (n - 1) * d) / 2
  ans += num * (2 * i + (num - 1) * i) / 2
end
puts ans

# 解説
# 例えば、n=6のとき
# K * f(K) = 1 * 1
# K * f(K) = 2 * 2
# K * f(K) = 3 * 2
# K * f(K) = 4 * 3
# K * f(K) = 5 * 2
# K * f(K) = 6 * 4
# となるが、これは掛け算を読み替えれば1が1個(+1)、2が2個(2+2)、3が2個(3+3)、4が3個(4+4+4)、、、となり
# これらを足し合わせた結果は57となる。
# 各kの約数について考えたとき
# 1の約数は1が1個あるのみ
# 2は1が1個、2が1個あり
# 3は1,3が1個ずつ
# 4は1,2,4が1個ずつ
# 5は1,5が1個ずつ
# 6は1,2,3,6が1個ずつあるのみである
# 上で示した約数のように、1はn以下のどのkにも含まれる約数であり
# 一方で1にkを掛けたとき、K * f(K)の項の1つであるとも言える
# ※例えば、K=6のとき K * f(K) = 6 * f(6) = 6 * 4 = 6 * 1 + 6 * 1 + 6 * 1 + 6 * 1
# 1と同様に2はn以下の2の倍数すべてに含まれる約数であり
# 3も同様にn以下の3の倍数すべてに含まれる約数である
# (上の例でいえば、4..6も同様ではあるがn=6以下という条件から倍数は自分自身しか含まない)
# すなわち、1..nに含まれる値kについて、
# kの倍数を列挙して足し合わせれば、2k,3k,4k,...の各約数についてそのうちの1個を足し合わせているのと等価になる
# ※例えば、3は3,6の約数であるが、3の倍数は3,6である
# 　f(6)=4のとおり、6の約数は全部で4個で、その内訳は1,2,3,6
# 　1..6までのrangek=3として2k=6を足し合わせれば6 * f(6)のうちの1項を足し合わせたのと等しくなる
# よって、1からnまで、順にkの倍数を足し合わせていけば答えが求められる
# ここで、n以下のkの倍数は等差数列で表すことができる
# ※1,2,3,4,5,6は初項1、公差1、項数6の等差数列
# 　2,4,6は初項2、公差2、項数3の等差数列
# そのため、等差数列の和の公式を用いることで、各kについてkの倍数の和が計算できる。これはO(N)

Measured memory_bytes: 14376
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int main()
{
    int w, h, n;
    cin >> w >> h >> n;
    int x[110], y[110], a[110];
    rep(i, n){
        cin >> x[i] >> y[i] >> a[i];
    }
    int l = 0, r = 0;
    rep(i, n){
        switch(a[i]){
            case 1:
                if(l < x[i])l = x[i];
                break;
            case 2:
                if(w > x[i])w = x[i];
                break;
            case 3:
                if(r < y[i])r = y[i];
                break;
            case 4:
                if(h > y[i])h = y[i];
                break;
            default: break;
        }
    }
    if((w-l) > 0 && (h-r) > 0){
        cout << (w-l)*(h-r) << endl;
    }
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
N,M,x,y = map(int,input().split())
X = list(map(int,input().split()))
Y = list(map(int,input().split()))
cnn=-1
for Z in range(-100,101):
    if (x<Z and Z<=y):
        cnt = 0
        for i in range(0,N):
            if (X[i]<Z):
                cnt = cnt + 1 
                if (cnt == N):
                    cnt=0
                    for r in range(0,M):
                        if (Z<=Y[r]):
                            cnt=cnt+1
                            if (cnt==M):
                                cnn= cnn+1
                                if (cnn==0):
                                    print ("No War")                 
            
if(cnn == -1):
    print("War")



Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
  int N,M,L,R;
  scanf("%d %d",&N,&M);
  int i;
  int biggest=N;
  int smallest=1;
  
  for(i=0;i<N;i++)
  {
    scanf("%d %d",&L,&R);
    if(smallest<L)
      smallest=L;
    if(R<biggest)
      biggest=R;
  }
  
  if(smallest>biggest)
    printf("0");
  else
    printf("%d",biggest-smallest+1);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	int n, m;
	cin >> n >> m;
	vector<int>h(n+1);
	vector<vector<int>>a(n+1);
	rep(i, n+1) {
		if (i >= 1) {
			cin >> h[i];
		}
		else {
			h[0] = 0;
		}
	}
	rep(i, m) {
		int x, y;
		cin >> x >> y;
		//--x;
		//--y;
		a[x].push_back(y);
		a[y].push_back(x);
	}
	int c(0);
	rep(i, n+1) {
		if (i == 0) {
			continue;
		}
		int z = 1;
		rep(j, a[i].size()) {
			if (h[a[i][j]] >= h[i]) {
				z=-1;
			}
		}
		if (z == 1) {
			++c;
		}
	}
	cout << c;
	return 0;
}

Measured memory_bytes: 8764
N, K = gets.split.map(&:to_i)
ws, ds = [], []
N.times do |i|
    ws[i], ds[i] = gets.split.map(&:to_i)
end

puts (1..(2*10**18)).bsearch{|n|
    sum = 0
    N.times do |i|
        sum += (n - ws[i])/ds[i] + 1 if n >= ws[i]
    end
    sum >= K
}

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

int main() {
    string n;
    cin >> n;
    if (n=="Sunny") {
        cout << "Cloudy" << endl;
    }else if (n=="Cloudy"){
        cout << "Rainy" << endl;
    }else if (n=="Rainy"){
        cout << "Sunny" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;
import javax.xml.ws.WebEndpoint;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main //implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
	static double s;
	
    public static void main(String[] args)   throws Exception, IOException{        
//        long mod=1000000007;
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        int d[]=sc.nextIntArray(n);
        long s=0,ss=0,a=0;        
        for (int i = 0; i < d.length; i++) {
			s+=d[i];
		}
        a=s;
        for (int i = 0; i < d.length; i++) {
			s-=d[i];
			ss+=d[i];
			a=min(abs(s-ss),a);
		}

        out.println(a);
     	out.flush();
    }


    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

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

//
//class P {
//	int x, y, d;
//	P(int  x, int y, int d) {
//	  this.x=x;
//	  this.y=y;
//	  this.d=d;
//	}
//}

class P implements Comparable<P>{
    int a,b;
    P(int a, int b) {
    	this.b=b;
    	this.a=a;
    }

    public int compareTo(P p){
        return -p.a+a;//as
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() throws IOException{
        return this.nextString().toCharArray();
    }    
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 55892
#include <iostream>
#include<vector>

bool is_source(std::vector<int> b, int c, std::vector<int> a)
{
  int sum=0;
  size_t vlen;
  vlen = b.size();
  for(int i=0; i<vlen; ++i)
    sum += b[i] * a[i];
  sum += c;
  return (sum > 0)?true:false;
}

int main ()
{
  int n,m,c,res=0;
  std::cin >> n >> m >> c;
  std::vector<int> b_vec;
  std::vector<std::vector<int> > source_buf;
  int ret;
  for(int i=0; i<m; ++i){
    std::cin >> ret;
    b_vec.push_back(ret);
  }
  for(int j=0; j<n;++j){
    std::vector<int> ret_vec;
    for(int i=0; i<m; ++i){
      std::cin >> ret;
      ret_vec.push_back(ret);
    }
    source_buf.push_back(ret_vec);
  }
  for(auto v : source_buf)
    if(is_source(b_vec, c, v))
      ++res;

  std::cout << res;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 5;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const int N = 3e4+5;
string s;
int n;
vector<int> l[N];
vector<int> a[10];
set<int> se;

int dp[N][10];
int idx[10];

int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> s;
  rep(i,n) a[s[i] - '0'].push_back(i);

  for(int i=1; i< n-1; i++) {
    rep(j,100) {
      if(a[j/10].size() && a[j%10].size()) {
        if(a[j/10].front() < i && a[j%10].back() > i) {
          se.insert(j/10 * 100 + (s[i] - '0') * 10 + j%10);
        }
      }
    }
  }
  cout << se.size() << endl;
}


Measured memory_bytes: 1280
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
          
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n , m , a = 0;
    cin >> n;
    int t[n] , x = 0;
    for ( int i = 0 ; i < n ; i++ ) {
        cin >> t[i];
        x += t[i];
    }
    cin >> m;
    int p[m] , b[m];
    for ( int i = 0 ; i < m ; i++ ) cin >> p[i] >> b[i];
    for ( int i = 0 ; i < m ; i++ ) cout << x + ( b[i] - t[p[i] - 1] ) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    ll n; cin >> n;
    vector<ll> a(n+1,0);

    for(ll x=1;x<=100;x++){
        for(ll y=1;y<=100;y++){
            for(ll z=1;z<=100;z++){
                if(n < x*x+y*y+z*z+x*y+y*z+z*x) break;
                a[x*x+y*y+z*z+x*y+y*z+z*x]++;
            }
        }
    }

    for(ll i=1;i<=n;i++) cout << a[i] << endl;


    return 0;
}


Measured memory_bytes: 3556
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
using namespace std;

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

int main() {
	string s[3];
	rep(i, 0, 3) {
		cin >> s[i];
	}
	string ans;
	rep(i, 0, 3) {
		string a;
		a = s[i];
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
xyh=[list(map(int, input().split())) for i in range(N)]
 
for i in range(101):
  for j in range(101):
    check=True
    k=0
    while xyh[k][2]==0:
      k+=1
      
    h=abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2]
    
    for k in range(N):
      temph=abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2]
      if xyh[k][2]==0:
        if temph<h:
          check=False
      else:
        if h!=temph:
          check=False
        
    if check==True and 0<h:
        print(' '.join([str(i), str(j), str(h)]))
        exit()
        
sonnnakannsuuhateigisiteinai()

Measured memory_bytes: 3064
import java.io.*; 
import java.util.*; 
 
public class Main
{ 
    public static void main(String args[]) 
    { 
      
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		int add = A + B;
		int subtract = A-B;
		int multiply = A*B;
		
		
		if(add >= subtract && add >= multiply){
			
			System.out.println(add);
			
		} else if(subtract >= add && subtract >= multiply){

			System.out.println(subtract);

		}else {

			System.out.println(multiply);

		}			


	  
    } 
} 


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

char s[110];
char t[110];
char u[220];
int main(){
    int n,i,j,k;
    scanf("%d",&n);
    scanf("%s %s",s,t);
 
    for(i=0;i<=n;i++){
        u[i*2] = s[i];
    }
 
    for(j=1;j<=n;j++) {
        u[(j * 2) - 1] = t[j - 1];
    }
 
    for(k=0;k<2*n;k++){
        cout << u[k];
    }
 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int A,B;cin>>A>>B;
    if(A+B>=10)cout<<"error"<<endl;
    else cout<<A+B<<endl;
}


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

int main(){
  
  int n, k, x, sum = 0;
  cin >> n >> k;
  
  for(int i = 0; i < n; i++){
    cin >> x;
    if(k > x * 2) sum += x * 2;
    else if(k > x) sum += (k - x) * 2;
    else sum += (x - k) * 2;
  }
  cout << sum << endl;
}

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

using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;
using LL = long long;

#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()

int main()
{
	int n;
	cin >> n;
	VI a(n);
	IN(n, a);
	
	sort(ALL(a));
	int ans = 0;
	for (int i = 0; i < n - 2; i++)
	{
		for (int j = i + 1; j < n - 1; j++)
		{
			for (int k = j + 1; k < n; k++)
			{
				if (a[i] + a[j] > a[k])
				{
					ans++;
				}
			}
		}
	}

	cout << ans << endl;
}

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

int N;
string S[2];

ll ans;
int MOD = 1e9 + 7;

int main(void){
    cin >> N;
    for(int i=0;i<2;i++)    cin >> S[i];
    
    int current = 0;
    ans = 1;
    int state = -1;
    while(current < N){
        if(S[0][current] == S[1][current]){
            if(state == -1){
                ans *= 3;
            } else {
                if(state == 0)  ans *= 2;
            }
            state = 0;
            current++;
        } else {
            if(state == -1){
                ans *= 6;
            } else {
                if(state == 0)  ans *= 2;
                else            ans *= 3;
            }
            state = 1;
            current += 2;
        }
        ans %= MOD;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 764
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void calc(int n, int[] a) {
    int[dchar] d;
    int lo, hi; // 重複文字の位置
    for (int i = 0; i < a.length; i++) {
        if (a[i] in d) {
            lo = d[a[i]] + 1;
            hi = i + 1;
            break;
        }
        d[a[i]] = i;
    }

    int span = hi - lo;
    foreach (k; 1..n+2) {
        long ans = nck(n + 1, k) - nck(lo - 1 + (n + 1) - hi, k - 1);
        if (ans < 0) ans += MOD;
        writeln(ans);
    }
}

void main() {
    int n = readint;
    auto a = readints;

    initFactTable(n + 1);
    calc(n, a);
}

const MOD = 10^^9 + 7;

long[] fact; // 階乗
long[] factInv; // 階乗の逆元

void initFactTable(int n) {
    fact = new long[n + 1];
    fact[0] = 1;
    for (int i = 1; i <= n; i++)
        fact[i] = i * fact[i - 1] % MOD;

    factInv = new long[n + 1];
    factInv[n] = modPow(fact[n], MOD - 2, MOD);
    for (int i = n - 1; i >= 0; i--)
        factInv[i] = factInv[i + 1] * (i + 1) % MOD;
}

long modPow(long x, long k, long m) {
    if (k == 0) return 1;
    if (k % 2 == 0) return modPow(x * x % m, k / 2, m);
    return x * modPow(x, k - 1, m) % m;
}

long nck(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return (fact[n] * factInv[k] % MOD) * factInv[n - k] % MOD;
}


Measured memory_bytes: 12348
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

// comb(n, r)
// == n! / (n-r)!r!

void solve() {
  long n;
  cin >> n;
  vector<long> a(n);
  rep (i, n) cin >> a[i];
  sort(a.begin(), a.end());

  long ans1 = a[n-1];
  long ans2 = a[0];
  long foo = max(ans1 - ans2, ans2);
  a.pop_back();
  for (auto it: a) {
    long tmp = max(ans1 - it, it);
    if (tmp < foo) {
      foo = tmp;
      ans2 = it;
    }
  }
  cout << ans1 << " " << ans2 << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=100005,p=1e9+7;
int n,m,v[N],f[N],ans;
int C(int n,int m)
{
	return f[n]*v[m]%p*v[n-m]%p;
}
signed main() 
{
	v[0]=v[1]=f[0]=f[1]=1;
	for (int i=2;i<N;i++)v[i]=v[p%i]*(p-p/i)%p;
	for (int i=2;i<N;i++)f[i]=f[i-1]*i%p,v[i]=v[i-1]*v[i]%p;
	scanf("%d%d",&n,&m);
	ans=n+1;
	for (int i=1;i<m;i++)
	 {
		if (m-i>n)continue;
		for (int j=1;j<=m-i;j++)
		 {
		 	if ((m-i)+(m-i-j)>n)continue;
			(ans+=C(m-1,i-1)*C(m-i-1,j-1)%p*C(n-(m-i)-(m-i-j)+2,2)%p)%=p;
		 }
	 }
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
 
  cin.tie(0);
  ios::sync_with_stdio(false);

  int cnt=0,ans=0;
  string s;
  cin>>s;
  
  for(int i=0; i<s.size(); i++){
    if(s[i]=='C') cnt=1;
    if(s[i]=='F' && cnt==1){
      ans=1;
      break;
    }
  }
  if(ans==1) cout<<"Yes"<<'\n';
  else cout<<"No"<<'\n';
}


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

int main() {
    int h, w;
    while(cin >> h >> w){
        if(h==0 && w==0) break;
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                if(i%2==0){
                    if(j%2==0){
                        cout << "#";
                    }
                    else{
                        cout << ".";
                    }
                }
                else{
                    if(j%2==0){
                        cout << ".";
                    }
                    else{
                        cout << "#";
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

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

int main() {
	string s;
	int sum = 0;
	while (getline(cin, s)) {
		string sa;
		for (int i = 0;i < s.size();i++) {
			if (s[i] >= '0'&&s[i] <= '9') {
				sa.push_back(s[i]);
			}
			else {
				if (i != 0 && s[i - 1] >= '0'&&s[i - 1] <= '9') {
					int a = stoi(sa);
					sum += a;
					sa.clear();
				}
			}
		}
		if (!sa.empty() && sa[sa.size() - 1] >= '0'&&sa[sa.size() - 1] <= '9') {
			int a = stoi(sa);
			sum += a;
			sa.clear();
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3148
//use BIT to sum 1 -> i
/*    ####################  */
/*   # I_LOVE_THUY_LINH #  */
/*  ####################  */
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ld long double
#define ii pair<int,int>
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define matrix vector<vector<ll>>
#define fir first
#define sec second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define sz(a) int((a).size())
#define ms(s,val) memset(s,val,sizeof(s))
#define bitcount(n) __builtin_popcountll(n)
#define getbit(s,k) ((s >> k)&1)
#define turnbit(s,k) (s | (1<<k))
#define offbit(s,k) (s & ~(1<<k))
#define flipbit(s,k) (s ^ (1<<k))
#define prec(n) fixed<<setprecision(n)
#define sqr(x) (ll)(x)*(ll)(x)
#define lcm(a,b) ((ll)a/__gcd((ll)a,(ll)b)*(ll)(b))
#define gcd(a,b) __gcd(a,b)
using namespace std;
const int INF = int(1e9);
vector<ll> Fen;
int n, D, A;

void Update(int id,ll val = 1){
    for (id++ ; id <= n; id += (id & - id)) Fen[id] += val;
}

ll get(int id){
    ll res = 0;
    for (id++; id > 0 ; id -= (id & -id)) res += Fen[id];
    return res; 
}


int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> D >> A;
    vector<pair<ll,ll>> a(n);
    Fen.resize(n + 2);
    for (int i = 0; i < n; i++) cin >> a[i].fir >> a[i].sec;

    sort(all(a));
    D *= 2;
    ll ans = 0;
    for (int i = 0; i < n; i++){
        ll remain = a[i].sec - get(i);
        //cout << remain << ' ';
        if (remain <= 0) {
            //cout << '\n';
            continue;
        }
        ll delta = (remain + A - 1)/A;
        //cout << delta << ' ';
        ans += delta;
        int far = upper_bound(all(a),make_pair(a[i].fir + D*1LL + 1,-1LL)) - a.begin();
        //cout << far + 1 << '\n';
        Update(i,delta*(ll)A);
        Update(far,-delta*(ll)A);
    }
    cout << ans;
    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  bool judge = false;
  for(int i = 0; i < n; i++){
    if(a.at(i) % 2 == 1) judge = true;
  }
  
  if(judge) cout << "first" << '\n';
  else cout << "second" << '\n';
}

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

#define pb push_back
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pii pair<int,int>

const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    vector<int>v;
    f(n) {
        int x;
        cin >> x;
        v.pb(x);
    }
    ll ans = 0;
    map<int,int>mp;
    for (int i = 0 ; i < n ; i++) {
        int x = v[i] - (n - i);
        int tar = i - v[i] - n;
        //cout << x << endl;
        //cout << x <<' '<<tar<< endl;
        if (mp.count(tar)) {
            //cout << tar << endl;
            ans += mp[tar];
        }
        mp[x]++;
    }
    cout << ans << endl;  
}


Measured memory_bytes: 13296
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a;
  for(int i=0;i<5;i++){
    int b;cin>>b;
    a.push_back(b);
  }
  sort(a.begin(),a.end());
  for(int i=0;i<5;i++){
    cout<<a[4-i];
    if(i!=4)
      cout<<" ";
  }cout<<endl;
  return 0;
}

Measured memory_bytes: 3136
def f(S):
    all_cnt = 0
    cnt = 0
    for i in range(len(S)-1):
        if S[i] == S[i+1]:
            cnt += 1
        else:
            if cnt > 0:
                if cnt % 2 == 1:
                    all_cnt += (cnt + 1) / 2
                else:
                    all_cnt += cnt / 2
            cnt = 0
        # print(cnt,all_cnt)
    if cnt > 0:
        if cnt % 2 == 1:
            all_cnt += (cnt + 1) / 2
        else:
            all_cnt += cnt / 2
    return int(all_cnt)

def main():
    S = input()
    K = int(input())
    if S.count(S[0]) == len(S):
        print(len(S)*K // 2)
        return
    if S[-1] == S[0]:
        print((f(S + S) - f(S))*(K-1) + f(S))
    else:
        print(f(S)*K)

if __name__ == '__main__':
    main()

Measured memory_bytes: 61936
#include <cstdio>

int main(){
    int p[3];
    int max = 0;
    for(int i = 0; i < 3; i++){
        scanf("%d",&p[i]);
        if(max < p[i]){
            max = p[i];
        }
    }
    int ans = p[0] + p[1] + p[2] - max;
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 128