akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000000;
#define MOD 1000000007LL;
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
typedef int64_t i64;

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

i64 N; cin>> N;
VI A(N); 
rep(i, 0, N) {
    cin >> A[i];
    A[i] -= i + 1;
}
sort(ALL(A));
int med0 = A[N/2];
i64 sad0 = 0;
rep(i, 0, N) sad0 += abs(A[i] - med0);

cout << sad0 << endl;



}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    static int M;
    static int[][] pair;
    static int max = 0;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        M = sc.nextInt();
        int Q = sc.nextInt();
        pair = new int[Q][4];
        for (int i = 0; i < pair.length; i++) {
            for (int j = 0; j < 4; j++) {
                pair[i][j] = sc.nextInt();
            }
        }
        int[] A = new int[N];
        numArray(A, 0, 1);
        System.out.println(max);
        sc.close();
    }

    static void numArray(int[] array, int index, int pre) {
        if (index == array.length) {
            max = Math.max(max, res(array, pair));
            return;
        }
        for (array[index] = pre; array[index] <= M; array[index]++) {
            numArray(array, index + 1, array[index]);   
        }
    }

    static int res(int[] array, int[][] abcd) {
        int sum = 0;
        for (int i = 0; i < abcd.length; i++) {
            if (array[abcd[i][1] - 1] - array[abcd[i][0] - 1] == abcd[i][2]) {
                sum += abcd[i][3];
            }    
        }
        return sum;
    }
}

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



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    int m=0;
    cin>>n;
    if(n>=105)m++;
  	if(n>=135)m++;
    if(n>=165)m++;
  	if(n>=189)m++;
    if(n>=195)m++;
    cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int n,m,l;
    int i,j,k;
    int a[110][110];
    int b[110][110];
    long long c[110][110]={0};
    
    scanf("%d %d %d", &n, &m, &l);
    
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d", &a[i][j]);
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
            scanf("%d", &b[i][j]);
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            for(k=0;k<m;k++){
                c[i][j]+=a[i][k]*b[k][j];
            }
            if(j!=0) printf(" ");
            printf("%ld", c[i][j]);
        }
        puts("");
    }
    return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
int main() {
    stack<int> stk;
    string s;
    while (cin >> s) {
        if (s[0] >= '0' && s[0] <= '9') {
            stk.push(stoi(s));
        } else {
            int a, b;
            a = stk.top();
            stk.pop();
            b = stk.top();
            stk.pop();
            switch (s[0]) {
                case '+':
                    stk.push(a + b);
                    break;
                case '-':
                    stk.push(b - a);
                    break;
                case '*':
                    stk.push(a * b);
                    break;
            }
        }
    }
    cout << stk.top() << endl;
}


Measured memory_bytes: 3196
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int len = Integer.parseInt(sc.nextLine());
		long[] line = Stream.of(sc.nextLine().split(" ", 0)).mapToLong(Long::parseLong).toArray();

		Arrays.sort(line);

		long sum = line[len - 1];

		if (len > 2) {
			int items = (len - 1) / 2;
			int lastItems = (len - 1) % 2;
			for (int i = 1; i <= items; i++) {
				if (i == items) {
					if (lastItems == 0) {
						sum += line[len - 1 - i];
					} else {
						sum += line[len - 1 - i] * 2;
					}
				}else {
					sum += line[len - 1 - i] * 2;
				}
			}
		}

		System.out.println(sum);
	}

}

Measured memory_bytes: 83268
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <vector>
using namespace std;
const int INF = 0x3f3f3f3f;

int m[100005];
int isOk(int n, int p, int cap){
	int j = 0;
	for(int i = 0; i < p; i++){
		int temp = cap;
		while(m[j] <= temp && j < n){
			temp -= m[j];
			j++;
		}
	}
	return j == n ? 1 : 0;
}

int main(){
	int n, p, Max1 = 0;
	cin >> n >> p;
	for(int i = 0; i < n; i++){
		scanf("%d", m + i);
		Max1 += m[i];
	}
	int l = 0, r = Max1, mid;
	while(l + 1 < r){
		mid = (l + r) / 2;
		if(isOk(n, p, mid))
			r = mid;
		else
			l = mid;
	}
	printf("%d\n", r);
	return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

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

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



int main(){
	int M,T,P,R;
	while(1){
		cin >> M >> T >> P >> R;
		if(M == 0) break;
		int sum[55][15] = {};
		int passed[56] = {};
		int solved[56] = {};
		for(int i = 0;i < R;i++){
			int m,t,p,j;
			cin >> m >> t >> p >> j;
			if(j == 0){
				passed[t] += m + sum[t][p];
				solved[t]++;
			}else{
				sum[t][p] += 20;
			}
		}
		int ban = 0;
		int ch[55] = {};
		while(ban != T){
			if(ban != 0) cout << ",";
			int max_sol = -1,min_time = 1000000;
			for(int i = 1;i <= T;i++){
				if(ch[i] == 0 && solved[i] > max_sol){
					max_sol = solved[i];
					min_time = passed[i];
				}else if(ch[i] == 0 && solved[i] == max_sol && passed[i] < min_time){
					min_time = passed[i];
				}
			}
			int douritu = 0;
			for(int i = T;i >= 1;i--){
				if(ch[i] == 0 && solved[i] == max_sol && passed[i] == min_time){
					ban++;
					ch[i] = 1;
					if(douritu == 0){
						cout << i;
					}else{
						cout << "=" << i;
					}
					douritu++;
				}
			}
		}
		cout << endl;
		
		
	}




}
	


Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,A;
    cin >> H >> A;
    cout << (H+A-1)/A << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=998244353;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}
ll dp[303][303][303];
int main()
{
    string s;
    int k;
    cin>>s>>k;
    s+='0';
    int cnt=0;
    vector<int> v;
    int l=0;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='0'){
            v.push_back(cnt);
            cnt=0;
        }else{
            cnt++; l++;
        }
    }
    int m=v.size();
    dp[0][0][0]=1;
    for(int i=0; i<m; i++){
        for(int j=0; j<=l; j++){
            for(int t=0; t<=l; t++){
                if(dp[i][j][t]==0) continue;
                for(int u=max(0, v[i]-t); u<=min({l, l+v[i]-t, l+v[i]-j}); u++){
                    if(u<v[i]){
                        dp[i+1][j][t-(v[i]-u)]+=dp[i][j][t];
                        if(dp[i+1][j][t-(v[i]-u)]>=MOD) dp[i+1][j][t-(v[i]-u)]-=MOD;
                    }else{
                        dp[i+1][j+u-v[i]][t+u-v[i]]+=dp[i][j][t];
                        if(dp[i+1][j+u-v[i]][t+u-v[i]]>=MOD) dp[i+1][j+u-v[i]][t+u-v[i]]-=MOD;
                    }
                }
            }
        }
    }
    ll ans=0;
    for(int i=0; i<=min(l, k); i++){
        (ans+=dp[m][i][0])%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 57896
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ft first
#define sd second
#define pb push_back
using namespace std;
const ll mod = 1e9+7;

ll power(ll a, ll b, ll m = mod) {
    ll x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}

const int N = 5e5;
// ll a[N];

signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);    
    
    string a, b; cin >> a >> b;
    cout << b << a << "\n";


 
    return 0;
    
}
    


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

using namespace std;

int main()
{
	vector<string> s(3);
	cin >> s[0] >> s[1] >> s[2];
	
	cout << s[0][0] << s[1][1] << s[2][2] << endl;
	return 0;
}

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

int main() {
    int H, W;

    for ( ;; ) {
        cin >> H >> W;

        if ( H == 0 && W == 0 ) break;

        for (int i = 0; i < H; i++) {
            // cout << "Debug : " << i;
            for (int j = 0; j < W; j++ ) {
                if ( i == 0 || i == H - 1 || j == 0 || j == W - 1 ) {
                    cout << "#" ;
                } else {
                    cout << "." ;
                }
            }
            cout << '\n';
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3016
N, M, C = map(int, input().split())
b_list = list(map(int, input().split()))

result = 0
for n in range(0, N):
    a_list = list(map(int, input().split()))
    judge = C
    for idx in range(0, M):
        judge += a_list[idx] * b_list[idx]
    if judge > 0:
        result += 1

print (result)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second
#define NIL -1
using ll = long long;
const ll MOD = 1000000007;
#define REP(i,n) for (ll i=0; i < (n); ++i)
#define FOR(i,a,b) for (ll i=(a); i < (b); ++i)
using namespace std;

int get_gcd(int a, int b) {
  while(1) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    a %= b;
  }
}
int get_lcm(int a, int b){return a * b / get_gcd(a, b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

signed main () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;

  vector<vector<pair<int,int>>> g(n);
  vector<int> color(n, NIL);
  int u,v,w;
  REP(i,n-1) {
    cin >> u >> v >> w;
    u--; v--;
    g[u].push_back(make_pair(v, w));
    g[v].push_back(make_pair(u, w));
  }

  function<void(int,int)> dfs = [&](int n, int c){
    color[n] = c;
    REP(i,g[n].size()) {
      if (color[g[n][i].fi] != NIL) continue;
      dfs(g[n][i].fi, (g[n][i].se + c) % 2);
    }
    return;
  };

  dfs(0, 0);

  REP(i,n) cout << color[i] << endl;

  return 0;
}


Measured memory_bytes: 10880
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)

int main(void){
  int N, K;
  cin >> N >> K;
  int A[N];
  rep(i, N)
    cin >> A[i];
  //ここまで入力

  //整数iが何回出てくるか
  int count[N] = {0};
  rep(i, N)
    count[A[i]-1]++;

  //登場する整数が少ないものをいくつか取れば最適
  //そのまま考えたら難しいので
  //登場する整数が多いものをK種類選ぶ
  //カウントしたものをNから引けば解答になる
  sort(count, count+N, greater<>());

  //登場する整数が多いものをK種類分足す
  int ans_ = 0;
  for(int i=0; i<K; i++)
    ans_ += count[i];
  
  cout << N - ans_ << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
typedef long long     ll;
#define fast          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fr            first
#define sc            second
#define com(i,n)      for(int i=0;i<n;i++)
#define dom(i,n)      for(int i=1;i<=n;i++)
#define mom(i,n)      for(int i=n;i>=0;i--)
#define sortI(a,n)    sort(a,a+n)
#define sortD(a,n)    sort(a,a+n,greater<int>())
#define sortvi(a)     sort(a.begin(),a.end())
#define sortvd(a)     sort(a.begin(),a.end(),greater<int>())
#define sumall(a,x)   accumulate(a.begin(),a.end(),x)
#define pi            3.14159265358979323846264338327950
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    if(y%2==0 && y>=2*x && y<=4*x)
        cout << "Yes\n";
    else
        cout << "No\n";
}


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

const int MOD = 1e9+7;

int putere(int x, int p);
int comb(int n, int k);

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, a, b;

    cin >> n >> a >> b;
    int ans = putere(2,n);
    ans = (ans+MOD-1)%MOD;
    ans = (ans+MOD-comb(n,a))%MOD;
    ans = (ans+MOD-comb(n,b))%MOD;
    cout << ans << '\n';
}

int putere(int x, int p)
{
    int aux = 1;

    while (p)
    {
        if (p%2)
            aux = (1ll*aux*x)%MOD;
        x = (1ll*x*x)%MOD;
        p /= 2;
    }
    return aux;
}

int comb(int n, int k)
{
    int f1=1, f2=1;

    for (int i=n-k+1;i<=n;i++)
        f1 = (1ll*f1*i)%MOD;
    for (int i=1;i<=k;i++)
        f2 = (1ll*f2*i)%MOD;
    f2 = putere(f2,MOD-2);
    return (1ll*f1*f2)%MOD;
}

Measured memory_bytes: 256
import sys
import socket

if socket.gethostname() in ['N551J', 'F551C']:
    test_case = 'c1.in'
    sys.stdin = open(test_case)


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    n = read_int()
    rows = [read_int_list() for i in range(n)]
    a, b = map(list, zip(*rows))
    res = sum(a)
    res = min(res, sum(b))
    all_values = [(a[i], i, 0) for i in range(n)]
    all_values.extend([(b[i], i, 1) for i in range(n)])
    all_values.sort()
    index_of_value = {v: i for i, v in enumerate(all_values)}
    first_values = [
        set(all_values[:n - 2]),
        set(all_values[:n - 1]),
        set(all_values[:n]),
    ]

    s = [sum([t[0] for t in v]) for v in first_values]
    for i in range(n):
        rest = []
        k = 0
        last = n - 2
        indices = sorted([(index_of_value[(a[i], i, 0)], a[i]),
                          (index_of_value[(b[i], i, 1)], b[i])])

        for index, value in indices:
            if index < last:
                last += 1
                k += 1
            else:
                rest.append(value)
        t = s[k] + sum(rest)
        res = min(res, t)
    return res


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()


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

int main(){
  double d,t,s;
  cin >> d >> t >> s;
  if(d/s <= t) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3720
import java.util.*;
import java.util.Map.Entry;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String, Integer> map = new HashMap<>();
        int max = 0;
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            if(!map.containsKey(s)) map.put(s, 0);
            map.put(s, map.get(s) + 1);
            if(max < map.get(s)) max = map.get(s);
        }
        List<String> list = new ArrayList<String>();
        for(Entry<String, Integer> e : map.entrySet()){
            if(e.getValue().equals(max)) list.add(e.getKey());
        }
        Collections.sort(list);
        for(String a : list) System.out.println(a);
        sc.close();

    }

}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  string ans = "";
  if (a <= 0 && b >= 0) ans = "Zero";
  if (a > 0 && b > 0) ans = "Positive";
  else if (a < 0 && b < 0) {
    int num = b - a + 1;
    if (num % 2 == 0) ans = "Positive";
    else ans = "Negative";
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	int n;
	cin >> n;
	vector<int> a(n+1);
	for (int i = 1; i < n; i++){
		int x;
		cin >> x;
		a[x]++;
	}
	for (int i = 1; i <= n; i++){
		cout << a[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3988
def calculate_dived_by_two(n):
    count = 0
    while n % 2 == 0:
        count += 1

        n //= 2

    return count


n = int(input())

result = 1
max_count = 0
for i in range(1, n + 1):
    count = calculate_dived_by_two(i)
    if count > max_count:
        max_count = count
        result = i

print(result)


Measured memory_bytes: 2940
a=list(map(int,input().split()))
b=[0,0,0]
count=0
if a[0]==a[1]==a[2] and a[0]%2==0:
    print(-1)
else:
    while a[0]%2==a[1]%2==a[2]%2==0:
        b[0]=a[0]
        b[1]=a[1]
        b[2]=a[2]
        a[0]=b[1]/2+b[2]/2
        a[1]=b[0]/2+b[2]/2
        a[2]=b[1]/2+b[0]/2
        count+=1
    print(count)

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
	int i,n,k;
	char x[10001];
	while(scanf("%s",x) != EOF){n=0,k=0;
		for(i=0;x[i]!='\0';i++){
			if(x[i]=='J' && x[i+1]=='O' && x[i+2]=='I')++n;
			if(x[i]=='I' && x[i+1]=='O' && x[i+2]=='I')++k;
		}
		printf("%d\n%d\n",n,k);
	}
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    int t[n],x[n],y[n];
    for(int i=0; i<n; i++){
        cin >> t[i] >> x[i] >> y[i];
    }
    for(int i=0; i<n; i++){
        if(x[i]+y[i] > t[i]){
            cout << "No" << endl;
            return 0;
        }
        if((x[i]+y[i])%2 != t[i]%2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define scn(var)         cin >> var;
#define pYes()           prt("Yes")
#define pNo()            prt("No")
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------------------
string digit_4(int n, int k){
  string s;
  int digit = 4;
  if(k==0){s="0";}
  while(k>0){
    s.push_back((k%digit)+'0');
    k -= k%digit;
    k /= digit;
  }

  while(s.size()<n){
    s.push_back('0');
  }
  return s;
}

int main(void) {
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  arr(l,n);

  int ans=10000000;
  rep(i,pow(4,n)){
    string s=digit_4(n, i);

    int take[4]={};
    int tmp=0;
    rep(i,n){
      if(s[i]!='0' && take[s[i]-'0']>0) tmp+=10;
      take[s[i]-'0']+=l[i];
    }

    if(take[1]==0) continue; tmp+=abs(take[1]-a);
    if(take[2]==0) continue; tmp+=abs(take[2]-b);
    if(take[3]==0) continue; tmp+=abs(take[3]-c);

    //prt3(s, tmp, ans);
    ans=min(ans,tmp);
  }

  prt(ans);

}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

vector<pair<int, ll> > L[100100];
ll cost[100100];
int N;

void dfs(int v){
    for(int i = 0; i < L[v].size(); i++){
        pair<int, ll> p = L[v][i];
        int next = p.first;
        ll c = p.second;
        if(cost[next] != -1) continue;
        cost[next] = cost[v] + c;
        dfs(next);
    }
}

int main(){
    cin >> N;
    REP(i,N-1){
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--, b--;
        L[a].push_back(make_pair(b, c));
        L[b].push_back(make_pair(a, c));
    }

    int Q, K;
    cin >> Q >> K;
    K--;
    fill(cost, cost+N, -1);
    cost[K] = 0;
    dfs(K);

    REP(i,Q){
        int x, y;
        cin >> x >> y;
        x--,y--;
        cout << cost[x] + cost[y] << endl;
    }
    return 0;
}


Measured memory_bytes: 14336
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int answer = (int)Math.ceil((-1.0 + Math.sqrt(1 + 8L * n)) / 2.0);
        System.out.println(answer);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <string>
#include <bitset>
#include <algorithm>
#include <vector>
#include <cmath>
// #define int long long
#define mod (int)(1e9 + 7)
#define pb push_back
#define ll long long int
using namespace std;
typedef pair<int,int> pii;


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

  vector<vector<pii> > vvp(n+1);
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    int x,y;
    for(int j=0;j<a;j++){
      cin>>x>>y;
      vvp[i].pb(pii(x-1,y));
    }
  }
  
  int ret=0;
  for(int i=1;i<pow(2,n);i++){
    //cout<< bitset<15>(i)<<endl;
    int t=0;
    for(int j=0;j<=n;j++){
      if(i&(1<<j)){
        t++;
        bool f=true;
        for(int k=0;k<vvp[j].size();k++){
          if(((i >> vvp[j][k].first) & 1) == vvp[j][k].second) continue;
          else f=false;
          if(!f) break;          
        }
        if(!f){
          t=-1;
          break;
        }
      }
    }
    ret=max(ret,t);
  }
  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 256
/******

AUTHOR : RUDRANSH TRIPATHI, IIIT NAGPUR, CCID(rt24) & CFID(rsgt24)

MOTTO : Use criticism as fuel and you will never run out of energy.
        AIM : TO BECOME A BETTER CODER
        INTROSPECT + COURSE CORRECTIONS = CATALYST FOR SUCCESS
        Every moment is an opportunity to better yourself

*******/

#include<bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
const int MAX = 2e6 + 5;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define pb push_back
#define d(x) cout<<x<<"\n"
#define time_passed	1.0 * clock() / CLOCKS_PER_SEC

vector<int> graph[100000];
bool visited[100000];
int total=0;

void dfs(int v){
    
	visited[v] = 1;
	
	for(auto x: graph[v]){
	    
		if(visited[x] == 0)
		{
		    dfs(x);
		}
		
	}
}

void solve()
{
    int n;
    cin>>n;
    string x = "";
    for(int i=0;i<n;i++)
    x+="ACL";
    
    cout<<x<<"\n";
    
    /*int a,b,c,d;
    cin>>a>>b>>c>>d;
    
    if(a>=c&&a<=d || b>=c&&b<=d)
    cout<<"Yes"<<"\n";
    else if(c>=a&&c<=b || d>=a&&d<=b)
    cout<<"Yes"<<"\n";
    else
    cout<<"No"<<"\n";*/
    
    
}


int32_t main(void)
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	cerr << "\n" << "Time elapsed : " << time_passed << "\n";
	return 0;
}

Measured memory_bytes: 6120
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<int, lli> il;
template<class T>bool chmax(T &a, const T &b) { if( a < b ) { a = b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) { if( b < a ) { a = b; return 1; } return 0;}

#ifdef LOCAL
	#define eprintf(...) printf(__VA_ARGS__)
#else 
	#define eprintf(...) 1
#endif

#define ROUNDUP(a, b) 		( ((a) + ((b) - 1) ) / b)
#define SET_ZERO(a)	 		( memset((a), 0, sizeof(a)))
#define SET_NUM_ARRAY(a,b)	( memset((a), b, sizeof(a)))
#define int long long

int N;
int A, B;
int h[100010];
bool judge (int n) {
	int t = 0;
	for (int i = 0; i < N; i++) {
		if (h[i] > B*n) {
			t += (h[i] - B*n + (A - B - 1)) / (A - B);
		}
	}

	return t <= n;
}

signed main() {
	scanf("%lld %lld %lld", &N, &A, &B);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &h[i]);
	}

	int l = -1, r = 1001001001, m;
	while (r - l > 1) {
		m = (r + l) / 2;
		if ( judge(m) ) r = m;
		else l = m;
	}

	printf("%lld\n", r);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;

int m=1000000007;

int main()
{
    faster

    int h,w;
    cin>>h>>w;

    char c[h][w];
    int dp[h][w];

    dp[0][0]=1;

    for(int i=0; i<h; i++)
    {
        for(int j=0; j<w; j++)
        {
            cin>>c[i][j];

            if(c[i][j]=='#')
            {
                dp[i][j]=0;
            }
            else
            {
                if(i-1>=0 && j-1>=0)
                    dp[i][j]=(dp[i-1][j]+dp[i][j-1])%m;
                else if(i-1>=0)
                    dp[i][j]=dp[i-1][j];
                else if(j-1>=0)
                    dp[i][j]=dp[i][j-1];
            }
        }
    }

    cout<<dp[h-1][w-1]<<endl;






    return 0;
}


Measured memory_bytes: 8440
#include<stdio.h>

int main(void) {
  char str[4];
  int i;
  scanf("%s", str);
  for (i = 0; i < 3; i++){
    if(str[i] == str[i+1]){
      printf("Bad\n");
      break;
    } else if(i == 2)
    printf("Good\n");
  }
  return 0;
}

Measured memory_bytes: 128
import java.util.*;
//import java.lang.Math;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            int n=sc.nextInt();
            int x=sc.nextInt();
            if(n==0 && x==0) break;
            int ans=0;
            for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++) for(int k=j+1;k<=n;k++){
                if(i+j+k==x) ans++;
            }
            System.out.println(ans);
        }
        sc.close();
    }
}


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

int main(){
  int N,K;
  cin >> N >> K;
  int a[N];
  int i,j,c=0;
  long long int ans[2]={1,1};
  for(i=0;i<N;i++){
    cin >> a[i];
  }
  
  for(i=0;i+K<N;i++){
    if(a[i]<a[i+K]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 4420
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;


template<typename T>
vector<vector<T>> keisann(const vector<vector<T>>l, const vector<vector<T>>r) {
	vector<vector<T>>ans(l.size(), vector<T>(r[0].size()));
	assert(l[0].size() == r.size());
	for (unsigned int h = 0; h < l.size(); ++h) {
		for (unsigned int i = 0; i < r.size(); ++i) {
			for (unsigned int w = 0; w < r[0].size(); ++w) {
				if (l[h][i] && r[i][w])ans[h][w] = true;
				//ans[h][w] += l[h][i] * r[i][w];
			}
		}
	}
	return ans;
}

template<typename T>
vector<vector<T>>powgyou(vector<vector<T>>a, const long long int n) {
	assert(a.size() == a[0].size());
	if (!n) {
		vector<vector<T>>e(a.size(), vector<T>(a[0].size()));
		for (unsigned int i = 0; i < a.size(); ++i) {
			e[i][i] = 1;
		}
		return e;
	}
	if (n == 1)return a;
	else {
		vector<vector<T>>ans(a.size(), vector<T>(a[0].size(), 0));
		ans = powgyou(a, n / 2);
		ans = keisann(ans, ans);
		if (n % 2) {
			ans = keisann(ans, a);
		}
		return ans;
	}
}

struct node{
	int now;
	int from;
};

int main() {
	while (1) {

		int N, M, Z; cin >> N >> M >> Z;
		if (!N)break;
		vector<node>nodes;
		for (int i = 0; i < N; ++i) {
			nodes.push_back(node{ i,-1 });
		}
		
		vector<vector<int>>gyou(N +2* M, vector<int>(N +2*M));
		for (int i = 0; i < M; ++i) {
			int s, d; cin >> s >> d; s--; d--;
			nodes.push_back(node{ d,s });
			nodes.push_back(node{ s,d });
		}
		for (int i = 0; i < nodes.size(); ++i) {
			for (int j = 0; j < nodes.size(); ++j) {
				if (nodes[i].now == nodes[j].from&&nodes[i].from!=nodes[j].now) {
					gyou[j][i] = 1;
				}
			}
		}
		auto kakeru = powgyou<int>(gyou, Z);
		vector<vector<int>>start(N + 2*M,vector<int>(1));
		start[0][0] = true;
		
		vector<int>cango(N);
		vector<vector<int>>goal = keisann<int>(kakeru, start);
		for (int i = 0; i < N +2* M; ++i) {
			if (goal[i][0]) {
				cango[nodes[i].now] = true;
			}
		}
		if (cango[N - 1])cout << "yes" << endl;
		else cout << "no" << endl;


	}
	return 0;
}

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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if((a==b && b == c) || (a != b && b != c && c != a)){
        printf("No");
    }else{
        printf("Yes");
    }

    return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        char[] s = Console.ReadLine().ToCharArray();
        int x = 753;
        int ans = int.MaxValue;
        int tmp;
        for (int i = 0; i < s.Length - 2; i++)
        {
            tmp = int.Parse($"{s[i]}{s[i + 1]}{s[i + 2]}");
            ans = Math.Min(ans, Math.Abs(x - tmp));
        }
        Console.WriteLine(ans);
    }
}

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

template <unsigned mod>
struct RollingHash {
    vector<unsigned> hashed, power;

    inline unsigned mul(unsigned a, unsigned b) const {
        unsigned long long x = (unsigned long long)a * b;
        unsigned xh = (unsigned)(x >> 32), xl = (unsigned)x, d, m;
        asm("divl %4; \n\t" : "=a"(d), "=d"(m) : "d"(xh), "a"(xl), "r"(mod));
        return m;
    }

    RollingHash(const string &s, unsigned base = 10007) {
        int sz = (int)s.size();
        hashed.assign(sz + 1, 0);
        power.assign(sz + 1, 0);
        power[0] = 1;
        for (int i = 0; i < sz; i++) {
            power[i + 1] = mul(power[i], base);
            hashed[i + 1] = mul(hashed[i], base) + s[i];
            if (hashed[i + 1] >= mod) hashed[i + 1] -= mod;
        }
    }

    unsigned get(int l, int r) const {
        unsigned ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
        if (ret >= mod) ret -= mod;
        return ret;
    }

    unsigned connect(unsigned h1, int h2, int h2len) const {
        unsigned ret = mul(h1, power[h2len]) + h2;
        if (ret >= mod) ret -= mod;
        return ret;
    }

    int LCP(const RollingHash<mod> &b, int l1, int r1, int l2, int r2) {
        int len = min(r1 - l1, r2 - l2);
        int low = -1, high = len + 1;
        while (high - low > 1) {
            int mid = (low + high) / 2;
            if (get(l1, l1 + mid) == b.get(l2, l2 + mid))
                low = mid;
            else
                high = mid;
        }
        return (low);
    }
};

using RH = RollingHash<1000000007>;

int n;

bool solve(int len, string s) {
    RH rh0(s);
    for (int i = 0; i + 2 * len <= s.size(); i++) {
        for (int j = i + len; j + len <= s.size(); j++) {
            if (rh0.get(j, j + len) == rh0.get(i, i + len)) return true;
        }
    }
    return false;
}

int binary_search(int ok, int ng, string s) {
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (solve(mid, s)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    return ok;
}

int main() {
    string s;
    cin >> n >> s;
    int ans = binary_search(-1, s.size(), s);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from typing import List


def solve(A: List[int], N: int) -> int:
    current_money = 1000
    for i in range(N - 1):
        stocks = 0

        if A[i] < A[i + 1]:
            stocks = current_money // A[i]
        current_money += (A[i + 1] - A[i]) * stocks
    return current_money


def main():
    N = int(input())
    A = [int(x) for x in input().split(" ")]

    print(solve(A, N))


if __name__ == "__main__":
    main()


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

int main() {
	string S;
	cin >> S;
	vector<int> count(26, 0);
	for (auto c : S) count[c-'a']++;
	string ans = "yes";
	for (auto i : count) {
		if (i > 1) {
			ans = "no";
			break;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
r = [[[]]]
4.times do |i|
  r[i] =[[], [], []]
  3.times do |j|
    r[i][j] = Array.new(10,0)
  end
end
n = gets.to_i
n.times do
  d = gets.split.map(&:to_i)
  r[ d[0]-1 ][ d[1]-1 ][ d[2]-1 ] += d[3]
end
4.times do |i|
  3.times do|j|
    10.times do |k|
      print (" #{r[i][j][k]}")
    end
  puts
  end
break if i == 3
puts "####################"
end


Measured memory_bytes: 6900
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int X;
int main(){
  rd(X);
  if(X==3||X==5||X==7){
    wt_L("YES");
    wt_L('\n');
  }
  else{
    wt_L("NO");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// int X;
// {
//   rd(X);
//   wt( if[X==3||X==5||X==7, "YES", "NO"] );
// }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <deque>
#include <string>
using namespace std;
typedef long long ll;

int main(void){
    ll n; cin >> n;
    vector<vector<ll> > a(2,vector<ll> (n + 1,0));
    vector<ll> s1(n + 1,0);
    vector<ll> s2(n + 1,0);
    ll sum1 = 0;
    ll sum2 = 0;
    for(ll i = 0;i < 2; i++){
        for(ll j = 1;j < n + 1; j++){
            cin >> a[i][j];
            if(i == 0){
                sum1 += a[i][j];
                s1[j] = s1[j - 1] + a[i][j];
            }else{
                sum2 += a[i][j];
                s2[j] = s2[j - 1] + a[i][j];
            }
        }
    }
    ll ans = 0;
    for(ll i = 0;i < n + 1;i++){
        ans = max(s1[i] + sum2 - s2[i - 1], ans);
    }
    cout << ans << endl;
    return 0;
}


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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

int main()
{
    string s;
    int k;
    cin >> s >> k;
    rep(i, s.size()) {
        int d = 'z' + 1 - s[i];
        if(d>k||d>25)
            continue;
        k -= d;
        s[i] = 'a';
    }
    s[s.size()-1] += k % 26;
    P(s);
    return 0;
}



Measured memory_bytes: 640
#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 < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

void mainsolve(){

	string s;
	cin >> s;
	ll k;
	cin >> k; 


	ll dp[105][2][105];
	// 1桁目
	ll first = s[0] - '0';
	rep(i,first+1) dp[0][i < first][i != 0]++;
	
	// 2桁目以降
	rep(i,s.size()-1) rep(j,2) rep(kk,105){
		ll lim = j? 9 : s[i+1] - '0';
		rep(next, lim+1){
			ll tmp = 0;
			if(next != 0) tmp++;
			dp[i+1][j || next < lim][kk + tmp] += dp[i][j][kk];
		}
	}

	cout << dp[s.size()-1][true][k] + dp[s.size()-1][false][k] << endl;
	// rep(i,2) rep(kk,3) cout << dp[i][false][kk] << endl;

	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}


Measured memory_bytes: 384
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

S = input()
T = input()
ls = len(S)+1
lt = len(T)+1

dp = dp2(0, ls, lt)

#moji = [['']*ls for i in range(lt)]
#print(moji)
for i in range(1, lt):
    for j in range(1, ls):
        if S[j-1]==T[i-1]:
            dp[i][j] = dp[i-1][j-1]+1
            #moji[i][j] = moji[i-1][j-1] + S[j-1]
        else:
            if dp[i-1][j] >= dp[i][j-1]:
                dp[i][j] = dp[i-1][j]
                #moji[i][j] = moji[i-1][j]
            else:
                dp[i][j] = dp[i][j-1]
                #moji[i][j] = moji[i][j-1]
#print(moji)
#print(moji[lt-1][ls-1])
ans = ''
i = lt-1
j = ls-1
while i > 0 and j > 0:
    if dp[i][j] > dp[i-1][j-1] and S[j-1]==T[i-1]:
        ans += S[j-1]
        i -= 1
        j -= 1
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
    else:
        j -= 1

print(ans[::-1])

Measured memory_bytes: 112220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans;
int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	for(int i = k + 1; i <= n; ++i)
	{
		ll step = (n + 1) / i;
		ans += step * (i - k);
		if(k == 0) --ans;
		int j = step * i;
		if(j + k <= n)
		{
			int l = max(1, j + k);
			int r = min(n, j + i - 1);
			ans += r - l + 1;
		}
		/*
		for(int j = 0; j + k <= n; j += i)
		{
			int l = max(1, j + k);
			int r = min(n, j + i - 1);
			ans += r - l + 1;
		}
		*/
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
X, N = map(int, input().split())
p_list = list(map(int, input().split()))

if N == 0: #①
   print(X)
else:
   for i in range(0,100):#②
       if not X-i in p_list:#③
           print(X-i)
           break
       elif not X+i in p_list:
           print(X+i)
           break

Measured memory_bytes: 9072
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define REPR(i, n) for(ll i = n; i >= 1; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
const ld INF = 1e9+123;
#define VEC(type,A,N) vector<type> A(N+10)
#define VECi(type,A,N,i) vector<type> A(N+10,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N+10,vector<type>(M+10))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N+10,vector<type>(M+10,i))
#define ALL(v) v.begin()+1, v.end()-9
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    double N,K;
    cin>>N>>K;
    
    double t,k=0;
    REP(i,N){
        t=(int)ceil(log(K/i)/log(2));
        k+=(pow((ld)1/2,t<=0?0:t))/N;
        
        //sl(t,k,(pow((ld)1/2,t<=0?0:t))/N)
    }
    //cout<<ac<<" "<<wa;
    cout<<fixed<<setprecision(15)<<k;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


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

using namespace std;

int n, m, y[200005][2], z[2];
char x[200005];
bool g[200005];
multiset<int> v[200005];
int ta, tb;

void go(int a) {
	g[a] = 1;
	z[x[a]]--;
	while (!v[a].empty()) {
		int tt = *v[a].begin();
		v[a].erase(v[a].begin());
		if (!g[tt]) {
			v[tt].erase(v[tt].find(a));
			y[tt][x[a]]--;
			if (y[tt][0] == 0 || y[tt][1] == 0)
				go(tt);
		}
	}
}

int main() {
	scanf("%d%d%s", &n, &m, x + 1);
	for (int i = 1; i <= n; i++) {
		x[i] -= 'A';
		z[x[i]]++;
	}
	while (m--) {
		scanf("%d%d", &ta, &tb);
		v[ta].insert(tb);
		v[tb].insert(ta);
		y[ta][x[tb]]++;
		y[tb][x[ta]]++;
	}
	for (int i = 1; i <= n; i++)
		if (y[i][0] == 0 || y[i][1] == 0)
			if (!g[i])
				go(i);
	printf(z[0] ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 33920
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int a[1001];
int c[10];
int main(){
    int n;cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    memset(c,0,sizeof(c));
    int i;
    for(i=0;i<n;i++){
        if(1<=a[i]&&a[i]<=399)c[0]++;
        if(400<=a[i]&&a[i]<=799) c[1]++;
        if(800<=a[i]&&a[i]<=1199 )c[2]++;
        if(1200<=a[i]&&a[i]<=1599 )c[3]++;
        if(1600<=a[i]&&a[i]<=1999 )c[4]++;
        if(2000<=a[i]&&a[i]<=2399 )c[5]++;
        if(2400<=a[i]&&a[i]<=2799 )c[6]++;
        if(2800<=a[i]&&a[i]<=3199 )c[7]++;
        if(a[i]>3199)break;
    }
    int ans=0;
    for(int i=0;i<8;i++){
        if(c[i])ans++;
    }
    if(i==n)cout<<ans<<" "<<ans<<endl;
    else if(ans==0)cout<<1<<" "<<n-i+ans<<endl;
    else  cout<<ans<<" "<<n-i+ans<<endl;
return 0;
}


Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t D;
int32_t C[30];
int32_t S[400][30];

int32_t res[400];
void greedy1()
{
    int32_t last[40] = {};
    for (int32_t d = 0; d < D; d++)
    {
        int32_t max = S[d][0];
        int32_t max_index = 0;
        for (int32_t i = 0; i < 26; i++)
        {
            auto ss = S[d][i] - C[i]*(d- last[i]);
            if (max < ss) {
                max = ss;
                max_index = i;
            }
        }
        res[d] = max_index;
        last[max_index] = d;
    }
}

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> D;
    for (size_t i = 0; i < 26; i++)
    {
        in >> C[i];
    }
    for (size_t d = 0; d < D; d++)
    {
        for (size_t i = 0; i < 26; i++)
        {
            in >> S[d][i];
        }
    }
    greedy1();

    for (size_t d = 0; d < D; d++)
    {
        out << res[d]+1 << '\n';
    }

    return 0;
}
#endif


Measured memory_bytes: 3252
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N >> M;
	vector<int>v;
	for (int i = 1; i <= M; i += 2) {
		v.push_back(i);
	}
	reverse(v.begin(), v.end());
	vector<pair<int, int>>ans;
	for (int i = 0; i < v.size(); i++) {
//		cout << i + 1 << " " << i + 1 + v[i] << endl;
		ans.push_back({ i + 1, i + 1 + v[i] });
	}
	v.clear();
	for (int i = 2; i <= M; i += 2) {
		v.push_back(i);
	}
	reverse(v.begin(), v.end());
	for (int i = 0; i < v.size(); i++) {
		ans.push_back({ ans.front().second + i + 1, ans.front().second + 1 + i + v[i] });
	}
	for (auto i : ans)cout << i.first << " " << i.second << endl;
}

Measured memory_bytes: 4396
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int A[3];
    REP(i,3) cin>>A[i];
    sort(A,A+3);
    cout<<A[0]*A[1]/2<<endl;
}


Measured memory_bytes: 256