akhauriyash/Code-Regression huggingface dataset:
package main

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

// {{{
// source: https://github.com/raahii/algo
func MaxInts(nums []int) (int, int) {
	var maxIdx, maxVal int
	for i, e := range nums {
		if i == 0 || e > maxVal {
			maxIdx = i
			maxVal = e
		}
	}
	return maxVal, maxIdx
}

func MinInts(nums []int) (int, int) {
	var minIdx, minVal int
	for i, e := range nums {
		if i == 0 || e < minVal {
			minIdx = i
			minVal = e
		}
	}
	return minVal, minIdx
}

func SumInts(nums []int) int {
	s := 0
	for _, v := range nums {
		s += v
	}
	return s
}

func ReverseInts(nums []int) []int {
	rnums := make([]int, len(nums))
	for i := 0; i < len(nums); i++ {
		rnums[len(nums)-1-i] = nums[i]
	}
	return rnums
}

func ExtendInts(nums1 []int, nums2 []int) []int {
	for _, v := range nums2 {
		nums1 = append(nums1, v)
	}
	return nums1
}

func Ints2d(n_rows, n_cols int) [][]int {
	ints := make([][]int, n_rows)
	for i := 0; i < n_rows; i++ {
		ints[i] = make([]int, n_cols)
	}
	return ints
}

func MemsetInts1d(nums []int, val int) {
	for i := range nums {
		nums[i] = val
	}
}

func MemsetInts2d(nums [][]int, val int) {
	for i := range nums {
		for j := range nums[i] {
			nums[i][j] = val
		}
	}
}

func ContainsInt(nums []int, num int) bool {
	sort.Ints(nums)

	s, e := 0, len(nums)
	for {
		if s >= e {
			break
		}

		m := (e + s) / 2
		if nums[m] == num {
			return true
		} else if num > nums[m] {
			s = m + 1
		} else {
			e = m
		}
	}

	return false
}

func ReadInt(f *os.File) int {
	var n int
	fmt.Fscanf(f, "%d", &n)
	return n
}

func ReadInts(f *os.File, n int) []int {
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(f, "%d", &nums[i])
	}
	return nums
}

func ScanInts(f *os.File, vars ...*int) {
	for i := 0; i < len(vars); i++ {
		fmt.Fscanf(f, "%d", vars[i])
	}
}

func ReadLines(f *os.File, n int) []string {
	var lines []string
	reader := bufio.NewReader(f)
	for i := 0; i < n; i++ {
		bytes, _, err := reader.ReadLine()
		if err != nil {
			break
		}
		lines = append(lines, string(bytes))
	}

	return lines
}

func ReadWords(f *os.File, n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(f, "%s", &strs[i])
	}
	return strs
}

func Pow(a, n int) int {
	c := 1
	for i := 0; i < n; i++ {
		c *= a
	}
	return c
}

// }}}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func calc(indices []int) int {
	counter := make([]int, 4)
	bamboos := make([]int, 4)
	cost := 0

	for i, v := range indices {
		if v != 3 && counter[v] > 0 {
			cost += 10
		}
		bamboos[v] += L[i]
		counter[v]++
	}

	if counter[0] == 0 || counter[1] == 0 || counter[2] == 0 {
		return math.MaxInt32
	}

	targets := []int{A, B, C}
	for i, v := range bamboos {
		if i != 3 {
			cost += abs(targets[i] - v)
		}
	}

	return cost
}

func dfs(d int, v []int, c *[]int) {
	if d == N {
		*c = append(*c, calc(v))
		return
	}

	for i := 0; i < 4; i++ {
		v[d] = i
		dfs(d+1, v, c)
	}
	v[d] = 0
}

var N, A, B, C int
var L []int

func main() {
	fmt.Scan(&N, &A, &B, &C)
	L = ReadInts(os.Stdin, N)

	v := make([]int, len(L))
	costs := make([]int, 0, 2<<16)
	dfs(0, v, &costs)
	min, _ := MinInts(costs)
	fmt.Println(min)
}

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

public class Main {
    public static void main(String[] args)throws  Exception{
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int a = Integer.parseInt(tokenizer.nextToken());
        int b = Integer.parseInt(tokenizer.nextToken());
        int c = Integer.parseInt(tokenizer.nextToken());
        if (a == c){
            System.out.println(b);
        }else if (a == b){
            System.out.println(c);
        }else{
            System.out.println(a);
        }
    }
}


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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


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

    double dif = 10000000;
    ll index = 0;
    rep(i, n) {
        if(dif > abs((t-h[i]*0.006)-a)) {
            dif = abs((t-h[i]*0.006)-a);
            index = i+1;
        }
    }
    cout << index << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


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

#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int MN = 300 + 5, LN = 17, MOD = 1e9 + 7, INF = 0x3f3f3f3f, BSZ = 320;
const ll INFLL = 1e17;
ll N, M, L, Q;
ll dis[MN][MN], f[MN][MN];

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
   // freopen("in.txt", "r", stdin);
   // freopen("out.txt", "w", stdout);
    cin >> N >> M >> L;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            dis[i][j] = f[i][j] = INFLL;
        }
        dis[i][i] = f[i][i] = 0;
    }
    for (int i = 0; i < M; i++) {
        int u, v; ll w;
        cin >> u >> v >> w;
        dis[u][v] = min(dis[u][v], w);
        dis[v][u] = min(dis[v][u], w);
    }

    for (int k = 1; k <= N; k++) {
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
            }
        }
    }

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            if (i == j) continue;
            if (dis[i][j] <= L)
                f[i][j] = min(f[i][j], 1LL);
        }
    }

    for (int k = 1; k <= N; k++) {
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
            }
        }
    }

    cin >> Q;
    for (int i = 0; i < Q; i++) {
        int s, t;
        cin >> s >> t;
        if (f[s][t] < INFLL) {
            cout << f[s][t] - 1 << '\n';
        } else cout << -1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 2048
h=int(input())
w=int(input())
n=int(input())
ans=0
ansc=0
while True:
    if ansc>=n:
        print(ans)
        break
    if h>w:
        w-=1
        ansc+=h
        ans+=1
    else:
        h-=1
        ansc+=w
        ans+=1

Measured memory_bytes: 3060
<?php
 fscanf(STDIN,"%d%d",$n,$m);
$citys = array();
 for($i=0;$i<$m;$i++){
   $p_y = explode(" ",trim(fgets(STDIN)));
   $pref[$p_y[0]][] = $p_y[1];
   $py_li[] = $p_y;
 }
 

//昇順にする
$p_y_key_li = array_keys($pref);
for($i=0;$i<count($p_y_key_li);$i++){
  sort($pref[$p_y_key_li[$i]]);
}

// print_r($pref);

$memo = [];
foreach($pref as $key => $list){
    foreach($pref[$key] as $num => $year){
        $memo[$year] = $num+1;
    }
}
// print_r($memo);

foreach($py_li as $py){
  $x = $memo[$py[1]];
  for($i=0;$i<6-strlen($py[0]);$i++){
    echo "0";
  }
  echo $py[0];
   for($i=0;$i<6-strlen($x);$i++){
    echo "0";
  }
  echo $x."\n";
}
//print_r($pref);


Measured memory_bytes: 115944
// ABC 154-D
// 2020.2.9 bal4u

#include <stdio.h>

typedef long long ll;

#define gc() getchar_unlocked()

int in() {   // 非負整数の入力
	int n = 0; int c;
	c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

int s[200005];
int a[200005];

int main()
{
	int i, K, N;
	int ma, ii;
	double ans;
	
	N = in(), K = in();
	for (i = 1; i <= N; ++i) {
		a[i] = in() + 1;
		s[i] = s[i-1] + a[i];
	}
	ma = 0;
	for (i = K; i <= N; ++i) {
		if (s[i]-s[i-K] > ma) {
			ma = s[i]-s[i-K], ii = i-K;
		}
	}
	ans = 0;
	for (i = 1; i <= K; ++i) ans += a[i+ii]*0.5;
	printf("%.10lf\n", ans);
	return 0;
}


Measured memory_bytes: 1792
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        int N = in.nextInt();
        int arrayT [] = new int [N];
        int arrayB [] = new int [N];
        int top [] = new int [N];
        int sumT = 0;
        int sumB = 0;
        int best = 0;
        for (int i = 0; i < N; i++ )
        {
            arrayT[i] = in.nextInt();
        }
        for (int i = 0; i < N; i++ )
        {
            arrayB[i] = in.nextInt();
        }
        int bottom [] = new int [N];
        for (int i =0; i<N;i++)
        {
            sumT += arrayT[i];
            top[i] = sumT;
        }

        for (int i =N-1; i>=0;i--)
        {
            sumB += arrayB[i];
            bottom[i] = sumB;
        }
        int sum = 0;
        for (int i = 0; i < N; i ++){
            sum = top[i] + bottom[i];

            best = Math.max(sum,best);



        }
        System.out.println(best);



        }




    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}


Measured memory_bytes: 21332
#include<iostream>
#include<algorithm>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

// input
uint64_t getZ() {
  uint64_t v = 0; int c;
  while((c = getchar_unlocked()) >= '0') v=v*10+c-'0';
  return v;
}

int main() {
  int N = getZ(), m = 0;
  for(int i = 0; i < N; ++i) {
    int H = getZ();
    if(H+1 < m) fin("No");
    m = std::max(m, H);
  }
  fin("Yes");
  return 0;
}


Measured memory_bytes: 256
//
//  main.c
//  Prison
//
//  Created by yuta on 2019/05/25.
//  Copyright © 2019 501Software. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {

	int N,M;
	int L,R;
	int l=1,r;
	int t=0;
	
	
	// スペース区切りの整数の入力
	scanf("%d %d",&N,&M);

	r = N;
	
	// ゲート
	for(int i = 0; i<M ; i++) {
		
		scanf("%d %d",&L,&R);
		
		if(l < L)
			l = L;
		
		if(r > R)
			r = R;
	}
	
	for(int i=0; i <= N; i++ ){
		if(l <= i && r >= i)
			t++;
	}
	
	printf("%d\n",t);
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int a,b,c,x;
	x='x';
	for(a=1;a<=9;a++){
		for(b=1;b<=9;b++){
			c=a*b;
	printf("%dx%d=%d\n",a,b,c);
			}
		}
	return 0;
}


Measured memory_bytes: 1988
N = int(input())
S = str(input())
dic = {'a':0,'b':0,'c':0,'d':0,'e':0,'f':0,'g':0,'h':0,'i':0,'j':0,'k':0,'l':0,'m':0,'n':0,'o':0,'p':0,'q':0,'r':0,'s':0,'t':0,'u':0,'v':0,'w':0,'x':0,'y':0,'z':0}

ans = 1

for i in range(N):
	dic[S[i]] += 1

for key in list(dic.keys()):
	ans *= (dic[key]+1)

print(str((ans-1)%(10**9+7)))

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

int main()
{
    ll n, k = 0;
    cin >> n;
    vector<ll> a(n + 1), b(n);
    for (ll i = 0; i < n + 1; i++)
    {
        cin >> a[i];
    }
    for (ll i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    for (ll i = 0; i < n; i++)
    {
        if (a[i] < b[i])
        {
            k += a[i];
            b[i] -= a[i];
            if (a[i + 1] <= b[i])
            {
                k += a[i + 1];
                a[i + 1] = 0;
            }
            else
            {
                k += b[i];
                a[i + 1] -= b[i];
            }
        }
        else
        {
            k += b[i];
        }
    }
    cout << k << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int cnt,head[N],n,u,v,Cnt[N][20],ans;
struct node{int to,next;}num[N<<1];
void add(int x,int y)
{
	num[++cnt].to=y;num[cnt].next=head[x];head[x]=cnt;
}
void dfs(int x,int fa)
{
	for (int i=head[x];i;i=num[i].next)
	  if (num[i].to!=fa) {
	     dfs(num[i].to,x);
	     for (int j=0;j<20;j++)
	       Cnt[x][j]+=Cnt[num[i].to][j];   
	  }
	int Min=0;
	for (int j=19;j>=0;j--) if (Cnt[x][j]>=2) {Min=j+1;break;}
	while (Cnt[x][Min]) Min++;
	Cnt[x][Min]=1;
	ans=max(ans,Min);
	for (int j=0;j<Min;j++) Cnt[x][j]=0;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<n;i++) scanf("%d%d",&u,&v),add(u,v),add(v,u);
	dfs(1,-1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 15744
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
#define SP << " " <<
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
vector<ll> kazu0;
vector<ll> kazu1;
vector<ll> kazu(202020);
struct edge{ll to;};
struct graph{
    ll N;
    vector<vector<edge> > G;
    vector<bool> used;

    graph(ll n): N(n), G(N), used(N,false) {}

    void ade(ll s, ll t){
        G[s].emplace_back((edge){t});
        G[t].emplace_back((edge){s}); //無向ならON
    }

    void dfs(ll v=0){
        used[v]=true;
        for(auto E : G[v]){
            if(!used[E.to]){
                kazu[E.to]=1-kazu[v];
                if(kazu[E.to]==0) kazu0.emplace_back(E.to);
                if(kazu[E.to]==1) kazu1.emplace_back(E.to);
                dfs(E.to);
            }
        }
    }
};
vector<ll> ans(202020);
ll num1,num2,num3;
//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    graph g(N);
    rep(i,N-1){
        ll a,b; cin>>a>>b; --a,--b;
        g.ade(a,b);
    }
    kazu[0]=0;
    kazu0.emplace_back(0);
    g.dfs(0);
    if(kazu0.size()<kazu1.size()) swap(kazu0,kazu1);
    
    
    if(kazu1.size()<=N/3){
        for(auto x: kazu1){
            ans[x]=(++num3)*3;
        }
        rep(i,N){
            if(ans[i]!=0) continue;
            if(++num1<=(N+2)/3){
                ans[i]=num1*3-2;
            }
            else if(++num2<=(N+1)/3){
                ans[i]=num2*3-1;
            }
            else{
                ans[i]=(++num3)*3;
            }
        }
    }
    else{
        for(auto x: kazu0){
            if(++num1<=(N+2)/3){
                ans[x]=num1*3-2;
            }
            else{
                ++num3;
                ans[x]=num3*3;
            }
        }
        for(auto x: kazu1){
            if(++num2<=(N+1)/3){
                ans[x]=num2*3-1;
            }
            else{
                ++num3;
                ans[x]=num3*3;
            }
        }
    }
    rep(i,N){
        cout<< ans[i] <<" ";
    }
    cout<<"\n";
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

int main()
{
	std::string s, t;
	std::cin >> s >> t;
	int *table_as{new int[s.size() + 1]}, *table_at{new int[t.size() + 1]};
	table_as[0] = table_at[0] = 0;
	for (unsigned int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'A') table_as[i + 1] = table_as[i] + 1;
		else table_as[i + 1] = table_as[i] + 2;
	}
	for (unsigned int i = 0; i < t.size(); i++)
	{
		if (t[i] == 'A') table_at[i + 1] = table_at[i] + 1;
		else table_at[i + 1] = table_at[i] + 2;
	}
	int q;
	scanf("%d", &q);
	for (int i = 0; i < q; i++)
	{
		int a, b, c, d;
		scanf("%d%d%d%d", &a, &b, &c, &d);
		if ((table_as[b] - table_as[a - 1]) % 3 == (table_at[d] - table_at[c - 1]) % 3)
			printf("YES\n");
		else
			printf("NO\n");
	}

	delete[] table_as;
	delete[] table_at;
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>

using namespace std;

string s;

int main() {
	cin >> s;
	auto pos = s.find('C');
	if(pos != string::npos and s.find('F', pos) != string::npos) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-8;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int par[505];
int find(int x)
{
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

void unite(int x, int y)
{
	x = find(x); y = find(y);
	if (x == y) return;
	if (par[x] < par[y]) swap(x, y);
	if (par[x] == par[y]) par[x]--;
	par[y] = x;
}

bool same(int x, int y)
{
	return find(x) == find(y);
}

int main()
{
	int n, m;
	cin >> n >> m;
	vector<edge> es;
	MS(par, -1);
	REP(i, m)
	{
		int a, b, c;
		cin >> a >> b >> c;
		es.push_back(edge{ a, b, c });
	}
	sort(ALL(es));
	vector<edge> used; 
	int sum = 0;
	REP(i, es.size())
	{
		if (!same(es[i].from, es[i].to))
		{
			unite(es[i].from, es[i].to);
			sum += es[i].cost;
			used.push_back(es[i]);
		}
	}
	
	int ans1 = 0, ans2 = 0;
	REP(j, used.size())
	{
		int sum_ = 0;
		MS(par, -1);
		REP(i, es.size())
		{
			if (es[i].from == used[j].from && es[i].to == used[j].to) continue;
			if (!same(es[i].from, es[i].to))
			{
				unite(es[i].from, es[i].to);
				sum_ += es[i].cost;
			}
		}
		if (sum == sum_)
		{
			ans1++;
			ans2 += used[j].cost;
		}
	}
	cout << n - ans1 - 1 << " " << sum - ans2 << endl;

	return 0;
}

Measured memory_bytes: 2008
N=int(input())
a=list(sorted([int(input()) for _ in range(N)]))

if N%2==0:
    l1=a[:N//2]
    l2=a[N//2:N]
    ans=0
    for i in range(len(l1)):
        ans-=l1[i]*2
    ans+=l1[-1]
    for i in range(len(l2)):
        ans+=l2[i]*2
    ans-=l2[0]
else:
    l11=a[:N//2+1]
    l21=a[N//2+1:N]

    ans1=0
    for i in range(len(l11)):
        ans1-=l11[i]*2
    ans1+=l11[-1]+l11[-2]
    for i in range(len(l21)):
        ans1+=l21[i]*2

    l12=a[:N//2]
    l22=a[N//2:N]

    ans2=0
    for i in range(len(l12)):
        ans2-=l12[i]*2

    for i in range(len(l22)):
        ans2+=l22[i]*2
    ans2-=l22[0]+l22[1]
    ans=max(ans1,ans2)
print(ans)


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

int main(){
	bool cup[ 3 ] = { false };
	cup[ 0 ] = true;
	string s;

	while ( cin >> s ){
		if ( cup[ s[ 0 ] - 'A' ] || cup[ s[ 2 ] - 'A' ] ){
			cup[ s[ 0 ] - 'A' ] = !cup[ s[ 0 ] - 'A' ];
			cup[ s[ 2 ] - 'A' ] = !cup[ s[ 2 ] - 'A' ];
		}
	}

	for ( int i = 0; i < 3; ++i ){
		if ( cup[ i ] ){
			cout << static_cast< char >( i + 'A' ) << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>

using namespace std;

int main()
{
	uint32_t n; cin >> n;
	vector<uint32_t> cs(n);
	for (uint32_t i = 0; i < n; i++) {
		cin >> cs[i];
	}

	vector<uint64_t> vals(n);
	vector<uint32_t> marks(200001, -1); // 1 origin, idx: c, elem : idx
	
	vals[0] = 1;
	marks[cs[0]] = 0;
	for (uint32_t i = 1; i < n; i++) {
		//cout << i << " "  << vals[i - 1] << endl;
		uint32_t c = cs[i];
		if (c == cs[i - 1]) {
			vals[i] = vals[i - 1];
			continue;
		}

		uint32_t& cur_mark = marks[c];
		if (cur_mark != -1) {
			vals[i] = vals[i - 1] + vals[cur_mark];
			vals[i] %= 1000000007;
		}
		else {
			vals[i] = vals[i - 1];
		}

		//cout << i << " " << c << " " << vals[i] << endl;

		cur_mark = i;
	}

	cout << vals[n - 1] << endl;

	return 0;
}


Measured memory_bytes: 3328
n,m=map(int,input().split())
h=list(map(int,input().split()))
ans=[True]*n

for i in range(m):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    ha=h[a]
    hb=h[b]
    if ha>hb:
        ans[b]=False
    elif hb>ha:
        ans[a]=False
    else:
        ans[a]=False
        ans[b]=False
cnt=0
for f in ans:
    if f:
        cnt+=1
print(cnt)

Measured memory_bytes: 20116
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;

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

    int n, m, q, a[112345], b[112345], v[112345], d[112345], c[112345];
    P res[112345];
    V g[112345];

    cin >> n >> m;
    REP(i, m)
    {
        cin >> a[i] >> b[i];
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }
    cin >> q;
    REP(i, q)
    cin >> v[i] >> d[i] >> c[i];

    fill(res, res + n + 1, make_pair(-1, -1));

    for (int i = q - 1; i >= 0; i--)
    {
        queue<int> que;

        que.push(v[i]);

        REP(j, d[i] + 1)
        {
            V vec;
            while (que.size())
            {
                vec.push_back(que.front());
                que.pop();
            }

            for (int k : vec)
            {
                if (res[k].first == -1)
                {
                    res[k].first = c[i];
                }

                if (res[k].second < d[i] - j)
                {
                    res[k].second = d[i] - j;
                    for (int l : g[k])
                        que.push(l);
                }
            }
        }
    }

    REP(i, n)
    {
        res[i + 1].first = max(0, res[i + 1].first);
        cout << res[i + 1].first << endl;
    }

    return 0;
}

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

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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);

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

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

    ll ans = 0, cnt = 0;
    rep(i, n) {
        cnt++;
        if (a[i] != a[i + 1]) {
            if (cnt % 2) ans++;
            cnt = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4848
#include <iostream>
using namespace std;
int main(){
	string a;
	cin >> a;
	for(int i=0;i<a.length();i++){
		if(a[i] == 'C'){
			for(int j=i;j<a.length();j++){
				if(a[j] == 'F'){
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

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

using namespace std;


long long hpCount(long long HP) {
	if (HP == 1) {
		return 1;
	}
	else {
		return 2 * hpCount(HP / 2) + 1;
	}
}

int main()
{
	long long H;
	cin >> H;


	cout << hpCount(H) << endl;

	return 0;
}

Measured memory_bytes: 256
n=int(input())
dumA=list(map(int,input().split()))
numbers=list(range(1,n+1))              #出席番号のリスト
A=dumA[:n]                              #到着時の人数のリスト

D=dict(zip(A,numbers))                  #出席番号と到着順を関連付けるための辞書
for a in sorted(A):
    print(D[a],end=" ")

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

typedef long long ll;
ll MOD = 1000000007;
ll MOD1 = 2019;

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;}

int main()
{
    ll L, R, mi = 1LL<<60;
    cin >> L >> R;

    if (R - L >= 2019) {
        cout << 0 << endl;
        return 0;
    } else {
        for (ll i = L; i < R; i++) {
            for (ll j = i+1; j <= R; j++) {
                mi = min(mi, i*j%2019);
            }
        }
    }
    cout << mi << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
const int A = 2e3;
const int mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s;
    cin >> s;
    cout << s;
    if (s[(int)s.size() - 1] == 's') cout << "es";
    else cout << 's';
    return 0;
}

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

int main(){
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n), b(m);
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];
  vector<ll> c = convolution<>(a,b);
  for(ll x : c) cout << x << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 27188
#include <bits/stdc++.h>
#define int long long
#define INF 1e+18
using namespace std;

bool ok[8000000];

signed main(){
	int m,n;
	while(cin >> m >> n,m){
		for(int i = 0;i < 8000000;i++) ok[i] = false;
		for(int ans = m;;ans++){
			if(!ok[ans]){
				if(!n){
					cout << ans << endl;
					break;
				}
				n--;
				for(int i = ans;i < 8000000;i += ans) ok[i] = true;
			}
		}
	}
}


Measured memory_bytes: 10868
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

const int N = 200010;

int n, x;
int A[N], num[N], c;
bool vis[N];

int main(){
	scanf("%d%d", &n, &x);
	if(x == 1 || x == 2 * n - 1){
		puts("No");
		return 0;
	}
	puts("Yes");
	if(n == 2){
		puts("1 2 3");
		return 0;
	}
	if(x == 2) A[n] = x, A[n + 1] = x - 1, A[n - 1] = x + 1, A[n + 2] = x + 2;
	else A[n] = x, A[n + 1] = x + 1, A[n - 1] = x - 1, A[n + 2] = x - 2;
	For(i, 1, 2 * n - 1) vis[A[i]] = true;
	For(i, 1, 2 * n - 1) if(!vis[i]) num[++c] = i;
	For(i, 1, 2 * n - 1) if(!A[i]) A[i] = num[c--];
	For(i, 1, 2 * n - 1) printf("%d\n", A[i]);
	return 0;
}

Measured memory_bytes: 3072
def half(toll)
  toll /= 2
  div, mod = toll.divmod(100)
  if(mod > 0 and mod < 50)
    toll = (div * 100) + 50
  elsif(mod > 50 and mod <= 99)
    toll = (div + 1) * 100
  end

  return toll
end

toll_dist = Array.new(8).map{[]}
toll_dist[1][2] = [300, 6]; toll_dist[1][3] = [500, 13]; toll_dist[1][4] = [600, 18]; toll_dist[1][5] = [700, 23]; toll_dist[1][6] = [1350, 43]; toll_dist[1][7] = [1650, 58]
toll_dist[2][3] = [350, 7]; toll_dist[2][4] = [450, 12]; toll_dist[2][5] = [600, 17]; toll_dist[2][6] = [1150, 37]; toll_dist[2][7] = [1500, 52]
toll_dist[3][4] = [250, 5]; toll_dist[3][5] = [400, 10]; toll_dist[3][6] = [1000, 30]; toll_dist[3][7] = [1350, 45];
toll_dist[4][5] = [250, 5]; toll_dist[4][6] = [850, 25]; toll_dist[4][7] = [1300, 40]
toll_dist[5][6] = [600, 20]; toll_dist[5][7] = [1150, 35]
toll_dist[6][7] = [500, 15]

loop do
  start_ic = gets.to_i
  break if start_ic == 0
  start_time = gets.split.join.to_i
  goal_ic = gets.to_i
  goal_time = gets.split.join.to_i

  if(start_ic > goal_ic)
    start_ic, goal_ic = goal_ic, start_ic
  end

  toll = toll_dist[start_ic][goal_ic][0]
  dist = toll_dist[start_ic][goal_ic][1]

  if(start_time.between?(1730, 1930) or goal_time.between?(1730, 1930)) and (dist <= 40)
    toll = half(toll)
  end

  puts toll
end

Measured memory_bytes: 8584
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()

struct team{
    string name;
    int score, id;
};

int main(){
    bool begin = true;
    int n;

    while(cin >> n && n){
        if(!begin) puts("");
        begin = false;

        vector<team> rs(n);
        rep(i,n){
            int a, b, c;
            cin >> rs[i].name >> a >> b >> c;
            rs[i].score = a*3 + c;
            rs[i].id = i;
        }

        sort(all(rs),[](const team& a, const team& b){
                if(a.score != b.score) return a.score > b.score;
                else return a.id < b.id;
            });

        rep(i,n){
            cout << rs[i].name << "," << rs[i].score << endl;
        }
    }

}

Measured memory_bytes: 1216
def check(bingo):
    for j in range(3):#縦と横
        if bingo[j][0] == bingo[j][1] == bingo[j][2] == 0:
            return True
        elif bingo[0][j] == bingo[1][j] == bingo[2][j] == 0:
            return True
        else:
            pass
    #斜め
    if bingo[0][0] == bingo[1][1] == bingo[2][2] == 0:
        return True
    elif bingo[2][0] == bingo[1][1] == bingo [0][2] == 0:
        return True
    else:
        return False
    
    

bingo = []
for _ in range(3):
    bingo.append(list(map(int,input().split())))

n = int(input())

for _ in range(n):
    b = int(input())

    for i in range(3):
        for j in range(3):
            if bingo[i][j] == b:
                bingo[i][j] = 0



if check(bingo) == True:
    print("Yes")
else:
    print("No")






Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

//#define debug(x) ;
#define debug(x) cerr << #x << " = " << x << "\n";

ostream& operator<<(ostream& cerr, vector<ll> aux) {
  cerr << "[";
  for (auto e : aux) cerr << e << ' ';
  cerr << "]";
  return cerr;
}

const int maxN = 3011;
const int mod = 998244353;

int a, b, c, d;
int dp[maxN][maxN][2];

void upd(int& dest, int& sour, int coef = 1) {
  dest += (1LL * sour * coef) % mod;
  if (dest >= mod) dest -= mod;
}

int main()
{
  //freopen("test.in", "r", stdin);

  cin >> a >> b >> c >> d;
  dp[a][b][0] = 1;

  for (int i = a; i <= c; i++) {
    for (int j = b; j <= d; j++) {

      // From flex state
      upd(dp[i][j + 1][0], dp[i][j][0], i);
      upd(dp[i + 1][j][1], dp[i][j][0], j);
      
      // From forced state
      upd(dp[i][j + 1][0], dp[i][j][1]);
      upd(dp[i + 1][j][1], dp[i][j][1], j);
    }
  }

  int answer = dp[c][d][0];
  upd(answer, dp[c][d][1]);

  cout << answer;


  return 0;
}


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

using namespace std;
 
typedef long long ll;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)

int main(){
    string str;
    cin >> str;
    int ans = 0;
    REP(i, str.length()){
        ans += str[i] - '0';
    }
    ans = max(ans, ((int)str.length() - 1) * 9);
    if(str[0] != '1'){
        ans = max(ans, ((int)str.length() - 1) * 9 + str[0] - '1');
    }
    cout << ans << endl;
}


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

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <map>
#include <cmath>
#include <cstdlib>

//using ll = long long;
using namespace std;

int main(){
  double a,b;
  cin>>a>>b;
  printf("%.8lf\n", M_PI*b*b*b*4/3);
  return 0;
}



Measured memory_bytes: 3272
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i,start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	ll n,x,t;
	cin>>n>>x>>t;
	ll s=ceil(n/(double)x)*t;
	cout<<s<<endl;
		return 0;	
}


Measured memory_bytes: 3628
import java.util.*;

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

        Map<Integer, List<Integer>> graph = new HashMap<>();
        int n = sc.nextInt();
        int m = sc.nextInt();
        for (int i = 0; i < m; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            List<Integer> edges = graph.computeIfAbsent(x, k -> new ArrayList<>());
            edges.add(y);
        }

        Integer[] maxes = new Integer[n+1];
        int maxPath = 0;
        for (int i = 1; i <= n; i++) {
            maxPath = Math.max(maxPath, maxPath(graph, i, maxes));
        }

        System.out.println(maxPath);
    }

    private static int maxPath(Map<Integer, List<Integer>> graph, int i, Integer[] maxes) {
        List<Integer> edges = graph.get(i);
        if(edges == null || edges.isEmpty()) {
            return 0;
        }

        if(maxes[i] != null) {
            return maxes[i];
        }

        int max = 0;
        for (int edge: edges) {
            int path = maxPath(graph, edge, maxes);
            max = Math.max(path, max);
        }

        max++;
        maxes[i] = max;
        return max;
    }
}


Measured memory_bytes: 112860
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,a[300000],ma[300000],mi[300000];
	cin >> n;
	for(int i = 0;i < 3 * n;i++) cin >> a[i];
	int sum = 0;
	map<int,int> mp;
	for(int i = 0;i < n;i++) {
		sum += a[i];
		mp[a[i]]++;
	}
	ma[n - 1] = sum;
	for(int i = n;i < 3 * n;i++){
		int nowmi = mp.begin()->first;
		if(nowmi < a[i]) {
			sum = sum - nowmi + a[i];
			mp[a[i]]++;
			mp[nowmi]--;
			if(!mp[nowmi]) mp.erase(mp.begin());
		}
		ma[i] = sum;
	}
	mp.clear();
	sum = 0;
	for(int i = 3 * n - 1;i >= 2 * n;i--){
		sum += a[i];
		mp[a[i]]++;
	}
	mi[2 * n] = sum;
	for(int i = 2 * n - 1;i >= 0;i--){
		int nowma = (--mp.end())->first;
		if(nowma > a[i]) {
			sum = sum - nowma + a[i];
			mp[a[i]]++;
			mp[nowma]--;
			if(!mp[nowma]) mp.erase((--mp.end()));
		}
		mi[i] = sum;
	}
	int ans = -INF;
	for(int i = n - 1;i < 2 * n;i++){
		ans = max(ans,ma[i] - mi[i + 1]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 13440
#include <cstdio>
typedef long long ll;

int n,x,y,z,s,t;
int f[50][1<<17],Ans=1;
const int p=1000000007;

int main()
{
    scanf("%d%d%d%d",&n,&x,&y,&z);
    for(int i=1;i<=n;++i)Ans=(ll)Ans*10%p;
    t=(1<<(x-1))|(1<<(x+y-1))|(1<<(x+y+z-1));
    s=(1<<(x+y+z))-1;
    f[0][0]=1;
    for(int i=1;i<=n;++i)
        for(int j=0;j<=s;++j)
            for(int k=1;k<=10;++k)
            {
                int r=(j<<k|(1<<(k-1)))&s;
                if((r&t)!=t)(f[i][r]+=f[i-1][j])%=p;
            }
    for(int i=0;i<=s;++i)Ans=(Ans-f[n][i]+p)%p;
    printf("%d\n",Ans);
    return 0;
}


Measured memory_bytes: 22144
/* 
    Author : Jeff Ahn
    Sat 13 Jun 2020 12:57:43 AM PDT 
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define uint unsigned long long
#define endl '\n'
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const map<T,T> &vec){ os<< "{"; for (auto p : vec) os << "(" << p.first << "," << p.second << "), "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_map<T,T>&vec){ os<< "{"; for (auto p : vec) os << "(" << p.first << "," << p.second << "), "; os << "}"; return os; }

template <typename T> struct Modular {
  /* to abbreviate the word "Modular" */
  using M = Modular; 

  /* Infers type from template. The struct/class T must have 
     "modulus" defined as member.*/
  using Type = typename decay<decltype(T::modulus)>::type; 

  /* Mod() is now an alias to the "modulus" (eg 1e9+7) */
  constexpr static Type Mod() { return  T::modulus; }

  /* v is the value of the Mint. [0 <= v < Mod) */
  Type v;
  Modular(long long a = 0) : v((a %= Mod()) < 0 ? a + Mod() : a) {}
  M operator-() const { return M() -= *this; }
  M& operator+=(M r) { if ((v += r.v) >= Mod()) v -= Mod(); return *this; }
  M& operator-=(M r) { if ((v += Mod() - r.v) >= Mod()) v -= Mod(); return *this; }
  M& operator*=(M r) { v = (uint64_t)v * r.v % Mod(); return *this; }
  M& operator/=(M r) { return *this *= mdpow(r, Mod() - 2); }
  friend M operator+(M l, M r) { return l += r; }
  friend M operator-(M l, M r) { return l -= r; }
  friend M operator*(M l, M r) { return l *= r; }
  friend M operator/(M l, M r) { return l /= r; }
  friend bool operator==(M l, M r) { return l.v == r.v; }
  friend M mdpow(M b, unsigned exp) {
    Modular res(1);
    while(exp) {
      if (exp & 1) {
        res *= b;
        if ((res.v += Mod()) >= Mod()) res.v -= Mod();
      }
      b *= b;
      exp >>= 1;
    }
    return res;
  }
};

/* (1) Creates a struct as a template for Mint. */
struct VarMod { static unsigned modulus; };
/* (2) Assigns a reference to the modulus in the newly crated struct. */
unsigned VarMod::modulus = 1e9 + 7;
// uncomment if modulus needs to be changed during runtime
//unsigned& md = VarMod::modulus; 
/* (3) Alias the templated class as Mint. */
using Mint = Modular<VarMod>;

const int mxn = 1e5 + 10;
Mint dp[mxn];

signed main() {
  fastio;
  unsigned n, k;
  cin >> n >> k;
  Mint res(0);
  for (int i = k; i >= 1; i--) {
    Mint b(k / i);
    b = mdpow(b, n);
    dp[i] = b;
    for (int j = 2*i; j <= k; j += i) {
      dp[i] -= dp[j];
    }
    res += (dp[i] * Mint(i));
  }
  cout << res.v << endl;
  
}


Measured memory_bytes: 4008
#include<iostream>

using namespace std;

int main()
{
    int a,b;
    
    while(1){
    cin>>a>>b;
    if(a==0 &&b==0)
        break;
    if(a>b)
        cout<<b<<" "<<a<<endl;
    else
        cout<<a<<" "<<b<<endl;
    }
    return 0;
    
}


Measured memory_bytes: 3088
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

std::vector<int> ZAlgorithm(const std::string& s){
  int c=0;
  std::vector<int> result(s.size());
  for(int i=1;i<s.size();i++){
    if(i+result[i-c]<c+result[c]){
      result[i]=result[i-c];
    }else{
      int j=std::max(0,c+result[c]-i);
      while(i+j<s.size()&&s[j]==s[i+j]){
        ++j;
      }
      result[i]=j;
      c=i;
    }
  }
  return result;
}

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int n;
  std::string s;
  cin>>n>>s;
  int result=0;
  for(int i=0;i<n;i++){
    std::vector<int> lcs=ZAlgorithm(s);
    for(int j=1;j<lcs.size();j++){
      int left_back=i+lcs[j]-1-i;
      if(left_back<j){
        result=std::max(result,lcs[j]);
      }

    }
    s.erase(s.begin());
  }
  cout<<result<<endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = long.Parse(Console.ReadLine());
        //long[] n = Console.ReadLine().Split().Select(long.Parse).ToArray();

        var ans = "No";
        if (n >= 30) ans = "Yes";

        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 27532
n,k=map(int,input().split())
d=list(map(int,input().split()))
use = [str(i) for i in range(10) if i not in d]
mon5 = [int(i+j+k+l+m) for i in use for j in use for k in use for l in use for m in use if int(i+j+k+l+m)>=n]

mon4 = [int(i+j+k+l) for i in use for j in use for k in use for l in use if int(i+j+k+l)>=n]

mon3 = [int(i+j+k) for i in use for j in use for k in use if int(i+j+k)>=n]

mon2 = [int(i+j) for i in use for j in use if int(i+j)>=n]

mon1 = [int(i) for i in use if int(i)>=n]

print(min(mon1+mon2+mon3+mon4+mon5))

Measured memory_bytes: 5884
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

// 参考：Um_nik氏のソースコード
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  sort(ALL(a));
  bool ok = true;
  if (n % 3 == 0) {
    n /= 3;
    bool check1 =
        a[0] == a[n - 1] && a[n] == a[2 * n - 1] && a[2 * n] == a[3 * n - 1];
    bool check2 = (a[0] ^ a[n] ^ a[2 * n]) == 0;
    if (check1 && check2)
      ok = true;
    else
      ok = false;
  } else {
    if (a[n - 1] != 0) ok = false;
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;

int a[N];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 

    int t=1,te=0;
    // cin>>t;
    while(t--){
        int n;
        cin>>n;

        int s=0;
        for(int i=1;i<=n;++i){
            cin>>a[i];
            s+=a[i];
        }
        int res=INT_MAX,ps=0;

        for(int i=1;i<n;++i){
            ps+=a[i];
            res=min(res,abs((s-ps)-ps));
        }

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


        //printf("Case %d: ",++te);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <unordered_map>
using namespace std;

typedef long long llong;
// -2.1e-9 <= int <= 2.1e9

int main()
{
    int N, R, ans;
    cin >> N >> R;
    if (N >= 10) {
        ans = R;
    }
    else {
        ans = R + 100 * (10 - N);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256