akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define SORT(i) sort((i).begin(),(i).end())
constexpr ll INF = 2000000000;
constexpr ll mod = 1000000007;

int main() {
	int N, M; cin >> N >> M;
	vector<pair<int, int>>stu(N);
	vector<pair<int, int>>co(M);
	rep(i, N) {
		int a, b; cin >> a >> b;
		stu[i] = make_pair(a, b);
	}
	rep(i, M) {
		int a, b; cin >> a >> b;
		co[i] = make_pair(a, b);
	}
	vector<int>ans(N);
	rep(i, N) {
		int xy = INF;
		int sx = stu[i].first, sy = stu[i].second;
		rep(j, M) {
			int x = abs(sx - co[j].first), y = abs(sy - co[j].second);
			if (xy > x + y) {
				xy = min(xy, x + y);
				ans[i] = j + 1;
			}
		}
	}
	rep(i, N)cout << ans[i] << "\n";

	return 0;
}

Measured memory_bytes: 256
B=[];C=[];S=0
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
for i in range(Q):
  b,c=map(int,input().split())
  B.append(b)
  C.append(c)

X=[0]*(10**5+1)
for i in range(N):
  X[A[i]]+=1
  S=S+A[i]

#print(A)
#print(B)
#print(C)

for i in range(Q):
  X[C[i]]+=X[B[i]]
  S=S+X[B[i]]*(C[i]-B[i])
  X[B[i]]=0
  print(S)

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

int main() {
  int N, oma=0;
  cin >> N;
  if (N%2==1) {oma=1;}
  vector<int> a(N);
  for (int i=0; i<N; i++) {
    cin >> a[i];
  }
  
  for (int i=N-1; i>=0; i-=2) {
    cout << a[i] << " ";
  }
  for (int i=oma; i<N; i+=2) {
    cout << a[i];
    if (i<N-2) {
       cout << " ";
    }
  }
  cout << endl;
}


Measured memory_bytes: 4060
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<list>
#include<vector>
#include<cmath>

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

using namespace std;


int main(){
    int n, k;
    cin >> n >> k;
    if(n%k==0)cout << 0 << endl;
    else cout << 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(k,i,n) for(long long i=k;i<n;++i)
using namespace std;
typedef long long ll;
int main(void){
    map<string,int> m;
    m["SAT"]=1;
    m["FRI"]=2;
    m["THU"]=3;
    m["WED"]=4;
    m["TUE"]=5;
    m["MON"]=6;
    m["SUN"]=7;
    string S;
    cin>>S;
    cout<<m[S]<<endl;
}


Measured memory_bytes: 256
# 0-indexed
from math import gcd
INF = 10**9+1
class SegTree:
    def __init__(self, vals, seg_f, ide_ele):
        n = len(vals)
        self.seg_f = seg_f
        self.ide_ele = ide_ele
        self.leaf_n = 1 << (n-1).bit_length()
        self.tree = [ide_ele]*(2*self.leaf_n-1)
        for i in range(n):  # init leaf
            self.tree[i+self.leaf_n-1] = vals[i]
        for i in range(self.leaf_n-2, -1, -1):  # bottom-up
            self.tree[i] = self.seg_f(self.tree[2*i+1], self.tree[2*i+2])

    def update(self, i, x):
        i += (self.leaf_n-1)
        self.tree[i] = x
        while i > 0:
            i = (i-1)//2
            self.tree[i] = self.seg_f(self.tree[2*i+1], self.tree[2*i+2])

    # [l,r)
    def query(self, l, r):
        v_l = self.ide_ele
        v_r = self.ide_ele
        l += (self.leaf_n-1)
        r += (self.leaf_n-1)
        while l < r:
            if l&1 == 0:
                v_l = self.seg_f(v_l, self.tree[l])
            if r&1 == 0:
                v_r = self.seg_f(v_r, self.tree[r-1])
                r -= 1
            l >>= 1
            r >>= 1
        return self.seg_f(v_l ,v_r)


def gcd2(a,b):
    if a >= INF: return b
    elif b >= INF: return a
    else: return gcd(a,b)



n = int(input())
al = list(map(int, input().split()))
st = SegTree(al,gcd2,INF)
ans = 0
for i in range(n):
    if i != 0:
        st.update(i-1,al[i-1])
    st.update(i,INF)
    v = st.query(0,n)
    ans = max(ans,v)


print(ans)

Measured memory_bytes: 88164
package main

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

var si = bufio.NewScanner(os.Stdin)

func readInt() int {
	si.Scan()
	r, _ := strconv.Atoi(si.Text())
	return r
}

func main() {
	si.Split(bufio.ScanWords)
	si.Buffer(make([]byte, 0), 10000000)
	N := readInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = readInt() - 1
	}
	ret := -1
	now := 0
	for i := 0; i < N; i++ {
		if now == 1 {
			ret = i
			break
		}
		now = a[now]
	}
	fmt.Println(ret)
}


Measured memory_bytes: 2048
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author teiwa
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        static long mod = 1000000007;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            long[][][][][] dp = new long[N + 1][5][5][5][5];

            if (N == 3) {
                out.println(61);
                return;
            }

            long ans = 0;
            for (int i = 0; i < 4; i++) {
                for (int j = 0; j < 4; j++) {
                    for (int k = 0; k < 4; k++) {
                        for (int l = 0; l < 4; l++) {
                            ans += dp(N, i, j, k, l, dp);
                        }
                    }
                }
            }
            out.println(ans % mod);
        }

        private long dp(int n, int i, int j, int k, int l, long[][][][][] dp) {
            if (isTarget(i, j, k, l)) {
                return 0;
            }
            if (n == 4) return 1;

            if (dp[n][i][j][k][l] != 0) {
                return dp[n][i][j][k][l];
            }

            long tmp = 0;
            for (int m = 0; m < 4; m++) {
                tmp += dp(n - 1, m, i, j, k, dp);
            }

            tmp %= mod;

            return dp[n][i][j][k][l] = tmp;
        }

        private boolean isTarget(int i, int j, int k, int l) {
            if (i == 0 && j == 1 && k == 2) return true;
            if (i == 1 && j == 0 && k == 2) return true;
            if (i == 0 && j == 2 && k == 1) return true;
            if (i == 0 && k == 1 && l == 2) return true;
            if (i == 0 && j == 1 && l == 2) return true;
            if (j == 0 && k == 1 && l == 2) return true;
            if (j == 1 && k == 0 && l == 2) return true;
            if (j == 0 && k == 2 && l == 1) return true;
            return false;
        }

    }
}



Measured memory_bytes: 24740
N,M = map(int,input().split())
X = []
for i in range(N):
    K = list(map(int,input().split()))
    for i in range(K[0]):
        X.append(K[i+1])
ans = 0
for j in range(M):
    if X.count(j+1) == N:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
	int a,b,c,tmp;
	cin >> a >> b >>c;
	if (a > b){
		tmp = a;
		a = b;
		b = tmp;
	}
	if (a > c){
		tmp = a;
		a = c;
		c = tmp;
	}
	if (b > c){
		tmp = b;
		b = c;
		c = tmp;
	}
	cout << a << " " << b << " " << c << endl;
	return 0;
}


Measured memory_bytes: 3004
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

int m[100010];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N;cin>>N;
    int t;
    for(int i=1;i<=N;++i){
        cin >> t;
        m[i] = t;
    }
    int ans = 1;int cnt = 0;
    for(int i=0;i<=N;++i){
        ++cnt;
        ans = m[ans];
        if(ans==2) {
            cout << cnt << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 768
#include "bits/stdc++.h"
#define ll long long
#define FOR(x) for(ll i = 0;i<(x);i++)
#define ALL(v) (v).begin(),(v).end()


using namespace std;


int main(){
vector<ll> a(5);
FOR(5)cin>>a[i];
ll k;
cin>>k;
if(a[4]-a[0]>k){
cout<<":(\n";
return 0;
}
cout<<"Yay!\n";

}


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

const int DIM = 1e5 + 5;

vector<int> lst;
int arr[DIM], par[DIM];

int main( void ) {
    
    int n;
    cin >> n;
    
    for( int i = 1; i <= n; i ++ ) {
        cin >> arr[i];
        lst.push_back( arr[i] );
    }
    
    sort( lst.begin(), lst.end() );
    
    int ans = 0;
    for( int i = 1; i <= n; i ++ ) {
        arr[i] = (int)( lower_bound( lst.begin(), lst.end(), arr[i] ) - lst.begin() + 1 );
        
        if( arr[i] % 2 == 0 && i % 2 == 1 )
            ans ++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1148
def solve(s, k):
    c = []
    if s[0] == '0':
        c.append(0)

    target = ''

    for si in s:
        if si != target:
            target = si
            c.append(1)
        else:
            c[-1] += 1

    if s[-1] == '0':
        c.append(0)

    c_len = len(c)

    if 2*k+1 >= c_len:
        return sum(c)
    else:
        current = sum(c[0:2*k+1])
        ans = current

        for i in range(2, c_len-2*k, 2):
            current -= (c[i-2] + c[i-1])
            current += (c[i+2*k-1]+c[i+2*k])
            ans = current if current > ans else ans
    return ans


if __name__ == '__main__':
    _, k = map(int, input().split())
    s = input()
    print(solve(s, k))


Measured memory_bytes: 4596
N,A,B = map(int,input().split())
sum1 = 0
for i in range(1,N+1):
  sum2 = 0
  I = str(i)
  for j in range(len(I)):
    sum2 += int(I[j])
  if A <= sum2 <= B:
    sum1 += i
print(sum1)

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007

using namespace std;
using ll = long long int;
using ull = unsigned long long;

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) {
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

int main() {
	ll n;
	cin >> n;
	vector<string> s(n);
	for (ll i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s.begin(), s.end());
	ll count = 1;
	for (ll i = 0; i < n - 1; i++) {
		if (s[i] != s[i+1]) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)

typedef long long ll;

const int N = 1000;
const int M = 500;
int n, m;
int l[M], r[M];
int check[N+2];
int il[M], ir[M];

int main() {
	int i, j;
	scanf("%d%d ", &n, &m);
	for (i=0; i<n; i++)
		scanf("%d%d ", l+i, r+i);

	memset(check, 0, sizeof(check));
	for (i=0; i<m; i++) {
		for (j=l[i]; j<r[i]; j++)
			check[j] = 1;
		if (check[r[i]] != 1)
			check[r[i]] = 2;
	}

	m = 0;
	for (i=1; i<=n; i++) {
		if (check[i-1] != 1 && check[i])
			il[m] = i;
		if (check[i] == 2)
			ir[m++] = i; 
	}

	int res = 0;
	int prev = 0;
	i = 0;
	while (i<m) {
		res += ir[i] - prev;	
		res += ir[i] - il[i];
		prev = il[i++];
	}	

	res += n+1 - prev;
	printf("%d\n", res);

	return 0;
}

Measured memory_bytes: 1208
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=103;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

int vis[M+2][M+2];

 main()

{
    fast
    int n,flag=0;
    cin>>n;
    if(n%2==1)
    {
        n=n-1;
        flag=1;
    }
    int h=n/2;
    f(i,1,n-1)
    {
        f(j,i+1,n)
        {
            vis[i][j]=1;
        }
    }
    f(i,1,h)
    {
        int x=i;
        int y=n-i+1;
        vis[x][y]=0;
    }
    if(flag==1)
    {
        f(i,1,n)vis[i][n+1]=1,vis[n+1][i]=1;
        n++;
    }
    int cnt=0;
     f(i,1,n-1)
    {
        f(j,i+1,n)
        {
            if(vis[i][j]==1)
            {
                 cnt++;
            }
        }
    }
    cout<<cnt<<endl;
    f(i,1,n-1)
    {
        f(j,i+1,n)
        {
            if(vis[i][j]==1)
            {
                cout<<i<<" "<<j<<endl;
            }
        }
    }
    return 0;

}













Measured memory_bytes: 384
using System;
using System.Linq;
using System.Security.Cryptography.X509Certificates;

namespace AtcoderProblem
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = System.Console.ReadLine();
            var stArrayData = line.Split(' ');
            long a = long.Parse(stArrayData[0]);
            var b = long.Parse(stArrayData[1]);
            var c = long.Parse(stArrayData[2]);
            var d = long.Parse(stArrayData[3]);

            long n = a * c;
            long m = a * d;
            long o = b * c;
            long p = b * d;

            long[] q = { n, m, o, p };
            long r = (q.Max());
            Console.WriteLine(r);
        }         
    }
}


Measured memory_bytes: 27964
package main

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

var n, ans int

func main() {
	fmt.Scan(&n)
	reader := bufio.NewScanner(os.Stdin)
	reader.Split(bufio.ScanWords)

	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		reader.Scan()
		a[i], _ = strconv.Atoi(reader.Text())
	}

	var i, j int
	for 0 <= len(a)-1-j {
		b[i] = a[len(a)-1-j]
		j += 2
		i += 1
	}

	if len(a)%2 == 0 {
		j = 0
	} else {
		j = 1
	}
	for j < len(a) {
		b[i] = a[j]
		j += 2
		i += 1
	}

	for i := 0; i < n; i++ {
		fmt.Printf("%d ", b[i])
	}
}

/*  ----------------------------------------  */

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}

func pow(x, y int) uint64 { return uint64(math.Pow(float64(x), float64(y))) }
func abs(x int) int       { return int(math.Abs(float64(x))) }
func floor(x int) int     { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i][0] == a[j][0] {
		return a[i][1] > a[j][1]
	}
	return a[i][0] > a[j][0]
}


Measured memory_bytes: 8832
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int r,g,b,n;
  cin >>r>>g>>b>>n;
  int ans=0;
  rep(i,n+1){
    rep(j,n+1){
      int s=n-i*r-j*g;
      if(s>=0 && s%b==0) ans++;
    }

  }
  cout <<ans<<endl;
}


Measured memory_bytes: 256
#ABC172-D

N=int(input())
yaku=[0]+[1]*N

for i in range(2,N+1):
    t=N//i
    for j in range(1,t+1):
        #print(i,j)
        yaku[i*j] +=1
ans=0
for i in range(1,N+1):
    ans += i*yaku[i]
print(ans)

Measured memory_bytes: 224164
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multi_set;

#define mod         1000000007
#define pi          acos(-1.0)
#define eps         1e-9


#define fast       ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define fs          first
#define sc          second
#define pb         push_back
#define sp          printf(" ")
#define nl          '\n'
#define all(a) a.begin(),a.end()
#define unique(c) (c).resize(unique(all(c)) - (c).begin())
#define itn int

#define set0(a)     memset(a,0,sizeof(a))
#define setneg(a)   memset(a,-1,sizeof(a))
#define setinf(a)   memset(a,126,sizeof(a))

#define REP(i,start,end) for (int i = start; i <=end; i++)
#define RREP(i,end,start) for (int i=end; i>=start ;i--)

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef vector<double> vd;
typedef vector<vector<LL> > matrix;
typedef vector<vector<int> > graph;
LL INF=1e9;

const int maxn=3e3+5;
double dp[maxn][maxn];
bool dp2[maxn][maxn];
int n;
double p[maxn];

double func(int i, int j)
{
    if(i==0 and j==0)
        return 1;
    double &r =dp[i][j];
    if(dp2[i][j]==1)
        return r;
    dp2[i][j]=1;
    double ans1=0;
    double ans2=0;
    int x=i+j;
    if(i>0)
        ans1=p[x]*func(i-1,j);
    if(j>0)
        ans2=(1-p[x])*func(i,j-1);
    return r=ans1+ans2;
}
void solve()
{
    set0(dp2);
    cin>>n;
    REP(i,1,n)
        cin>>p[i];
    double ans=0;
    REP(i,n/2+1,n)
        ans+=func(i,n-i);
    cout<<setprecision(10)<<fixed<<ans<<nl;

}
int main()
{
    fast;
        solve();
}


Measured memory_bytes: 78464
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
int pw(int n,int k){
  if(k<0)return pw(n,k+MOD-1);
  int res=1;
  while(k){
    if(k&1)res*=n;//res%=MOD;
    n*=n;//n%=MOD;
    k>>=1;
  }
  return res;
}
//main
signed main(){
  string s;cin>>s;
  string d="dream",dr="dreamer",e="erase",er="eraser";
  int N=s.size();
  reverse(s.begin(),s.end());
  reverse(d.begin(),d.end());
  reverse(dr.begin(),dr.end());
  reverse(e.begin(),e.end());
  reverse(er.begin(),er.end());
  s+="#############";
  int out=0;
  for(int i=0;i<N;i++){
    if(s.substr(i,5)==d)i+=4;
    else if(s.substr(i,7)==dr)i+=6;
    else if(s.substr(i,5)==e)i+=4;
    else if(s.substr(i,6)==er)i+=5;
    else out++;
  }
  if(out)cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
}


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

using namespace std;

int main () {
    int n; cin >> n;
    int l = 1;
    int r = n;
    int ans = -1;
    while (l <= r) {
        int m = (l + r) >> 1;
        int x = n - m;
        for (int i = min (x, m - 1); x > 0 && i >= 1; i = min (i - 1, x)) {
            if (x >= 0) {
                x -= i;
            }
        }
        if (x == 0) {
            ans = m;
            r = m - 1;
        } else {
            l = m + 1;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
use std::io;


/// https://beta.atcoder.jp/contests/abc075/tasks/abc075_b
fn main() {
    let (h, w) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    let mut s = vec![vec![0; w + 2]; h + 2];
    let mut buf = Vec::new();
    for i in 0..h {
        let m = read_one::<String>().chars().collect::<Vec<char>>();
        buf.push(m.clone());
        for j in 0..w {
            s[i + 1][j + 1] = if m[j] == '#' { 1 } else { 0 };
        }
    }
    let mut ans = vec![vec!["#".to_string(); w]; h];
    for i in 0..h { for j in 0..w {
        if buf[i][j] == '.' {
            let mut cnt = 0;
            for x in 0..3 { for y in 0..3 {
                cnt += s[y + i][x + j];
            }}
            ans[i][j] = cnt.to_string();
        }
    }}

    for row in ans {
        println!("{}", row.join(""));
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	int N,M,number,numbers[200000];
	map<int,int> mp;

	cin>>N;
	REP(i,N) cin>>numbers[i];

	cin>>M;
	REP(i,M){
		cin>>number;
		mp[number]++;
	}
	
	REP(i,N){
		if(mp.find(numbers[i])!=mp.end()){
			if(mp[numbers[i]]==1) mp.erase(numbers[i]);
			else mp[numbers[i]]--;
		}
	}

	if(mp.size()==0) print("YES");
	else print("NO");
	return 0;
}



Measured memory_bytes: 10368
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

a, b = inintm()

ans = 0

for i in range(a,b+1):
    if str(i) == str(i)[::-1]:
        ans += 1

print(ans)


Measured memory_bytes: 73220
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
struct UnionFind {
    //If the vertex is a parent, this value will be the number of vertices that belongs to the set, multiplied by -1
    //Otherwise, this value will be the parent's id
    vector<int> r;
 
    UnionFind(int N) {
        r = vector<int>(N, -1);
    }
 
    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }
 
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] < r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }
 
    int size(int x) {
        return -r[root(x)];
    }
};
 
 
int main() {
    int N, M;
    cin >> N >> M;
 
    //Make friends-sets
    UnionFind UF(N);
    for (int i = 0; i < M; i++)
    {
        int A, B;
        cin >> A >> B;
        A -= 1; B -= 1;
        UF.unite(A, B);
    }
 
    //Find the maximum friends-set
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans = max(ans, UF.size(i));
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 10292
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define debug(a) cout << #a ": " << a << endl
using namespace std;
typedef long long ll;
int main(void){
    IOS;
    string s; cin >> s;
    int tot = 0;
    for (int i = 0; i < s.size(); ++i){
        tot += s[i]-'0';
    }
    cout << (tot%9 == 0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3780
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] d = new int[K];
        int[][] A = new int[K][N];
        for (int i=0; i<K; i++) {
            d[i] = sc.nextInt();
            for (int j=0; j<d[i]; j++) {
                A[i][j] = sc.nextInt();
            }
        }

        System.out.println(solve(N, K, d, A));
    }

    private static int solve(int N, int K, int[] d, int[][] A) {
        boolean[] hit = new boolean[N];
        for (int k=0; k<K; k++) {
            for (int i=0; i<d[k]; i++) {
                hit[A[k][i]-1] = true;
            }
        }


        int count = 0;
        for (int i=0; i<N; i++) {
            if (!hit[i]) count++;
        }

        return count;
    }
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

vector<int> sieve(int n) {
	vector<int> res;
	vector<bool> is_prime(n + 1, true);
	
	is_prime[0] = is_prime[1] = false;
	
	for (int i = 2; i * i <= n; i++) if (is_prime[i]) {
		res.push_back(i);
		is_prime[i] = false;
		for (int j = 2; i * j <= n; j++) if (is_prime[i * j]) {
			is_prime[i * j] = false;
		}
	}
	
	REP(i, n + 1) if (is_prime[i]) res.push_back(i);
	sort(res.begin(), res.end());
	return res;
}

int n, x;
int v[30];

int main() {
	vector<int> prime = sieve(1000000);
	
	while (cin >> n >> x, n || x) {
		REP(i, n) scanf("%d", v + i);
		
		bitset<1000001> bs(1);
		REP(i, x + 1) if (bs[i]) {
			REP(j, n) if (i + v[j] <= x) bs[i + v[j]] = 1;
		}
		
		int ans = -1;
		int p = upper_bound(ALL(prime), x) - prime.begin() - 1;
		
		while (p >= 0) {
			if (bs[prime[p]]) {
				ans = prime[p];
				break;
			}
			p--;
		}
		
		if (ans == -1) puts("NA");
		else cout << ans << endl;
	}
	return 0;
}

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

int n, s, sum; vector<int>vec, vec2; bool flag = false;

int main() {
	cin >> n;
	if (n == 3) {
		cout << "2" << endl;
		cout << "5" << endl;
		cout << "63" << endl;
		return 0;
	}
	for (int i = 1; i <= 30000; i++) {
		if (n >= 3 && (i % 2 == 0 || i % 3 == 0)) {
			vec.push_back(i);
			s = i; n--; sum += i;
		}
	}
	for (int i = s + 1; i <= s + 12; i++) { if (i > 30000) continue; if (i % 2 == 0 || i % 3 == 0) vec2.push_back(i); }
	for (int i = 0; i < vec2.size(); i++) {
		for (int j = i + 1; j < vec2.size(); j++) {
			if ((sum + vec2[i] + vec2[j]) % 6 == 0) {
				vec.push_back(vec2[i]);
				vec.push_back(vec2[j]);
				flag = true;
				break;
			}
		}
		if (flag == true) break;
	}
	for (int i = 0; i < vec.size(); i++) { if (i >= 1) cout << " "; cout << vec[i]; }cout << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;

int main(){
    int d;
    cin>>d;
    cout<<"Christmas ";
    if(d==24)cout<<"Eve";
    else if(d==23)cout<<"Eve Eve";
    else if(d==22)cout<<"Eve Eve Eve";
    cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll n,m,ans=0;
void Main(){
    string s,t;cin>>n>>s>>t;
    For(i,0,n) cout<<s[i]<<t[i];
    cout<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#include<climits>
#include<set>
#include<map>
#define ll long long
using namespace std;

int main() {
	string s;
	ll sum=0;
	ll k;
	cin >> s >> k;
	for (ll i = 0; i < s.size(); i++) {
		if (sum+pow(s[i]-'0',5000000000000000) < k) {
			sum += pow(s[i]-'0',  5000000000000000);
		}
		else {
			cout << s[i] << endl;
			//cout << sum << endl;
			break;
		}

	}


}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <math.h>

#define INPUT_FROM_FILE (0)
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif
	int n = 0;
	int debt = 100000;

	std::cin >> n;
	
	for(int i = 0; i < n; i++){
		debt = int(debt * 1.05);
		debt = int(ceil(debt / 1000.0)) * 1000;
	}
	std::cout << debt << std::endl;
	return 0;
}

Measured memory_bytes: 3096
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;

int main(){
    int N; cin >> N;
    vi d;
    rep(i, 0, N){
        int _d;
        cin >> _d;
        d.push_back(_d);
    }
    int cnt = 0;
    rep(i, 0, N){
        rep(j, i+1, N){
            cnt += d[i] * d[j];
        }
    }
    cout << cnt << endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

long lcm(long a, long b)
{
   return a * b / gcd(a, b);
}

int main()
{
   long a, b;
   cin >> a >> b;
  if (b < a){
    long t = b;
    b = a;
    a = t;
  }
   cout << lcm(a, b) << endl;
   return 0;
}


Measured memory_bytes: 256
use proconio::input;
use std::cmp;

fn main() {
    input! {
        x: i32,
        n: usize,
        ps: [i32; n],
    }

    let mut nums = (0..=101).collect::<Vec<_>>();
    nums.retain(|v| !ps.contains(v));

    let mut ans = nums[0];
    for &v in &nums[1..] {
        if (v - x).abs() == (ans - x).abs() {
            ans = cmp::min(ans, v);
        } else if (v - x).abs() < (ans - x).abs() {
            ans = v;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio (false) ;cin.tie(NULL);
#define tc  int t;cin>>t;for(int i=0;i<t;i++)
#define ll long long int
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define um(a,b) unordered_map<a,b>
#define vv(a) vector<a>
#define pp(a,b) pair<a,b>
int main(){
  FIO;
  ll n,k;
  cin>>n>>k;
  ll arr[n+1];
  forn1(i,1,n){
  cin>>arr[i];
  }
  ll temp[n+5];
  memset(temp,0,sizeof(temp));
  ll count=0;

  while(k--&&count!=n){
    count=0;
    for(ll i=1;i<=n;i++){
        ll a=max(1LL,i-arr[i]);
        ll x=n;
        ll b=min(x,i+arr[i]);
        temp[a]++;
        temp[b+1]--;
    }

    for(ll i=1;i<n+2;i++){
        temp[i]+=temp[i-1];
        arr[i]=temp[i];
        if(arr[i]==n){
            count++;
        }
    }

    memset(temp,0,sizeof(temp));

  }
  forn1(i,1,n)
    cout<<arr[i]<<" ";
}

Measured memory_bytes: 6768
/* Which of the favors of your Lord will you deny? */

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

#define pi       acos(-1)

#define SI(n)    scanf("%d",&n)
#define SLL(n)   scanf("%lld",&n)
#define SULL(n)   scanf("%llu",&n)
#define SC(n)    scanf("%c",&n)
#define SD(n)    scanf("%lf",&n)

#define fr(i,a,b) for(int i=a ,_b=(b) ;i<= _b;i++)

#define LL      long long
#define PUB     push_back
#define POB     pop_back
#define MP      make_pair;
#define PII     pair<int,int>
#define PLL     pair<ll,ll>


#define GCD     __gcd
#define DEBUG   cout<<"aw"<<endl;

char ara[100];

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

    scanf("%s",ara);

    int len = strlen(ara);

    int cnt=0;

    fr(i,0,len-1)
    {
        if(ara[i]=='-')
            cnt++;
    }

    if(len==a+b+1 && ara[a]=='-' && cnt==1)
        printf("Yes\n");
    else
        printf("No\n");





    return 0;
}



Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
    public static void main(String[] args){
        FastScanner sc = new FastScanner();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        String result = "YES";
        int[] array = new int[]{a, b ,c};
        int total = a + b + c;
        for (int i : array){
            if(i == 5 || i == 7){
                ;
            }else{
                result = "NO";
                break;
            }
        }
        if(total != 17) result ="NO";

        System.out.println(result);


    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }
}


Measured memory_bytes: 21332
s = list(input())

s_sorted = sorted(set(s))
alpha_dict = {chr(a):0 for a in range(ord('a'), ord('z')+1)}
#{'a':0, 'b':0, ..., 'z':0}

def getKeyFromValue(d, val):
    keys = [k for k, v in d.items() if v == val]
    keys = sorted(keys)
    if keys:
        return keys[0]
    else:
        return 'None'

for i in range(len(s_sorted)):
    alpha_dict[s_sorted[i]] += 1

print(getKeyFromValue(alpha_dict, 0))


Measured memory_bytes: 3956
#include <stdio.h>

int main(void){
    char s[200005], t[200005];

    scanf("%s %s", s, t);

    int ans = 0;
    int i = 0;
    while(s[i] != '\0'){
        if(s[i] != t[i]) ans++;
        i++;
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 2124
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

N = int(input())

# 複数個の数値を、intの配列として取得
B = list(map(int, input().split()))

ans=B[0]+B[N-2]
for i in range(N-2):
    ans+=min(B[i],B[i+1])

print(ans)

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

int main(){
   int N,M; cin >> N >> M;
   vector<int> food(M);
   for(int i=0;i<M;i++){
       food[i] = i+1;
   }
   vector<int> num(M,0);

   int k = 0,x = 0;
   for(int i=0;i<N;i++){
       cin >> k;
       for(int j=0;j<k;j++){
           cin >> x;
           for(int l=0;l<M;l++){
               if(x==food[l]){
                   num[l]++;
               }
           }    
       }
   }

   int cnt = 0;
   for(int i=0;i<M;i++){
       if(num[i]==N){
           cnt++;
       }
   }

   cout << cnt << endl;
}

Measured memory_bytes: 256
fun main(arr:Array<String>) {
    val acgt = "ACGT"
    val mjr = readLine()!!
    var ans = 0
    for(i in (0 .. mjr.length)) {
        for(j in (i..mjr.length)) {
            val wd = mjr.substring(i,j)
            if(wd.all { acgt.contains(it) }) {
                ans = Math.max(ans, wd.length)
            }
        }
    }
    println(ans)

}


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

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());
		String[] s = br.readLine().split(" ");
		long[] prefix = new long[n + 1];
		for (int i = 0; i < n; i++)
			prefix[i + 1] = prefix[i] + Integer.parseInt(s[i]);

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

		for (int i = 2; i <= n; i++) {
			for (int j = i - 1; j > 0; j--) {
				dp[j][i] = Long.MAX_VALUE;
				for (int k = j; k < i; k++) {
//					System.out.println(i + " " + j + " " + k);
					long val = dp[j][k] + dp[k+1][i] + (prefix[k] - prefix[j - 1]) + (prefix[i] - prefix[k]);
//					System.out.println(val);
					if (dp[j][i] > val)
						dp[j][i] = val;
				}
			}
		}
		System.out.println(dp[1][n]);
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))
int main()
{
    ll odd = 0,even=0;
  ll n;
  cin>>n;
  for(ll i=1;i<=n;i++)    
  {
    if(i%2)   odd++;
    else      even++;
  }
  ld ans = odd/(ld)n;
  cout<<fixed<<setprecision(12)<<ans;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7

int need(int num, int target);

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

	double ans = 0;

	for (int i = 1; i <= N; i++) {
		ans += 1 / (pow(2, need(i, K)) * N);
	}

	printf("%.16f", ans);

}

int need(int num, int target) {
	int time = 1;
	int ret = 0;
	while (num * time < target) {
		time *= 2;
		ret++;
	}
	return ret;
}






Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<cstring>

using namespace std;


typedef struct{

}list_t;

int main(){

    int n;
    cin >> n;

    string str[n];
    for(int i=0;i<n;i++)cin >> str[i];

    int characters[26];
    for(int i=0;i<26;i++)characters[i] = 50;
    int tmp[26];

    for(int i=0;i<n;i++){
        int j;

        for(j=0;j<26;j++)tmp[j] = 0;

        j = 0;
        while(str[i][j]){
            for(int k=0;k<26;k++){
                if(str[i][j] == char(int('a')+k)){
                    tmp[k]++;
                    break;
                }
            }
            j++;
        }

        for(int j=0;j<26;j++){
            if(characters[j]>tmp[j])characters[j] = tmp[j];
        }
    }

    for(int j=0;j<26;j++){
        //cout << characters[j];
        for(int loop=0;loop<characters[j];loop++)cout << char(int('a')+j);
    }
    cout << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cstdio>
#include <utility>
#include <algorithm>
using std::cin;
using std::cout;
using std::endl;

int main(void)
{
    double n, m, d;
    cin >> n >> m >> d;
    double answer;
    if (d == 0)
    {
        answer = 1.0 / n * (m - 1);
    }
    else
    {
        answer = 2.0 * (n - d) * (m - 1) / n / n;
    }

    //
    //＿Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^＿
    //＞  cout << answer << endl; ＜
    //￣Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^￣
    //Why does this code make WA!!!!????
    //

    printf("%f\n", answer);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define PP pair<int,int>
int inf = 1 << 30;
int N, Q;
int S[300010], T[300010], X;
vector<int> D;
vector<PP> xs;

int n, q, dat[600010];
 
void init(int &n_) {
    int n = 1;
    while (n < n_)n *= 2;
    n_ = n;
    for (int i = 0; i < 2 * n - 1; i++)dat[i] = inf;
}
void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
    if(r < 0) r = n;
    if (r <= a)return;
    if (b <= l)return;
    if(a <= l && r <= b) {
        dat[k] = min(dat[k], x);
        return;
    }
    
    update(a, b, x, k * 2 + 1, l, (r + l) / 2);
    update(a, b, x, k * 2 + 2, (r + l) / 2, r);
}
int find(int a, int b, int k = 0, int l = 0,int r = -1) {
    if(r < 0) r = n;
    if (r <= a)return inf;
    if (b <= l)return inf;
    if (a <= l&&r <= b)return dat[k];
    int val1 = find(a, b, k * 2 + 1, l, (r + l) / 2);
    int val2 = find(a, b, k * 2 + 2, (r + l) / 2, r);
    return std::min(val1,val2);
}

int mini(int k){
    if(k <= 0) return dat[0];
    return min(dat[k], mini((k - 1) / 2));
}

int main(){
    cin >> N >> Q;
    n = Q;
    init(n);
    for(int i = 0; i < N; i++){
        cin >> S[i] >> T[i] >> X;
        xs.push_back({X, i});

    }
    for(int i = 0; i < Q; i++){
        int d;
        cin >> d;
        D.push_back(d);
    }
    for(int i = 0; i < N; i++){
        int idx = xs[i].second;
        int X = xs[i].first;
        int lb = lower_bound(D.begin(), D.end(), S[idx] - X) - D.begin();
        int ub = lower_bound(D.begin(), D.end(), T[idx] - X) - D.begin();
        update(lb, ub, X);
    }
    for(int i = 0; i < Q; i++){
        int ans = mini(i + n - 1);
        cout << ( ans == 1 << 30 ? -1 : ans) << endl;
    }
    return 0;
}

Measured memory_bytes: 9584
#pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef int64_t i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
	i64 from, to, cost;
	edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
	edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}
#pragma endregion

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<i64> a(3 * n);
	for(int i = 0; i < 3 * n; ++i) cin >> a[i];
	sort(a.begin(), a.end(), greater<i64>());
	i64 cnt = 0, ans = 0;
	for(int i = 1; i < 3 * n; i += 2){
		if(cnt >= n) break;
		ans += a[i];
		++cnt;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2688