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

#define fast() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define o(a) { cout << #a << ":" << (a) <<" ";}
#define ov(a) { cout << "["; \
	for(int i = 0; i < (a).size(); ++i){ \
		cout << i <<":" << a[i] <<" "; \
		if(i % 10 == 9) cout <<"\n"; \
		} \
	cout << "]"; \
}
#define ovv(a) { cout << "["; \
	for(int i = 0; i < a.size(); ++i){ \
		for(int j = 0; j < a[i].size(); ++j){ \
			cout << "(" << i <<"," <<j <<")" <<":" << a[i][j] <<" "; \
		} \
		cout << "\n"; \
	} \
	cout << "]"; \
}
#define op(a) { cout <<"[" << #a << ".fi:"<<a.first; \
					cout << " "<< #a << ".se:" << a.second <<"]"; }

using ll = long long;
const int mod = 1e9 + 7;
const int nax = 1e5 + 5;
vector<ll> a(10 * nax);
int cnt = 0;
//const int max_num = 10;
const ll max_num = 1e10;

void dfs(ll s){
    if(s >= 1e10) return;
    //cout << s <<" ";
    a[cnt++] = s;
    ll last = s%10;
    if(last == 0) {
        dfs(s * 10);
        dfs(s * 10 + 1);
    }
    else
        if(last == 9) {
            dfs(s * 10 + 9);
            dfs(s*10 + 8);
        }
        else {
            dfs(s * 10 + last);
            dfs(s*10 + last + 1);
            dfs(s*10 + last - 1);
        }
}
int main()
{
	//fast();
	int k;
	cin >> k;
	for(ll i = 1; i <= 9; ++i){
		dfs(i);
	}
	sort(a.begin(), a.begin() + cnt);
	/*for(int i = 0; i < 50; ++i){
		cout << a[i] <<" ";
	}*/
	//cout << "cc";
	cout << a[k - 1] <<"\n";
	//cout << cnt;
}


Measured memory_bytes: 8064
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;

ll factorial(ll n) {
    ll f = 1;
    for (ll i = 1; i <= n; ++i) f *= i;
    return f;
}

double distance(int x1, int y1, int x2, int y2) {
    return pow(pow(x1 - x2, 2) + pow(y1 - y2, 2), 0.5);
}

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    vector<int> route(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
        route[i] = i;
    }

    double total = 0;
    int pattern = 0;
    do {
        pattern++;
        int fromX = x[route[0]];
        int fromY = y[route[0]];
        for (int i = 1; i < n; ++i) {
            int toX = x[route[i]];
            int toY = y[route[i]];
            total += distance(fromX, fromY, toX, toY);
        }
    } while(next_permutation(route.begin(), route.end()));

    cout.precision(10);
    cout << total / pattern;

    return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace abc093_b
{
    class program
    {
        static void Main(string[] args)
        {
            ChangeLocalDebugInput();

            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int k = int.Parse(input[2]);

            List<int> l = new List<int>();
            for (int i = a; i <= Math.Min(b,a+k-1); i++)
            {
                if (!l.Contains(i))
                {
                    l.Add(i);
                }
            }
            for (int i = Math.Max(a, b-k+1); i <= b; i++)
            {
                if (!l.Contains(i))
                {
                    l.Add(i);
                }
            }
            foreach (int c in l)
            {
                Console.WriteLine(c);
            }

            Console.ReadKey();
        }


        [System.Diagnostics.Conditional("LOCAL_DEBUG")]
        static void ChangeLocalDebugInput()
        {
            Console.SetIn(new System.IO.StreamReader("../../stdin.txt"));
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  int ans=1;
  for (int i=0;i < n; i++) cin >> v.at(i);
  for (int i=1; i < n; i++){
    for (int j=0; j < i; j++){
      if (v.at(i) < v.at(j)) break;
      if (j==i-1) ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}
  


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(cin.hasNext()){
			double xa1 = cin.nextDouble();
			double ya1 = cin.nextDouble();
			double xa2 = cin.nextDouble();
			double ya2 = cin.nextDouble();
			double xb1 = cin.nextDouble();
			double yb1 = cin.nextDouble();
			double xb2 = cin.nextDouble();
			double yb2 = cin.nextDouble();
			if(xb1 <= xa1 && xa1 <= xb2 && yb1 <= ya1 && ya1 <= yb2 ){
				System.out.println("YES");
			}
			else if(xa1 <= xb1 && xb1 <= xa2 && ya1 <= yb1 && yb1 <= ya2){
				System.out.println("YES");
			}
			else if(xb1 <= xa1 && xa1 <= xb2 && ya1 <= yb1 && yb1 <= ya2){
				System.out.println("YES");
			}
			else if(xa1 <= xb1 && xb1 <= xa2 && yb1 <= ya1 && ya1 <= yb2 ){
				System.out.println("YES");
			}
			else{
				System.out.println("NO");
			}
		}

	}

}

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

int mod = pow(10,9) + 7;
int main(void)
{
	int h;
	cin >> h;

	int w;
	cin >> w;

	vector<vector<char>> grid;

	for(int i = 0;i < h;i++)
	{
		vector<char>temp;
		for(int j = 0;j < w;j++)
		{
			char ch;
			cin >> ch;

			temp.push_back(ch);
		}
		grid.push_back(temp);
	}

	vector<vector<int>> dp;

	for(int i = 0;i < h+1;i++)
	{
		vector<int> temp;
		for(int j = 0;j < w+1;j++)
		{
			temp.push_back(0);
		}
		dp.push_back(temp);
	}

	dp[0][1] = 1;

	for(int i = 1;i <= h;i++)
	{
		for(int j = 1;j <= w;j++)
		{
			if(grid[i-1][j-1] == '.')
				dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod ;
		}
	}

	cout << dp[h][w];

	return 0;
}

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

int main() {
    int b,r,g,c,s,t;
    while(cin >> b >> r >> g >> c >> s >>t && b+r+g+c+s+t>0) {
	cout << 100+b*77+r*51+g*4+c*(-1)+(-3)*(t-b*6-r*4-g-c-s) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import sys
sys.setrecursionlimit(10**9)

def main():
    n = int(input())
    compare = [1]
    total = 1
    for i in range(1, 11):
        now = 26**i
        total = total+now
        if n < total:
            break
        compare.append(now)
    ans = ''
    n -= sum(compare)
    for i_compare in compare[::-1]:
        q, mod = divmod(n, i_compare)
        ans += chr(97+q)
        n = mod

    print(ans)
    return


if __name__ == "__main__":
    main()
    sys.exit(0)

Measured memory_bytes: 61856
package main

import (
    "fmt"
)

func main(){
    m := make([]int, 5)
    for i := 0; i < 5; i++ {
        fmt.Scan(&m[i])
    }
    var k int
    fmt.Scan(&k)
    if m[4] - m[0] <= k {
        fmt.Println("Yay!")
    } else {
        fmt.Println(":(")
    }
}


Measured memory_bytes: 512
from bisect import bisect_left

n = int(input())
A = [int(input()) for _ in range(n)]


def LIS(arr):
	dp = [arr[0]]
	for i in arr[1:]:
		if dp[-1] < i:
			dp.append(i)
		else:
			dp[bisect_left(dp, i)] = i
	return len(dp)

print(LIS(A))


Measured memory_bytes: 11140
# %% constants & libraries
# ------------------------

# %% body
# -------

function main(io = stdin)
    readto(target = '\n') = readuntil(io, target)
    readnum(T::Type{<:Number} = Int; dlm = isspace, kwargs...) =
        parse.(T, split(readto(), dlm; kwargs...))::Vector{T}

    # handle IO and solve
    H, W, M = readnum()
    G = Set{Tuple{Int,Int}}()
    Rcnt, Ccnt = Dict{Int,Int}(), Dict{Int,Int}()
    for h in 1:M
        h, w = readnum()
        push!(G, (h, w))
        Rcnt[h] = get(Rcnt, h, 0) + 1
        Ccnt[w] = get(Ccnt, w, 0) + 1
    end

    maxr = first(findmax(Rcnt))
    maxc = first(findmax(Ccnt))
    ret = maxr + maxc

    rs = filter(Rcnt) do (k,v)
        v == maxr
    end |> keys
    cs = filter(Ccnt) do (k,v)
        v == maxc
    end |> keys

    for r in rs
        for c in cs
            (r, c) ∉ G && return println(ret)
        end
    end
    return println(ret - 1)
end

@static if @isdefined(Juno) || @isdefined(VSCodeServer)
    main(open(replace(@__FILE__, r"(.+)\.jl" => s"\1.in")))
else
    main()
end


Measured memory_bytes: 265600
#include<bits/stdc++.h>
#define int long long
const int inf=1145141919;
const int dd[]={0,-1,0,1,0};
using namespace std;
int p[314514];
signed main(){
	int n,a,b;
	int i,j;
	cin>>n;
	for(i=0;i<n*3;i++)
		cin>>p[i];
	sort(p,p+n*3);
	reverse(p,p+n*3);
	int ans=0;
	for(i=0;i<n;i++)
		ans+=p[i*2+1];
	cout<<ans<<endl;
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
    static int n = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();
        String b = sc.nextLine();
        n = a.length();
        int count = 0;

        for (int i = 0; i < n; i++) {
            if (a.charAt(i) != b.charAt(i)) {
                count++;
            }

        }

        System.out.print(count);

    }
}

Measured memory_bytes: 42284
from heapq import heapify, heappop

N, K = map(int, input().split())
vl = list(map(int, input().split()))
vr = list(reversed(vl))
sum_L = [0]
for vv in vl:
    sum_L.append(sum_L[-1] + vv)

sum_R = [0]
for vv in vr:
    sum_R.append(sum_R[-1] + vv)

ans = 0
for pick in range(min(K, N) + 1):
    for to_remove in range(K + 1):
        if pick + to_remove > K: break
        for left in range(pick + 1):
            right = pick - left

            t = sum_L[left] + sum_R[right]

            q = vl[:left] + vr[:right]
            heapify(q)

            cnt = 0
            while cnt < to_remove and q:
                t -= heappop(q)
                cnt += 1
            ans = max(ans, t)
print(ans)


Measured memory_bytes: 3188
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class B
{
	public static void Main()	
	{
		int N = GetInt();
		int aMin = Int32.MaxValue;
		int aMax = Int32.MinValue;
		for(int i = 0; i < N; i++)
		{
			int a = GetInt();
			aMin = Math.Min(aMin, a);
			aMax = Math.Max(aMax, a);
		}
		Console.WriteLine(aMax - aMin);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 11220
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int[] point = new int[100000];
        
        for(int i = 0; i < N; i++) {
            int a = scan.nextInt();
            if(a > 1) point[a-2]++;
            if(a > 0) point[a-1]++;
            if(a != 100000) point[a]++;
        }
        
        int maxPoint = 0;
        int maxX = 0;

        for(int i = 0; i < 100000; i++) {
            if(point[i] > maxPoint) {
                maxPoint = point[i];
                maxX = i;
            }
        }

        System.out.println(point[maxX]);
    }
}


Measured memory_bytes: 50348
#include <stdlib.h>
#include <stdio.h>
typedef struct{
    int number;
    int attend;
}student;
int compare(const void *a,const void*b){
    student x=*(student *)a,y=*(student*)b;
    int tmp1=x.attend,tmp2=y.attend;
    if(tmp1>tmp2)return 1;
    return -1;
}
int main()
{   
    int n,ans=0;
    scanf("%d",&n);
    student a[n];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i].attend);
        a[i].number=i+1;
    }
    qsort(a,n,sizeof(student),compare);
    for(int i=0;i<n;i++)
    printf("%d ",a[i].number);
    
    return 0;
}


Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int H,W;
int white;
char s[55][55];
int visited[55][55];

int main(){

	int i,j;

	scanf("%d %d",&H,&W);

	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
		scanf(" %c",&s[i][j]);
		if(s[i][j]=='.'){white++;}
		}
	}

	 queue<pair<int,pair<int,int> > > q;

	 int min_dist=-1;

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

	 q.push(make_pair(1,make_pair(0,0)));

	 while( !q.empty() ) {
        pair<int,pair<int,int> > cur = q.front(); q.pop();

		if(cur.second.first == H-1 && cur.second.second==W-1) {
			min_dist=cur.first;
			break;
        }

        for(i=0;i<4;i++) {
			int ny=cur.second.first+dy[i];
			int nx=cur.second.second+dx[i];
			pair<int,pair<int,int> > next;
            if(0<=ny&&ny<H&&0<=nx&&nx<W && s[ny][nx]=='.') {
                    if(visited[ny][nx] == 0) {
						next.second.first=ny;
						next.second.second=nx;
						next.first=cur.first+1;
                        q.push(next);
                        visited[ny][nx]=1;
                    }
                }
            }
        }
	 if(min_dist==-1){
	 printf("%d\n",min_dist);
	 }
	 else{
		 printf("%d\n",white-min_dist);
	 }

return 0;
}

Measured memory_bytes: 256
A, B, C, D = list(map(int, input().split()))
a = A
c = C
is_t = True
while True:
    c -= B
    if c <= 0:
        break
    a -= D
    if a <= 0:
        is_t = False
        break
ans = "Yes" if is_t else "No"
print(ans)


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

using namespace std;

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0);
	long double PI = 3.141592653589793238463;
	int r; 
	cin >> r;
	long double result = (long double)(PI *2)*r;
	cout <<result;
	
	return 0;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
#define si(a) scanf("%d", &a)
#define fore(i,a,b) for(int i = a; i < b; ++i)
#define N_MAX 100005
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
int n,k;
vi v;
vi dp;
void leer(){
    si(n); 
    //si(k);//B
    k=2; //A
    v.assign(n+1,0);
    dp.assign(n+1,INT_MAX);
    fore(i,1,n+1)
        si(v[i]);
    int x;
    x = v[1];
    if(k>n)
        k = n;
    fore(i,1,k+1)
        dp[i] = abs(x-v[i]);
    fore(i,k+1,n+1){
        fore(j,1,k+1){
            dp[i] = min(dp[i],dp[i-j] + abs(v[i]-v[i-j]));
        }
    }
}
void solve(){
	leer();
    printf("%d\n", dp[n]);
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 4044
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#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 SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) REV(SORT(V)) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) for(int i = 0; i < (V).size(); i++) {cout << (V).at(i) << endl;}

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,x,y,z;
string s,t;
//

signed main() {
  RAPID;
  IN2(a,s);
  if(a >= 3200) {
    OUT(s);
  } else {
    OUT("red");
  }
}

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

typedef long long ll;
ll ans = 1, worsCase, n;

int main() {
	cin >> n >> worsCase;
	for (ll i = 1, tmp; i < n; i++)
		cin >> tmp, (worsCase > tmp? ans++, worsCase = tmp: 0);
	cout << ans << endl;
}
	


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

int main() {
    int n;
    std::cin >> n;

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

    int q;
    std::cin >> q;

    for (int j = 0; j < q; ++j) {
        int b, e;
        std::cin >> b >> e;
        std::reverse(vec.begin() + b, vec.begin() + e);
    }

    for (auto iter = vec.begin(); iter != vec.end(); ++iter) {
        int member = *iter;
        std::cout << member;
        if (iter != vec.end() - 1) std::cout << ' ';
    }
    std::cout << std::endl;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define fs first
#define sc second

using namespace std;
typedef double D;
typedef pair<int,int> P;
typedef pair<P,P> L;
typedef pair<D,int> pdi;

const D EPS = 1e-8;

inline D func(int x, P a, P b){
  D difx = b.fs - a.fs;
  D dify = b.sc - a.sc;
  return (D)dify/difx * (x-a.fs) + a.sc;
}

int main(){
  int m,l,r;
  P p[110];
  L s[110];
  while(scanf("%d",&m),m){
    l = 10000, r = -10000;
    rep(i,m){
      scanf("%d%d",&p[i].fs,&p[i].sc);
      p[i].fs*=2;
      l = min(l,p[i].fs);
      r = max(r,p[i].fs);
    }
    rep(i,m){
      s[i] = L(p[i],p[(i+1)%m]);
      if(s[i].fs > s[i].sc)swap(s[i].fs,s[i].sc);
    }

    int ans = 0;
    for(D x=l+1;x<r;x+=2){
      vector<pdi> inv; inv.reserve(110);
      rep(i,m){
	if(s[i].fs.fs < x+EPS && x< s[i].sc.fs+EPS){
	  inv.push_back(pdi(func(x,s[i].fs,s[i].sc), i));
	}
      }

      sort(all(inv));
      int prv = -10000;
      for(int i=0;i<(int)inv.size();i+=2){
	int u = inv[i+1].sc, b = inv[i].sc;
	int up = ceil(max(func(x-1,s[u].fs,s[u].sc),
			  func(x+1,s[u].fs,s[u].sc))-EPS);
	int bot = floor(min(func(x-1,s[b].fs,s[b].sc),
			    func(x+1,s[b].fs,s[b].sc))+EPS);
	if(bot<prv)bot = prv;
	ans += up - bot;
	prv = up;
      }
    }
    printf("%d\n",ans);
  }
}

Measured memory_bytes: 1200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
	public static void main(String[] args) throws NumberFormatException, IOException
	{
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int a = Integer.parseInt(br.readLine());
		int minus = a / 15;
		System.out.println(a * 800 - minus * 200);
	}
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X;cin>>X;
  int b=2,m=1;
  for(;b<=X;b++){
    int c=b*b;
    while(true){
      if(c<=X)m=max(m,c);
      else break;
      c*=b;
    }
  }
  cout<<m<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j,k,l,a,b,c;
    cin>>n;
    c=0;
    k=INT_MIN;
    for(i=0;i<n;i++)
    {
        cin>>l;
        c+=l;
        if(l>k)
        {
            k=l;
        }
    }
    c-=k;
    if(c>k)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    from math import floor
    input = sys.stdin.readline

    a, b = input().split()
    a = int(a)
    b = 100 * int(b[:-3]) + int(b[-2:])
    print(a * b // 100)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62420
// music - INF
#include <bits/stdc++.h>
 
 
#define F first
#define S second 
#define int long long
#define farth(i, s) for (__typeof (s.begin ()) i = s.begin (); i != s.end (); ++i)
 
#define make make_pair
#define rall(x) x.rbegin (), x.rend () 
#define read scanf
#define print printf
 
#define bp pop_back
#define pb push_back
#define sz(x) (int)(x.size())
 
#define pf push_front
#define bit __builtin_popcount
#define lower(a, n, x) lower_bound (a + 1, a + 1 + n , x) - a 
#define upper(a, n, x) upper_bound (a + 1, a + 1 + n , x) - a 
 
#define sqr(x) ((x) * 1ll * (x))
#define FAST cin.tie(0); cout.tie(0);
#define all(x) x.begin (), x.end ()
 
#define TIME clock () * 1.0 / CLOCKS_PER_SEC
#define lcm (n, m) (((a) * 1ll * (b)) / __gcd (n, m))
#define CLOCK clock () / (double)CLOCKS_PER_SEC
#define MAGARADZHA ios_base::sync_with_stdio(false);
 
using namespace std;
 
typedef unsigned long long ull;
typedef long double ld;
typedef long long ll;
typedef pair < ll, pair < ll, ll > > plll;
typedef vector < pair < ll, ll > > vpll;
                                                                 
typedef pair < pair < ll, ll >, pair < ll, ll > > pllll;
typedef vector < ll > vl;
typedef vector < string > vs;
typedef vector < vector <ll > > matrix;
 
typedef pair < ll, ll > pll;
typedef map <ll, ll> mll;
typedef set <ll> sl;
typedef set < pair < ll, ll > > spll;
 
const int MOD = (int)1e9 + 7;
const int N = (int)1e6;                                
const int M = (int)1e3 * 3;
const ll INF = (ll)1e18;
const int NBA = (int)1e6 * 4;                                                                        
const double eps = (double)1e-9;
const int inf = (int)1e9 + 338;

int n;
main () {
	MAGARADZHA
	FAST
	cin >> n;
	int mx = INF;
	for (int i = 1; i <= (n ) / 2; ++i) {
		int l = n - i;
		int r = i;
		int sum = 0;
		//cout << l << " " << r << endl;
		while(l != 0) {
			sum += l % 10;
			l /= 10;
		}
		while(r != 0) {
			sum += r % 10;
			r /= 10;
		}
		mx = min(mx, sum);
	}
	cout << mx;
	return 0;
}

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

using namespace std;

bool add_to_basis(vector<long long> & basis, long long x) {
    for (int j = 61; j >= 0; j--) {
        if ((x>>j) & 1) {
            for (long long t : basis) {
                if (((t >> j) & 1) && ((t>>j+1) == 0)) {
                    x ^= t;
                }
            }
        }
    }
    if (x == 0) return false;
    basis.push_back(x);
    return true;
}

void solve() {
    int n;
    cin >> n;
    vector<long long> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    string s;
    cin >> s;
    vector<long long> basis;
    for (int i = n-1; i >= 0; i--) {
        bool b = add_to_basis(basis, v[i]);
        if (s[i] == '1' && b) {
            cout << 1 << "\n";
            return;
        }
    }
    cout << 0 << "\n";
}

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

    int T;
    cin >> T;
    for (int t = 0; t < T; t++) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define W while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007
#define mp make_pair
  int main()
  {
     FASTIO;
    ll n;
    map <string,int> fgr;
    cin>>n;
    ll count=0,i;
    string s;
    for(i=0;i<n;i++)
    {
        cin>>s;
        fgr[s]++;
    }
    for(auto it:fgr)
    {
        count++;
    }
    cout<<count;
     }

Measured memory_bytes: 19180
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x);
#define PUT(x) cout << x << endl
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

int x[300 * 300 + 1] = {};
int y[300 * 300 + 1] = {};

ll a[200001] = {};
ll b[200001] = {};

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

	for (int i = 0; i < n; i++) {
		int p;
		cin >> p;
		p--;
		a[p] += i;
		a[n + 1] -= i;
		b[0] += i;
		b[p + 1] -= i;
	}

	for (int i = 0; i < n; i++) {
		a[i + 1] += a[i];
		b[i + 1] += b[i];
	}

	for (int i = 0; i < n; i++) {
		a[i] += i + 1;
		b[i] += n - i;
	}

	for (int i = 0; i < n - 1; i++) {
		cout << a[i] << " ";
	}
	cout << a[n - 1] << endl;

	for (int i = 0; i < n - 1; i++) {
		cout << b[i] << " ";
	}
	cout << b[n - 1] << endl;



	return 0;
}



Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define endl '\n'
#define y1 holyshit
const int inf=0x3f3f3f3f;
const int mod=998244353;

int N,S,d[3010];
ll dp[3010],ans;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>N>>S;
    for(int i=1;i<=N;i++) cin>>d[i];
    for(int i=1;i<=N;i++){
    	dp[0]=i;
    	for(int j=3000;j>=d[i];j--) dp[j]=(dp[j]+dp[j-d[i]])%mod;
    	ans=(ans+dp[S])%mod;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n;
    cin >> n;
    vector<int> arr(n, 0);
    for(auto& val: arr)
        cin >> val;
    int S = accumulate(arr.begin(), arr.end(), 0);
    int M = *max_element(arr.begin(), arr.end());
    cout << S - M/2 << endl;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;

ll K=0;

void dfs(ll n,ll c,vector<vector<P>> &children,vector<ll> &color){
    ll x=1;
    for(ll i=0;i<children[n].size();i++){
        if(color[children[n][i].second]!=0){continue;}
        if(x==c){x++;}
        color[children[n][i].second]=x;
        dfs(children[n][i].first,x,children,color);
        K=max(K,x);
        x++;
    }
}


int main(){
    ll N;
    cin >> N;
    vector<ll> A(N-1,0);
    vector<ll> B(N-1,0);
    vector<vector<P>> children(N+1, vector<P>(0));
    vector<ll> color(N-1,0);

    for(int i=0;i<N-1;i++){
        cin>>A[i]>>B[i];
        children[A[i]].emplace_back(P(B[i],i));
        children[B[i]].emplace_back(P(A[i],i));
    ;}
    ll mark=0;
    for(int i=1;i<N+1;i++){
        if(children[i].size()==1){mark=i;break;}
    ;}
    dfs(mark,0,children,color);

    cout<<K<<endl;
    for(int i=0;i<N-1;i++){
        cout<<color[i]<<endl;
    ;}

    


return 0;
}  



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

int main() {
  int k,n;cin>>k>>n;
  vector<int> a(n+1);
  rep(i,n)cin>>a[i];
  a[n]=k+a[0];
  int cnt=0;
  rep(i,n+1){
    cnt=max(cnt,a[i+1]-a[i]);
  }
  cout<<k-cnt<<endl;
}

Measured memory_bytes: 4048
def main():
    _ = int(input())
    A = list(map(int, input().split()))
    ans = 1e10
    for i in range(len(A)+1):
        sum_diff = abs(sum(A[:i]) - sum(A[i:]))
        ans = min(ans, sum_diff)

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9016
from collections import deque

S = input()
Q = int(input())
d = deque()
for s in S:
    d.append(s)
cnt = 0
for _ in range(Q):
    q = input().split()
    if q[0] == '1':
        cnt += 1
    else:
        if q[1] == '1':
            if cnt & 1:
                d.append(q[2])
            else:
                d.appendleft(q[2])
        else:
            if cnt & 1:
                d.appendleft(q[2])
            else:
                d.append(q[2])
if cnt & 1:
    ans = reversed(list(d))
else:
    ans = list(d)
print(''.join(ans))


Measured memory_bytes: 10356
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		// 文字列の入力

		int counter = 0;
		for (int i = 0; i <= a; i++) {
			int tmp1 = x - 500 * i;
			for (int j = 0; j <= b; j++) {
				int tmp2 = tmp1 - 100 * j;
				for (int k = 0; k <= c; k++) {
					int tmp3 = tmp2 - 50 * k;
					if (tmp3 == 0) {
						counter++;
					}
				}
			}
		}

		System.out.println(counter);

	}
}


Measured memory_bytes: 22740
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
long long A, B, C, N, bit[120000], dp[120000];
pair<string, int>x[120000];
void add(int s, int t) {
	while (s <= N + 1) { bit[s] += t; s += s&-s; }
}
long long sum(int s) {
	long long v = 0;
	while (s >= 1) { v += bit[s]; s -= s&-s; }
	return v;
}
int main() {
	while (true) {
		for (int i = 0; i < 120000; i++) {
			bit[i] = 0; x[i] = make_pair("", 0); dp[i] = 0;
		}
		cin >> A >> B >> C; N = B - A + 1; if (C == 0)break;
		for (int i = A; i <= B; i++) {
			x[i - A] = make_pair(to_string(i), i);
		}
		sort(x, x + N); dp[1] = 1; add(1, 1);
		for (int i = 0; i < N; i++) {
			int T = x[i].second - A;
			dp[T + 2] = sum(T + 1); dp[T + 2] %= C;
			add(T + 2, dp[T + 2]);
		}
		long long res = 0;
		for (int i = 2; i <= N + 1; i++)res += dp[i];
		cout << res%C << endl;
	}
	return 0;
}

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

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
//    static final long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // int d[]=new int[n];
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        int n=sc.nextInt();
        int a=sc.nextInt();
        int b=sc.nextInt();
        int p[]=sc.nextIntArray(n);
        int x=0,y=0,z=0;
        for (int i = 0; i < p.length; i++) {
			if(p[i]<=a)x++;
			else if(a<p[i]&&p[i]<=b)y++;
			else z++;
        }
        
        int ans=min(x,y);
        ans=min(ans,z);

        out.println(ans);
        out.flush();
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//    public int compareTo(P p){
//        return d-p.d; //des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


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

const ll MOD = ll(1e9+7);


// ll pow(ll x, ll n) {
//     ll ret = 1;
//     while (n > 0) {
//         if (n & 1) ret = ret * x % MOD;  // n の最下位bitが 1 ならば x^(2^i) をかける
//         x = x * x % MOD;
//         n >>= 1;  // n を1bit 左にずらす
//     }
//     return ret;
// }
ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%MOD;
    }
    return res;
}
int main(){
    ll n;
    cin>>n;
    ll ans=powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n);
    ans%=MOD;
    ans=(ans+MOD)%MOD;
    cout<<ans<<"\n";
    return 0;
}

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

struct node_t {
	int key;
	struct node_t *parent;
	struct node_t *left;
	struct node_t *right;
};
typedef struct node_t Node;

Node *tree_insert(Node *top, Node *z) {
	Node *y, *x;

	y = NULL;
	x = top;
	while (x != NULL) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	z->parent = y;
	if (y == NULL) {
		top = z;
	} else if (z->key < y->key) {
		y->left = z;
	} else {
		y->right = z;
	}
	return top;
}

void inorder_walk(Node *node) {
	if (node->left != NULL) {
		inorder_walk(node->left);
	}
	printf(" %d", node->key);
	if (node->right != NULL) {
		inorder_walk(node->right);
	}
}

void preorder_walk(Node *node) {
	printf(" %d", node->key);
	if (node->left != NULL) {
		preorder_walk(node->left);
	}
	if (node->right != NULL) {
		preorder_walk(node->right);
	}
}

int main(void) {
	int n, i, key;
	char cmd[20];
	Node *top = NULL, *p;

	scanf("%d ", &n);
	for (i = 0; i < n; i++) {
		scanf("%s %d ", cmd, &key);
		if (cmd[0] == 'i') {
			p = malloc(sizeof(Node));
			p->key = key;
			p->parent = p->left = p->right = NULL;
			top = tree_insert(top, p);
		} else {
			inorder_walk(top);
			putchar('\n');
			preorder_walk(top);
			putchar('\n');
		}
	}
	return 0;
}

Measured memory_bytes: 24044
#include <bits/stdc++.h>
using namespace std;
#define int long long 
int n,a[200005],h[200005],dp[200005],mn=INT_MAX;
struct node{
	int l,r,val;
} s[800020];
void build(int k,int l,int r){
	s[k].l=l;s[k].r=r;s[k].val=0;
	if(l==r)	return;
	int mid=(l+r)>>1;
	build(k<<1,l,mid);
	build(k<<1|1,mid+1,r);
}
void modify(int k,int ind,int x){
	if(s[k].l==s[k].r){
		s[k].val=x;
		return;
	}
	int mid=(s[k].l+s[k].r)>>1;
	if(ind<=mid)	modify(k<<1,ind,x);
	else			modify(k<<1|1,ind,x);
	s[k].val=max(s[k<<1].val,s[k<<1|1].val);
}
int query(int k,int l,int r){
	if(l<=s[k].l&&s[k].r<=r){
		return s[k].val;
	}
	int mid=(s[k].l+s[k].r)>>1;
	if(r<=mid)			return query(k<<1,l,r);
	else if(l>mid)		return query(k<<1|1,l,r);
	else				return max(query(k<<1,l,mid),
						query(k<<1|1,mid+1,r));
}
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>h[i],mn=min(mn,h[i]);
	for(int i=1;i<=n;i++)	cin>>a[i];
	build(1,1,200002);
	for(int i=1;i<=n;i++){
		if(h[i]==mn)	dp[i]=a[i];
		else			dp[i]=query(1,1,h[i]-1)+a[i];
		modify(1,h[i],dp[i]);
	}
	int ans=0;
	for(int i=1;i<=n;i++)	ans=max(ans,dp[i]);
	cout<<ans<<endl;
}

Measured memory_bytes: 19584
#include <bits/stdc++.h>
using namespace std;
int main() {
  string O,E;
  cin >> O >> E;
  reverse(O.begin(),O.end());
  reverse(E.begin(),E.end());
  for (int i = 1; !O.empty() || !E.empty(); i++) {
    if (i%2) {
      cout << O.back();
      O.pop_back();
    } else {
      cout << E.back();
      E.pop_back();
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int r[20000];
int main() {
  int n, S;
  while(cin >> n >> S, n||S) {
    REP(i, n) {
      cin >> r[i];
    }
    sort(r, r+n);
    int ans = 0;
    REP(i, n) {
      ans += r+n-upper_bound(r+i+1, r+n, S-r[i]);
    }
    cout << ans << endl;
  }
}

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

int main() {
    vector<int> A(3);
    for(int i = 0; i < 3; i++) {
        cin >> A[i];
    }
    cout << *max_element(A.begin(), A.end()) - *min_element(A.begin(), A.end()) << endl;
}


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


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

bool prime(int64_t a){
	bool pro=true;
	if(a == 1){
		return false;
	}
	else{
		for(int64_t i=2;i<=pow(a,0.5);i++){
			if(a%i == 0){
				pro = false;
				return false;
				break;
			}
		}
		
		if(pro){
			return true;
		}
	}
}

int main(){
	int64_t N,i,j;
	cin >> N;
	
	if (prime(N) == true){
		cout <<N-1<<endl;
	}
	
	
	else {	
		for (i=floor(pow(N,0.5));i>1;i=i-1){
			if(N%i==0){
				j=N/i;
				break;
			}
		}
		
		cout << i+j-2<<endl;
	}
	
}




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

class Main {
	
	static int[] preorder;
	static int[] inorder;
	static int[] postorder;
	
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		final int n = sc.nextInt();
		
		preorder = new int[n];
		inorder = new int[n];
		postorder = new int[n];
		
		for (int i = 0; i < n; i++) {
			preorder[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			inorder[i] = sc.nextInt();
		}
		
		reconstruct(0,0,0,n);
		System.out.print(postorder[0]);
		for (int i = 1; i < n; i++) {
			System.out.print(" "+postorder[i]);
		}
		System.out.println();
	}
	
	static void reconstruct(int pre, int in, int post, int n){
		if(n<=0) return;
		final int q = preorder[pre];
		postorder[post+n-1] = q;
		int x;
		for(x = in; inorder[x]!=q; x++);
		final int l = n-(x-in)-1;
		reconstruct(pre+1, in, post, x-in);
		reconstruct(pre+1+x-in, x+1, post+x-in, l);
	}

}


Measured memory_bytes: 26548
N=int(input())
A=[int(i) for i in input().split()]
A.sort()
cnt={}
K=list(set(A))
K.sort()
for k in K:
  cnt[k]=0
for a in A:
  cnt[a]+=1
E=[]
for k in K:
  if cnt[k]>=2:
    if cnt[k]>=4:
      E.append(k)
    E.append(k)
E.sort()
# print(E)
if len(E)>=2:
  print(E[-1]*E[-2])
else:
  print(0)

Measured memory_bytes: 20236
N = int(input())
T, A = list(map(int, input().split()))
H = list(map(int, input().split()))

delta = [0 for i in range(N)]
for i in range(N):
  delta[i] = abs(A - (T - 0.006*H[i]))

min_d = min(delta)
print(delta.index(min_d)+1)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	const long o=1;
	static int[] s,a;
	static bool[] h;
	static int ans=int.MaxValue;
	static void Main(){
		Sc sc=new Sc();
		s=sc.Ia;
		a=new int[s[0]];
		h=new bool[s[0]];
		for(int i = 0;i<s[0];i++) {a[i]=sc.I;}
		for(int i = 0;i<s[0];i++) {Fu(i,1,0,0);}
		Console.WriteLine("{0}",ans);
	}
	static void Fu(int n,int b,int m,int q){
		m+=a[n];
		h[n]=true;
		if(b==3){ans=Math.Min(q+Math.Abs(s[b]-m),ans);}
		else{
			for(int i = 0;i<s[0];i++) {
				if(!h[i]){Fu(i,b+1,0,q+Math.Abs(s[b]-m));}
			}
		}
		for(int i = n+1;i<s[0];i++) {
			if(!h[i]){Fu(i,b,m,q+10);}
		}
		h[n]=false;
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

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


#define base 1000000007LL
#define ll long long
// unsigned long long int t = 10000000000000000003ULL;
#define ulint unsigned long long int
#define ld long double
#define X first
#define Y second
#define pb push_back
#define EPS 1e-15
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())

#define ms(s, n) memset(s, n, sizeof(s))

#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define sqr(a) (a)*(a)

#define foru(i,a,b) for (ll i = (a); i <= (b); i++)
#define ford(i,a,b) for (ll i = (a); i >= (b); i--)
#define cbit(a) __builtin_popcount(a)
#define uni(a) (a).resize(unique(all(a)) - (a).begin())
#define cprint(n) printf("%.6lf + %.6lfi\n", (n).real(), (n).imag())

#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it !=(a).end(); it++)


using namespace std;
typedef pair<ll, ll> II;
typedef pair<int, int> ii;



struct Edge{
    ll u,v,w;
    Edge(ll u=0, ll v=0, ll w=0): u(u),v(v),w(w) {}
    bool operator < (Edge a){return w<a.w;}
};

const int M=1e5+7;
const int MM=4*M;
const ll MOD=base;
const int MAX=1e9;


inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll power(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = r * n % p; n = n * n % p;} return r;}
inline ll inverse(ll n, ll p=MOD){return power(n,p-2);}
ll search(ll a[], ll N, ll x){ ll l = 0, r = N - 1; while (l <= r){ ll mid = (l + r) / 2; if (x == a[mid]){ return 1; } else if (x < a[mid]){ r = mid - 1; } else if (x > a[mid]){ l = mid + 1; } } return -1; }
ll find_greater_equal(ll a[], ll N, ll x){ int q = lower_bound(a, a + N, x) - a; if(q == N){ return -1; } return q; }
ll find_greater(ll a[], ll N, ll x){ int q = upper_bound(a, a + N, x) - a; if(q == N){ return -1; } return q; }

ll n;
ll a;
ll b;

int main(){
    ios::sync_with_stdio(0);
	cin >> n;
	if(n == 1){
		cout << "Hello World"; return 0;
	}    
	cin >> a >> b;
	cout << a + b;
    return 0;
}





Measured memory_bytes: 256
x=require('fs').readFileSync('/dev/stdin','utf8').split(/\s/);for(i=1;i<x[0]*3+1;){a=x[i]*x[i++],b=x[i]*x[i++],c=x[i]*x[i++];if(a+b==c||b+c==a||c+a==b){console.log("YES");}else{console.log("NO");}}

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

int main(){
  
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if(max(a, c) - min(a, c) <= d || (max(a, b) - min(a, b) <= d && max(b, c) - min(b, c) <= d)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}


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

const ll INF = 1e18;

int main(){
  ll N; cin >> N;
  bool clr = false;
  for(ll i=1; i<10;i++){
    for(ll j = 1; j<10; j++){
      if(i*j==N) clr = true;
    }
  }
  cout << (clr?"Yes":"No");
}

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

int main(){
    int k,n;
    string s;
    cin>>k>>s;

    n=s.length();

    if(n<=k){
        cout<<s<<endl;
    }else{
        for(int i=0; i<k; i++){
            cout<<s[i];
        }
        cout<<"..."<<endl;
    }
}


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

int main() {
	int N,ans;
	cin>>N;
	ans=0;
	vector<int> vec(2*N);
	for(int i=0;i<2*N;i++) {
		int L;
		cin>>L;
		vec.at(i)=L;
	}
	sort(vec.begin(),vec.end());
	for(int i=0;i<2*N;i+=2) {
		ans+=vec.at(i);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

signed main(){
  int n;cin >> n;
  vector<int> a(n), ans;
  rep(i,n)cin >> a[i];
  rep(i,n){
    int used = 0;
    drep(j,a.size()-1,0)if(a[j] == j+1){
      a.erase(a.begin()+j);
      ans.push_back(j+1);
      used = 1;
      break;
    }
    if(used == 0){
      cout << -1 << endl;
      return 0;
    }
  }
  reverse(all(ans));
  rep(i,n)cout << ans[i] << endl;
  return 0;
}





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

using namespace std;

typedef long long ll;

const ll MOD = 1e9+7;

signed main()
{
    ll n;
    cin >> n;
    vector<ll> x(n - 1);
    vector<ll> y(n - 1);
    vector<vector<ll>> edges(n);
    for(ll i = 0; i < n - 1; ++i){
        cin >> x[i] >> y[i];
        --x[i];
        --y[i];
        edges[x[i]].push_back(y[i]);
        edges[y[i]].push_back(x[i]);
    }
    vector<ll> flag(n, 0);
    flag[0] = 1;

    function<pair<ll,ll>(ll)> f = [&](ll p){
        pair<ll,ll> ans(1, 1);
        for(auto& xx : edges[p]){
            if(!flag[xx]){
                flag[xx] = true;
                auto h = f(xx);
                ans.first *= (h.first + h.second);
                ans.first %= MOD;
                ans.second *= h.first;
                ans.second %= MOD;
            }
        }
        return ans;
    };
    auto p = f(0);
    cout << (p.first + p.second) % MOD << endl;
}


Measured memory_bytes: 14976