akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main() {
	ULL n;
	cin >> n;
	V<ULL> a(n);
	RBF(ai, a) {
		cin >> ai;
	}

	const int b = 60;
	V<ULL> zeros(b, 0), ones(b, 0);
	RBF(ai, a) {
		bitset<b> bit(ai);
		REP(j, b) {
			if (bit[j]) {
				ones[j]++;
			}
			else {
				zeros[j]++;
			}
		}
	}

	ULL ans = 0, k = 1;
	REP(i, b) {
		ans += (zeros[i] * ones[i] % MOD) * k;
		ans %= MOD;
		k = k * 2 % MOD;
	}
	col(ans);
	return 0;
}

Measured memory_bytes: 5536
#include<stdio.h>
        int main(){
          int a[5];
          int i,k;
          
          for(i=0;i<5;i++)
            scanf("%d",&a[i]);
          scanf("%d",&k);
          
          if(a[4]-a[0]>k){
            printf(":(");
          }else{
            printf("Yay!");
          }
          
          return 0;
        }

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <fstream>
#include <string>
#include <sstream>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
    int x, n;
    cin >> x >> n;
    unordered_set<int> s;
    for(int i = 0; i < n; ++i) {
    	int t;
    	cin >> t;
    	s.insert(t);
    }
    int diff = 0;
    while(true) {
    	if(!s.count(x - diff)){
    		cout << x - diff << "\n";
    		return 0;
    	} else if(!s.count(x + diff)) {
    		cout << x + diff << "\n";
    		return 0;
    	}
    	diff++;
    }
	return 0;
}


Measured memory_bytes: 3252
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    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;
    int main(){
  string s,t;
  cin>>s>>t;
  for(int i=0;i<s.size();i++){
    if(s[i] != t[i]){
        cout<<"No";
        return 0;
    }
  }
  cout<<"Yes";
}

Measured memory_bytes: 3628
#include <stdlib.h>

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

main()
{ int K,N;
	scanf("%d%d",&N,&K);
    int l[50];
    int i,j,k;
    for(k=0;k<=N-1;k++){
    	scanf("%d",&l[k]);
    }
    int sum;
    sum=0;

    qsort(l, N, sizeof(int), compare_int);
    for (i = N-1; i >=N-K ; i--) {
    	sum+=l[i];
    }
   printf("%d",sum);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long int n;
  cin >> n;
  long int sum = 0;
  for(int i = 1; i < n+1; i++){
    if(i%3!=0 && i%5!=0){
      sum = sum + i;
    }
  }
  cout << sum << endl;
}

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

using namespace std;

int main()
{
	int t;
t=1;
	while(t--)
	{
	
	
   
	
	int i,j,k,n,x;
	cin>>x;
	cin>>n;
	int a[10000] {0};
	for(i=0;i<n;i++)
	{
		cin>>k;
		
		a[k]=1;
		
		
	}
	if(a[x]==0)
	cout<<x<<endl;
	
	else
	{
		int a1,b1,c1,d1;
		
		i=x;
		b1=0;
		while(a[i]!=0)
		{
			
			i--;
		b1++;	
			
			
		}
		
		a1=i;
		
		i=x;
		d1=0;
		while(a[i]!=0)
		{
			
			i++;
		d1++;	
			
			
		}
		
		c1=i;
		
	
		if(d1>b1)
		{
			
			cout<<a1<<endl;
		}
		
		else if(d1<b1)
		{
			cout<<c1<<endl;
			
		}
		
		else
		{
			cout<<min(a1,c1)<<endl;
			
			
		}
		
		
	}
	
	
	
	
	
	}



}


Measured memory_bytes: 3672
#include <stdio.h>

int main(void) {
	int y,m,d;
	while(scanf("%d%d%d",&y,&m,&d) != EOF){
		if(y <= 1867 || ((y == 1868) && ((m < 9) || (d < 8)))){
			printf("pre-meiji\n");
		}
		else if(y <= 1911 || ((y == 1912) && ((m < 7) || (d < 30)))){
			printf("meiji %d %d %d\n",y - 1867,m,d);
		}
		else if(y <= 1925 || ((y == 1926) && ((m < 12) || (d < 25)))){
			printf("taisho %d %d %d\n",y - 1911,m,d);
		}
		else if(y <= 1988 || ((y == 1989) && (d < 8))){
			printf("showa %d %d %d\n",y - 1925,m,d);
		}
		else{
			printf("heisei %d %d %d\n",y - 1988,m,d);
		}
	}
	return 0;
}

Measured memory_bytes: 604
use proconio::*;
use proconio::marker::Chars;

fn valid(s: &[char], p: i32, parity: i32) -> bool {
    let mut l = parity;
    let mut r = if p % 2 == 0 {
        p / 2 * 2 - parity
    } else {
        p / 2 * 2 + parity
    };
//    println!("query {} {}, s: {} {}", p, parity, l, r);
    for &c in s.iter() {
        match c {
            '0' => {
                l += 1;
                r += if r + 1 > p {
                    -1
                } else {
                    1
                };
            },
            '1' => {
                l -= if l == 0 {
                    -1
                } else {
                    1
                };
                r -= 1;
            },
            _ => {
                l -= if l == 0 {
                    -1
                } else {
                    1
                };
                r += if r + 1 > p {
                    -1
                } else {
                    1
                };
            },
        }
        if l > r {
            return false;
        }
    }
    true
}

fn run() {
    input! {
        s: Chars,
    }
    let mut ng = 0;
    let mut ok = 1_000_000;
    while ok - ng > 1 {
        let mid = (ok + ng) / 2;
        if valid(&s, mid, 0) || valid(&s, mid, 1) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    println!("{}", ok);
}

fn main() {
    run();
}


Measured memory_bytes: 6956
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) 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 (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion

#pragma region Combination
const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++)
	{
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k)
{
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
#pragma endregion


int main()
{
	int n, k; cin >> n >> k;
	COMinit();
	for (int i = 1; i <= k; ++i)
	{
		ll res = COM(n - k + 1, i)*COM(k - 1, i - 1);
		res %= MOD;
		cout << res << endl;
	}
}

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

int main(){
	int w, h, n;
	cin >> w >> h >> n;
	vector<vector<int>> data(n, vector<int>(3));
	for(int i=0; i<n; i++){
		for(int j=0; j<3; j++){
			cin >> data.at(i).at(j);
		}
	}
	vector<vector<int>> ori(w, vector<int>(h));
	for(int i=0; i<n; i++){
		if(data.at(i).at(2)==1){
			for(int j=0; j<data.at(i).at(0); j++){
				for(int k=0; k<h; k++){
					ori.at(j).at(k)++;
				}
			}
		}
		if(data.at(i).at(2)==2){
			for(int j=data.at(i).at(0); j<w; j++){
				for(int k=0; k<h; k++){
					ori.at(j).at(k)++;
				}
			}
		}
		if(data.at(i).at(2)==3){
			for(int j=0; j<data.at(i).at(1); j++){
				for(int k=0; k<w; k++){
					ori.at(k).at(j)++;
				}
			}
		}
		if(data.at(i).at(2)==4){
			for(int j=data.at(i).at(1); j<h; j++){
				for(int k=0; k<w; k++){
					ori.at(k).at(j)++;
				}
			}
		}
	}
	int num=0;
	for(int i=0; i<w; i++){
		for(int j=0; j<h; j++){
			if(ori.at(i).at(j)==0){
				num++;
			}
		}
	}
	cout << num << endl;
}


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

#define pi 3.141592654
#define fix(n) cout << fixed << setprecision(n)

#define rep(i,a,b) for(int i=a;i<b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)

#define ll  long long
#define ull unsigned long long

#define mp make_pair
#define pb push_back
#define fi first
#define se second

#define vi      vector<int>
#define pii     pair<int,int>
#define piii    pair<pair<int,int>,int>
#define all(v)  v.begin(), v.end()

int mod = 1000000007;
const int N = 1005;

// gcd
ll gcd(ll a , ll b)
{
    if ( b == 0)
    return a;
    return gcd( b, a % b);
}
int incnt[N];
int outcnt[N];
ll inweight[N];
ll outweight[N];
int desired[N];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string ans = "";
	for ( int i = 0; i < 3; i++)
    {
        
        for ( int j = 0; j < 3;j ++)
            
        {
            char x;
            cin >> x;
            if ( i == j)
            {
                ans += x;
            }
        }
    }
    cout << ans << endl;
	return 0;
}


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


int MOD=1000000007;

int main(void){
    int N;
    cin >> N;
    int A[N+10],B[N+10];
    for(int i=1; i<=N; i++){
        cin >> A[i];
        B[A[i]]=i;
    }
    for(int i=1; i<=N; i++){
        cout << B[i] << ' ';
    }
    cout << endl;

}


Measured memory_bytes: 1536
n = int(input())
march_l = [0]*5
for _ in range(n):
    s = input()
    s0 = s[0]
    if s0 == 'M':
        march_l[0] += 1
    elif s0 == 'A':
        march_l[1] += 1
    elif s0 == 'R':
        march_l[2] += 1
    elif s0 == 'C':
        march_l[3] += 1
    elif s0 == 'H':
        march_l[4] += 1

cnt =  [i for i in march_l if i != 0]
len_cnt = len(cnt)
ans = 0

if len_cnt > 3:
    for i in range(2**len_cnt):
        tmp = 1
        if str(bin(i)).count('1') == 3:
            for j in range(len_cnt):
                if ((i>>j) & 1):
                    tmp *= cnt[j]
            ans += tmp
elif len_cnt == 3:
    ans = 1
    for i in cnt:
        ans *= i
        
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    vector<int> data(n);
    for (auto &v : data)
        cin >> v;
    int cnt= 0 ;
    for (int i = 1 ; i < n - 1 ; i++) {
        vector<int> tmp;
        for (int j = 0 ; j < 3 ; j++)
            tmp.push_back(data[j + i - 1]);
        sort(tmp.begin(), tmp.end());
        if (tmp[1] == data[i])
            cnt++;
    }
    cout << cnt << '\n';
}


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


typedef long long ll;

const int MAX_N = 205000;

struct Edge
{
	int to;
	int next;
};
Edge G[2 * MAX_N];
int head[MAX_N];
int deg;
void init();
void add_edge(const int u, const int v);

bool vis[MAX_N];
void bfsc(const int v, const int d, int& maxd, int& t);

bool dp[MAX_N];

int main()
{
	int N, a, b;

	dp[1] = true;
	dp[2] = false;
	for (int i = 3; i < MAX_N; ++i)
	{
		if ((i - 2) % 3 == 0)
		{
			dp[i] = false;
		}
		else
		{
			dp[i] = true;
		}
	}
	init();

	scanf("%d", &N);

	for (int i = 1; i < N; ++i)
	{
		scanf("%d%d", &a, &b);
		add_edge(a, b);
	}

	memset(vis, true, sizeof(vis));
	int t = 1, maxd = 0;
	bfsc(1, 0, maxd, t);
	maxd = 0;
	memset(vis, true, sizeof(vis));
	bfsc(t, 0, maxd, t);

	printf("%s\n", dp[maxd + 1] ? "First" : "Second");

	return 0;
}

void init()
{
	memset(head, -1, sizeof(head));
	deg = 0;
}

void add_edge(const int u, const int v)
{
	G[deg].to = v;
	G[deg].next = head[u];
	head[u] = deg++;

	G[deg].to = u;
	G[deg].next = head[v];
	head[v] = deg++;
}


void bfsc(const int v, const int d, int& maxd, int& t)
{
	vis[v] = false;
	if (d > maxd)
	{
		maxd = d;
		t = v;
	}
	for (int i = head[v]; ~i; i = G[i].next)
	{
		const int& to = G[i].to;
		if (vis[to])
		{
			bfsc(to, d + 1, maxd, t);
		}
	}
}

Measured memory_bytes: 14080
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}


int main(){
  int n, i, j,v;
  int A[N+1];
  A[0] = A[1] = -1;
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);

  for(i=2;i<=n;i++){
    v=A[i];
    j=i-1;
    while(j>=1 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
      A[j+1]=v;
      trace(A,n);
    }

    return 0;
  }

Measured memory_bytes: 604
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n,k ;
	cin >> n >> k ;
	vll cnt(100001,0) ;
	for(int i=0;i<n;i++){
		ll a,b ;
		cin >> a >> b ;
		cnt.at(a) += b ;
	}
	ll sum = 0 ;
	for(int i=1;i<=100000;i++){
		sum += cnt.at(i) ;
		if(sum>=k){
			cout << i << endl ;
			return 0 ;
		}
	}
}


Measured memory_bytes: 1024
if __name__ == "__main__":
    import sys
    from collections import deque
    input = sys.stdin.readline
    N = int(input())
    edges = [[] for _ in range(N)]
    for i in range(N-1):
        a,b = map(int,input().split())
        a -= 1
        b -= 1
        edges[a].append((b,i))
        edges[b].append((a,i))

    color = [None]*(N-1)
    SIZE = 1
    q = deque([(0,None)])
    while q:
        v, prev_color = q.popleft()
        c = 1
        for w, i in edges[v]:
            if not color[i]:
                if c == prev_color:
                    c += 1
                color[i] = c
                c += 1
                q.append((w,color[i]))
        SIZE = max(SIZE, c-1)
    print(SIZE)
    for n in range(N-1):
        print(color[n])

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

int main(){
    
    int n,m;
    cin >> n >> m;
    int ans=0;
    ans+=n*(n-1)/2+m*(m-1)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())

// http://drken1215.hatenablog.com/entry/2019/03/03/205300

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> a(n), acc(n + 1, 0), plus(n + 1, 0);
    rep(i, n) {
        cin >> a[i];
        acc[i + 1] = acc[i] + a[i];
        plus[i + 1] = plus[i] + (a[i] > 0 ? a[i] : 0);
    }
    ll res = -(1LL << 60);
    for (int i = 0; i + k <= n; ++i) { // 区間の右端(開区間)が範囲の1つ外まで
        int l = i, r = i + k;
        ll tmp = (plus[l] - plus[0]) + (plus[n] - plus[r]);
        tmp += max(0LL, acc[r] - acc[l]); // 最後連続kを白にするか黒にするか
        chmax(res, tmp);
    }
    
    out(res);
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,height=0;
    ll cnt=0;
    cin>>n;
    int a[n+1];
    a[n]=0;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<=n;i++){
        if(a[i]>height){
            cout<<"-1\n";
            return 0;
        }
        if(a[i]<height){
            cnt+=height-1;
            height=a[i];
        }
        height++;
    }
    cout<<cnt<<endl;
    return 0;
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;
using namespace std;
#define MOD 1000000007


struct CNK{
	const int mod = 1000000007;
	int mx;
	
private:
	vi fac , ifac;
		
public:
	CNK(int max){
		mx = max;
		
		fac.resize(max + 1);
		ifac.resize(max + 1);
		
		fac[0] = ifac[0] = 1;
		
		for(int i = 1 ; i <= max ; ++i){
			fac[i] = (ll)fac[i - 1] * i % mod;
			ifac[i] = fpow(fac[i], mod - 2);
		}
	}
	
	int fpow(int a , int b){
		int ans = 1;
		while(b > 0){
			if(b & 1){
				ans = (1ll * ans * a) % mod;
			}
			a = (1ll * a * a) % mod;
			b /= 2;
		}
		return ans;
	}
	
	int cnk(int n , int k){
		assert(mx >= n);
		if (n < 0 || k < 0 || k > n) return 0;
		return (ll)fac[n] * ifac[n - k] % mod * ifac[k] % mod;
	}
};

pii sec(vi & v){
	vi used(sz(v) + 1 , 0);
	rep(i , sz(v)){
		int e = v[i];
		if(used[e])
			return {used[e] - 1 , i};
		used[e] = i + 1;
	}
}

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

	int n;
	cin >> n;
	
	vi v(n + 1);
	rep(i , n + 1){
		cin >> v[i];
	}
	
	auto m = sec(v);
	
	ll ans = 0;	
	
	CNK cnk(n + 1);
	
	repi(i , n + 1){
		ans = 0;
		if(i == 1){
			ans = n;
		}else if(i == n + 1){
			ans = 1;
		}else{
			ans = cnk.cnk(n + 1 , i) % MOD;
 
			ans -= cnk.cnk(n - m.se + m.fi , i - 1);
 
			ans %= MOD;
			while(ans < 0)ans += MOD;
		}
		cout << ans << nl;
	}	

	return 0;
}

Measured memory_bytes: 2424
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
 
typedef struct FOUNTAIN_DATA{
	int area;
	int plane;
	struct FOUNTAIN_DATA *next;
} ST_FOUNTAIN;
 
void push(ST_FOUNTAIN **p, ST_FOUNTAIN *d)
{
	d->next = *p;
	*p = d;
}
 
ST_FOUNTAIN *pop(ST_FOUNTAIN **p)
{
	ST_FOUNTAIN *d = *p;
	if(d != NULL)
	{
		*p = (*p)->next;
	}
	
	return d;
}
 
int main()
{
	char ch;
	int area;
	int plane;
	int total;
	int count;
	int loop;
	ST_FOUNTAIN *w1;
	ST_FOUNTAIN *w2;
	ST_FOUNTAIN *d;
	
	w1 = NULL;
	w2 = NULL;
	while((ch = getchar()) != '\n')
	{
		if(ch == '\\')
		{
			d = (ST_FOUNTAIN*)malloc(sizeof(ST_FOUNTAIN));
			d->area = 0;
			d->plane = 0;
			push(&w1, d);
		}
		else if(ch == '_')
		{
			d = pop(&w1);
			if (d != NULL)
			{
				d->plane++;
				push(&w1, d);
			}
			else
			{
				/* error process */
			}
		}
		else if(ch == '/')
		{
			area = plane = 0;
			while((d = pop(&w1)) != NULL)
			{
				/* merge foutain data with more depth point */
				area += d->area;	
				plane += d->plane;
				if(d->area == 0)	/* if check point */
				{
					break;
				}
				else
				{
					push(&w2,d);
				}
			}
 
			if(d != NULL)	/* calcration or merge foutain data with more depth point */
			{
				d->area = area + plane + 1;
				d->plane = plane + 2;
				push(&w1, d);
				while((d = pop(&w2)) != NULL)
				{
					free(d);
				}
			}
			else if (area > 0)
			{
				while((d = pop(&w2)) != NULL) push(&w1, d);
			}
		}
		else
		{
		}
	}
 
	total = count = 0;
	while((d = pop(&w1)) != NULL)
	{
		if(d->area == 0)
		{
			free(d);
			continue;
		}
 
		total += d->area;
		count++;
		push(&w2, d);
	}
 
	printf("%d\n", total);
	printf("%d", count);
	if (count > 0)
	{
		printf(" ");
		for(loop = 0; loop < count; loop++)
		{
			d = pop(&w2);
			printf("%d", d->area);
			free(d);
			if(loop + 1 < count) printf(" ");
		}
	}
	printf("\n");
 
	return 0;
}



Measured memory_bytes: 2284
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <utility>
#include <stack>
#include <vector>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

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

int main() {
	int m, f, r;
	while(scanf("%d %d %d", &m, &f, &r)) {
		if(m == -1 && f == -1 && r == -1) break;
		if(m == -1 || f == -1) printf("F\n");
		else {
			if(m + f >= 80) printf("A\n");
			else if(m + f >= 65 && m + f < 80) printf("B\n");
			else if(m + f >= 50 && m + f < 65) printf("C\n");
			else if(m + f >= 30 && m + f < 50) {
				if(r >= 50) printf("C\n");
				else printf("D\n");
			}
			else printf("F\n");
		}
	}
	return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
using qp=queue<pair<int,int>>;
 
int main(){
  int H,W; 
  cin>>H>>W;
  
  string s;
  vector<string> S(H+2,string(W+2,'#'));
  int cnt=0;
  REP(h,H) {
    cin>>s;
    S[h+1]='#'+s+'#';
    for(auto x: S[h+1]) if(x=='.') cnt++;
  }
  int I[H+2][W+2]={};
  qp Q;
  Q.push(make_pair(1,1));
  I[1][1]=1;
  int h,w,nh,nw;
  int dh[4]={1, 0,-1, 0};
  int dw[4]={0, 1, 0,-1};
  while(!Q.empty()){
    h=Q.front().first;
    w=Q.front().second;
    Q.pop();
    REP(i,4){
      nh=h+dh[i];
      nw=w+dw[i];
      if(S[nh][nw]=='.'&&I[nh][nw]==0){
        Q.push(make_pair(nh,nw));
        I[nh][nw]=I[h][w]+1;
      }
    }
  }
  int ans=(I[H][W])? cnt-I[H][W]: -1;
  cout<<ans<<endl;   
}

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

int main()
{
  string s, t;
  cin >> s >> t;

  vector<bool> table('z'-'a'+1, false);
  vector<vector<long long>> m('z'-'a'+1);
  for (long long i = 0; i < (long long)s.size(); i++) {
    char c = s.at(i);
    table.at(c-'a') = true;
    m.at(c-'a').push_back(i);
  }
  bool can_be_solved = true;
  for (char c : t) {
    if (!table.at(c-'a')) {
      can_be_solved = false;
    }
  }
  if (!can_be_solved) {
    cout << "-1\n";
    return 0;
  }

  long long cnt = 0;
  long long idx = -1;
  for (char c : t) {
    auto it = upper_bound(m.at(c-'a').begin(), m.at(c-'a').end(), idx);
    if (it == m.at(c-'a').end()) {
      idx = -1;
      cnt++;
      it = upper_bound(m.at(c-'a').begin(), m.at(c-'a').end(), idx);
    }
    idx = *it;
  }
  cout << s.size() * cnt + idx + 1 << '\n';

  return 0;
}


Measured memory_bytes: 1724
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() {
            var t = ReadLine();
            if (t.Trim().Length == 0) return new List<int>();
            return new List<int>(t.Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var AB = Sarray();
            var A = AB[0];
            var B = AB[1];
            if(9<A||9<B)
            {
                WriteLine(-1);
                return;
            }
                WriteLine(A*B);
        }
    }
}


Measured memory_bytes: 18924
c=0
i = 0
h = []
w = []
while c == 0:
    a = input().split()
    if int(a[0]) == 0:
        c = 1
    elif int(a[1]) == 0:
        c = 1
    else:
        h.append(a[0])
        w.append(a[1])
        i = int(i) + 1

for j in range(int(i)):
    for k in range(int(h[j])):
        for o in range(int(w[j])-1):
            print('#',end='')
        print('#')
    print('')


Measured memory_bytes: 7000
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 9e18;

signed main() {
    int N;
    cin >> N;
    vector<pair<int, int>> ratio(N);
    for (int i = 0; i < N; i++) {
        int T, A;
        cin >> T >> A;
        ratio[i] = {T, A};
    }
    int left = 1, right = 1;
    for (auto temp : ratio) {
        int time = max((left / temp.first) + (left % temp.first != 0), (right / temp.second) + (right % temp.second != 0));
        left = temp.first * time;
        right = temp.second * time;
    }
    cout << left + right << endl;

}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x) 
#define rep(i, n) for (int i = 0; i < n; ++i) 
#define fo(i, a, b) for (int i = a; i <= b; ++i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    int h[n][3]; rep(i, n) rep(j, 3) cin >> h[i][j];

    int dp[n+1][3];
    fill(all(dp[n]), 0);
    for (int i = n-1; i >= 0; --i) {
        for (int x = 0; x < 3; ++x) {
            dp[i][x] = 0;
            for (int y = 0; y < 3; ++y) if (y != x) {
                dp[i][x] = max(dp[i][x], dp[i+1][y] + h[i][y]);
            }
        }
    }

    cout << max({ dp[0][0], dp[0][1] }) << '\n';
}



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

const ll N = 55;
const long double eps = 1e-6;
ll n, a, b;
ll v[N];
ll choose[N][N];

void init() {
	for(int i = 1; i < N; i++) {
		choose[i][0] = choose[i][i] = 1;
		for(int j = 1; j < i; j++)
			choose[i][j] = choose[i-1][j] + choose[i-1][j-1];
	}
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> a >> b;
	for(int i = 1; i <= n; i++)
		cin >> v[i];
	sort(v+1, v+n+1, greater<ll>());
	init();

	long double sum = 0;
	for(ll i = 1; i < a; i++)
		sum += 1.0*v[i];

	ll ans = 0;
	long double best = -1;
	for(ll i = a; i <= b; i++) {
		sum += 1.0*v[i];
		long double avr = sum / (1.0*i);
		if(avr < best) continue;
		if(avr > best)
			best = avr, ans = 0;

		ll cnt = 0, need = 0;
		for(int j = i+1; j <= n && abs(v[j] - v[i]) < eps; j++)
			cnt++;
		for(int j = i; j > 0 && abs(v[j] - v[i]) < eps; j--)
			cnt++, need++;
		ans += choose[cnt][need];
	}	

	cout << fixed << setprecision(6) << best << '\n';
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)


int a, b;
int main() {
	REP(i, 7) {
		cin >> a >> b;
		cout << abs(a - b) << endl;
	}
}


Measured memory_bytes: 3080
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main() {

	string S;
	cin >> S;

	int shirokuro = 0;
	int kuroshiro = 0;
	int saisyou = 0;

	for (int i = 0;i < S.size();i++) {

		if (i % 2 == 0 && S[i] == '0') {
			shirokuro++;
		}
		else if (i % 2 == 1 && S[i] == '1') {
			shirokuro++;
		}

		else if (i % 2 == 0 && S[i] == '1') {
			kuroshiro++;
		}
		else if (i % 2 == 1 && S[i] == '0') {
			kuroshiro++;
		}
	}

	if (shirokuro <= kuroshiro) {
		saisyou = shirokuro;
	}
	else if (shirokuro >= kuroshiro) {
		saisyou = kuroshiro;
	}

	cout << saisyou << endl;

	return 0;
}

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

int main()
{
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int L = A + B, R = C + D;
  if (R > L){
    cout << "Right" << endl;
  }
  else if (R == L){
    cout << "Balanced" << endl;
  }
  else {
    cout << "Left" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include<cmath>
#include<string>
#define pb push_back
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
//void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
// look for  all edge cases
//search for a pattern

const int nax = 1e6+2;
bool prime[nax];


signed main() {    
	ios::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);
	
	int n;
	cin  >> n;
	unordered_set<int> s;
	map<int,int> m;
	vector<int> v(n);
	cin >> v[0];
	int val = v[0];
	s.insert(v[0]);
	m[v[0]] += 1;
	for(int i =1 ; i < n;i++){
		cin >> v[i];
		val = __gcd(val , v[i]);
		s.insert(v[i]);
		m[v[i]] += 1;
	}
	 
	if(val != 1){
		cout<<"not coprime";
		return 0;
	}
	//if((int)s.size() != n){
		//debug("hi");
		//cout<<"setwise coprime";
		//return 0;
	//}
	
	
	
	for(int i =1 ; i < nax ; i++){
		prime[i] = true;
	}
	
	bool ok = true;
	for(int i = 2 ; i < nax; i++){
		int cnt = 0;
		if(prime[i] == true){
			if(s.find(i) != s.end()){
				cnt += m[i];
			}
			for(int j = 2 * i ; j < nax ; j += i ){
				prime[j] = false;
				if(s.find(j) != s.end()){
					cnt += m[j];
				}
			}
		}
		//debug(i , cnt);
		if(cnt > 1)	{
			//debug("hi");
			ok = false;
			break;
		}
	} 
	
	if(ok){
		cout<<"pairwise coprime";
	}
	else{
		cout<<"setwise coprime";
	}
	 
	return 0;
}


Measured memory_bytes: 114080
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

int main(){
  int N;cin>>N;
  vector<ll>A(100001,0);
  ll sum=0;
  for(int i=0;i<N;i++){
    int a;cin>>a;
    A[a]+=1;
    sum+=a;
  }
  int Q;cin>>Q;
  while(Q--){
    int b,c;
    cin>>b>>c;
    sum+=A[b]*(c-b);
    A[c]+=A[b];
    A[b]=0;
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 4028
import bisect


def triangles():
    n = int(input())
    l = [int(v) for v in input().split()]
    l.sort()

    count = 0
    for i in range(n):
        for j in range(i + 1, n):
            c = l[i] + l[j]
            index = bisect.bisect_left(l, c)
            count += max(index - j - 1, 0)

    print(count)


if __name__ == '__main__':
    triangles()


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

int main(void){
 int A, B, K;
  cin >> A >> B >> K;
  int large = max(A, B);
  int count = 0;
  int i = 1;
  for(i = large; i > 1; i--){
    if(A % i == 0 && B % i == 0){
      count++;
      if(count == K){
       break;
      }
    }
  }
  cout << i;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define sz size
#define pb push_back
#define er erase
#define in insert
#define fr first
#define sc second
#define mp make_pair
#define pi pair
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
#define rc(s) return cout<<s,0
const int mod=1e9+7;
const int inf=1e5;
using namespace std;

int a,b,c;

int main(){ _
    cin >> a >> b>> c;
    if(a+b>=c) rc("Yes");
    else rc("No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long 
#define ii pair<int,int>
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define inf 1000000005
#define MOD 1000000007 
#define N 305
#define M 1000003
#define LOG 20
#define KOK 250
#define EPS 0.0000001
using namespace std;

int n,m;
int dp[N][N][N],vis[N][N][N];
vector<ii> v[N];

int mul(int x,int y) {
	
	return (ll)x*y%MOD;

}

int add(int x,int y) {

	x+=y;

	if(x>=MOD) x-=MOD;
	if(x<0) x+=MOD;

	return x;

}

bool ok(int A,int B,int C) {

	for(auto x:v[A]) {

		if(x.nd==1) {

			if(x.st<=B) return 0;

		}
		else if(x.nd==2) {

			if(x.st>B || x.st<=C) return 0;

		}
		else {

			if(x.st>C) return 0;

		}

	}

	return 1;

}

int f(int A,int B,int C) {

	if(!ok(A,B,C)) return 0;

	if(A==n) return 1;

	int& res=dp[A][B][C];
	int& vs=vis[A][B][C];

	if(vs) return res;

	vs=1;

	return res=add(f(A+1,B,C),add(f(A+1,A,C),f(A+1,A,B)));

}

int main() {

	scanf("%d %d",&n,&m);

	for(int i=1;i<=m;i++) {

		int l,r,x;

		scanf("%d %d %d",&l,&r,&x);

		v[r].pb({l,x});

	}

	printf("%d",f(0,0,0));

}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main()
{
	int N;
	vector<int> L;
	int count = 0;

	cin >> N;
	rep(i, N)
	{
		int tmp;
		cin >> tmp;
		L.push_back(tmp);
	}

	sort(L.begin(), L.end());

	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
        	for(int k = j + 1; k < N; k++)
            {
            	if(L[k] < L[i] + L[j])
                	count++;
            }
		}
	}

	cout << count << endl;

	return 0;
}


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<P> a(n);
  rep(i, n) {
    int tmp;
    cin >> tmp;
    a[i] = make_pair(tmp, i + 1);
  }

  sort(a.begin(), a.end());

  rep(i, n) {
    if (i != 0) {
      cout << " ";
    }
    cout << a[i].second;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1536
s=list(input())
n=len(s)
s1=["0"for i in range(n)]
s2=["1"for i in range(n)]
for i in range(0,n,2):
    s1[i]="1"
    s2[i]="0"
tmp1=0
tmp2=0
for i in range(n):
    if s[i]!=s1[i]:
        tmp1+=1
    if s[i]!=s2[i]:
        tmp2+=1
print(min(tmp1,tmp2))

Measured memory_bytes: 11244
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;

int main()
{
	int n,k,ans=0;
	string s;
	cin >> s;
	
	int cnt = 1;
	for (int i = 0; i < s.size(); i++) {
		if (cnt % 2 == 0) {
			if (s[i] == 'R') {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			if (s[i] == 'L') {
				cout << "No" << endl;
				return 0;
			}
		}
		cnt++;
	}
	cout << "Yes" << endl;
	return 0;
}



Measured memory_bytes: 256
ai = lambda: list(map(int,input().split()))

mod = 10**9+7


def nCb(n, b):
    if b > n - b:
        b = n - b
    r = 1
    for k in range(n, n-b, -1):
        r = r * k % mod
    d = 1
    for k in range(1, b+1):
        d = d * k % mod
    return r * inv(d) % mod


def inv(x):
    return pow(x, mod - 2, mod)


h,w,a,b = ai()
aa = h-a-1
bb = w-b-1
c1 = nCb(aa+b, b)
c2 = nCb(a+bb-1, bb)
ans = c1 * c2
ans %= mod

for i in range(1, bb+1):
    c1 = c1 * (aa + b + i) * inv(b + i) % mod
    c2 = c2 * (bb - i + 1) * inv(a + bb - i) % mod
    ans += c1 * c2
    ans %= mod
print(ans)


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

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

    vector<unsigned long long> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    for(int i = 0; i < n; i++)
    {
        if(a[i] == 0)
        {
            cout << 0;
            return 0;
        }
    }

    unsigned long long ans = a[0];
    unsigned long long limit = pow(10, 18);
    for(int i = 1; i < n; i++)
    {
        if(ans > limit / a[i])
        {
            cout << -1;
            return 0;
        }

        ans *= a[i];
    }

    cout << ans;

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  ll ans = 0;
  rep(i, n) {
    if (i%2 == 0) ans += d[i];
    else ans -= d[i];
  }
  rep(i, n) {
    cout << ans << ' ';
    ans = (d[i] - ans/2) * 2;
  }
  return 0;
}

Measured memory_bytes: 3748
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	var n int
	n = nextInt()

	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	for j := 1; j < n; j++ {
		printSlice(a)
		v := a[j]
		l := j - 1
		for l >= 0 && a[l] > v {
			a[l+1] = a[l]
			l--
		}
		a[l+1] = v
	}
	printSlice(a)

}

func printSlice(s []int) {
	length := len(s)
	for i, v := range s {
		if i == length-1 {
			fmt.Printf("%d\n", v)
		} else {
			fmt.Printf("%d ", v)
		}
	}

}


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

int main(){
  int N;
  bool flg = false;
  cin >> N;
  for(int i ; i < N ; i++){
    string s;
    cin >> s;
    if(s == "Y"){
      flg = true;
      break;
    }
  }
  if(flg){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))
tot = np.sum(A)

if tot > N:
	print(-1)
else:
	print(N-tot)

Measured memory_bytes: 27780
import sys
import queue
input = sys.stdin.readline

N = int(input())
alist = [[] for _ in range(N+1)]
idx = {}
for i in range(N-1):
    a, b = map(int, input().split())
    alist[a].append(b)
    alist[b].append(a)
    idx[(a, b)] = i
    idx[(b, a)] = i

q = queue.Queue()
ans = [0]*(N-1)
typeNum = 0
for a in alist:
    typeNum = max(typeNum, len(a))

f = [False]*(N+1)
q.put([1, 1])
f[1] = True
while not q.empty():
    n = q.get()
    c = n[1]
    for nxt in alist[n[0]]:
        if not f[nxt]:
            ans[idx[(n[0], nxt)]] = c
            c = c % typeNum+1
            q.put([nxt, c])
            f[nxt] = True

print(typeNum)
print(*ans, sep='\n')


Measured memory_bytes: 99612
/*
Created by Rishu Sahu
*/
/*
*****************************************************************
*/

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define pai pair<int,int>
#define f first
#define s second
#define sz(x) (int)x.size()
#define vi vector<nt>

const int mod = 1e9+7;
const int INF = INT_MAX;



void solve(){
   ll x,k,d;
   cin>>x>>k>>d;
   ll req=(abs(x))/d;
   if(req>=k){
        cout<<""<<abs(x)-d*k<<endl;
   }else{
        k=k-req;
        x=abs(x)-req*abs(d);
        if(k%2==0){
            cout<<""<<abs(x)<<endl;
        }
        else{
            cout<<""<<d-abs(x)<<endl;
        }
   }


}


int main(){
    /*int t;
    cin>>t;
    while(t--){*/
        solve();
    //}
}
/*
1000000000000000
1000000000000000
1000000000000000
*/


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

int main() {
  string s;
  while (cin >> s) {
    ll a = 0, bc = 0, result = 0;
    s += "########$$$$$$$$";
    for (int i = 0; s[i] != '$';) {
      if (s[i] == 'A') {
        a++;
        i++;
      } else if (s[i] == 'B' && s[i+1] == 'C') {
        bc++;
        result += a;
        i += 2;
      } else {
        a = bc = 0;
        i++;
      }
    }
    cout << result << endl;
  }
}


Measured memory_bytes: 832
#include<iostream>

using namespace std;

int a[27];
string str;
int main(){
    while(getline(cin, str)){
        for(int i = 0; i < str.length(); ++i){
            if(islower(str[i])) ++a[str[i] - 'a'];
            else if(isupper(str[i])) ++a[str[i] - 'A'];
        }
    }
    for(int i = 0; i < 26; ++i){
        cout << (char)('a' + i) << " : " << a[i] << endl; 
    }
    return 0;
}


Measured memory_bytes: 3212
// 2011/02/20 Tazoe

#include <iostream>
using namespace std;

void eratos(bool prime[], int n)
{
	if(n>=1)
		prime[0] = false;
	if(n>=2)
		prime[1] = false;

	for(int i=2; i<n; i++)
		prime[i] = true;

	for(int i=2; i<n; i++){
		if(!prime[i])
			continue;
		for(int j=i+i; j<n; j+=i)
			prime[j] = false;
		if(n<i*i)
			return;
	}
}

int main()
{
	bool prime[1000001];
	eratos(prime, 1000001);

	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		int cnt = 0;
		for(int p=2; p<=n-p; p++)
			if(prime[p]&&prime[n-p])
				cnt++;

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

        int N=gi();

        //System.out.println(ans);

        if(N>=30) {

		    System.out.println("Yes");
        } else {
        	System.out.println("No");

        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> a(3 * N);
    for (int i = 0; i < 3 * N; i++) {
        cin >> a.at(i);
    }
    long sum = 0;
    sort(a.begin(), a.end(), greater<int>());
    for (int i = 0; i < N; i++) {
        sum += a.at(2 * i + 1);
    }
    cout << sum << endl;
}

Measured memory_bytes: 1408