akhauriyash/Code-Regression huggingface dataset:
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

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

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve2.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

int solve() {
    int n;cin>>n;
    vec<pll> edges;
    rep(i, n-1){
        int u,v;cin>>u>>v;
        u--;v--;
        edges.pb(mp(u, v));
    }

    ll ans = 0;
    rep(i, n){
        ans += (i - 0 + 1) * (n-1 - i + 1);
    }
    dump(ans);
    for (auto [u, v] : edges){
        if (u>v) swap(u, v);
        ans -= (u - 0 + 1) * (n-1 - v + 1);
    }

    cout << ans << endl;
    return 0; 
}


int main(){/*{{{*/
    solve();
    // check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 7392
import java.util.Scanner;

public class Main{

	static long min(int[] a){
		long minValue=a[0];
		for(int i=1;i<a.length;i++){
			if(a[i]<minValue){
				minValue=a[i];
			}
		}
		return minValue;
	}

	static long max(int[] a){
		long maxValue=a[0];
		for(int i=1;i<a.length;i++){
			if(maxValue<a[i]){
				maxValue=a[i];
			}
		}
		return maxValue;
	}
	static long sum(int[] a){
		long sumValue=0;
		for(int i=0;i<a.length;i++){
			sumValue+=a[i];
		}
		return sumValue;
	}

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

		int n=scan.nextInt();

		if(0<n){
			int[] a=new int[n];


			for(int i=0;i<n;i++){
				a[i]=scan.nextInt();
			}

			System.out.printf("%d %d %d\n",min(a),max(a),sum(a));
		}else{
			System.out.println("0 0 0");
		}
		scan.close();
	}
}

Measured memory_bytes: 31732
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	long long k;
	cin>>s>>k;
	long long cnt=0;
	for(int i=1;i<s.size();i++){
		if(s[i]==s[i-1]){
			cnt++;
			i++;
		}
	}
	int strk1=1, strk2=1;
	for(int i=1;i<s.size();i++){
		if(s[i]==s[0]) strk1++;
		else break;
	}
	for(int i=s.size()-2;i>=0;i--){
		if(s.back()==s[i]) strk2++;
		else break;
	}
	if(strk1==(int)s.size()){
		cout<<(long long)(s.size())*k/2;
	}
	else{
		if(strk1%2==1 && strk2%2==1 && s[0]==s.back()){
			cout<<cnt*k+k-1;
		}
		else{
			cout<<cnt*k;
		}
	}
}

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

int main(){
  int k,s;
  cin >> k >> s;
  
  int x,y,z;
  int c = 0;
  for(int x = 0; x <= k; x++){
    for(int y = 0; y <= k; y++){
      z = s-x-y;
      if(z >= 0 && z <= k){
        c++;
      }
    }
  }
  
  cout << c << endl;   
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
ans_lis = [0]
check = False
count = 0
for i in range(N-1):
  if (check == True and A[i] < A[i+1]) or i == N-2:
    if A[i] >= A[i+1]:
      count += 1
    ans_lis.append(count)
    check = True
    count = 0
  elif check == False and A[i] >= A[i+1]:
    check = True
    count = 1
  elif check == True and A[i] >= A[i+1]:
    count += 1
print(max(ans_lis))

Measured memory_bytes: 20376
import sys
import numpy as np
import math
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()))
n,k = Mi()
a = np.array(sys.stdin.readline().split(), np.int64)
sa = np.sum(a)
mina = sa//(n+k)
maxa = np.max(a)
while maxa > mina+1:
  mid = (mina+maxa)//2
  div = np.sum(np.ceil(a/mid-1))
  #print(mina,maxa,div)
  if div > k:
    mina = mid
  else:
    maxa = mid
  
print(maxa)

Measured memory_bytes: 52796
#include<stdio.h>
int main() {
	int a,i,b;
	i = 0;
	long int max,min,sum;
	max = -1000000;
	min = 1000000;
	sum = 0;
	scanf("%d", &a);
	while (1) {
		if (i == a) {
			break;
		}
		scanf("%d", &b);
		sum += b;
		if (min > b) {
			min = b;
		}
		if (max < b) {
			max = b;
		}
		i++;
	}
	printf("%ld %ld %ld\n", min, max, sum);
	return 0;
}

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

int main(){
  int n,k,len=0;
  int l[55];
  cin>>n>>k;
  for (int i = 0; i < n; i++) {
    cin>>l[i];
  }

  sort(l, l+n, greater<int>());
  for (int i = 0; i < k; i++) {
    len += l[i];
  }
  cout<<len<<endl;
}


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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

#define pr(v) for(auto x : v) cerr << x << " "; cerr << endl;

bool f(pair<ll, ll> a, pair<ll, ll> b) {
	return (a.second > b.second);
}

int main(int argc, const char* argv[]) {
	ll n, m;
	cin >> n >> m;

	vector<ll> a(n);
	vector<pair<ll, ll>> bc(m);	
	rep(i, n) {
		cin >> a.at(i);
	}
	rep(i, m) {
		cin >> bc[i].first >> bc[i].second;
	}
	sort(bc.begin(), bc.end(), f);

	vector<ll> d;
	rep(i, m) {
		vector<ll> tmp(bc[i].first, bc[i].second);
		d.insert(d.end(), tmp.begin(), tmp.end());
		if(n <= d.size()) break;
	}

	d.insert(d.end(), a.begin(), a.end());
	sort(d.begin(), d.end(), greater<ll>());

	ll ret = 0;
	rep(i, n) {
		ret += d[i];
	}

	cout << ret << endl;
	return 0;
}


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

using ll = long long;

#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define len(x) int((x).size())

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define randint(n) uniform_int_distribution<int>(1, (n))(rng)

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int n;
	cin>>n;

	ll a1,a2;
	cin>>a1>>a2;

	ll x=0LL;

	for(int i=0; i<n-2; i++)
	{
		ll a;
		cin>>a;
		x^=a;
	}

	ll minn = 0LL;
	vector<ll> in_one;
	vector<ll> dub_nut;

	for(int b=50; b>=0; b--)
	{
		if(((1LL<<b) & x) > 0LL)
		{
			minn += (1LL<<b);
			in_one.push_back((1LL<<b));

			//cout << (1LL<<b) << "yee"<<endl;
		}

		else
		{
			dub_nut.push_back((1LL<<(b+1)));
			// cout << dub_nut.back() << endl;
		}
	}

	ll base_line = 0LL;

	for(auto thing:dub_nut)
	{
		if(minn+thing <= a1+a2)
		{
			minn += thing;
			base_line+=(ll(thing/2LL));
		}
	}

	//cout << base_line << " " << minn << endl;

	if(minn!=a1+a2 || base_line>a1)
	{
		cout << -1 << endl;
		return 0;
	}

	// cout << base_line << endl;

	ll old_a1 = a1;

	for(auto ii:in_one)
	{
		if(base_line + ii <= a1) base_line += ii;
	}

	if(base_line==0LL) cout << -1 << endl;
	else cout << a1-base_line << endl;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
	int n;
	cin>>n;
	int a[n+1];
	int dp[n+1];
	
	for(int i=0;i<n;i++){
	cin>>a[i];
	}
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n-1];
	return 0;
	
}

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


//TLEして放棄したコード
/*
int AC(string p){
    int N;
    N=p.size();
    int cnt=0;
    for(int i=0;i<N-1;i++){
        if(p.at(i)=='A' && p.at(i+1)=='C'){
            cnt++;
            i++;
        }
    }
    return cnt;
}

int main(){
    int N,Q;
    cin>>N>>Q;

    string S;
    cin>>S;

    vector<pair<int,int>> lr(Q);
    for(int i=0;i<Q;i++){
        cin>>lr.at(i).first>>lr.at(i).second;
    }

    
    for(int i=0;i<Q;i++){
        int nagasa=0;
        nagasa=lr.at(i).second-lr.at(i).first+1;
        cout<<AC(S.substr(lr.at(i).first-1,nagasa))<<endl;
    }

    }
*/

int main(){
    int N,Q;
    cin>>N>>Q;
    string S;
    cin>>S;
    
    vector<pair<int,int>> lr(Q);
    for(int i=0;i<Q;i++){
        cin>>lr.at(i).first>>lr.at(i).second;
    }

    map<int,int> mp;
    for(int i=1;i<=N;i++){
        mp[i]=0;
    }
    for(int i=1;i<N;i++){
        if(S.at(i-1)=='A' && S.at(i)=='C'){
            mp[i+1]=mp[i]+1;
            
        }
        else{
            mp[i+1]=mp[i];
        }
    }
    for(int i=0;i<Q;i++){
        cout<<mp[lr.at(i).second]-mp[lr.at(i).first]<<endl;
    }
}

Measured memory_bytes: 6400
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
S = input()

def Z_algorithm(S):
    N = len(S)
    res = [0] * N
    res[0] = N
    i = 1
    j = 0
    while i < N:
        while i+j < N and S[j] == S[i+j]:
            j += 1
        res[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i+k < N and k+res[k] < j:
            res[i+k] = res[k]
            k += 1
        i += k
        j -= k
    return res

ans = 0
for i in range(N):
    # Z-algorithmでLCP(最長共通接頭辞の長さ)を取得
    LCP = Z_algorithm(S[i:])
    for j, lcp in enumerate(LCP):
        # 最大値更新の際は、共通部分が重複していないことを確認する
        if lcp > ans and j >= lcp:
            ans = lcp
print(ans)


Measured memory_bytes: 49528
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int main()
{
	int n;cin>>n;
	int mini = n+1,ans=0;
	for(int i=1;i<=n;i++){
		int x;scanf("%d",&x);
		mini = min(mini,x);
		if(x==mini)ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <string>

const int MOD = 1000000007;

using namespace std;

bool func(string str) {
  string mae = str.substr(0, str.size() / 2);
  string usiro = str.substr(str.size() / 2, str.size());
  if (mae == usiro) {
    return true;
  } else {
    return false;
  }
}

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);

  string str;
  cin >> str;
  str.pop_back();
  bool flag = false;
  while (!str.empty()) {
    if (str.size() & 1) {
      str.pop_back();
      continue;
    } else {
      flag = func(str);
      if (flag) {
        cout << str.size() << endl;
        break;
      } else {
        str.pop_back();
      }
    }
  }
}



Measured memory_bytes: 256
#coding: utf-8
S = list(input())
ans = 0
n = len(S) - 1
for i in range(2**n):
    tmp = S[:]
    for j in range(n):
        if (i >> j) & 1 == 1:
            tmp[j] += "+"
    ans += eval("".join(tmp))
print(ans)

Measured memory_bytes: 3060
def main(argv)
  n, m, d = gets.chomp.split(' ').map(&:to_i)
  
  r = 0.0
  
  if d == 0 then
    r = (m - 1).to_f / n.to_f
  else
    r = (2 * (n - d) * (m - 1)).to_f / (n ** 2).to_f
  end
  
  puts r.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define pi(n,m) n.insert(n.begin(),m);
#define ee(n) n.erase(n.end()-1)
#define eb(n) n.erase(n.begin())
#define check(n) reverse(all(n));rep(z,0,n.size())cout<<n[z];co("");reverse(all(n));
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  ll n,k,b=1,c=0,d=0,e;
  cin>>n>>k;
  pair<ll,ll> a[n];
  rep(i,0,n){cin>>a[i].first; a[i].second=0;}
  rep(i,0,600000){
    a[b-1].second++;
    b=a[b-1].first;
  }
  rep(i,0,n){
    if(a[i].second==1) c++;
    else if(a[i].second>1) d++;
  }
  b=1;
  if(c>k){
    rep(i,0,k){
      b=a[b-1].first;
    }
    co(b);
    return 0;
  }
  else{
    rep(i,0,c){
      b=a[b-1].first;
    }
    k-=c;
    k%=d;
    rep(i,0,k){
      b=a[b-1].first;
    }
    co(b);
    return 0;
  }
  
  
  return 0;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    int Num[N] = {0};
    for(int i =0; i < N; i++){
        int A;
        cin >> A;
        Num[A] ++;
    }
    sort(Num, Num + N, greater<int>());
    int res = 0;
    for(int i =0; i < K; i++){
        res += Num[i];
    }
    cout << N - res << endl;       
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <string>
#include <functional>
#include <math.h>
#include <utility>
using namespace std;
int main()
{
	int a=0,b=0,t;
	for(int i=0;i<4;i++){cin>>t;a+=t;}
	for(int i=0;i<4;i++){cin>>t;b+=t;}
	cout<<max(a,b)<<endl;
}

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

int main(){
    string s;cin >> s;
    int a=0,b=0;
    for (int i=0;i<s.size();i++){
        if (s[i]=='R'){
            a++;
        }
        else if(s[i]!='R'){
            a=0;
        }
        if (b<a){
            b=a;
        }
        
    }
    cout << b;
}


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

using namespace std;

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

    int n;
    cin >> n;

    if (n == 1) {
        cout << "Hello World\n";
    }
    else {
        int a, b;
        cin >> a >> b;
        cout << a + b << '\n';
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if (a<b)
    {if(b<c) printf("%d %d %d\n", a,b,c);
      else if(a<c) printf("%d %d %d\n",a,c,b);
      else printf("%d %d %d\n",c,a,b);
    }
  else
    {if(a<c) printf("%d %d %d\n",b,a,c);
      else if(b<c) printf("%d %d %d\n",b,c,a);
      else printf("%d %d %d\n",c,b,a);
    }
  return 0;
}

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


int main() {
  int N, K, S;
  cin >> N >> K >> S ;
  if(S != 1000000000){
    for(int i=0;i<K;i++){
      cout << S << " " ;
    }  
    for(int i=0;i<(N-K);i++){
      cout << 1000000000 << " " ;
    }  
    cout << endl ;
  }  
  else{
    for(int i=0;i<K;i++){
      cout << S << " " ;
    }  
    for(int i=0;i<(N-K);i++){
      cout << (S-1) << " " ;
    }  
    cout << endl ;
  }  
  return 0;
}

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

void checknum(int &i, int &n);

void endchecknum(int i, int n)
{
	i++;
	if (i <= n)
	{
		checknum(i, n);
	}
	else
	{
		cout << endl;
	}
}

void include3(int &x, int &i, int &n)
{
	if (x % 10 == 3)
	{
		cout << " " << i;
		endchecknum(i, n);
	}
	else
	{
		x /= 10;
		if (x)
		{
			include3(x, i, n);
		}
		else
		{
			endchecknum(i, n);
		}
	}
}

void checknum(int &i, int &n)
{
	int x = i;

	if (x % 3 == 0)
	{
		cout << " " << i;
		endchecknum(i, n);
	}
	else
	{
		include3(x, i, n);
	}
}

void call(int &n)
{
	int i = 1;

	checknum(i, n);
}

int main()
{
	int n;

	cin >> n;
	call(n);
	return 0;
}

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

int main(void){
    string a,b;
    cin>>a>>b;
    if(a.size() > b.size()){
        cout<<"GREATER"<<endl;
    }else if(a.size() < b.size()){
        cout<<"LESS"<<endl;
    }else{
        if(a>b) cout<<"GREATER"<<endl;
        else if(a<b) cout<<"LESS"<<endl;
        else cout<<"EQUAL"<<endl;
    }
}

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

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))

int main()
{
	int n, counter = 1, state = 0;
	cin >> n;
	vector<int> a(n);
	rep(i, 0, n)cin >> a[i];
	rep(i, 0, n - 1)
	{
		if (state == 0)
		{
			if (a[i] < a[i + 1])
				state = 1;
			else if (a[i] > a[i + 1])
				state = 2;
		}
		else if (state == 1)
		{
			if (a[i] > a[i + 1])
			{
				++counter;
				state = 0;
			}
		}
		else if (state == 2)
		{
			if (a[i] < a[i + 1])
			{
				++counter;
				state = 0;
			}
		}
	}
	cout << counter << endl;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;

int main()
{
	char X,Y;
	while(~scanf(" %c %c",&X,&Y))
	{
		if(X<Y)	printf("<\n");
		else if(X>Y) printf(">\n");
		else if(X=Y) printf("=\n");
	}
	return 0;
}

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

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

  vector<int> a(n + 1);
  vector<int> b(n);
  long long ans = 0;

  for(int i = 0; i < n + 1; ++i) {
    cin >> a[i];
  }
  for(int i = 0; i < n; ++i) {
    cin >> b[i];
    long long t = min(a[i] + a[i+1], b[i]);
    ans += t;
    a[i+1] -= t - min(a[i], b[i]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>

int main() {
	int n;

	std::cin >> n;

	std::string s;

	std::cin >> s;

	int k;

	std::cin >> k;

	for (size_t i = 0; i < s.length(); i++)
	{
		if (s[k - 1] != s[i]) {
			s[i] = '*';
		}
	}

	std::cout << s << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>  
using namespace std; 
int main() { int n; while(cin>> n){ int ans=0; for(int a=0;a<10;a++){ for(int b=0;b<10;b++){ for(int c=0;c<10;c++){ for(int d=0;d<10;d++){ if(a+b+c+d==n)ans++; } } } } cout << ans << "\n"; } return 0; }

Measured memory_bytes: 1160
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=2e5+5;
char s[N];int vis[N],n,res;
int main(){
	scanf("%s",s+1),n=strlen(s+1);
	fp(i,1,n){
		++res,vis[i]=1;
		if(s[i]==s[i-1]&&vis[i-1]){
			if(i==n)--res;
			++i;
		}
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 1788
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  std::vector<ll> v(3);
  rep(i,3) cin>>v[i];
  sort(all(v));
  ll a = INF,b = 0,c = 0;
  a = 0 + v[1] -v[0]+ v[2] - v[1];
  // maxch(a,v[0] + 0 + v[2]);
  // maxch(a,v[0] + v[1]-v[0]);
  cout<<a<<endl;

}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });

            var N = Sarray()[0];
            var Pi = Sarray();
            var Qi = Sarray();
            var pb = new List<long>();
            var qb = new List<long>();
            for (var i = 1; i <= N; ++i)
            {
                pb.Add(i);
                qb.Add(i);
            }
            var pNos = new List<long>();
            var qNos = new List<long>();
            for (var i = 0; i < N; ++i)
            {
                for (var j = 0; j < pb.Count; ++j)
                {
                    if (Pi[i] == pb[j])
                    {
                        pNos.Add(j);
                        pb.Remove(Pi[i]);
                        break;
                    }
                }
                for (var j = 0; j < qb.Count; ++j)
                {
                    if (Qi[i] == qb[j])
                    {
                        qNos.Add(j);
                        qb.Remove(Qi[i]);
                        break;
                    }
                }
            }
            var pPos = 0L;
            var qPos = 0L;
            for (var i = 0; i < N - 1; ++i)
            {
                pPos += pNos[i] * factorial(N - 1 - i);
                qPos += qNos[i] * factorial(N - 1 - i);
            }
            WriteLine(Abs(pPos - qPos));
            //Out.Flush();
        }
        static long factorial(long n)
        {
            if (n <= 1) return 1;
            return n * factorial(n - 1);
        }
    }
}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep2(i,n) for (int i = 1; i <= (n); i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;

int main() {
  string s;

  cin >> s;
  bool flag = false;
  if (s[2] == s[3] && s[4] == s[5]) {
    flag = true;
  }
  
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl; 

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 998244353;
int N;
int a[300];
int S;
ll dp[310][90010];
ll dp2[310][90010];
ll A,B,C;
ll Ans;

ll pow_MOD(ll x,ll n){//x^n
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    res %= MOD;
    return res;
}

int main() {
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        S += a[i];
    }
    dp[0][0] = 1;
    for(int i = 1; i <= N; i++){
        for(int j = 0; j <= S; j++){
            if(j-a[i-1] >= 0){
                dp[i][j] = (dp[i-1][j] * 2) % MOD + dp[i-1][j-a[i-1]]; 
            }else{
                dp[i][j] = dp[i-1][j] * 2;
            }
            dp[i][j] %= MOD;
        }
    }
    
    for(int i = (S + 1)/2; i <= S; i++){
        A += dp[N][i];
    }
    
    dp2[0][0] = 1;
    for(int i = 1; i <= N; i++){
        for(int j = 0; j <= S; j++){
            if(j-a[i-1] >= 0){
                dp2[i][j] = dp2[i-1][j] + dp2[i-1][j-a[i-1]]; 
            }else{
                dp2[i][j] = dp2[i-1][j];
            }
            dp2[i][j] %= MOD;
        }
    }
    if(S % 2){
        B = 0;
    }else{
        B = dp2[N][S/2];
    }
    
    C = 0;
    Ans = ((((pow_MOD(3, N) - 3 * A) % MOD) + MOD) % MOD + 3 * B) % MOD - C;
    
    cout << Ans << endl;
}

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

int main() {
    std::string S;
    std::cin >> S;

    uint32_t b = 0;
    for (size_t i = 0; i < S.size(); ++i) {
        const int c = S[i] - 'a';
        b |= (1u << c);
    }

    for (uint32_t i = 0; i < 26; ++i) {
        if (((b >> i) & 1) == 0) {
            std::printf("%c\n", (char)('a' + i));
            return 0;
        }
    }

    std::cout << "None" << std::endl;

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>


int a[1100][1100];

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

  int n;
  cin>>n;

  rep(i,n){
    rep(j,n-1){
      cin>>a[i][j];
      a[i][j]--;
    }
  }

  bool flag=true;
  int count=0;
  int ans=0;
  int c[1100]={};
  int res[1100]={};
  while(count!=n){
    flag=false;
    rep(i,n){
      if(c[i]==n-1) continue;
      int b=a[i][c[i]];
      if(i==a[b][c[b]]){
        flag=true;
        int r=max(res[i]+1,res[b]+1);
        ans=max(ans,r);
        res[i]=r;
        res[b]=r;
        c[i]++;
        c[b]++;
        if(c[i]==n-1) count++;
        if(c[b]==n-1) count++;
        break;
      }
    }
    if(!flag){
      cout<<-1<<endl;
      return 0;
    }
  }

  cout<<ans<<endl;

}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

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

const ll mod = 1e9 + 7;


int main(){
    ll x;
    cin >> x;
    ll ans = 0;
    ans += x / 11;
    ans *= 2;
    x %= 11;
    if (x==0){
        cout << ans << endl;
    }
    else if (x<=6){
        cout << ans + 1 << endl;
    }
    else{
        cout << ans + 2 << endl;
    }
}


Measured memory_bytes: 256
h, w, k=map(int,input().split())
masu =[input() for _ in range(h)]
ans=0
for x in range(2**h):
    for y in range(2**w):
        cnt=0
        for i in range(h):
            for j in range(w):
                if x>>i&1 and y>>j&1 and masu[i][j]=="#":
                    cnt+=1
        if cnt == k:
            ans += 1
print(ans)

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

bool comb(pair<int, int> a, pair<int, int> b) {
	return a.second < b.second;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int x, a, b;
	cin >> x >> a >> b;

	if (b - a <= 0) {
		out("delicious");
	}
	else if (b - a <= x) {
		out("safe");
	}
	else {
		out("dangerous");
	}

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
//#include <vector>
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod =  1000000007;
ll maxn = 1000000000;
 
//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pii = pair<int, int>; // これ以降 pii という型名はpair<int, int> と同じ意味で使える
//---------------------------------------------------------------------------------------------------
 
int main(){
   ll n;
   ll ans=0;
   cin>>n;
   vector<ll> a(n),b(n+1);
   
   rep(i,n) b.at(i+1)=0;
   
   rep(i,n){
       cin>>a.at(i);
       b.at(a.at(i))+=1;
   }
   
   rep(i,n){
       if(b.at(i+1)>=2){
        ans+=(b.at(i+1)*(b.at(i+1)-1))/2;
       }
   }//cout<<ans<<endl;
    rep(i,n){
       if(b.at(a.at(i))>=2){
           cout<<ans-(b.at(a.at(i))*(b.at(a.at(i))-1))/2+((b.at(a.at(i))-1)*(b.at(a.at(i))-2))/2<<endl;
       }//else if(b.at(a.at(i))==2)cout<<ans-b.at(a.at(i))*(b.at(a.at(i))-1)/2<<endl;
       else cout<<ans<<endl;
    }
   
   
}

Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <map>
#include <deque>
#include <vector>
typedef unsigned int UINT;
using namespace std;

int main() 
{
    int x, a, b;
    cin >> x >> a >> b;
    int da = abs(a - x);
    int db = abs(b - x);
    if (da < db)
        cout << "A" << endl;
    else
        cout << "B" << endl;

    return 0;
}


Measured memory_bytes: 256
s=input()
m=["+","-"]
for i in m:
    for j in m:
        for k in m:
            a=s[0]+i+s[1]+j+s[2]+k+s[3]
            if eval(a)==7:
                print(a+"=7")
                break
        else:continue
        break
    else:continue
    break

Measured memory_bytes: 3060
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
sys.setrecursionlimit(4100000)
from functools import lru_cache
INF = 1 << 60

#ここから書き始める
n = int(input())
x = sorted(list(map(int, input().split())))
ans = INF

for i in range(x[0], x[-1] + 1):
    total = 0
    for j in x:
        total += (i - j) ** 2
    ans = min(ans, total)

print(ans)


Measured memory_bytes: 5692
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    int n = readint;
    int k = readint;

    int ans = 1;
    for (int i = 0; i < n; i++) {
        ans = min(ans * 2, ans + k);
    }
    writeln(ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;



int main(){
    int a, b, c, d;
  cin >> a >> b >> c >> d;
    cout << (a != c ? 1 : 0);
}

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

#define UNDEF -1
#define UP 0
#define DN 1
#define NB 0
#define BD 1

using namespace std;

string buf;
int A[501],dp[501][10][2][2][500],len;
int M;

int dfs(int cnt,int dig,int udn,int bdr,int amr)
{
	if(dp[cnt][dig][udn][bdr][amr] == UNDEF)
	{
		dp[cnt][dig][udn][bdr][amr] = 0;
		if(cnt == 0)
		{
			if(amr == 0)
				dp[cnt][dig][udn][bdr][amr]++;
		}
		else
		{
			if(udn == UP)
			{
				if(bdr == BD)
				{
					for(int nd = dig+1;nd < A[cnt-1];nd++)
					{
						dp[cnt][dig][udn][bdr][amr] += dfs(cnt-1,nd,DN,NB,((amr*10)+nd)%M);
					}
					if(A[cnt-1] > dig)
					{
						dp[cnt][dig][udn][bdr][amr] += dfs(cnt-1,A[cnt-1],DN,BD,((amr*10)+A[cnt-1])%M);
					}
				}
				else
				{
					for(int nd = dig+1;nd < 10;nd++)
					{
						dp[cnt][dig][udn][bdr][amr] += dfs(cnt-1,nd,DN,NB,((amr*10)+nd)%M);
					}
				}
			}
			else
			{
				if(bdr == BD)
				{
					for(int nd = min(A[cnt-1]-1,dig-1);nd >= 0;nd--)
					{
						dp[cnt][dig][udn][bdr][amr] += dfs(cnt-1,nd,UP,NB,((amr*10)+nd)%M);
					}
					if(A[cnt-1] < dig)
					{
						dp[cnt][dig][udn][bdr][amr] += dfs(cnt-1,A[cnt-1],UP,BD,((amr*10)+A[cnt-1])%M);
					}
				}
				else
				{
					for(int nd = dig-1;nd >= 0;nd--)
					{
						dp[cnt][dig][udn][bdr][amr] += dfs(cnt-1,nd,UP,NB,((amr*10)+nd)%M);
					}
				}
			}
		}
	}
	dp[cnt][dig][udn][bdr][amr] = dp[cnt][dig][udn][bdr][amr] % 10000;
	return dp[cnt][dig][udn][bdr][amr];
}

int zigzag()
{
	for(int cnt = 0;cnt < 501;cnt++)
	{
		for(int dig = 0;dig < 10;dig++)
		{
			for(int udn = 0;udn < 2;udn++)
			{
				for(int bdr = 0;bdr < 2;bdr++)
				{
					for(int amr = 0;amr < 500;amr++)
					{
						dp[cnt][dig][udn][bdr][amr] = UNDEF;
					}
				}
			}
		}
	}
	int result;
	if(len == 1)
		result = A[0]/M;
	else
	{
		result = 9 / M;
		for(int cnt = 1;cnt < len-1;cnt++)
		{
			for(int dig = 1;dig < 10;dig++)
			{
				result += dfs(cnt,dig,UP,NB,dig);
				result += dfs(cnt,dig,DN,NB,dig);
			}
			result = result % 10000;
		}
		for(int dig = 1;dig < A[len-1];dig++)
		{
			result += dfs(len-1,dig,UP,NB,dig);
			result += dfs(len-1,dig,DN,NB,dig);
		}
		result += dfs(len-1,A[len-1],UP,BD,A[len-1]);
		result += dfs(len-1,A[len-1],DN,BD,A[len-1]);
		result = result % 10000;
	}
	return result;
}

int main(void)
{
	cin >> buf;
	len = buf.length();
	char t;
	for(int i = 0;i < len;i++)
	{
		t = buf[(len-1)-i];
		A[i] = atoi(&t);
	}
	for(int i = 0;i < len;i++)
	{
		if(A[i] != 0)
		{
			A[i]--;
			break;
		}
	}
	cin >> buf;
	cin >> M;
	int zig1 = zigzag();
	len = buf.length();
	for(int i = 0;i < len;i++)
	{
		t = buf[(len-1)-i];
		A[i] = atoi(&t);
	}
	int zig2 = zigzag();
	cout << ((zig2 - zig1)+10000)%10000 << endl;
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    rep(i,n)
    {
        cin >> a[i];
        sum += a[i];
    }
    ll ans = LINF;
    ll sunuke = 0;
    ll arai = 0;
    for (int i = 0; i <=n-2; i++)
    {
        sunuke += a[i];
        arai = sum - sunuke;
        chmin(ans, abs(sunuke-arai));
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define INF = 1001001001
#define pi = acos(-1)
using namespace std;
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

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

    ll a1,a2,a3,a4;

    a1 = a*c;
    a2 = a*d;
    a3 = b*c;
    a4 = b*d;

    ll ans1 = max(a1, a2);
    ll ans2 = max(a3, a4);
    cout << max(ans1, ans2) << endl;


    return 0;
}

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

#define pb push_back
#define mp make_pair

typedef long long LL;
typedef pair<int,int> pii;

const int N = 110;
bool vis[N];

int main(){
	int x, n, a;
	memset(vis, 0, sizeof(vis));
	scanf("%d %d", &x, &n);
	for(int i=0; i<n; i++){
		scanf("%d", &a);
		vis[a] = 1;
	}

	int ans = -1;
	int d = abs(-1 - x);

	for(int i=0; i<=101; i++){
		if(vis[i])	continue;
		int d1 = abs(i - x);
		if(d1 < d){
			ans = i;
			d = d1;
		}
	}

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

	return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF  = 1<<30;


struct item {
  int v, w;
  bool operator<(const item &r) const { return w < r.w; }
  void operator+=(const item &r) { w += r.w, v += r.v; }
};


vector<item> enum_powerset(const vector<item> &is) {
  vector<item> a = {{0, 0}};
  vector<item> c;
  c.reserve(1<<sz(is));
  for (auto &i : is) {
    auto b = a;
    for (auto &e : b) e += i;
    merge(all(a), all(b), back_inserter(c));
    swap(a, c);
    c.clear();
  }
  return a;
}


int solve(const vector<item> &is, int W) {
  int n = sz(is);
  auto a = enum_powerset({is.begin(), is.begin() + n/2});
  auto b = enum_powerset({is.begin() + n/2, is.end()});
  reverse(all(a));
 
  int ans = 0;
  int vbmax = 0;
  auto itr = b.begin();
  for (auto &[va, wa] : a) {
    if (wa > W) continue;
    while (itr != b.end() && wa + itr->w <= W) {
      chmax(vbmax, itr->v);
      ++itr;
    }
    chmax(ans, va + vbmax);
  }
  return ans;
}


int main() {
  int n; cin >> n;
  vector<item> is(n);
  for (auto &[v, w] : is) cin >> v >> w;
  is.insert(is.begin(), {0, 0});

  int q; cin >> q;
  rep(_, q) {
    int v, l; cin >> v >> l;
    vector<item> qi;
    while (v) {
      qi.push_back(is[v]);
      v /= 2;
    }
    cout << solve(qi, l) << '\n';
  }
}


Measured memory_bytes: 7408
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
    
    int c[110010]={0};
    vector<int> a(110010, 1);
  
    a[0] = 0, a[1] = 0;
    for (int i = 2; i < 110010; ++i) {
        if (!a[i]) continue;
      
        for (int j = i*2; j < 110010; j += i) a[j] = 0;
      
    }
 
    for (int i = 3; i < 110010; i+=2 ) {
     
        if (a[i] && a[(i+1)/2]) c[i] = 1;
    }
 
    
    vector<int> s(110010, 0);
    for (int i = 0; i < 110010; ++i) s[i+1] = s[i] + c[i];
 
    int t; cin >> t;
    for (int i = 0; i < t; i++) {
      
        int l, r;
        cin >> l >> r;
      
 
        cout << s[r+1] - s[l] << endl;
    }
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll x,y;
  cin>>x>>y;
  
  ll ans=0;
  vll v(3);
  v[0]= 300000;
  v[1]=200000;
  v[2]=100000;
  REP(i,3){
    if(i+1==x)
      ans+=v[i];
    if(i+1==y)
      ans+=v[i];
  }
  if(x==1&&y==1)
    ans+=400000;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
target = STDIN.gets.chomp

def checkAtoZ?(str)
  str[0] == "A" && str[-1] == "Z"
end

def alternatelyAZ?(str, nxt)
  (str[-1] == "Z" && nxt == "A") || (str[-1] == "A" && nxt == "Z")
end

def chompAZ(str)
  str.split('').drop_while{|s| s != "A"}.reverse.drop_while{|s| s != "Z"}.reverse
end

r = chompAZ(target).select{|s| s == "A" || s == "Z"}.inject("Z"){|acc, s| alternatelyAZ?(acc, s) ? acc + s : acc}[1..-1]
puts r == "" ? -1 : r

Measured memory_bytes: 8708
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
    ll n,x;
    cin >> n >> x;
    vector<ll> m(n);
    for (ll i = 0;i < n;i++) {
        cin >> m[i];
    }
    sort(m.begin(),m.end());
    ll count1 = 0;
    for (ll i = 0;i < n;i++) {
        if (x - m[i] >= 0) {
            x -= m[i];
            count1++;
        } else {
            break;
        }
    }
    if (x > 0) {
        count1 += x / m[0];
    }
    cout << count1 << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n, d;
	scanf("%d%d", &n, &d);
	int look;
	look = d * 2 + 1;
	int ans = n / look;
	if (ans * look != n) {
		ans += 1;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
a,b,c = map(int,input().split())
count = 0
while(True):
    if a%2 == 1 or b%2 == 1 or c%2 == 1:
        break
    a0 = a
    b0 = b
    c0 = c
    a = (b0+c0)/2
    b = (c0+a0)/2
    c = (a0+b0)/2
    count += 1
    if a0 == a and b0 == b and c0 == c:
        count = -1
        break
print(count)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

    long long int dp[110][100010];

int main()
{
    int N,W;
    int weight[110];
    long long int value[110];

    cin >> N >> W;
    for(int i=1; i<=N; i++){
        cin >> weight[i] >> value[i];
    }

    for(int sumw=0; sumw<=W; sumw++){
        dp[0][sumw] = 0;
    }

    for(int i=1; i<=N; i++){
        for(int sumw=1; sumw<=W; sumw++){
            if(sumw < weight[i])    dp[i][sumw] = dp[i-1][sumw];
            else    dp[i][sumw] = max(dp[i-1][sumw],dp[i-1][sumw-weight[i]] + value[i]);
        }
    }

    cout << dp[N][W];
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double a, t, r;
    cin >> a >> t >> r;
    cout << fixed << setprecision(10) << t * r / a << endl;
}



Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<double> x(n);//数値
  vector<string> u(n);//JPY or BTC
  for(int i=0;i<n;i++)
    cin >> x.at(i) >> u.at(i);
  
  double sum = 0;
  for(int i=0;i<n;i++){
    if(u.at(i) == "JPY")
      sum += x.at(i);
    else if(u.at(i) == "BTC")
      sum += x.at(i) * 380000.0;
  }

  cout << std::fixed << sum << endl;
}


Measured memory_bytes: 256
s = input()
n = int(s)

v = input().split()
d = int(v[0])
x = int(v[1])

eats = 0

for i in range(n):
    p = input()
    q = int(p)
    c = 1
    while (c <= d):
        eats += 1
        c += q

answer = eats + x
print(answer)

Measured memory_bytes: 9088