akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#define int long long
using namespace std;
int n,top,minn;
const int N=1000010;
int a[N],zhan[N],r[N],l[N];
long long ans;
signed main()
{
	cin>>n;
	for(int i=1;i<=n;++i)scanf("%lld",&a[i]);
	for(int i=1;i<=n;++i)r[i]=n+1,l[i]=0;
	for(int i=1;i<=n;++i)
	{
		while(top&&a[zhan[top]]>a[i])r[zhan[top--]]=i;
		l[i]=zhan[top];
		zhan[++top]=i;
	}
	for(int i=1;i<=n;++i)ans+=(r[i]-i)*(i-l[i])*a[i];
	cout<<ans;
	return 0;
}
/*
8
5 4 8 1 2 6 7 3
*/

Measured memory_bytes: 14080
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	scanner := makeWordScanner()
	n := eGetInt(scanner)
	k := eGetInt(scanner)
	hs := make([]int, n)
	for i := 0; i < n; i++ {
		hs[i] = eGetInt(scanner)
	}
	if k >= n {
		fmt.Println("0")
	} else {
		n = n - k
		sort.Sort(sort.Reverse(sort.IntSlice(hs)))
		hs = hs[k:]
		var count int64
		for _, v := range hs {
			count += int64(v)
		}
		fmt.Println(count)
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func pow(a, n int) int {
	return int(math.Pow(float64(a), float64(n)))
}
func countBitOfOn(i, numbits int) int {
	count := 0
	var bit uint64
	for bit = 0; bit < uint64(numbits); bit++ {
		t := 1 << bit
		if i&t > 0 {
			count++
		}
	}
	return count
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    string p, q;
    for (int i = 0; i < n; i++) {
        char pi;
        cin >> pi;
        p += pi;
    }
    for (int i = 0; i < n; i++) {
        char qi;
        cin >> qi;
        q += qi;
    }
    set<string> s;
    s.insert("");
    for (int i = 1; i <= n; i++) {
        set<string> new_s;
        for (auto e: s) {
            int size = e.size();
            for (int k = 0; k < size; k++) {
                string ns = e.substr(0, k) + to_string(i) + e.substr(k, size - k);
                new_s.insert(ns);
            }
            new_s.insert(e + to_string(i));
        }
        s = new_s;
    }
    int idx = 0;
    int a = 0, b = 0;
    for (auto ss: s) {
        if (ss == p) {
            a = idx;
        }
        if (ss == q) {
            b = idx;
        }
        idx++;
    }
    cout << abs(a - b) << "\n";
    return 0;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
 
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
 
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())
 
template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }
 
const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int N = 2e3 + 10;
const int M = 2e3 + 10;
const int mod = 1e9 + 7;
 
#define FILENAME ""
 
int n;
int m;

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

ll dp[N][M];
int grid[N][M];

ll f (int x, int y) {
	if (x >= n || y >= m) re 0;
	if (x == n - 1 && y == m - 1) re 1;
	if (dp[x][y] != -1) re dp[x][y];
	if (!grid[x][y]) {
		dp[x][y] = 0;
		re 0;
	}
	dp[x][y] = 0;
	for (int i = 0; i < 2; i++) {
		dp[x][y] += f (x + dx[i], y + dy[i]) % mod;
		dp[x][y] %= mod;
	}	
	re dp[x][y];
}
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
//  freopen(FILENAME ".in", "r", stdin);
//  freopen(FILENAME ".out", "w", stdout);
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
	        char x;
			cin >> x;
			dp[i][j] = -1;
			grid[i][j] = (x == '.' ? 1 : 0);
		}
	}
	cout << f (0, 0);
	
    re 0;
}

Measured memory_bytes: 27008
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

string S, T;
map<char, char> S_cnt,T_cnt;

void solve(){
    bool flag = true;

    rep(i, S.size()){
        char s = S[i], t = T[i];
        if(S_cnt.count(s)) if(S_cnt[s] != t) flag = false;
        if(T_cnt.count(t)) if(T_cnt[t] != s) flag = false;
        S_cnt[s] = t, T_cnt[t] = s;
    }

    if(flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int main(){
    cin >> S >> T;

    solve();
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll              long long 

void solve(){
		int n;
		cin >> n;
		cout << (n>=30?"Yes":"No");
}
int main(){
		FIO;
//		int t; cin >> t;
//		while(t--)
			solve();
		return 0; 
}
/*

*/

Measured memory_bytes: 3636
import java.util.*;
import java.io.*;

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

        int ans = 700;
        for(int i = 0; i < c.length; i++){
            if(c[i] == 'o'){
                ans += 100;
            }
        }
        
        System.out.println(ans);

        sc.close();
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
int cnt[100000];
int main() {
  int n,m;
  cin>>n>>m;
    string s;
    cin>>s;
    for(int i=1;i<s.length();i++){
      if(s[i-1]=='A'&&s[i]=='C') cnt[i]++;
      cnt[i]+=cnt[i-1];
    }
    for(int i=0;i<m;i++){
      int l,r;
      cin>>l>>r;
      cout<<cnt[r-1]-cnt[l-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 int main(){
   int N;
   cin>>N;
   vector<int>p(N);
   for(int i=0;i<N;i++){
     cin>>p[i];
     }
   sort(p.begin(),p.end());
   p[N-1]/=2;
   int ans=0;
   for (int i=0;i<N;i++){
   ans+=p[i];
   }
   cout<<ans<<endl;
   return 0;
   }

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
a, v = map(int,input().split())
b, w = map(int,input().split())
t = int(input())

if a == b:
    print("YES")
    exit()

if v <= w:
    print("NO")
    exit()

#print(b-a, w-v, t*(w-v))
if a < b:
    if (b - a) <= t * (v - w): #(b - a) // (w - v) <= t
        print("YES")
    else:
        print("NO")
elif a > b:
    if (a - b) <= t * (v - w): #(a - b) // (v - w) <= t
        print("YES")
    else:
        print("NO")


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

int main(){
    long x,a,b;
    cin >> x >> a >> b;
    if(b <= a){
        cout << "delicious" << endl;
    }
    else if(b <= a + x){
        cout << "safe" << endl;
    }
    else{
        cout << "dangerous" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
typedef	long long ll;
typedef unsigned long long ull;
#define all(v) ((v).begin()),((v).end())
#define PI(n) ((double)acos(n))
int dx8[8] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy8[8] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	// online submission
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
}
vector<vector<int>> gh(1e5+1);
int vis[100001];
int cnt = 0;
bool ff = 0;
int n;
vector<int> bfs2(int st){
	queue<int>q;
	vector<int>len(100001, 100005); // intialize be infinte
	q.push({ st });
	len[st] = 0;
	int dep = 0;
	while (!q.empty()){
		dep++;
		int sz = q.size();
		while (sz--){
			int node = q.front();
			q.pop();
			for (int i = 0; i < gh[node].size(); i++){
				int nxtnode = gh[node][i];
				if (len[nxtnode] == 100005){
					len[nxtnode] = dep;
					q.push(nxtnode);
				}
			}
		}
	}
	return len;
}
int main()
{
	fast();
	cin >> n;
	for (int i = 0; i < n-1; i++){
		int u, v;
		cin >> u >> v;
		gh[u].push_back(v);
		gh[v].push_back(u);
	}
	vector<int>v1, v2;
	v1 = bfs2(1);
	v2 = bfs2(n);
	int c1=0, c2 = 0;
	for (int i = 2; i < n; i++){
		if (v1[i] <= v2[i])
			c1++;
		else c2++;
	}
	if (c1>c2)
		cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
}

Measured memory_bytes: 6656
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
#include <string>
#include <numeric>
using namespace std;

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

    long long ans = 0;
    for (int a = 1; a <= K; ++a)
    {
        for (int b = 1; b <= K; ++b){
            for (int c = 1; c <= K; ++c){
                ans += gcd(gcd(a, b), c);
            }
        }

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

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std;
#define maxn 10000000

int n,cnt=0; 
int a[195]; 
int main()
{
	cin>>n;
	rep(i,0,n)
		cin>>a[i];
	rep(i,0,n)
	{
		if(i%2==0 && a[i]%2==1) cnt++; 
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int ara[4];
    cin>>ara[0]>>ara[1]>>ara[2];
    sort(ara,ara+3);
    if(ara[0]+ara[1]==ara[2])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}


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

int main() {
    string r,g,b;
    cin>>r>>g>>b;
    string s=r+g+b;
    int k=stoi(s);
    if (k%4==0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define st(v) sort(v.begin(),v.end());
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> ii;

const int MAXN = 2e5+3; //AREGLAAAAAAAAR!!!!
const int MAXLOG = 20;
int good = 0;
char s[101];

int main(){
	ll k;
	scanf("%s",s);
	lri(k);
	int n = strlen(s);
	FOR(i,0,n){
		if(k==1){
			printf("%d\n",s[i]-'0');
			return 0;
		}
		if(s[i]!='1'){
			printf("%d\n",s[i]-'0');
			return 0;
		}
		k--;
	}
}
	

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

typedef long long ll;

int main(){
    int n, k;
    cin >> n >> k;
    vector<bool> d(10, true);
    for(int i = 0; i < k; i++)
    {
        int c; cin >> c;
        d[c]=false;
    }
    
    int ans = n;
    while(1){
        int num = ans, t;
        bool ok= true;
        while(num>0){
            t = num%10;
            if(!d[t]) ok=false;
            num/=10;
        }
        if(ok) break;
        ans++;
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}
void YES_NO(bool f) {
  if (f)
    printf("YES\n");
  else
    printf("NO\n");
}

template <typename T>
void deb1(T x) {
  cout << x << "\n";
}

template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  string s;
  cin >> s;
  out(s[0] + to_string(size(s) - 2) + s[size(s) - 1]);
}
int main(void) { solve(); }

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)
 
int n;
 
bool f(vector<vector<int>> v, vector<int> r){
    map<int,int> mp[3];
    rep(j,3){
        map<int,int> &mpp = mp[j];
        vector<int> tmp;
        rep(i,n){
            tmp.pb(v[i][j]);
        }
        sort(all(tmp));
         
        rep(i,tmp.size()){
            mpp[tmp[i]] = r[i];
        }
    }
     
    vector<pii> s;
    rep(i,n){
        int tmp = 0;
        rep(j,3){
            tmp+=mp[j][v[i][j]];
        }
        s.pb(pii(-tmp,i));
    }
     
    sort(all(s));
     
    int pos=-1;
    rep(i,s.size()){
        if(s[i].second==0){
            pos = i;
            break;
        }
    }
    assert(pos!=-1);
    if(pos<8)return true;
    else return false;
}
 
int main(){
    cin>>n;
    vector<int> r(n);
    rep(i,n)cin>>r[i];
    reverse(all(r));
     
    vector< vector<int> > v(n,vector<int>(3));
    rep(i,n)rep(j,3)cin>>v[i][j];
     
    int ans = INF;
    rep(i,101){
        rep(j,3){
            v[0][j]+=i;
             
            if(f(v,r)){
                ans = min(ans,(int)i);
            }
             
            v[0][j]-=i;
        }
    }
    if(ans==INF)cout<<"Saiko"<<endl;
    else cout<<ans<<endl;
}

Measured memory_bytes: 3172
package main

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

func main() {
	var n, m, an int
	fmt.Scanf("%d %d", &n, &m)
	sc := bufio.NewScanner(os.Stdin)
	var k [][]int
	var p []int
	for i := 0; i < m; i++ {
		k = append(k, []int{})
		sc.Scan()
		strs := strings.Split(sc.Text(), " ")
		for l, j := range strs {
			tmp, _ := strconv.Atoi(j)
			if l != 0 {
				k[i] = append(k[i], tmp)
			}
		}
	}
	sc.Scan()
	strs := strings.Split(sc.Text(), " ")
	for _, i := range strs {
		tmp, _ := strconv.Atoi(i)
		p = append(p, tmp)
	}

	for ons := 0; ons < (1 << n); ons++ {
		var a bool
		for i := 0; i < m; i++ {
			if !judgment(i, ons, k, p) {
				a = true
				break
			}
		}
		if !a {
			an++
			//fmt.Printf("%b ", ons)
		}
	}
	//fmt.Printf("\n")
	fmt.Println(an)
}

func judgment(i int, ons int, k [][]int, p []int) bool {
	on := 0
	for _, j := range k[i] {
		if (ons & (1 << (j - 1))) > 0 {
			on++
		}
	}
	if on%2 == p[i] {
		return true
	}
	return false
}


Measured memory_bytes: 1860
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   int n;
           string s;
           cin>>n>>s;
           int x=0;
           int ans=0;
           rep(i,0,n){
            if(s[i]=='I')x++;
             else x--;
             chmax(ans,x);
           }
           cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main()
{
    unsigned int num,div;
    cin>>num;
    div=num%10;
    if(div==2 || div==4 || div==5 || div==7 || div==9) cout<<"hon"<<endl;
    else if(div==0 || div==1 || div==6 || div==8) cout<<"pon"<<endl;
    else cout<<"bon"<<endl;
    return 0;
}


Measured memory_bytes: 3544
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long ll;

const int mod = 998244353;

template<typename T>
struct BIT {
	int n;
	vector<T> d;
	BIT(int n = 0) : n(n), d(n + 1) {}
	void add(int i, T x = 1) {
		++i;
		while (i <= n) {
			d[i] += x;
			i += i & -i;
		}
	}
	T sum(int i) {
		++i;
		T x = 0;
		while (i > 0) {
			x += d[i];
			i -= i & -i;
		}
		return x;
	}
};

long long mod_pow(long long a, long long p) {
	long long ans = 1;

	while (p != 0) {
		if (p & 1) {
			ans = ans * a % mod;
		}
		a = a * a % mod;
		p = p >> 1;
	}
	return ans;
}

ll f(int a, int b, int c, int d) {
	ll res = 0;
	vector<int> num = {a, b, c, d};
	vector<ll> o(4), ox(4);
	for (int i = 0; i < 4; i++) {
		ox[i] = mod_pow(2, num[i]);
		o[i] = ox[i] - 1;
	}
	ll v = ((ox[0] % mod) * (o[1] % mod)) % mod;
	ll w = (v * (o[2] % mod)) % mod;
	ll x = (w * (ox[3] % mod)) % mod;
	res += x;
	res %= mod;
	v = ((o[0] % mod) * (ox[1] % mod)) % mod;
	w = (v * (ox[2] % mod)) % mod;
	x = (w * (o[3] % mod)) % mod;
	res += x;
	res %= mod;
	v = ((o[0] % mod) * (o[1] % mod)) % mod;
	w = (v * (o[2] % mod)) % mod;
	x = (w * (o[3] % mod)) % mod;
	res -= x;
	res %= mod;
	v = ((ox[0] % mod) * (ox[1] % mod)) % mod;
	w = (v * (ox[2] % mod)) % mod;
	x = (w * (ox[3] % mod)) % mod;
	res += x;
	res %= mod;
	return res;
}

int main(int argc, char *argv[])
{
	int N;
	pair<int, int> p[200005];

	cin >> N;
	
	for (int i = 0; i < N; i++) {
		cin >> p[i].first >> p[i].second;
	}
	{
		map<int, int> mp;
		for (int i = 0; i < N; i++) {
			mp[p[i].first] = 0;
		}
		int j = 0;
		for (auto&& x : mp) {
			x.second = j++;
		}
		for (int i = 0; i < N; i++) {
			p[i].first = mp[p[i].first];
		}
	}
	{
		map<int, int> mp;
		for (int i = 0; i < N; i++) {
			mp[p[i].second] = 0;
		}
		int j = 0;
		for (auto&& x : mp) {
			x.second = j++;
		}
		for (int i = 0; i < N; i++) {
			p[i].second = mp[p[i].second];
		}
	}

	sort(p, p + N);
	int a[200005], b[200005], c[200005], d[200005];
	for (int i = 0; i < 2; i++) {
		BIT<ll> bit(N);
		for (int i = 0; i < N; i++) {
			a[i] = bit.sum(p[i].second);
			b[i] = i - a[i];
			bit.add(p[i].second);
		}
		reverse(p, p + N);
		swap(a, c);
		swap(b, d);
		reverse(a, a + N);
		reverse(b, b + N);
		reverse(c, c + N);
		reverse(d, d + N);
	}

	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ans += f(a[i], b[i], c[i], d[i]);
		ans %= mod;
	}

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

Measured memory_bytes: 14336
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        n: usize,
        a: [u64;n],
    }

    let mut money = 1000;
    let mut stock = 0;

    for i in 0..n - 1 {
        if a[i] < a[i + 1] && money >= a[i] {
            stock += money / a[i];
            money -= stock * a[i];
        }
        if a[i] > a[i + 1] && stock > 0 {
            money += stock * a[i];
            stock = 0;
        }
    }

    money += stock * a[n - 1];
    println!("{}", money);
}


Measured memory_bytes: 2128
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <bitset>
using namespace std;
const int INF = 0xfffffff;

int main()
{
	int h, w;
	cin >> h >> w;
	int first[105][105] = { 0 };
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			char a;
			cin >> a;
			if (a == '#') first[i][j] = 1;
		}
	}
	int second[105][105] = { 0 };
	int newh = h, newi = 0;;
	for (int i = 0; i < h; i++) {
		bool flag = true;
		for (int j = 0; j < w; j++) {
			if (first[i][j] == 1) {
				flag = false;
				second[newi][j] = 1;
			}
		}
		if (!flag) newi++;
		if (flag) newh--;
	}

	int third[105][105] = { 0 };
	int neww = w;
	newi = 0;
	for (int i = 0; i < w; i++) {
		bool flag = true;
		for (int j = 0; j < newh; j++) {
			if (second[j][i] == 1) {
				flag = false;
				third[j][newi] = 1;
			}
		}
		if (!flag) newi++;
		if (flag) neww--;
	}

	for (int i = 0; i < newh; i++) {
		for (int j = 0; j < neww; j++) {
			if (third[i][j] == 1) cout << '#';
			else cout << '.';
		}
		cout << endl;
	}
    return 0;
}



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

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

vector<int> g[100005];// 0-indexed
int root[100005];
const int inf=1e8;
vector<int> d(100005, inf);
int N, K;

void f(int i, int p=-1){
  int ret=inf;
  for(int j: g[i])if(j!=p){
    f(j, i);
    ret=min(ret, d[j]);
  }
  if(ret==inf) d[i]=0;
  else d[i]=ret+1;
}

int main(){

  cin>> N>> K;
  repeat(i, N){
    int x; cin>> x;
    if(x==0){
      root[i]=1;
    }else{
      g[x-1].push_back(i);
      // g[i].push_back(x-1);
    }
  }

  repeat(i, N)if(root[i]){
    f(i);
  }

  int c=0;
  repeat(i, N){
    if(root[i]) c++;
    else c+=(d[i]<K);
  }
  cout<< c<< endl;

  return 0;
}

Measured memory_bytes: 18180
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 11;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

class edge {
public:
	int s, e;
	ll f;
	edge() {
		*this = edge(0, 0, 0);
	}
	edge(int s, int e, ll f) : s(s), e(e), f(f) {}
};
vector <edge> Ve;
vector <int> fconn[100050];
void epush(int s, int e, ll f) {
	fconn[s].push_back(Ve.size());
	fconn[e].push_back(Ve.size() + 1);
	Ve.emplace_back(s, e, f);
	Ve.emplace_back(e, s, 0);
}
ll dchk[100050];
ll DFS(int n, int snk, ll C, ll F) {
	if (n == snk) return F;
	dchk[n] = C;
	for (auto it : fconn[n]) {
		edge& ed = Ve[it];
		if (ed.f == 0 || dchk[ed.e] == C) continue;
		ll t;
		if (t = DFS(ed.e, snk, C, min(F, ed.f))) {
			ed.f -= t;
			Ve[it ^ 1].f += t;
			return t;
		}
	}
	return 0;
}
void init(int snk) {
	int i;
	for (i = 0; i <= snk; i++) {
		fconn[i].clear();
		dchk[i] = false;
	}
	Ve.clear();
}

int main() {
	int N, i, j;
	scanf("%d", &N);

	int src = 0, snk = 2 * N + 1;
	for (i = 1; i <= N; i++) {
		ll t;
		scanf("%lld", &t);

		ll t1 = (ll)INF * 101 - t;
		ll t2 = (ll)INF * 101;
		epush(src, i, t1);
		epush(i + N, snk, t2);
		epush(i, i + N, LL_INF);
	}
	for (i = 1; i <= N; i++) for (j = i; j <= N; j += i) epush(i, j + N, LL_INF);

	ll f = 0, t;
	while (t = DFS(src, snk, f + 1, LL_INF)) f += t;
	return !printf("%lld\n", -(f - 101ll * N * INF));
}

Measured memory_bytes: 2688
h,w=map(int,input().split())
a=[]
for i in range(h):
  s=input()
  a.append(s)

H=""
for j in range(w+2):
  H+="#"

for i in range(h+2):
  r=""
  if i==0 or i==h+1:
    print(H)
  else:
    r+="#"
    r+=a[i-1]
    r+="#"
    print(r)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long N;
long long ans[222222];
int main(){
    cin>>N;
    vector<pair<int,int> > latte;
    for(int i=0;i<N;i++){
        int a;cin>>a;
        latte.push_back(make_pair(a,i));
    }
    sort(latte.begin(),latte.end());
    for(int i=0;i<latte.size();i++){
        if(i<N/2){
            ans[latte[i].second]=latte[N/2].first;
        }
        else{
            ans[latte[i].second]=latte[N/2-1].first;
        }
    }
    for(int i=0;i<N;i++)cout<<ans[i]<<endl;
    return 0;
}

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

int main(void){
  char buf[16] = { 0 };
  int N;
  char *str = NULL;
  
  fgets(buf, sizeof(buf), stdin);
  sscanf(buf, "%d", &N);
  
  str = (char*)malloc(sizeof(char) * (N + 2));
  fgets(str, sizeof(char) * (N + 2), stdin);
  
  int count = 0;
  for(int i = 1; i < N; i++){
    if(str[i] == 'E') count++;
  }
  int min = count;
  int count_tmp = count;
  for(int i = 1; i < N; i++){
    if(str[i] == 'E') count_tmp--;
    if(str[i-1] == 'W') count_tmp++;
    if(count_tmp < min) min = count_tmp;
  }
  
  printf("%d\n", min);
  
  free(str);
  return 0;
}


Measured memory_bytes: 1772
#include "bits/stdc++.h"
using namespace std;

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

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

    int a, b, n;
    cin >> a >> b >> n;

    int x = min(b - 1, n);
    cout << a * x / b - a * (x / b);
}

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

int n,m,s,t;

int to[200005],nxt[200005],fst[100005],tot;
void add(int u,int v)
{
    to[++tot]=v;
    nxt[tot]=fst[u];
    fst[u]=tot;
}

bool vis[100005];
int q[200005],l,r;

void extend(int u,int &p,int d)
{
    vis[q[p+=d]=u]=1;
    for(int e=fst[u],v;e;e=nxt[e])
	if(!vis[v=to[e]]){extend(v,p,d);return;}
}

int main()
{
    scanf("%d%d",&n,&m);
    for(int e=1;e<=m;++e)
    {
	scanf("%d%d",&s,&t);
	add(s,t),add(t,s);
    }

    vis[s]=vis[t]=1;
    extend(s,l=100001,-1);
    extend(t,r=100000,1);

    printf("%d\n",r-l+1);
    for(int i=l;i<=r;++i)
	printf("%d ",q[i]);
    
    return 0;
}

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

using namespace std;

int main(void)
{
	int n;
	string s;

	cin >> n;
	cin >> s;

	int count=0;
	string res = s;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='(')
		{
			count++;
		}
		else
		{
			count--;
			if(count==-1)
			{
				res = '(' + res;
				count=0;
			}
		}
	}
	if(count>0)
	{
		for(int i=0;i<count;i++)
		{
			res = res + ')';
		}
	}

	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define pr pair<LL, LL>
#define FASTER ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;

int main()
{
    FASTER;

    string s;
    cin >> s;
    if(s[0] == '9' || s[1] == '9') cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
#include<map>
#include<numeric>
using namespace std;
#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)
int INF=1e9;
const long long mod=1e9+7;
typedef long long ll;
int main(){
    multimap<string,int>m;
    int q;
    cin>>q;
    while(q--){
        int t,y;
        string x;
        cin>>t;
        if(t==0){
            cin>>x>>y;
            m.insert(make_pair(x,y));
        }
        if(t==1){
            string l;
            cin>>l;
            map<string,int>::iterator end,it;
            it=m.lower_bound(l);
            end=m.upper_bound(l);
            for(;it!=end;it++){
                cout<<(*it).second<<endl;
            }
        }
        if(t==2){
            cin>>x;
            m.erase(x);
        }
        if(t==3){
            string l,r;
            cin>>l>>r;
            map<string,int>::iterator end,it;
            it=m.lower_bound(l);
            end=m.upper_bound(r);
            for(;it!=end;it++){
                cout<<(*it).first<<' '<<(*it).second<<endl;
            }
        }
    }
    return 0;
}


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

int main() {
  int y, m, d;
  char c1, c2;
  cin >> y >> c1 >> m >> c2 >> d;
  if (m <= 4) cout << "Heisei" << endl;
  else cout << "TBD" << endl;
  return 0;
}

Measured memory_bytes: 256
def solve r,a
  hit = 0
  blow = 0
  r.size.times do |i|
    a.size.times do |j|
      if a[j] == r[i]
        if i == j
          hit += 1
        else
          blow += 1
        end
      end
    end
  end
  [hit, blow]
end

loop do
  r, a = $stdin.gets.chomp.split(" ")
  break if r === "0" || a === "0"
  result = solve r, a
  printf "%d %d\n", result[0], result[1]
end

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    string s,t;cin>>s;
    char m=s[0];
    map<char,bool>a;
    for(char i='a';i<='z';++i){
        a[i]=true;
    }
    if(s.size()<26){
    rep(i,s.size()){
        a[s[i]]=false;
    }
    for(char i='a';i<='z';++i){
        if(a[i]){
            cout<<s+i<<endl;
            return 0;
        }
    }
    }
    else{
        rep(i,s.size()){
            a[s[i]]=false;
        }
        for(int i=s.size();i>=0;--i){
            a[s[i]]=true;
            for(char j=s[i]+1;j<='z';++j){
                if(a[j]){
                    s[i]=j;
                    cout<<s.substr(0,i+1)<<endl;
                    return 0;
                }
            }
        }
        cout<<-1<<endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int m = sc.nextInt();
    int x = sc.nextInt();
    int[][] arr = new int[n][m+1];
    int ans = Integer.MAX_VALUE;


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

    void run() {

        for (int i=0; i<n; i++) {
            for (int j=0; j<m+1; j++) {
                arr[i][j] = sc.nextInt();
            }
        }

        dfs("0");
        dfs("1");

        if (ans == Integer.MAX_VALUE) {
            System.out.println(-1);
        } else {
            System.out.println(ans);
        }

    }

    void dfs(String s) {
        if (s.length() == n) {
            ans = Math.min(ans, calc(s));
//            System.out.println(s);
        }
        if (s.length() <= n) {
            for (int i=0; i<2; i++) {
                s = s + String.valueOf(i);
                dfs(s);
                s = s.substring(0, s.length()-1);
            }
        }
    }

    int calc(String s) {
        int ret = 0;
        int[] p = new int[m];
        for (int i=0; i<n; i++) {
            if (s.charAt(i) == '1') {
                for (int j=0; j<m; j++) {
                    p[j] += arr[i][j+1];
                }
                ret += arr[i][0];
            }
        }
        for (int i=0; i<m; i++) {
            if (p[i] < x) {
                return Integer.MAX_VALUE;
            }
        }
        return ret;
    }
}



Measured memory_bytes: 43144
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		long ex[] = new long[n + 1];

		for (long i = 2; i <= n; i++) {
			Map<Long, Integer> map = primeFactorization(i);

			for (long key : map.keySet()) {
				ex[(int) key] += map.get(key);
			}
		}

		long ans = 1;
		for (long i = 2; i <= n; i++) {
			ans *= (ex[(int) i] + 1);
			ans %= 1000000007;
		}

		System.out.println(ans);
	}

	static Map<Long, Integer> primeFactorization(long n) {
		Map<Long, Integer> map = new HashMap<>();
		for (long p = 2; p * p <= n; p++) {
			if (n % p != 0)
				continue;
			int cnt = 0;
			while (n % p == 0) {
				cnt++;
				n = n / p;
			}
			map.put(p, cnt);
		}
		if (n > 1)
			map.put(n, 1);

		return map;
	}
}


Measured memory_bytes: 22740
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <list>
#include <numeric>
#include <stack>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

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

	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	deque<int> b;

	rep(i, n) {
		if (i % 2 == n % 2)
			b.push_back(a[i]);
		else
			b.push_front(a[i]);
	}

	for (auto itr = b.begin(); itr != b.end(); itr++) {
		cout << *itr << " ";
	}
	cout << endl;


	return 0;
}


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

typedef long long ll;
const int MaxN = 212345;
const ll mod = 998244353;


void solve_case() {
	int n, w;
	cin >> n >> w;
	
	vector<vector<ll> > arr(n, vector<ll>(2));
	for (int i = 0; i < n; i++) {
		cin >> arr[i][0] >> arr[i][1];
	}
	
	
	ll dp[2][w + 1];
	memset(dp, 0, sizeof(dp));
	
	for (int i = 0; i < n; i++) {
		int k = i%2;
		for (int j = 0; j <= w; j++) {
			if (arr[i][0] > j) {
				if (i == 0) dp[k][j] = 0;
				else dp[k][j] = dp[(k + 1) % 2][j];
			}
			else {
				if (i == 0) dp[k][j] = arr[i][1];
				else dp[k][j] = max(dp[(k + 1) % 2][j], arr[i][1] + dp[(k + 1) % 2][j - arr[i][0]]);
			}
		}
	}
	
	if(n&1) {
		cout << dp[0][w] << endl;
	}
	else cout << dp[1][w] << endl;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll t=1;
    //cin >> t;
    while(t--) solve_case();
}


Measured memory_bytes: 5208
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int K;
  int X;
  cin >>K>>X;
  rep(i,2*K-1) {
cout <<X-K+i+1<< " ";
  }
  cout << endl;
}
  

Measured memory_bytes: 256
N = int(input())
Red = [ list(map(int,input().split() ) ) for i in range(N) ]
Blue = [ list(map(int,input().split() ) ) for i in range(N) ]
Red.sort(reverse=True,key=lambda x:x[1])
Blue.sort()
count = 0
for B in Blue:
    for i in range(len(Red)):
        #print("i:",i)
        #print("Red[i][0]:",Red[i][0])
        #print("Red[i][1]:",Red[i][1])
        if (B[0] > Red[i][0]) and (B[1] > Red[i][1]) :
            #print("B:", B)
            #print("Red[i]:",Red[i] )
            count += 1
            Red[i][0] = 1000
            B[0] = -1
            continue
        
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int h,w; cin >> h >> w;
    char c[h][w];
    bool ok[h][w];
    rep(i,h){
        bool fl=1;
        rep(j,w){
            cin >> c[i][j];
            if(c[i][j]=='#') fl=0;
        }
        if(fl){
            rep(j,w)ok[i][j]=0;
        }else{
            rep(j,w)ok[i][j]=1;
        }
    }
    rep(j,w){
        bool fl=1;
        rep(i,h){
            if(c[i][j]=='#') fl=0;
        }
        if(fl){
            rep(i,h)ok[i][j]=0;
        }
    }
    rep(i,h){
        bool fl=0;
        rep(j,w){
            if(ok[i][j]){
                fl=1;
                cout<<c[i][j];
            }
        }
        if(fl)cout << endl;
    }
}


Measured memory_bytes: 256
program ABC162_B
  integer(8),dimension(15)::X,Y
  integer(8)::A,N,M
  X=(/1,2,0,4,0,0,7,8,0,0,11,0,13,14,0/)
  Y=(/1,1,0,1,0,0,1,1,0,0,1,0,1,1,0/)
  read(5,*)N
  M=N/15
  L=mod(N,15)
  if(N>=1) then
     A=60*M*M+15*M*sum(Y(1:L)) + sum(X(1:L))
  else
     A=60*(M**2)
  end if
  write(6,*)A
end program ABC162_B

Measured memory_bytes: 2860
n = gets.to_i
s = gets.chomp.split.map(&:to_i)

ary = []
(1..n).each do |i|
  ary << [i, s[i-1]]
end

ary.sort_by!{|x| x[1]}

(n-1).times do |i|
  print "#{ary[i][0]} "
end
print ary[-1][0]

Measured memory_bytes: 18376
#!/usr/bin/env python
# -*- coding: utf-8 -*-

n,d,x = map(int,input().split())
weights = []
for i in range(d):
    weights.append(list(map(int,input().split())))

prices = []
for i in range(d-1):
    prices.append([weights[i+1][j] - weights[i][j] for j in range(n)])

bag = x
for i in range(d-1):
    dp = [False for i in range(bag+1)]
    dp[0] = 0
    for j in range(n):
        for k in range(bag):
            if weights[i][j] + k < bag+1 and dp[k] is not False:
                dp[k+weights[i][j]] = max(dp[k+weights[i][j]],dp[k] + prices[i][j])

    bag += max(dp[:bag+1])

print(bag)

Measured memory_bytes: 7780
#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(){
	rep(i, 5){
		int n;
		cin >> n;
		if(0 == n) cout << i+1 << ' ';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3588
#include"bits/stdc++.h"
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((a + b + c) % 2 == 0) {
		int candy = (a + b + c) / 2;
		if (a == candy || b == candy || c == candy) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vec<ll> p(a), q(b), r(c);
    rep(i, a) cin >> p[i];
    rep(i, b) cin >> q[i];
    rep(i, c) cin >> r[i];
    sort(p.begin(), p.end(), greater<ll>());
    sort(q.begin(), q.end(), greater<ll>());
    sort(r.begin(), r.end(), greater<ll>());

    vec<ll> ans;
    vec<int> which;
    rep(i, x) ans.push_back(p[i]), which.push_back(0);
    rep(i, y) ans.push_back(q[i]), which.push_back(1);
    rep(i, c) ans.push_back(r[i]), which.push_back(2);

    iota(which.begin(), which.end(), 0);
    sort(which.begin(), which.end(), [&ans](int i1, int i2) {
        return ans[i1] < ans[i2];
    });
    sort(ans.begin(), ans.end());
    reverse(ans.begin(), ans.end());
    reverse(which.begin(), which.end());

    int r_rem = x;
    int b_rem = y;
    int idx = 0;
    ll ans_sum = 0;
    // rep(i, ans.size()) cout << ans[i] << " ";
    // cout << endl;
    while(true) {
        if (idx >= x + y) break;
        ans_sum += ans[idx];
        idx++;
    }
    cout << ans_sum << endl;
}

Measured memory_bytes: 10224
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cout<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1;

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int ans;
string s;
bool cf,ff;

main(){
    cin>>s;
    rep(i,s.size()){
        if(s[i]=='C'&&cf==0)cf=1;
        if(s[i]=='F'&&cf==1){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

int main()
{
	double maxh = 0, minh = 1000000;

	double h;
	for (; cin >> h;)
	{
		maxh = max(maxh, h);
		minh = min(minh, h);
	}

	cout << maxh - minh << endl;
}


Measured memory_bytes: 3192
import sys
from collections import deque, defaultdict
import copy
import bisect
#sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import combinations, permutations

import sys
def input():
	return sys.stdin.readline().strip()

N = int(input())
a = list(map(int, input().split()))

a_max = a[:N]
a_min = a[2*N:]

a_max_sum = sum(a_max)
score = [a_max_sum]
heapq.heapify(a_max)
for i in range(N):
	heapq.heappush(a_max, a[N + i])
	a_max_sum += a[N + i]
	a_max_sum -= heapq.heappop(a_max)
	score.append(a_max_sum)

a_min_sum = sum(a_min)
score[N] -= a_min_sum
for i in range(len(a_min)):
	a_min[i] *= -1
heapq.heapify(a_min)
for i in range(N):
	heapq.heappush(a_min, -a[2*N - 1 - i])
	a_min_sum += a[2*N - 1 - i]
	a_min_sum += heapq.heappop(a_min)
	score[N - i - 1] -=a_min_sum

print(max(score))

Measured memory_bytes: 119376