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

int a[2000000], ans[2000000], vis[2000000], b[2000000];

int main() {
    int m, K;
    cin >> m >> K;
    int now = 1;
    for (int i = 1; i <= m; ++i)
        now <<= 1;
    now -= 1;
    int tot = 0;
    int t = K;
    while (t) {
        int tmp = t & (-t);
        if (tmp >= now) {
            puts("-1");
            return 0;
        }
        vis[a[++tot] = tmp] = 1;
        t -= tmp;
    }
    int cnt = 0;
    for (int i = 0; i <= now; ++i)
        if (!vis[i])
            b[++cnt] = i;
    int i = 1, j;
    for (; i <= tot; ++i)
        ans[i] = a[i];
    for (j = 1; j <= cnt; ++i, ++j)
        ans[i] = b[j];
    
    for (j = tot; j >= 1; --j, ++i)
        ans[i] = a[j];

    for (j = cnt; j >= 1; --j, ++i)
        ans[i] = b[j];

    for (j = 1; j < i; ++j) printf("%d ", ans[j]);

    return 0;
}


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

int H, W, N;
int a[110 * 110];
int c[110][110];

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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> H >> W >> N;
	for (int i = 1; i <= N; ++i) cin >> a[i];
	int curx = 1, cury = 1;
	
	for (int i = 1; i <= N; ++i) {
		while(a[i]--) {
			c[curx][cury] = i;
			for (int j = 0; j < 4; ++j) {
				int nx = curx + dx[j], ny = cury + dy[j];
				if (nx < 1 || nx > H || ny < 1 || ny > W || c[nx][ny]) continue;
				curx = nx; cury = ny;
				break;
			}
		}
	}

	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= W; ++j) cout << c[i][j] << ' ';
		cout << endl;
	}
}

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

using namespace std;
#define taskname "TEST"
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 3e3 + 5;
const int mod = 1e9 + 7;
int n , dp[maxn][maxn];
string s;
void add(int & x , int y)
{
    x += y;
    if(x >= mod)x -= mod;
    if(x < 0)x += mod;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	if(fopen(taskname".INP","r"))
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
    int cnt = 0;
    cin >> n >> s;
    for(int i = 1 ; i <= n ; ++i)
        dp[1][i] = 1;
    s = "  " + s;
    for(int i = 2 ; i <= n ; ++i)
    {
        for(int j = 1 ; j <= i ; ++j)
        {
            if(s[i] == '>')add(dp[i][j],dp[i - 1][i - 1] - dp[i - 1][j - 1]);
            else add(dp[i][j],dp[i-1][j-1]);
            add(dp[i][j],dp[i][j-1]);
        }
    }
    cout << dp[n][n];
}



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


#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long int lli;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);


int main(void) {

	char     A[4];

	s_cin(A);
	if (A[0] == '7' || A[1] == '7' || A[2] == '7')
	{Yes_RTN;}
	No_RTN;
	
}
	
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	rept(i, 0, n) {
		i_cin(*(a + i));
	}

	return 0;
}




Measured memory_bytes: 1644
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
        String t = "No";
        if(s.equals("hi") || s.equals("hihi") || s.equals("hihihi")||s.equals("hihihihi")||s.equals("hihihihihi"))
        {t = "Yes";
                                                 }
                            
      
		System.out.println(t);
	}
}


Measured memory_bytes: 23252
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>

using namespace std;

const int maxN=1e5+5;
int n;char s[maxN];

void dfs(int x,int y)
{
    if(y==n)return ;
    if(s[y]=='1')
    {
        printf("%d %d\n",x,y+1);
        dfs(y+1,y+1);
    }
    else
    {
        printf("%d %d\n",x,y+1);
        dfs(x,y+1);
    }
}

int main()
{
    int k;
    scanf("%s",s+1);
    n=strlen(s+1);
    for(k=1;k<n;k++)
    {
        if(s[k]!=s[n-k])
        {
            cout<<"-1";
            return 0;
        }
    }
    if(s[1]!='1' || s[n]=='1')
    {
        cout<<"-1";
        return 0;
    }
    printf("1 2\n");
    dfs(1,2);
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
// #include <cassert>
#include <vector>
#include <algorithm>
#include <climits>

#include <stack>
#include <queue>
// #include <deque>
#include <set>
#include <map>
// #include <string>
// #include <unordered_set>
// #include <unordered_map>

#include <tuple>
// #include <cmath>
// #include <numeric>

using namespace std;
typedef long long ll;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef pair<int,long> pil;
typedef pair<long,int> pli;
typedef vector<vector<long long>> vvll;
typedef vector<vector<long>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;

#define emplace_back pb
const char el = '\n';

/*
Edge cases:


*/

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

    string s; cin>>s;
    int n = (int) s.length();


    bool ispalindrome = true;

    int left = n/2, right = n/2;
    while (left>=0 && right<n) {
        ispalindrome &= (s[left]==s[right]);
        --left, ++right;
    }

    if (!ispalindrome) {
        cout<<"No"<<el;
        return 0;
    }


    //only need to check one of them, because it's a mirror;
    left = 0; right = (n/2)-1;

    while (left<=right) {
        ispalindrome &= (s[left]==s[right]);
        ++left, --right;
    }
    if (ispalindrome) {
        cout<<"Yes"<<el;
        
    }  else {
        cout<<"No"<<el;
    }
}

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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int y,m,d;
	scanf("%d/%d/%d", &y, &m, &d);

	if(2019 >= y and 4 >= m and 30 >= d) printf("Heisei\n");
	else printf("TBD\n");

	return 0;

}


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

int main(){
    int n, i, j;
    vector<int> d(50);
    cin >> n;
    for(i = 0;i < n;i++){
        cin >> d.at(i);
    }
    int sum = 0;
    for(i = 0;i < n;i++){
        for(j = i+1;j < n;j++){
            sum += d.at(i) * d.at(j);
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using static System.Math;
using Debug = System.Diagnostics.Debug;

class P
{
    static void Main()
    {
        string s = Console.ReadLine();
        var a = Console.ReadLine().Split().Select(int.Parse).ToList();
        var any = a.Where(x => 3200 <= x).Count();
        var colors = a.Where(x => x < 3200).Select(x => x / 400).Distinct().Count();
        Console.WriteLine($"{Max(1, colors)} {colors + any}");
    }
}


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

using namespace std;

int main(void){

  int n;
  cin >> n;

  vector<int> a;
  for(int i = 0; i < n; ++i){
    int a_bf;
    cin >> a_bf;
    a.push_back(a_bf);
  }

  int n_half = (n + n%2) / 2;
  for(int i = 0; i < n; ++i){
    int j;
    if(i < n_half){
      j = n - 2 * i - 1;
    }else{
      j = n % 2 + 2 * (i - n_half);
    }
    cout << a[j];
    if(i == n - 1){
      cout << endl;
    }else{
      cout << " ";
    }
  }
  
  return 0;
}

Measured memory_bytes: 3060
#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 MAXN = 100000;
const int mod = 1e9 + 7;


#define FILENAME ""


int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    //  freopen(FILENAME ".in", "r", stdin);
    //  freopen(FILENAME ".out", "w", stdout);
    ll n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n - 1; i++) {
        ans += i;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
	const int maxn=500000;
	int p[32];
	int main(){
		int n,k;
		scanf("%d%d",&n,&k);
		p[0]=1;
		for(int i=1;i<31;i++){
			p[i]=(p[i-1]<<1);
		}
		double ans=0;
		double per=1.0/n;
		for(int i=1;i<=n;i++){
			if(i>=k)
				ans+=per;
			else{
				int t=i;
				for(int j=1;j<31;j++){
					if(p[j]*t>=k){
						ans+=per*(1.0/p[j]);
						break;
					}
				}
			}
		}
		cout<<setprecision(20)<<ans<<endl;
	} 

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <string>

void insert( std::set<std::string> &arr) {
	std::string str;
	std::cin >> str;
	arr.insert(str);
}

void serch( std::set<std::string> &arr) {
	std::string str;
	std::cin >> str;
	if (arr.find(str) != arr.end()) std::cout << "yes" << std::endl;
	else std::cout << "no" << std::endl;
}




int main(void)
{
	typedef  std::map<std::string, void(*)(std::set<std::string>&)> map_type;
	map_type funcs;
	funcs.insert(std::make_pair(std::string("insert"),insert));
	funcs.insert(std::make_pair(std::string("find"), serch));

	int n;
	std::set<std::string> arr;
	std::cin >> n;
	for (size_t i = 0; i < n; i++)
	{
		std::string com;
		std::cin >> com;
		funcs.find(com)->second(arr);
	}
	return 0;
}

Measured memory_bytes: 32140
N = input()
ok = [False for _ in xrange(N+1)]
for i in xrange(4, N+1, 4):
    ok[i] = True
for i in xrange(7, N+1, 7):
    ok[i] = True
for i in xrange(N+1):
    if ok[i] and i + 4 <= N:
        ok[i+4] = True
    elif ok[i] and i + 7 <= N:
        ok[i+7] = True
if ok[N]:
    print "Yes"
else:
    print "No"


Measured memory_bytes: 2568
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include<vector>
#include <set>
#define rep(i,n) for(i=0;i<n;i++)
#define P pair<int,int>
#define ll long long 
using namespace std;
int n;
ll a[100000];

int main()
{
	ll b, c, d, e, f, i, j,m;
	vector<ll> v;
	cin >> n;
	cin >> b;
	v.push_back(b);
	m = b;
	for(i=1;i<n;i++){
		cin >> b;
		if (m >= b) {
			v.push_back(b);
			m = b;
			continue;
		}

		rep(j, v.size()) {
			if (v[j] < b) {
				v[j] = b;
				if (j == v.size() - 1)m = b;
				break;
			}
		}


	}
	//rep(i, v.size())cout << v[i] << "\n";
	cout << v.size();

	return 0;
}

Measured memory_bytes: 1400
package main

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

var isProduct = true

type task struct {
	time  int
	limit int
}

func main() {
	nextReader = newScanner()

	n := nextInt()

	tasks := make(Sorter, n)
	for i := 0; i < n; i++ {
		tasks[i] = task{
			time:  nextInt(),
			limit: nextInt(),
		}
	}

	sort.Sort(tasks)
	// sort.Slice(tasks, func(i, j int) bool {
	// 	return tasks[i].limit < tasks[j].limit
	// })

	now := 0
	for _, task := range tasks {
		now += task.time

		// fmt.Println("now:", now, task.limit)
		if now > task.limit {
			fmt.Println("No")
			return
		}

	}

	fmt.Println("Yes")
}

type Sorter []task

func (a Sorter) Len() int           { return len(a) }
func (a Sorter) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Sorter) Less(i, j int) bool { return a[i].limit < a[j].limit }

// type Sorter []Sortable

// func (a Sorter) Len() int           { return len(a) }
// func (a Sorter) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
// func (a Sorter) Less(i, j int) bool { return a[i].Axis < a[j].Axis }

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}

func gcd(x, y int) int {
	tmp := x % y
	if tmp > 0 {
		return gcd(y, tmp)
	} else {
		return y
	}
}

func abs(i int) int {
	return int(math.Abs(float64(i)))
}

func debugln(s ...interface{}) {
	if !isProduct {
		fmt.Println(s...)
	}
}

func debug(s ...interface{}) {
	if !isProduct {
		fmt.Print(s...)
	}
}
func debugf(f string, s ...interface{}) {
	if !isProduct {
		fmt.Printf(f, s...)
	}
}

var nextReader func() string

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}


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

#define REP(i, a, n) for(int i=a; i<n; i++)

int main() {
	int n, a=0, b=0;
 	cin >> n;
  	vector<int> v(n);
	REP(i, 0, n) cin >> v[i];
	sort(v.begin(), v.end(), greater<>());
    REP(i, 0, n){
      if(i%2==0) a+=v[i];
        else{b+=v[i];}
    }
  cout << a-b << endl;
}


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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#define IF_DEBUG 0
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

ll n;

ll gcd(ll a, ll b){return !b?a:gcd(b,a%b);}
int main()
{
	cin >> n;
	fo(a,1,3500)
		fo(b,1,3500)
		{
			ll c = 1ll*4*a*b-1ll*n*b-1ll*n*a, d = 1ll*n*a*b;
			if(c<=0) continue; 
			ll e = gcd(c,d);
			c /= e; d /= e;
			if(c == 1) {cout << a << ' '<<b<<' '<<d<<endl;return 0;}
		}
	return 0;
}

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

int main() {
    int n, ans;
    cin >> n;
    ans = n / 2; 
    if (n % 2) {
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];

  string ans = "APPROVED";
  rep(i, n){
    if (a[i]%2 == 0){
      if (a[i]%3 != 0 and a[i]%5!=0){
        ans = "DENIED";
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
	int N,M,C;
	cin >> N >> M >> C;
	vector<int> b(M);
	vector<vector<int>> a(N, vector<int>(M));
	int sum;
	int ans = 0;
	for(int i=0; i<M;i++){
		cin >> b[i];
	}
	for(int i=0; i<N;i++){
		sum = C;
		for(int j=0; j<M;j++){
		cin >> a[i][j];
		sum += a[i][j]*b[j];
	}
	if(sum>0)	ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
S = input()

T = ""

while True:
    T_len = len(T)
    for word in ["dream", "dreamer", "erase", "eraser"]:
        if word + T == S[-1 * len(word + T):]:
            T = word + T
            if T == S:
                print("YES")
                exit()
    if T_len == len(T):
        print("NO")
        exit()


Measured memory_bytes: 83676
#include <iostream>
#include <iomanip>
#include <vector>

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


Measured memory_bytes: 3080
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];

	std::vector<int> b = a;
	std::sort(all(b));

	// extract even indices
	std::set<int> even;
	for(int i=0;i<n;i+=2) even.emplace(b[i]);
	int count = 0; // diff from even
	for(int i=0;i<n;i+=2) {
		if(even.count(a[i])==0) count++;
	}
	print(count);
	return 0;
}


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

int d[200005];
int kind=0;
int ans=0;

main()
{
  fill_n(d,200005,200000000);
  
  int n,k;
  int a;
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> a;
    if(d[a]==200000000){
      kind++;
      d[a]=0;
    }
    d[a]++;
  }

  sort(d,d+200005);

  for(int i=0;i<kind-k;i++){
    ans+=d[i];
  }

  cout << ans << endl;

  return (0);
}

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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int A, B;
    cin >> A >> B;
    int Bh = (B - A) * (B - A + 1) / 2;
    cout << Bh - B;
}

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

#define ul unsigned long int
#define ull unsigned long long
#define li long long int


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

  if (a<b&&b<c)cout<<"Yes"<<endl;
  else cout <<"No"<<endl;

  return 0;
}



Measured memory_bytes: 3116
import sys

input = sys.stdin.readline

N, W = map(int, input().split())
w, v = [], []
for _ in range(N):
    tw, tv = map(int, input().split())
    w.append(tw)
    v.append(tv)

dp = [[0 for _ in range(W + 1)] for _ in range(N + 1)]

for i in range(N):
    for j in range(W + 1):
        if j - w[i] >= 0:
            dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i])
        else:
            dp[i + 1][j] = dp[i][j]
print(dp[N][W])


Measured memory_bytes: 171656
extension String: CollectionType {}

let a:Int = Int(readLine()!)!
let b: [Int] = readLine()!.split(" ").map { Int($0)! }
let c: [Int] = readLine()!.split(" ").map { Int($0)! }

var d: [Int] = []
for var i = 0; i < a; i += 1 {
  d.append( b[i] - c[i] )
}

var o = 0
for var i = 0; i < a; i += 1 {
  if( d[i] > 0 ) {
  	o += d[i]
  }
}
print(o)

Measured memory_bytes: 4208
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<iostream>
#include<queue>
#include<utility>
#include<string>
#define mp make_pair
#define inf 1000000000
using namespace std;
typedef long long ll;
ll n,sum;
bool nine;
int main(){
	cin >> n;
	while(n>9){
		sum += 9;
		if(n%10 != 9) nine = true;
		n/=10;
	}
	if(!nine) cout<<n+sum<<endl;
	else cout<<n+sum-1<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,ans=0;int a[114514],b[114514];
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i]>>b[i];
	for(int i=n-1;i>=0;i--){
		ans+=(b[i]-(a[i]+ans)%b[i])%b[i];
	}
	cout<<ans<<endl;
}
		
		


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
	long long  n,m;
	cin>>n>>m;
	if (m>=n)
	{
		cout<<"unsafe"<<endl;
	 } 
	 else
	 {
	 	cout<<"safe"<<endl;
	 }
}

Measured memory_bytes: 3608
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const a = parseInt(args[0][0], 10)
	const b = parseInt(args[0][1], 10)
	const c = parseInt(args[0][2], 10)
	if (b - a === c - b) console.log('YES')
	else console.log('NO')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7496
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

vvpll G;
vl ans;

void dfs(ll v, ll p = -1, ll c = -1) {
    ll color = 1;
    for(auto x : G[v]) {
        ll u = x.first;
        ll e = x.second;
        if(u == p) {
            continue;
        }
        if(color == c) {
            color++;
        }
        ans[e] = color;
        color++;
        dfs(u, v, ans[e]);
    }
}

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

    G.resize(n);
    rep(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(make_pair(b, i));
        G[b].pb(make_pair(a, i));
    }

    ll K = 0;
    rep(i, n) {
        chmax(K, (ll)G[i].size());
    }
    out(K);

    ans.resize(n-1);
    dfs(0);

    rep(i, n-1) {
        out(ans[i]);
    }

    re0;
}

Measured memory_bytes: 9728
N, M = map(int, input().split())
st = [list(map(int, input().split())) for _ in range(N)]
cp = [list(map(int, input().split())) for _ in range(M)]

def dis(st, cp):
  return abs(st[0] - cp[0]) + abs(st[1] - cp[1])

for n in range(N):
  min_dis = dis(st[n], cp[0])
  ans = 1
  for m in range(1, M):
    cur_dis = dis(st[n], cp[m])
    if cur_dis < min_dis:
      min_dis = cur_dis
      ans = m + 1
  print(ans)

Measured memory_bytes: 9160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var ans = 0;
            if (s == "RRR") ans = 3;
            else if (s == "RRS" || s == "SRR") ans = 2;
            else if (s == "SSS") ans = 0;
            else ans = 1;

            Console.WriteLine(ans);






        }

        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }
        
        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }

        public static long Gcd(long a, long b)
        {
            long x = Math.Max(a, b);
            long y = Math.Min(a, b);
            if (x % y == 0) return y;
            else return Gcd(y, x % y);
        }
    }
}


Measured memory_bytes: 25844
import math

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

MAX = 1000005
c = [0]*MAX

for i in range(n):
  c[a[i]] += 1

pair = True

for i in range(2,MAX):
  cnt = 0
  for j in range(i,MAX,i):
    cnt += c[j]
  if cnt > 1:
    pair = False

if pair:
  print('pairwise coprime')
else:
  g = a[0]
  for i in range(1,n):
    g = math.gcd(g,a[i])
    
  if g == 1:
    print('setwise coprime')
  else:
    print('not coprime')


Measured memory_bytes: 189288
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    string S;
    cin >> S;
    if (S[2] == S[3] && S[4] == S[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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

int main(){
    char s[101];
    char p[101];
    int i=0,j=0;
    while((s[i]=getchar())!='\n'){
        i++;
    }
    while((p[j]=getchar())!='\n'){
        j++;
    }
    for(int k=0;k<i;k++){
        int count=0;
        for(int l=0;l<j;l++){
            if(s[(k+l)%i]==p[l]){
                count++;
                if(count==j){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }else{
                break;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3120
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
using i128 = i64;
using u128 = u64;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}

template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

//#define getchar getchar_unlocked
//#define putchar putchar_unlocked

int inp() {
	int x = 0, f = 0; char ch;
	for(ch = getchar(); !isdigit(ch); ch = getchar())
		if(ch == '-') f = 1;
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return f ? -x : x;
}

ll inp_ll() {
	ll x = 0; int f = 0; char ch;
	for(ch = getchar(); !isdigit(ch); ch = getchar())
		if(ch == '-') f = 1;
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return f ? -x : x;
}

template<class T>
bool read(T &x)
{
	x = 0;
	char ch = getchar();
	if (ch == EOF) return 0;
	for(; !isdigit(ch); )
	{
		ch = getchar();
		if (ch == EOF) return 0;
	}
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return 1;
}

template<class T>
void write(T x)
{
	static char s[22];
	static char *it = s+20;
	static char *end = s+20;
	if (!x)
		*-- it = '0';
	while (x)
	{
		*-- it = x%10+'0';
		x /= 10;
	}
	for (; it < end; ++ it)
		putchar(*it);
}

template<class T>
void writeln(T x)
{
	write(x);
	putchar('\n');
}

const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 200010;

int a[MAXN];
int L[MAXN], R[MAXN];

int main()
{
	
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++ i)
		cin >> a[i];
	for (int i = 1; i <= n; ++ i)
		L[i] = max(L[i-1], a[i]);
	for (int i = n; i >= 1; -- i)
		R[i] = max(R[i+1], a[i]);
	for (int i = 1; i <= n; ++ i)
		cout << max(L[i-1], R[i+1]) << endl;
	
	return 0;
}


Measured memory_bytes: 3968
H, M = map(int, input().split())
matrix = []
for i in range(H):
    matrix.append([_ for _ in list(map(str, input()))])

bad_row = set()
bad_column = set()
for i in range(H):
    if all([x == '.' for x in matrix[i]]):
        bad_row.add(i)

for j in range(M):
    tmp = [matrix[i][j] for i in range(H)]
    if all([x == '.' for x in tmp]):
        bad_column.add(j)

for i in range(H):
    for j in range(M):
        if i not in bad_row:
            if j not in bad_column:
                print(matrix[i][j], end='')
    if i not in bad_row:
        print('')


Measured memory_bytes: 4596
#include <algorithm>
#include <iostream>
#include <random>
#include <set>
#include <string>
#include <vector>

#define N_DAYS 365
#define N_CONTESTS 26

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

using namespace std;

static int assign[N_DAYS] = {0};
static int S[N_DAYS][N_CONTESTS] = {{0}};
static int C[N_CONTESTS] = {0};
static int V[N_DAYS] = {0};
static int last[N_CONTESTS] = {-1};
static int days = 0;

int score() { return 0; }

void read() {
  cin >> days;
  rep(c, N_CONTESTS) {
    last[c] = -1;
    cin >> C[c];
  }
  rep(d, days) {
    rep(c, N_CONTESTS) { cin >> S[d][c]; }
  }
  //   rep(d, days) { cin >> assign[d]; }
}

void init() {
  rep(d, days) {
    int best = 0;
    int choice = -99999;
    rep(c, N_CONTESTS) {
      if (S[d][c] > best) {
        choice = c;
        best = S[d][c];
      }
    }
    assign[d] = choice;
  }
}

void print_assign() {
  rep(d, days) { cout << assign[d] + 1 << endl; }
}

// void print_score() {
//   rep(d, days) { cout << V[d] << "\n"; }
// }

int main() {
  read();
  init();
  print_assign();
  score();

  //   print_score();
  return 0;
}


Measured memory_bytes: 3628
N = int(input())
A_list = [int(e) for e in input().split()]

buka_dict = dict()

for A in A_list:
    if A not in buka_dict:
        buka_dict[A] = 0
    
    buka_dict[A] += 1

for i in range(1,N+1):
    if i in buka_dict:
        print(buka_dict[i])
    else:
        print(0)

Measured memory_bytes: 33668
// {{{ Template
// Author:  wenxing
// Date:    2017-12-30 21:21 +0800
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, l, r) for (int i = l; i < r; ++i)
#define per(i, r, l) for (int i = r; i >= l; --i)
#define repv(ele, vec) for (auto &ele : vec)
#define zero(mem) memset(mem, 0, sizeof(mem))
#define sd(_) scanf("%d", &_)
#define sdd(_, __) scanf("%d%d", &_, &__)
#define sddd(_, __, ___) scanf("%d%d%d", &_, &__, &___)
#define sdddd(_, __, ___, ____) scanf("%d%d%d%d", &_, &__, &___, &____)
#define sl(_) scanf("%ld", &_)
#define sll(_, __) scanf("%ld%ld", &_, &__)
#define slll(_, __, ___) scanf("%ld%ld%ld", &_, &__, &___)
#define sc(_) scanf("%c", &_)
#define ss(_) scanf("%s", _)
#define mid(a, b) (((a) + (b)) >> 1)
#define lft(x) x << 1
#define rht(x) x << 1 | 1
#define inf 0x3f3f3f3f
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
// }}}

// - Pseudocode -

// {{{ Global Variables
int q, l, r, pcache[200010], cnt[100010];
// }}}

int isprime(int x) {
    if (x == 1) return 0;
    if (pcache[x]) return pcache[x] == 1 ? 1 : 0;

    int isp = 1;
    for (int i = 2; i <= sqrt(x); ++i) {
        if (x % i == 0) {
            isp = 0;
            break;
        }
    }

    pcache[x] = isp ? 1 : -1;
    return isp;
}

int main() {
    zero(pcache);
    zero(cnt);
    rep(i, 1, 100001) {
        cnt[i] = cnt[i - 1];
        if (isprime(i) && isprime((i + 1) / 2)) cnt[i]++;
    }

    sd(q);
    rep(i, 0, q) {
        sdd(l, r);
        printf("%d\n", cnt[r] - cnt[l - 1]);
    }
    return 0;
}


Measured memory_bytes: 1792
N,M = map(int,input().split()) #Nは10進法の桁数
flag = False
ans = [0]*N
s = []
c = []
answer = 0
for i in range(M):
  s1,c1 = [int(i) for i in input().split()]
  s.append(s1)
  c.append(c1)
if N != 1:
  for i in range(M):
    for j in range(M):
      if s[i] == s[j] and c[i] != c[j] and j != i:
        flag = True
    if s[i] == 1 and c[i] == 0:
      flag = True
if N ==1:
  for i in range(M):
    for j in range(M):
      if s[i] == s[j] and c[i] != c[j] and j != i:
        flag = True
if N == 1:
  for i in range(M):
    if s[i] == 1:
      ans[0] = c[i]
  answer = ans[0]
if N == 2:
  flag1 = False
  for i in range(M):
    if s[i] == 1:
      ans[1] = c[i]
      flag1 = True
    if s[i] == 2:
      ans[0] = c[i]
  if flag1 == True:
    answer = 10*ans[1] + ans[0]
  else:
    answer = 10 + ans[0]
if N == 3:
  flag2 = False
  for i in range(M):
    if s[i] == 1:
      ans[2] = c[i]
      flag2 = True
    if s[i] == 2:
      ans[1] = c[i]
    if s[i] == 3:
      ans[0] = c[i]
  if flag2 == True:
    answer = 100*ans[2] +10*ans[1] + ans[0]
  else:
    answer = 100 +10*ans[1] + ans[0]
if flag == False:
  print(answer)
else:
  print(-1)
    


Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>

int ref=0,max;
int *A;

int merge(int left,int mid,int right){
    /*sort????????????A[left..mid-1]??¨A[mid..right-1]??????????????±???*/
    int n1 = mid - left, n2 = right - mid;
    int i,j,k;
    int *L,*R;
    L = (int *)calloc(n1+1,sizeof(int));
    R = (int *)calloc(n2+1,sizeof(int));
    for(i=0;i<n1;i++)L[i] = A[left + i];
    for(i=0;i<n2;i++)R[i] = A[mid + i];
    L[n1] = R[n2] = max+1;
    i = j = 0;
    for(k=left;k<right;k++){
        ref++;
        if(L[i] <= R[j]){
            A[k] = L[i];
            i++;
        }else{ 
            A[k] = R[j];
            j++;
        }
    }
    free(L);
    free(R);
}

int mergeSort(int left,int right){
    int mid;
    if(left+1 < right){
        mid = (left + right)/2;
        mergeSort(left, mid);
        mergeSort(mid, right);
        merge(left, mid, right);
    }
}

int main(){
    int n,i;
    scanf("%d",&n);
    A = (int *)calloc(n,sizeof(int));
    for(i=0;i<n;i++)scanf("%d",A+i);
    max = A[0];
    for(i=1;i<n;i++)if(max<A[i])max=A[i];
    mergeSort(0,n);
    for(i=0;i<n;i++){
        if(i)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n%d\n",ref);
}

Measured memory_bytes: 4924
#include <bits/stdc++.h>
using namespace std; 
using ll = long long;
signed main() { 
	cin.tie(0);
	cin.sync_with_stdio();
	set<int> s;
	int a, b, c;
	cin>>a>>b>>c;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	if(s.size() == 2)
		cout<<"Yes";
	else
		cout<<"No";
}


Measured memory_bytes: 256
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline
    import numpy as np

    mod = 998244353

    N, S = map(int, input().split())
    A = list(map(int, input().split()))

    # 多項式
    polynomial = np.zeros(S+1, int)
    ans = 0
    for i in A:
        polynomial[0] += 1
        polynomial[i:] += polynomial[:-i].copy()
        polynomial %= mod
        ans += polynomial[S]

    print(ans % mod)

main()

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

int main() {
    long n, m;
    cin >> n >> m;
    priority_queue<int> q;
    rep(i, n) {
        int a;
        cin >> a;
        q.push(a);
    }
    rep(i, m) {
        int a = q.top();
        q.pop();
        a /= 2;
        q.push(a);
    }
    ll total = 0;
    rep(i, n) {
        ll a = (ll)q.top();
        total += a;
        q.pop();
    }
    cout << total;
}

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



int main() {
	long long int N, M;
	cin >> N >> M;
	vector<long long int>A(N);
	priority_queue<long long int, vector<long long int>, greater<long long int>>que;
	for(size_t i = 0; i < N; i++) {
		cin >> A[i];
		que.push(A[i]);
	}

	vector<pair<long long int, long long int>>BC(M);
	for(size_t i = 0; i < M; i++) {
		cin >> BC[i].second >> BC[i].first;
	}

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

	long long int countSum = 0;
	for(int i = M - 1; i >= 0; i--) {
		BC[i].second = min(N - countSum, BC[i].second);
		countSum += BC[i].second;
	}

	for(size_t i = 0; i < M; i++) {
		long long int nowV = BC[i].first, nowCount = BC[i].second;

		for(size_t j = 0; j < nowCount; j++) {
			long long int now = que.top(); que.pop();

			if(now < nowV) {
				que.push(nowV);
			} else {
				que.push(now);
				break;
			}
		}
	}

	long long int ans = 0;
	while(que.size()) {
		long long int now = que.top(); que.pop();
		ans += now;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3444
N = int(input())
A = list(map(int,input().split()))
D = dict()
for i in range(N):
    D[A[i]] = (i+1)
ans = []
for i in range(N):
    ans.append(D[i+1])
d = []
for i in range(N):
    d.append(str(ans[i]))
result = ' '.join(d)
print(result)

Measured memory_bytes: 25692
import java.util.Scanner;

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

		while (true) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			int map[] = new int[(n - 1) / 2];
			int rem[] = new int[n];
			for (int i = 1; i < n; i++) {
				rem[(i * i) % n] = 1;
			}
			int index = 0;
			for (int i = 0; i < n; i++) {
				if (rem[i] == 1) {
					rem[index++] = i;
				}
			}
			for (int i = 0; i < index; i++) {
				for (int j = 0; j < index ; j++) {
					if (i != j) {
						int res = rem[i] - rem[j];
						res += (res < 0) ? n : 0;
						res = ((n - 1) / 2 < res) ? n - res : res;
						map[res - 1]++;
					}
				}
			}
			for (int i = 0; i < (n - 1) / 2; i++) {
				System.out.println(map[i]);
			}
		}
	}
}

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

#define MAXN 300*1000 + 5

using ll = long long;

ll freq[MAXN], freq_freq[MAXN];

ll f(int x) {
	ll res = x * (freq_freq[MAXN-1] - freq_freq[x]) + freq[x];
	return res / x;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		freq[x]++;
	}
	
	for(int i = 0; i < MAXN; i++) {
		if(freq[i] == 0) continue;
		freq_freq[freq[i]]++;
	}
	
	for(int i = 1; i <= n; i++) {
		freq[i] = freq[i-1] + 1LL * i * freq_freq[i];
	}
	
	partial_sum(freq_freq, freq_freq + MAXN, freq_freq);
	//$ for(int i = 1; i <= n; i++) {
		//$ cerr << i << ' ' << f(i) << endl;
	//$ }
	
	//$ return 0;
	
	for(int k = 1; k <= n; k++) {
		int lo = 0, hi = n+1;
		while(lo < hi) {
			int x = lo + (hi-lo+1)/2;
			if(k <= f(x)) {
				lo = x;
			} else {
				hi = x-1;
			}
		}
		
		cout << lo << '\n';
	}
	
}


Measured memory_bytes: 5632
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define len(x) ((int)(x).size())
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

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

const ll LINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9+7;

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

const int M = 1e3+5;
const int MAXPOT = 5e3+5;
pii chave[M]; /// {price, abre}
int dp[M][MAXPOT];
int n, m;
int limite;

int solve(int i, int quantosAbre){
	//cout << i << ": " << quantosAbre << endl;
	if(i == m-1 and quantosAbre != limite) return INF;
	if(quantosAbre == limite) return 0;
	if(dp[i][quantosAbre] != -1) return dp[i][quantosAbre];
	return dp[i][quantosAbre] = min(solve(i+1, quantosAbre), solve(i+1, quantosAbre | chave[i].sc) + chave[i].fs);
}

int main(){
	fastio;
	memset(dp, -1, sizeof dp);
	cin >> n >> m;
	limite = pow(2, n)-1;
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		chave[i].fs = a;
		chave[i].sc = 0;
		for(int j = 0; j < b; j++){
			int x;
			cin >> x;
			chave[i].sc |= (1 << (x-1));
		}	
	}
	sort(chave, chave+m);
	int ans = solve(0, 0);
	if(ans == INF) cout << -1;
	else cout << ans;
	cout << endl;
	return 0;
}

Measured memory_bytes: 19968
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}

//INSERT ABOVE HERE
Int n,ans=0;
void dfs(Int x,Int a,Int b,Int c){
  if(x>n) return; 
  if(a&&b&&c) ans++;
  dfs(x*10+3,1,b,c);
  dfs(x*10+5,a,1,c);
  dfs(x*10+7,a,b,1);
}
signed main(){
  cin>>n;
  dfs(0,0,0,0);
  cout<<ans<<endl;
  return 0;
}

//なぜか通らないのでコードを借ります

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


visited = [0] * N

idx = 0

town = 0

if K <= N:
    for i in range(K):
        idx = t[idx] -1
    print(idx+1)
else:
    for i in range(K):
        if visited[idx]:
            cycle = i - visited[idx]
            rem_step = (K - i) % cycle
            town = visited.index(visited[idx] + rem_step)
            break


        visited[idx] = i
        idx = t[idx] - 1


    print(town+1)

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

int main(void) {
    string n;
    while(cin>>n) {
        int sum=0;
        if(n=="0") return 0;
        for(int i=0;i<(int)n.size();i++) {
            sum+=(int)n[i]-(int)'0';
        }
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
#include <unordered_map>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
# define INF 0x3f3f3f3f 
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
ll gcd(ll a , ll b){if(b==0) return a; a%=b; return gcd(b,a);}
const int N=500023;
bool vis[N];
vector <int> adj[N];

void solve() 
{
    int a, b, c, d, e;
    cin>>a>>b>>c>>d>>e;

    if(a == 0) cout<<1<<endl;
    if(b == 0) cout<<2<<endl;
    if(c == 0) cout<<3<<endl;
    if(d == 0) cout<<4<<endl;
    if(e == 0) cout<<5<<endl;


}

int main()
{   

    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)
    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 15536
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>

using namespace std;

int main() {
  int n, l;
  scanf("%d%d", &n, &l);
  int sum = 0, minabs = INT_MAX;
  for (int i = 1; i <= n; i++) {
    int taste = l + i - 1;
    sum += taste;
    if (abs(minabs) > abs(taste)) {
      minabs = taste;
    }
  }
  int ans = sum - minabs;
  printf("%d\n", ans);
  return 0;
}


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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 200005;

int n, k, s;

int main() {
	read(n), read(k), read(s);
	for (int i = 1; i <= k; ++i) {
		print(s, ' ');
	}
	for (int i = k + 1; i <= n; ++i) {
		if (s > n) {
			print(1, ' ');
		} else {
			print(s + 1, ' ');
		}
	}
	putchar('\n');
}


Measured memory_bytes: 4668