akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Print(bool c)
{
    if (c)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int cnt = 1;
    rep(i, 1, s.size())
    {
        if (s[i] != s[i - 1])
        {
            cnt++;
        }
    }
    cout << cnt << endl;
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

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

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

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

	map<string,int> memo;
	for (int i = 0; i < n; i++){
		string s;
		cin>>s;
		memo[s]++;
	}

	int mx=0;
	for(auto x: memo){
		int c=x.second;
		chmax(mx,c);
	}

	for (auto x: memo){
		int c=x.second;
		if(c==mx){
			string s=x.first;
			cout<<s<<endl;
		}
	}


	return 0;
}



Measured memory_bytes: 25472
#include <iostream>
using namespace std;
int main(void){
    int a;
    int b;
    int cnt = 0;
    while(true){
        scanf("%d%d",&a,&b);
//        printf("%d\n",a[t]);
        if(a==0 &&b==0){
            break;
        }
        if (a>b){
            int tmp = a;
            a = b;
            b = tmp;
            }
        cnt += 1;
    printf("%d %d\n",a,b);
    }
    return 0;
    
    
}

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

int main(){
    string s;
    cin >> s;
    long long ans=0;
    long long n=s.size();
    for(int i=0;i<n;i++){
        if(s[i]=='?') s[i]='D';
    }
    cout << s << endl;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = 1e9;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 105;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int H, W;
    cin >> H >> W;

    int cnt[SIZE][SIZE] = {};
    int mp[SIZE][SIZE] = {};
    for(int i = 1; i <= H; ++i) {
        for(int j = 1; j <= W; ++j) {
            char c;
            cin >> c;
            if(c == '#') mp[i][j] = 1;
            cnt[i][j] = INF;
        }
    }

    cnt[1][1] = 0;
    for(int i = 1; i <= H; ++i) {
        for(int j = 1; j <= W; ++j) {
            if(mp[i][j] == 1) {
                cnt[i][j] = 1;
            } else {
                cnt[i][j] = 0;
            }
            if(i == 1 && j == 1) {
                continue;
            }
            if(i == 1) {
                cnt[i][j] += cnt[i][j - 1];
                if(mp[i][j - 1] + mp[i][j] == 2) {
                    cnt[i][j]--;
                }
            } else if(j == 1) {
                cnt[i][j] += cnt[i - 1][j];
                if(mp[i - 1][j] + mp[i][j] == 2) {
                    cnt[i][j]--;
                }
            } else {
                int t = cnt[i - 1][j] + cnt[i][j];
                if(mp[i - 1][j] == 1 && mp[i][j] == 1) --t;
                int s = cnt[i][j - 1] + cnt[i][j];
                if(mp[i][j - 1] == 1 && mp[i][j] == 1) --s;
                cnt[i][j] = min(s, t);
            }
        }
    }

    /*
    for(int i = 1; i <= H; ++i) {
        for(int j = 1; j <= W; ++j) {
            cout << cnt[i][j] << " ";
        }
        cout << endl;
    }
    */

    cout << cnt[H][W] << endl;

    return 0;
}



Measured memory_bytes: 3676
n, k = map(int, input().split())
X = list(map(int, input().split()))
P = []
N = []
for x in X:
    if x >= 0:
        P.append(x)
    else:
        N.append(x)

P.sort()
N.sort(reverse=True)
P = [0]+P
N = [0]+N
ans = 10**16
for a in range(k+1):
    b = k-a
    if a > len(P)-1 or b > len(N)-1:
        continue
    else:
        ans = min(ans, min(2*P[a]+(-1)*N[b], P[a]+2*(-1)*N[b]))
print(ans)

Measured memory_bytes: 14228
<?php
fscanf(STDIN, "%d %d", $n, $k);
$hs=explode(' ',trim(fgets(STDIN)));
rsort($hs);
$cnt=0;
foreach($hs as $i => $h){
  if ($i>=$k) {
    $cnt += $h;
  }
}
echo $cnt;

Measured memory_bytes: 23200
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<set>
#include<sstream>
using namespace std;
typedef long long ll;
const ll maxn=1e4+10;
const ll inf=0x3f3f3f3f3f3f3f3f;
const ll mod=998244353;
void io(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
ll a[maxn],dp[maxn],f[3100][3100];
int main()
{
	io();
	ll n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i]; 
	ll ans=0; 
	for(int i=1;i<=n;i++)
	{
		dp[0]+=1;
		for(int j=k;j>=a[i];j--)
			dp[j]=(dp[j]+dp[j-a[i]])%mod;
		ans=(ans+dp[k])%mod;
	}
	cout<<ans<<endl;
	return 0;
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		int W = Integer.parseInt(st.nextToken());
		int[] v = new int[n];
		int[] w = new int[n];
		for (int i = 0; i < n; i++) {
			st = new StringTokenizer(reader.readLine());
			v[i] = Integer.parseInt(st.nextToken());
			w[i] = Integer.parseInt(st.nextToken());
		}
		reader.close();
		System.out.println(knapsack(n, W, v, w));
	}
	private int knapsack(int n, int W, int[] v, int[] w) {
		int[][] dp = new int[n+1][W+1];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= W; j++) {
				if (j < w[i]) {
					dp[i+1][j] = dp[i][j];
				} else {
					dp[i+1][j] = Math.max(dp[i][j], dp[i][j-w[i]] + v[i]);
				}
			}
		}
		return dp[n][W];
	}
}



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

struct UnionFind{
private:
    vector<int> par;
    vector<int> rank;
public:
    UnionFind(int n){
        par.resize(n);
        rank.resize(n);
        for (int i=0;i<n;i++){
            par[i]=i;
            rank[i]=0;
        }
    }
    int root(int x){
        if(par[x]==x)return x;
        else return par[x]=root(par[x]);
    }
    bool issame(int x,int y){
        return root(x)==root(y);
    }
    bool merge(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y)return false;
        if(rank[x]<rank[y])swap(x,y);
        if(rank[x]==rank[y])++rank[x];
        par[y]=x;
        return true;
    }
};

int main(){
    ll n,m;
    cin>>n>>m;
    UnionFind uf(2*n);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        --a,--b;
        uf.merge(a,b+n);
        uf.merge(a+n,b);
    }
    if(uf.issame(0,n)){
        cout<<n*(n-1)/2-m<<endl;
    }
    else{
        int par=uf.root(0);
        ll cnt=0;
        for(int i=0;i<n;i++){
            if(uf.root(i)==par)++cnt;
        }
        cout<<cnt*(n-cnt)-m<<endl;
    }
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() {
    int a,n,ok=1;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a;
        if(a%2==0)
        {
            if(!(a%3==0 || a%5==0))
            {
                ok=0;
            }
        }
    }
    if(ok==1)
    {
        cout<<"APPROVED";
    }
    else
    {
       cout<<"DENIED" ;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

    public static void main(String[] args){
        int w;
        int n;
        Scanner scanner = new Scanner(System.in);
        int[] amida;

        w = scanner.nextInt();
        amida = new int[w];

        int i;
        for(i = 0; i < w; i++){
            amida[i] = i + 1;
        }

        n = scanner.nextInt();

        int a, b, c;
        String ab;
        String[] abc;
        for(i = 0; i < n; i++){
            ab = scanner.next();
            abc = ab.split(",");
            a = Integer.parseInt(abc[0]) - 1;
            b = Integer.parseInt(abc[1]) - 1;

            c = amida[a];
            amida[a] = amida[b];
            amida[b] = c;
        }

        for(i = 0; i < w; i++){
            System.out.println(amida[i]);
        }

        scanner.close();
    }
}


Measured memory_bytes: 26096
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s=sc.next().toCharArray();

		int k=s.length;
		for(int i=1;i<s.length;i++){
			if(s[i]!=s[i-1]) k=Math.min(k, Math.max(i,s.length-i));
		}
				
		System.out.println(k);
	}
}


Measured memory_bytes: 26988
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int d = scanner.nextInt();
		int ans = Math.max(a*b,c*d);
		

		System.out.println(ans);
	}
}

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

#define sc(a) scanf("%d",&a)
#define scm(a,b) scanf("%d%d",&a,&b)
#define fl(c,i,n) for(int i=c;i<n;i++)
#define f(i,n) for(int i=0;i<n;i++)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long int
#define ull unsigned long long int
#define inf INT_MAX
#define linf LLONG_MAX
#define pb push_back
#define pp pop_back()
#define aov(a) a.begin(),a.end()
//#define mp make_pair
#define nl printf("\n")
#define PI 2.0*acos(0.0) //#define PI acos(-1.0)
#define xx first
#define yy second
#define mxv(a) *max_element(aov(a))
#define mnv(a) *min_element(aov(a))
#define LB(a,x) (lower_bound(aov(a),x)-a.begin())
#define UB(a,x) (upper_bound(aov(a),x)-a.begin())
#define to_c_string(a) a.c_str()
#define strtoint(c) atoi(&c[0])
#define pii pair<int,int>
#define MAXN 100005
#define MOD 1000000007

template <class T> inline T bigmod(T p,T e,T M){
    ll ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
/*int fact[MAXN];
int invfact[MAXN];
int inv(int a, int b){
    if(b==0)
        return 1;
    if(b&1)
        return (long long)a*inv(a, b-1)%MOD;
    else{
        int res = inv(a, b>>1);
        return (long long)res*res%MOD;
    }
}
void init(){
    fact[0] = 1;
    for(int i=1;i<MAXN;i++){
        fact[i] = (long long)fact[i-1]*i%MOD;
    }
    invfact[MAXN-1] = inv(fact[MAXN-1], MOD-2);
    for(int i=MAXN-1;i>0;i--){
        invfact[i-1] = (long long)invfact[i]*i%MOD;
    }
}
int C(int n, int r){
    if(r>n || r<0)
        return 0;
    return (long long)((long long)fact[n]*invfact[r]%MOD)*invfact[n-r]%MOD;
}*/
ll n, m, a, b, l = 0, r = 0;
vector<pair<ll, ll> > v;
vector<pair<ll, ll> > arr;
void solve(){
    cin>>n>>m;
    f(i, n){
        cin>>a>>b;
        arr.pb({a, b});
    }
    sort(arr.begin(), arr.end());
    f(i, n){
        a = arr[i].first;
        b=arr[i].second;
        l+=b;
        if(m<=l){
            cout<<a;
            break;
        }
    }
}
int main(){
    /*FILE *fin = freopen("C-small-attempt0.in", "r", stdin);
	assert( fin!=NULL );
	FILE *fout = freopen("C-small.out", "w", stdout);*/
	//init();
    solve();
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  int count=0;
  if(s.at(5)=='0'){
    count++;
  }
  if(s.at(6)-'0'<5){
    count++;
  }
  if(count==2){
    cout << "Heisei" << endl;
  }
  else{
    cout << "TBD" << endl;
  }
}

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

int main()
{
int x,y;
  cin>>x>>y;
  int a=y-2*x,b=4*x-y;
  if(a%2!=0||b%2!=0)
    cout<<"No";
  else if(a<0||b<0)
    cout<<"No";
  else
    cout<<"Yes";
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
using namespace std;
#define max(a,b) ((a)>=(b)?(a):(b))
#define min(a,b) ((a)<=(b)?(a):(b))
int main() {
	string S,T;
	while(cin>>S) {
		cin>>T;
		int len=0;
		for(int i=0;i<S.size();i++) {
			for(int j=0;j<min(S.size()-i,T.size());j++) {
				int k;
				for(k=j;k<min(S.size()-i,T.size());k++) if(S[i+k]!=T[k]) break;
				len=max(len,k-j);
				j=k;
			}
		}
		for(int i=0;i<T.size();i++) {
			for(int j=0;j<min(T.size()-i,S.size());j++) {
				int k;
				for(k=j;k<min(T.size()-i,S.size());k++) if(T[i+k]!=S[k]) break;
				len=max(len,k-j);
				j=k;
			}
		}
		cout<<len<<endl;
	}
}

Measured memory_bytes: 1208
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define log(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  int n;cin>>n;
  n %= 10;
  if(n == 3)print("bon");
  else if(n == 0 || n == 1 || n == 6 || n == 8)print("pon");
  else print("hon");
  
  return 0; 
}


Measured memory_bytes: 3540
a = input().split()
b = input()
tp = b[int(a[1])-1]
tp = tp.lower()
if int(a[1]) == 1:
	st = tp + b[1:len(b)]
elif int(a[1]) == int(a[0]):
  	st = b[0:len(b)-1] + tp
else:
  	st = b[0:int(a[1])-1] + tp + b[int(a[1]):len(b)]
print(st)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{
    int n;
    cin>>n;

    vector<int>a;
    for(int i=1;i<=n;i++)
        a.pb(i);
    pair<int,int>p[9];

    for(int i=1;i<=n;i++)
    {    int x,y;
        cin>>x>>y;
        p[i]={x,y};
    }
    ll c=0;
    double q;
    do
    {
        c++;
        for(int i=1;i<n;i++)
        {
            double d=abs(p[a[i]].first-p[a[i-1]].first);
            double e=abs(p[a[i]].second-p[a[i-1]].second);
            q+=(double)sqrt(d*d+e*e);
        }
    }while(next_permutation(a.begin(),a.end()));

    cout<<setprecision(9)<<(double)q/c<<"\n";
    return 0;
}


Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
// __uint128_t

int main(){
    ll N; cin >> N;
    ll SUM = 0;
    vector<ll> C(N+1); for(int i = 0; i < N+1; i++) cin >> C[i];
    if(C[N] == 0 ) {cout << -1 << endl; return 0;}
    vector<ll> P(N+1); P[N] = 0;
    
    for(int i = N-1; i >= 0; i--){
        P[i] = C[i+1] + P[i+1];
    }


    ll temp = 1;
    for(int i = 0; i <= N; i++){
        P[i] = min(temp - C[i], P[i]); temp = 2*P[i];
        if(temp <= -1) {cout << -1 << endl;return 0;}

    }
    for(int i = 0; i < N+1; i++) SUM += C[i]+P[i];
    cout << SUM << endl;
}


Measured memory_bytes: 4776
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

const int MAX_N = 7368791;
bool ok[MAX_N + 1];

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

    int m, n;
    while (cin >> m >> n, m) {
        memset(ok, 0, sizeof(ok));
        int y = m;
        while (true) {
            if (!ok[y]) {
                if (n == 0) break;
                n--;
                ok[y] = true;
                for (int yy = 2 * y; yy <= MAX_N; yy += y) {
                    ok[yy] = true;
                }
            }
            y++;
        }
        cout << y << endl;
    }
}


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

int main(){
    int N;
    cin >>N;
    int T[N];
    for(int i = 0; i < N ;i++)cin >> T[i];
    int M;
    cin >> M;
    int P[M],X[M];
    for(int i = 0; i < M ;i++)cin >> P[i] >> X[i];
    
    int ans=0;
     for(int i = 0; i < M ;i++){

        for(int j = 0; j < N ;j++){

            
            if(j==P[i]-1)ans += X[i];
            else ans += T[j];
            
            
        }
    cout << ans << endl;
    ans = 0;
    }

}

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

int main(){
  ll N,T;cin >> N >> T;
  ll sum =0;
  vector<ll> C(N);
  for(int i=0;i<N;i++){
    cin >> C[i];
  }
  for(int i=0;i<N-1;i++){
    sum += min(T,C[i+1]-C[i]);
  }
  sum += T;
  cout << sum << endl;
}

Measured memory_bytes: 4736
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int X, Y;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> X >> Y;
	int ans = 1;
	while ((X = X * 2) <= Y)ans++;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, m;
    cin >> n >> m;
    ll val, B, C;
    map<ll, ll> cnt;

    for(int i = 0; i < n; i++) {
        cin >> val;
        cnt[val] += 1;
    }
    for(int i = 0; i < m; i++) {
        cin >> B >> C;
        cnt[C] += B;
    }
    ll ans = 0;
    for(auto it = cnt.rbegin(); it != cnt.rend(); ++it) {
        if (it->second <= n) {
            ans += it->first * it->second;
            n -= it->second;
        } else {
            ans += it->first * n;
            break;
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 12800
n = int(input())
w = list(map(int, input().split()))
s1=0
s2=0
ans=[]


for t in range(len(w)):
    for i in range(0,t):
        s1+=w[i]
    for j in range(t,len(w)):
        s2+=w[j]
    ans.append(abs(s1-s2))
    s1=0
    s2=0

print(min(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, C;
int D[30][30], c[510][510];
int cnt[3][30];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> C;
  for (int i = 0; i < C; i++) {
    for (int j = 0; j < C; j++) {
      cin >> D[i][j];
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> c[i][j];
      c[i][j]--;
      cnt[(i + j + 2) % 3][c[i][j]]++;
    }
  }
  int ans = 1 << 30;
  for (int i = 0; i < C; i++) {
    for (int j = 0; j < C; j++) {
      for (int k = 0; k < C; k++) {
        if (i == j || j == k || k == i) continue;
        int sum = 0;
        for (int l = 0; l < C; l++) {
          sum += cnt[0][l] * D[l][i];
          sum += cnt[1][l] * D[l][j];
          sum += cnt[2][l] * D[l][k];
        }
        ans = min(ans, sum);
      }
    }
  }
  cout << ans << endl;

  return 0;
}

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

using ll = long long int;


int main(){
    ll n, q;
    string s;
    cin >> n >> s >> q;
    for(;q>0;q--){
        int k;
        cin >> k;
        ll d=0,m=0,dm=0,dmc=0;
        for(int i=0;i<k;i++){
            if(s[i]=='D'){
                d++;
            }
            if(s[i]=='M'){
                dm += d;
                m++;
            }
            if(s[i]=='C'){
                dmc += dm;
            }
        }
        for(int i=k;i<n;i++){
            if(s[i-k]=='D'){
                dm -= m;
                d--;
            }
            if(s[i-k]=='M'){
                m--;
            }
            if(s[i]=='D'){
                d++;
            }
            if(s[i]=='M'){
                dm += d;
                m++;
            }
            if(s[i]=='C'){
                dmc += dm;
            }
        }
        cout << dmc << endl;
    }
    return 0;
}


Measured memory_bytes: 1412
#include<iostream>
#include<string>
#include<algorithm>
#include <cstdlib>

using namespace std;

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

int main(){
    long int n;
    cin >> n;
    long int a[n];
    rep(i, n) cin >> a[i];
    long s[n];
    s[0] = a[0];

    rep(i, n - 1) s[i+1] = s[i] + a[i+1];
    long int ans = abs(s[0] - (s[n-1] - s[0]));
    rep(i, n - 1){
        ans = min(ans, abs(s[i] - (s[n-1] - s[i])));
    }
    cout << ans << endl;
}

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

bool pos[10];
int dig[10];
int power[6];
int DIG[10];
 
bool ok(int x){
	if(x == 0){
		if(!pos[0]) return true;
		else return false;
	}

	while(x){
		if(pos[x%10]) return false;
		x /= 10;
	}
	return true;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, k;
	cin >> n >> k;
	for(int i = 0; i < k; i++){
		cin>>dig[i];
		pos[dig[i]] = true;
	}
	int idx = 0;
	for(int i = 0; i < 10; i++){
		if(!pos[i]){
			DIG[idx] = i;
			idx++;
		}
	}
	power[0] = 1;
	for(int i = 1; i <= 5; i++){
		power[i] = power[i-1]*10;
	}
	
	int x = n;
	int cnt = 0;
	if(n == 0) cnt = 1;
	while(x){
		x /= 10;
		cnt++;
	}
	for(int i = n; i < power[cnt]; i++){
		if(ok(i)){
			cout << i << '\n';
			return 0;
		}
	}	
	int d = DIG[0];
	if(d == 0) d = DIG[1];
	cout << d;
	for(int i = 0; i < cnt; i++){
		cout << DIG[0];
	}
	cout << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int main(){
  int N; cin >>N;
  N *= 2;
  int L[N];
  REP(i,N){
    cin >> L[i];
  }
  sort(L,L+N,greater<int>());
  
  int r = 0;
  for(int i=1;i<N;i+=2){
    r += L[i];
  }
  cout << r << '\n';
}
  

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
using namespace std;
long long a[100010];
int n;
int main(){
	cin>>n;
	lol(i,n)cin>>a[i];
	sort(a,a+n);
	int pnt=n-1;
	long long best=0;
	while(true){
		if(pnt==0){
			cout<<"0"<<endl;
			break;
		}
		if(a[pnt]==a[pnt-1]){
			if(best==0)best=a[pnt];
			else{
				cout<<best*a[pnt]<<endl;
				break;
			}
			pnt-=2;
		}
		else pnt--;
	}
	return 0;
}


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

const int MAXN = 5e5+5;

ll n, l, d[MAXN], part[MAXN], up[MAXN];

ll s(int i, int j) {
	return part[j+1] - part[i];
}

ll up1(int i, int j) {
	return 2*(up[j+1] - up[i]) - (2*i+1)*s(i, j);
}

ll up2(int i, int j) {
	return up1(i, j) + s(i, j);
}

ll down1(int i, int j) {
	return (2*(j-i)+2)*s(i, j) - up1(i, j);
}

ll down2(int i, int j) {
	return down1(i, j) + s(i, j);
}

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

	cin >> l >> n;
	for (int i = 0; i < n; ++i)
		cin >> d[i];
	n++;
	d[n-1] = l - d[n-2];
	for (int i = n-2; i >= 0; --i)
		d[i] -= d[i-1];
	for (int i = n; i < 2*n; ++i)
		d[i] = d[i-n];
	part[0] = 0;
	for (int i = 1; i <= 2*n; ++i)
		part[i] = d[i-1] + part[i-1];
	up[0] = 0;
	for (int i = 1; i <= 2*n; ++i)
		up[i] = i*d[i-1] + up[i-1];
	ll ans = 0;
	// cout << s(1, 3) << endl;
	for (int i = 0; i < n; ++i) {
		if (i == n-i-1) {
			ans = max(ans, up2(i+1, n-1)+down1(0, i-1));
			ans = max(ans, up1(i+1, n-1)+down2(0, i-1));
		} if (i > n-i-1) {
			ans = max(ans, up2(i+1, n-1) + down1(2*i-n+1, i-1) + (2*(n-i-1)+1)*s(0, 2*i-n));
			ans = max(ans, up1(i+1, n-1) + down2(2*i-n+1, i-1) + (2*(n-i-1))*s(0, 2*i-n));
		} if (i < n-i-1) {
			ans = max(ans, down2(0, i-1) + up1(i+1, 2*i) + (2*i+1)*s(2*i+1, n-1));
			ans = max(ans, down1(0, i-1) + up2(i+1, 2*i) + (2*i)*s(2*i+1, n-1));
		}
		// cout << ans << endl;
	}

	cout << ans << endl;
}

Measured memory_bytes: 11264
#include <stdio.h>
int main(void)
{
  int n;
  scanf("%d",&n);
  int R[n];
  int i;
  for(i=0;i<n;i++) {
    scanf("%d",&R[i]);
  }
  int max=R[1]-R[0];
  int min=R[0];
  for(i=1;i<n;i++) {
    if(R[i]-min>max)
      max=R[i]-min;
    if(R[i]<min)
      min=R[i];
  }
  printf("%d\n",max);
  return 0;
}


Measured memory_bytes: 2564
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <math.h>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
using namespace std;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Graph vector<vector<ll>>
#define INF (1ll<<40-1)
#define mod 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll gcd(ll a,ll b){
    if(b==0){return a;}
    else{return gcd(b,a%b);}
}

int main(){
    ll n;cin>>n;
    vector<ll> t(n);
    rep(i,n) cin>>t[i];

    ll ans=1;
    rep(i,n){
        t[i]/=gcd(ans,t[i]);
        ans*=t[i];
    }

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

Measured memory_bytes: 3640
#include<stdio.h>
int main(void){


	int i,j,N,k;
	int v;
	scanf("%d",&N);
	int a[N];
	for(i=0;i<N;i++){
		scanf("%d",&a[i]);
	}

	for (i=0;i<N;i++){
		v=a[i];
		j=i-1;
		while(j>=0 && a[j]>v){
			a[j+1]=a[j];
			j--;
		}
			a[j+1]=v;
		
	for(k=0;k<N-1;k++){
		printf("%d ",a[k]);
	}
	printf("%d\n",a[N-1]);
	}

	return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed

using namespace std;

class Point
{
private:
  int m_x;
  int m_y;
public:
  void setX(int x);
  void setY(int y);
  int getX();
  int getY();

  Point(int x, int y) {
    setX(x);
    setY(y);
  }
};

void Point::setX(int x) {
  m_x = x;
}

void Point::setY(int y) {
  m_y = y;
}

int Point::getX() {
  return m_x;
}

int Point::getY() {
  return m_y;
}

int main() {
  int N, x, y, M, l, rx, ry;
  string d;
  while (1) {
    cin >> N;
    vector<Point> gems;
    if (N == 0) break;
    for (int i = 0; i < N; i++) {
      cin >> x >> y;
      gems.push_back(Point(x, y));
    }
    cin >> M;
    rx = 10;
    ry = 10;
    while (M--) {
      cin >> d >> l;
      while (l--) {
        if (d == "N") ry++;
        if (d == "E") rx++;
        if (d == "S") ry--;
        if (d == "W") rx--;
        for (int i = 0; i < gems.size(); i++) {
          if (rx == gems[i].getX() && ry == gems[i].getY()) {
            gems.erase(gems.begin()+i);
            break;
          }
        }
      }
    }
    if (gems.empty()) cout << "Yes" << el;
    else cout << "No" << el;
  }
}

Measured memory_bytes: 1204
#include <iostream>

int main()
{
    int n, a[10010];
    std::cin >> n;

    int sum = 0;
    for (int i = 0; i < n; ++i)
    {
        std::cin >> a[i];
        while (a[i] % 2 == 0)
        {
            a[i] /= 2;
            ++sum;
        }
    }

    std::cout << sum;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);

int main() {
	int N, M, K, x;
	scanf("%d%d%d", &N, &M, &K);
	LL A[N + 1], B[M + 1];
	for (int i = 1; i <= N; i++) {
		scanf("%lld", &A[i]);
		if (i > 1) A[i] += A[i - 1];
	}
	for (int i = 1; i <= M; i++) {
		scanf("%lld", &B[i]);
		if (i > 1) B[i] += B[i - 1];
	}
	int ans = 0;
	int idx = 1;
	for (int i = 1; i <= N; i++) {
		idx = max(idx, 1);
		while (idx <= M && A[i] + B[idx] <= K) idx++;
		idx--;
		LL cnt = A[i];
		if (idx > 0) cnt += B[idx];
		if (cnt <= K) ans = max(ans, i + idx);
	}
	for (int i = 1; i <= M; i++) {
		if (B[i] <= K) ans = max(ans, i);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 6920
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

const double inf=1e8;

int xs[202],ys[202];
int N;
int W,H;

vector<double> vec;

double get(int x1,int y1,int x2,int y2){
	if(x1==x2) return -1;
	if(x1>x2){
		swap(x1,x2);
		swap(y1,y2);
	}
	int dy=y2-y1;
	int dx=x2-x1;
	double a=(double)dy/dx;
	double res=y1-(double)x1*a;
	if(res>H||res<0) return -1;
	return res;
}

double as[200];

double getLen(double y){
	for(int i=0;i<N*2;i++){
		if(xs[i]==0){
			if(ys[i]<y) as[i]=-inf;
			else as[i]=inf;
		}else{
			as[i]=(double)(ys[i]-y)/xs[i];
		}
	}
	sort(as,as+N*2);
	double a1=as[N-1];
	double a2=as[N];
	double lo=y+a1*W;
	lo=max(lo,0.0);
	double hi=y+a2*W;
	hi=min(hi,(double)H);
	if(hi>lo) return hi-lo;
	else return 0;
}

double solve(){
	vec.clear();
	for(int i=0;i<N*2+2;i++) for(int j=i+1;j<N*2+2;j++){
		double tmp=get(xs[i],ys[i],xs[j],ys[j]);
		if(tmp<0) continue;
		vec.push_back(tmp);
	}
	for(int i=0;i<N*2;i++){
		if(xs[i]==0) vec.push_back(ys[i]);
	}
	vec.push_back(0);
	vec.push_back(H);
	sort(vec.begin(),vec.end());
	if(vec.size()==0){
		sort(ys,ys+N*2);
		int a=ys[N]-ys[N-1];
		return (double)a/H;
	}
	double res=0;
	for(int i=0;i<vec.size()-1;i++){
		double y=(vec[i]+vec[i+1])/2;
		double ln=getLen(y);
		res+=ln*(vec[i+1]-vec[i]);
	}
	return res/(H*H);
}

bool input(){
	scanf("%d%d%d",&W,&H,&N);
	if(W==0&&H==0&&N==0) return false;
	for(int i=0;i<N*2;i++){
		scanf("%d%d",xs+i,ys+i);
	}
	xs[N*2]=W;
	ys[N*2]=0;
	xs[N*2+1]=W;
	ys[N*2+1]=H;
	return true;
}

int main(){
	while(true){
		bool flg=input();
		if(flg==false) break;
		double ans=solve();
		printf("%.9f\n",ans);
	}
	return 0;
}

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

using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)

typedef long long ll;

int main() {
  int a, b;
  cin >> a >> b;

  int ret = -1;
  if(a < 10 && b < 10){
    ret = a*b;
  }

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;


public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        
        int count1 = 0;
        for (int i = 0; i < s.length(); i++) {
            if (i % 2 == 0) {
                if (s.charAt(i) != '0') count1++;
            }
            else {
                if (s.charAt(i) != '1') count1++;
            }
        }
        
        int count2 = 0;
        for (int i = 0; i < s.length(); i++) {
            if (i % 2 == 0) {
                if (s.charAt(i) != '1') count2++;
            }
            else {
                if (s.charAt(i) != '0') count2++;
            }
        }
        
        //System.out.println(count2);
        System.out.println(Math.min(count1, count2));
    }
}





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

int main() {
	int a, b;
	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
		cout << "Possible" << endl;
	else
		cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps DBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, v[50];
signed main() {
	cin >> n;
	prique<double,vector<double>,greater<double>> que;
	rep(i, n) {
		cin >> v[i];
		que.push(v[i]);
	}
	rep(i, n - 1) {
		double m1 = que.top(); que.pop();
		double m2 = que.top(); que.pop();
		que.push((m1 + m2) / 2);
	}
	printf("%.12lf\n", que.top());
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x 2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  int a[3][3];
  int b[3][3];
  rep(i,3){
    rep(j,3){
      cin >> a[i][j];
      b[i][j] = 0;
    }
  }
  int n,num;
  cin >> n;
  rep(k,n){
    cin >> num;
    rep(i,3){
      rep(j,3){
        if(num == a[i][j]){
          b[i][j]=1;
        }
      }
    }
  }
  if((b[0][0] == 1 && b[0][1] == 1 && b[0][2]==1)
|| (b[1][0] == 1 && b[1][1] == 1 && b[1][2]==1)
|| (b[2][0] == 1 && b[2][1] == 1 && b[2][2]==1)
|| (b[0][0] == 1 && b[1][1] == 1 && b[2][2]==1)
|| (b[2][0] == 1 && b[1][1] == 1 && b[0][2]==1)
|| (b[0][0] == 1 && b[1][0] == 1 && b[2][0]==1)
|| (b[0][1] == 1 && b[1][1] == 1 && b[2][1]==1)
|| (b[0][2] == 1 && b[1][2] == 1 && b[2][2]==1)
){
  cout << "Yes" << endl;
  return 0;
}else{

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


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    int N;
    cin >> N;
    if(N>=64)
    {
        cout<<64<<endl;
    }
    else if(N>=32){
        cout<<32<<endl;
    }
    else if(N>=16)
    {
        cout<<16<<endl;
    }
    else if(N>=8)
    {
        cout<<8<<endl;
    }
    else if(N >= 4)
    {
        cout<<4<<endl;
    }
    else if(N >=2)
    {
        cout<<2<<endl;
    }
    else {
        cout<<N;
    }
    return 0;
}



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

int n;
int a[500001];
int cnt[500001];
ll fact[500001];
int twice=0;
int f=0,t=0;

ll extgcd(ll a,ll b,ll& x,ll& y){
	ll d=a;
	if(b!=0LL){
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}else{
		x=1;
		y=0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
	ll x,y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}

ll mod_fact(ll n,ll p,ll& e){
	e=0;
	if(n==0)return 1;
	ll res=mod_fact(n/p,p,e);
	e+=n/p;
	if(n/p%2!=0){
		return res*(p-fact[n%p])%p;
	}
	return res*fact[n%p]%p;
}

ll mod_comb(ll n,ll k,ll p){
	if(n<0 || k<0 || n<k)return 0;
	ll e1,e2,e3;
	ll a1=mod_fact(n,p,e1),a2=mod_fact(k,p,e2),a3=mod_fact(n-k,p,e3);
	if(e1>e2+e3)return 0;
	return a1*mod_inverse(a2*a3%p,p)%p;
}

int main(void){
	scanf("%d",&n);
	fact[0]=1;
	fact[1]=1;
	for(int i=2;i<=n;i++){
		fact[i]=(ll)fact[i-1]*i%MOD;
	}
	for(int i=0;i<n+1;i++){
		scanf("%d",&a[i]);
		if(cnt[a[i]]==1){
			twice=a[i];
		}
		cnt[a[i]]++;
	}
	f=-1;
	t=-1;
	for(int i=0;i<n+1;i++){
		if(twice==a[i]){
			if(f==-1){
				f=i;
			}else if(t==-1){
				t=i;
			}
		}
	}
	for(int i=1;i<=n+1;i++){
		if(i==1){
			printf("%d\n",n);
		}else{
			ll res=0;
			res=mod_comb(n-1,i,MOD);
			res=(res+mod_comb(n-1,i-2,MOD))%MOD;
			ll v=mod_comb(n-1,i-1,MOD);
			v=v*2LL%MOD;
			ll v2=mod_comb(n-1-(t-f-1),i-1,MOD);
			res=(res+v)%MOD;
			res=(res+MOD-v2)%MOD;
			printf("%lld\n",res);
		}
	}
	return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int a, b;
    cin >> a >> b;
    int ans = a - b * 2;
    if (ans < 0) ans = 0;
    cout << ans << endl;

    
}

Measured memory_bytes: 3564
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  while(true){
    vector<vector<llong>> dp;
    llong n, m, k;
    scanf("%lld %lld %lld", &n, &m, &k);
    
    if(n == 0 && m == 0 && k == 0) break;

    dp = vector<vector<llong>>(n+1, vector<llong>(n * m+1, 0));
    dp[0][0] = 1;
    for(int i = 0; i < n; ++i){
      for(int j = 0; j <= n * m; ++j){
        for(int k = 1; k <= m; ++k){
          if(j + k <= n * m){
            dp[i+1][j+k] += dp[i][j];
          }
        }
      }
    }
    double p = 1.0;
    REP(i, n){
      p /= m;
    }
    double ans = 0.0;
    REP(i,n*m+1){
      double bill;
      if(i <= k){
        bill = 1;
      }else{
        bill = i - k;
      }
      //cout << dp[n][i] << " " << bill << " " << p << endl; 
      ans += (double)dp[n][i] * bill * p;
      //cout <<  i << " " << dp[n][i] * p << " " << dp[n][i] * bill * p << endl;
    }

    printf("%.8f\n", ans);

  }

  return 0;
}




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

#define K_MAX 3002
#define NM_MAX 200002
#define ll long long

using namespace std;

const ll MOD = 1e9+7;

ll pwr (ll a, ll b)
{
    if(b == 0)
        return 1;
    if(b & 1)
        return pwr(a, (b ^ 1)) * a % MOD;
    ll p = pwr(a, (b >> 1));
    return p * p % MOD;
}

int n, m, k;

ll fact[NM_MAX];
ll ifact[NM_MAX];

struct Wall
{
    int x, y;
};

bool operator < (Wall a, Wall b)
{
    return make_pair(a.x, a.y) < make_pair(b.x, b.y);
}

Wall v[K_MAX];

ll f (ll a, ll b)
{
    return fact[a + b] * ifact[a] % MOD * ifact[b] % MOD;
}

ll dp[K_MAX];

int main()
{
    cin >> n >> m >> k;
    fact[0] = 1;
    for(int i = 1; i <= n + m; i++)
        fact[i] = fact[i - 1] * i % MOD;
    ifact[n + m] = pwr(fact[n + m], MOD - 2);
    for(int i = n + m - 1; i >= 0; i--)
        ifact[i] = ifact[i + 1] * (i + 1) % MOD;
    for(int i = 1; i <= k; i++)
        cin >> v[i].x >> v[i].y;
    sort(v + 1, v + k + 1);
    ll ans = 0;
    for(int i = 1; i <= k; i++)
    {
        dp[i] = f(v[i].x - 1, v[i].y - 1);
        for(int j = 1; j < i; j++)
            if(v[j].y <= v[i].y)
                dp[i] = (dp[i] - dp[j] * f(v[i].x - v[j].x, v[i].y - v[j].y) % MOD + MOD) % MOD;
        ans += dp[i] * f(n - v[i].x, m - v[i].y) % MOD;
        if(ans >= MOD)
            ans -= MOD;
    }
    ans = (f(n - 1, m - 1) - ans + MOD) % MOD;
    cout << ans << "\n";
    return 0;
}


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

int main()
{
    size_t N;
    cin >> N;
    int ai;
    int sum = 0;
    for(size_t i=0;i<N;i++){
        cin >> ai;
        sum += ai-1;
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;

int main(){
	string s;
	while(cin >> s){
		int N = s.size();
		int p = 0;
		for(int i=0;i<N;i++) p += (s[i] == 'p');
		cout << (N/2 - p) << endl;
	}
}


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

using namespace std;
int t[200000], x[200000], y[200000];
int main(){
	int N, ans=0, countX, countT;
	x[0] =0;  y[0]=0; t[0]=0; 
	cin >> N;
	for(int i=1;i<N+1;i++){
		cin >> t[i] >> x[i] >> y[i];
	}
	for(int i=1;i<N+1;i++){
		countX =abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
		countT =t[i]-t[i-1];
		if(countX > countT)	{
			ans = 1;
			break;
		}
		else if((countT-countX)%2==1){
			ans = 1;
			break;
		}
	}
	if(ans == 1){
		cout << "No" <<endl;
	}
	else{
		cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 1408
n,a=int(input()),map(int,input().split());c=[0]*3
for i in a:c[i-1]+=1
x,y,z=c;dp=[[[None]*(z+2) for i in range(n-x+2)]for i in range(n+2)];dp[0][0][0]=0
for k in range(z+1):
  for j in range(n-x-k+1):
    for i in range(n-k-j+1):
      if i+j+k:dp[i][j][k]=((dp[i-1][j][k]*i if i else 0)+(dp[i+1][j-1][k]*j if j else 0)+(dp[i][j+1][k-1]*k if k else 0)+n)/(i+j+k)
print(dp[x][y][z])

Measured memory_bytes: 316424
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(int i=0; i<n; i++)
#define loop(i, j, n) for(int i=j; i<n; i++)
using namespace std;
// }}} End Header

int main()
{
	int n, T, min = 10000;
	cin >> n >> T;
	vector<int> c(n);
	vector<int> t(n);

	rep(i,n){
		cin >> c[i] >> t[i];
		if(t[i] <= T){
			if(c[i] < min) min = c[i];
		}
	}
	if(min == 10000) puts("TLE");
	else cout << min << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100000
int n,cnt=0;
int BinarySearch(int*,int);
int main(){
  int i,m,S[N],T[N];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&m);
   for(i=0;i<m;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<m;i++){
    BinarySearch(S,T[i]);
  }
    printf("%d\n",cnt);
  return 0;
}
int BinarySearch(int *A,int key){
  int left=0,right=n,mid;
  while(left<right){
    mid=(left+right)/2;
    if(A[mid]==key){
      cnt++;
      return mid;
    }
    else if(key<A[mid])right = mid;
    else left = mid + 1;
  }
    return 0;
  }



Measured memory_bytes: 2376
# coding: utf-8
# Your code here!
n = int(input())
x = list(map(int,input().split()))
x.sort()
ans = 1
limit = int(1e18)
flag = 1
if x[-1] == 0:
    print(0)
else:
    for i in range(n):
        ans *= x[i]
        if ans > limit:
            flag = 0
            break
    if flag ==1:
        print(ans)
    else:
        print(-1)

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

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

	int n, x, ali = 0, bob = 0;
	vector<int> a;
	cin >> n;
	for (int i = 0; i < n; ++i){
		cin >> x;
		a.push_back(x);
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; ++i){
		if (i % 2 == 0){
			ali += a[i];
		}else{
			bob += a[i];
		}
	}
	cout << ali - bob << "\n";
	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> G(n), x(n);
    vector<int> dp(n, 1), par(n);
    for(int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    function<void(int, int)> dfs1 = [&](int u, int p) {
        for(int v : G[u]) {
            if(v == p) {
                par[u] = x[u].size();
                x[u].push_back(-1);
            } else {
                dfs1(v, u);
                x[u].push_back((dp[v] + 1) % m);
                dp[u] = 1LL * dp[u] * x[u].back() % m;
            }
        }
    };
    dfs1(0, -1);
    function<void(int, int, int)> dfs2 = [&](int u, int p, int y) {
        if(p != -1) {
            x[u][par[u]] = y;
            dp[u] = 1LL * dp[u] * y % m;
        }
        vector<int> s = x[u];
        for(int i = 0; i + 1 < s.size(); i++)
            s[i + 1] = 1LL * s[i + 1] * s[i] % m;
        for(int i = s.size() - 1; i > 0; i--)
            x[u][i - 1] = 1LL * x[u][i - 1] * x[u][i] % m;
        for(int i = 0; i < s.size(); i++) {
            if(G[u][i] != p) {
                int a = (i ? s[i - 1] : 1);
                int b = (i + 1 < s.size() ? x[u][i + 1] : 1);
                dfs2(G[u][i], u, (1LL * a * b + 1) % m);
            }
        }
    };
    dfs2(0, -1, 1);
    for(int i = 0; i < n; i++)
        cout << dp[i] << endl;
}

Measured memory_bytes: 21760