akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
struct str
{
	char h;
	char w;
};
str v[100000];
char t,b[100000];
int main()
{
	long long int j,i,n,m;
	while(1)
	{
		cin>>n;
		if(n==0)
			break;
		for(i=0;i<n;i++)
		{
			cin>>v[i].h>>v[i].w;
		}
		cin>>m;
		for(i=0;i<m;i++)
		{
			cin>>t;
			for(j=0;j<n;j++)
			{
				if(t==v[j].h)
				{
					b[i]=v[j].w;
					break;
				}
				else
					b[i]=t;
			}
		}
		for(i=0;i<m;i++)
		{
			cout<<b[i];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

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

    int n;
    string s;
    cin >> n >> s;

    int all_w = 0;

    for (int i = 0; i < n; i++) {
        if (s[i] == 'W')
            all_w++;
    }

    int w = 0, ans = n;

    for (int i = 0; i < n; i++) {
        int cur = w;
        if (s[i] == 'W')
            w++;
        cur += n - i - 1 - (all_w - w);
        ans = min(ans, cur);
    }

    cout << ans;

    return 0;   
}

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

int main(){
	int n;
	while(cin>>n){
		bool fla=false;
		for(int i=0;i<10;i++){
			if(n&(1<<i)){
				if(fla){
					cout<<" ";
				}
				else fla=true;
				cout<<(1<<i);
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
using namespace std;
int main()
{
  int n;
  long long int sum = 0;
  cin >> n;
  int tab[n];
  for(int i = 0; i < n; i++)
  {
    cin >> tab[i];
    sum += tab[i];
  }
  int m, p, t;
  cin >> m;
  for(int i = 0; i < m; i++)
  {
    cin >> p  >> t;
    cout << sum - tab[p-1] + t << "\n";
  }
}

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

using namespace std;

using int64 = long long;

// For modular arithmetic when a modular is specified per input case.
// Verified: ABC129F
struct ModInt {
 private:
  static int64 M;
  int64 x;
 public:
  static void SetMod(int64 mod) {
    M = mod;
  }
  ModInt(int64 input_x) : x(input_x % M) {}
  ModInt() : x(0) {}
  int64 Value() { return x; }
  inline ModInt operator+(ModInt o) const {
    ModInt r(*this); r += o; return r;
  }
  inline ModInt operator-(ModInt o) const {
    ModInt r(*this); r -= o; return r;
  }
  inline ModInt operator* (ModInt o) const {
    ModInt r(*this); r *= o; return r;
  }
  inline ModInt operator/ (ModInt o) const {
    ModInt r(*this); r /= o; return r;
  }
  inline void operator+= (ModInt o) { x = (x + o.x) % M; }
  inline void operator-= (ModInt o) { x = (x + M - o.x) % M; }
  inline void operator*= (ModInt o) { x = (x * o.x) % M; }
  void operator/=(ModInt o) {
    int64 p = M - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};
int64 ModInt::M = 1;  // Do not forget to add this line.

constexpr int DEBUG = 0;

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

  int p;
  cin >> p;
  ModInt::SetMod(p);

  vector<ModInt> as(p);
  for (int i = 0; i < p; i++) {
    int raw_a;
    cin >> raw_a;
    as[i] = ModInt(raw_a);
  }

  vector<ModInt> cs(p);
  for (int k = 0; k < p; k++) {
    ModInt d_k = as[k];  // d_k will be Permutation(k, k) c_k
    ModInt permutation = 1;
    for (int i = 0; i <= k - 1; i++) {
      if (i > 0) {
        permutation *= k + 1 - i;
      }
      d_k -= permutation * cs[i];
    }
    cs[k] = d_k / permutation;
    if (DEBUG) cout << "cs[" << k << "]: " << cs[k].Value() << endl;
  }

  vector<ModInt> bs(p);
  bs[0] = cs[0];

  vector<ModInt> factor(p);
  factor[0] = 1;

  auto add_vector = [&](const vector<ModInt>& xs, const vector<ModInt>& ys) {
    vector<ModInt> zs(p);
    for (int i = 0; i < p; i++) {
      zs[i] = xs[i] + ys[i];
    }
    return zs;
  };

  auto shift_vector = [&](const vector<ModInt>& xs) {
    vector<ModInt> ys(p);
    for (int i = 1; i < p; i++) {
      ys[i] = xs[i - 1];
    }
    return ys;
  };

  auto scalar_vector = [&](const vector<ModInt>& xs, ModInt c) {
    vector<ModInt> ys(p);
    for (int i = 0; i < p; i++) ys[i] = xs[i] * c;
    return ys;
  };

  for (int k = 1; k <= p - 1; k++) {
    factor = add_vector(
        shift_vector(factor),
        scalar_vector(factor, -(k - 1) + p));
    bs = add_vector(bs, scalar_vector(factor, cs[k]));
  }

  for (int i = 0; i < p; i++) {
    cout << bs[i].Value() << " ";
  }
  cout << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

int main(){
  int x;
  cin >> x;
  cout << 1-x;
  
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(0);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";


using namespace std;

ll n;

int main(){
FLASH;
cin>>n;
cout<<n+n*n+n*n*n<<endl;







return 0;
} 


Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>/*toupperとかが入っている*/
#include<vector>/*可変長配列vectorのインクルード*/

const int MOD=1000000007;/* 1,000,000,007 で割った余りを出力する　のとき使う*/
using namespace std;/*標準名前空間を利用する。cinやcoutはこれによって利用可能になる*/

int N;
int P[55];
long long int A,B;

int main(void) {
  cin >> N;
  
  for(int i=0; i<N; i++){
    cin >> P[i];
  }
  
  int count=0;
  
  for(int i=0; i<N; i++){
    if(P[i]==i+1) count++;
  }
  
  if(count==N || count==N-2){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }

  return 0;
}


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

using namespace std;

typedef long long ll;

int main(){

	int N;
	cin >> N ;
	vector<int> A(N);
	for (int i = 0; i < N; i++){
		cin >> A[i];
	}

	for (int i = 1; i < N; i++){
		for (int k = 0; k < N-1; k++){
			cout << A[k] <<" ";
		}
		cout << A[N-1] << endl; 

		int v = A[i]; 
		int j = i-1;

		while(j >= 0 && A[j] > v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
	}
	for (int k = 0; k < N-1; k++){
			cout << A[k] <<" ";
	}
	cout << A[N-1] << endl; 

	return 0;

}


Measured memory_bytes: 3120
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            (long N, long A, long B) = Slice3<long>();
            var hi = new long[N];
            for (var i = 0; i < N; ++i)
                hi[i] = Sarray()[0];
            var ok = (long)1e9;
            var ng = 0L;
            bool IsOk(long n)
            {
                var diff = A - B;
                var cnt = 0L;
                foreach (var h in hi)
                    cnt += Max(0, (h - B * n + diff - 1) / diff);
                if (cnt <= n) return true;
                else return false;
            }
            while (1 < ok - ng)
            {
                var mid = (ok + ng) / 2;
                if (IsOk(mid)) ok = mid;
                else ng = mid;
            }
            WriteLine(ok);
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 47484
#include <iostream>

int min(int x,int y){
	if(x>y){
		return y;
	}else{
		return x;
	}
}

int main(){
	int n;
	int t[100002],a[100002],da[100002];
	std::cin >> n;
	for(int i=0;i<n;i++){
		std::cin >> t[i];
	}
	for(int i=0;i<n;i++){
		std::cin >> a[i];
		da[i]=-1;
	}
	da[0]=t[0];
	for(int i=1;i<n;i++){
		if(t[i]!=t[i-1]){
			da[i]=t[i];
		}
	}
	long long ans=1;
	if(da[n-1]==a[n-1]||da[n-1]==-1){
		da[n-1]=a[n-1];
	}else{
		ans=0;
	}
	for(int i=n-2;i>-1;i--){
		if(a[i]!=a[i+1]){
			if(da[i]==-1||da[i]==a[i]){
				da[i]=a[i];
			}else{
				ans=0;
			}
		}
	}
	for(int i=0;i<n;i++){
		if(da[i]==-1){
			ans=(long long)ans*min(a[i],t[i]);
			ans%=1000000007;
		}else{
			if(da[i]>min(a[i],t[i])){
				ans=0;
			}
		}
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
typedef long long  ll;
typedef unsigned long long int ull;
#define pb push_back
#define For(ii,aa,bb) for(ll ii = aa; ii < bb;ii++)
#define Rof(ii,aa,bb) for(ll ii = aa; ii >= bb;ii--)
#define st first 
#define nd second 
#define MP make_pair
#define MAX 1000000009
#define MOD 1000000007
#define all(v6) v6.begin(),v6.end()
#define IT iterator
#define ln "\n"
#define F(ii) ((abs(ii) + ii)/2)
#define N 500005
using namespace std;
ll n, x;
int main(){
	#ifndef ONLINE_JUDGE
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n;
	map <pair <ll,ll>, ll > m;
	ll t = n, n = 1;
	For(n, 1, t + 1){
		ll tmp = n;
		while (tmp / 10 > 0){
			tmp /= 10;
		}
		m[MP(tmp, n % 10)]++;
	
	} 
	ll ans = 0;
	For(i, 0, 10){
		For(q, 0, 10){
			//cout << i << " " << q << " " << m[MP(i, q)] * m[MP(q, i)] << ln;
			ans += m[MP(i, q)] * m[MP(q, i)];
		}	
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)

int main(){
  long long n,ans=0,r=0;cin>>n;
  vector<long long> a(n+1,0),b(n+1,0);
  REP(i,n) cin>>a.at(i);
  cin>>a.at(n);
  REP(i,n) cin>>b.at(i);
  b.at(n)=0;
  
  REP(i,n+1){
    if(b.at(i)+r>a.at(i)){
      ans+=a.at(i);
      if(r>=a.at(i)) r=b.at(i);
      else r=b.at(i)-a.at(i)+r;
    }else{
      ans+=(b.at(i)+r);
      r=0;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 1792
import java.util.*; 

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

  		int[] a=new int[n];
		for(int c=0;c<n;c++){
    		a[c]=sc.nextInt();
    	}
  		int[] b=a.clone();
  		Arrays.sort(b);
  		int max1=b[n-1];
  		int max2=b[n-2];
  		
  		
    for(int e=0;e<n;e++){
 	if(a[e]==max1){
    		System.out.println(max2);
    	}else{
     		System.out.println(max1);
   	 }
    }
    }
}



Measured memory_bytes: 90784
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define SZ(x) ((int)(x).size())
#define le length()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define fastIO                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define c(a) cout << a << "\n";
#define endl '\n'
const int MOD = 1e9 + 7;
const int N = 1e5 + 4;
#define pi 3.141592653589793
ll powmod(ll a, ll b, ll mod)
{
    ll res = 1;
    a %= mod;
    for (; b; b >>= 1)
    {
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}
int main()
{

    string s;
    cin >> s;
    for (int i = 0; i < s.le - 1; i++)
    {
        if (s[i] == s[i + 1])
        {
            return cout << i + 1 << " " << i + 2, 0;
        }
    }
    rep(i, s.le - 2)
    {
        if (s[i] == s[i + 2])
        {
            return cout << i + 1 << " " << i + 3, 0;
        }
    }
    cout << -1 << " " << -1;
    return 0;
}

Measured memory_bytes: 3736
using System;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        List<int> hon = new List<int> { 2, 4, 5, 7, 9 };
        List<int> pon = new List<int> { 0, 1, 6, 8 };
        List<int> bon = new List<int> { 3 };

        int i = n % 10;

        if (hon.Contains(i))
        {
            Console.WriteLine("hon");
        }
        else if (pon.Contains(i))
        {
            Console.WriteLine("pon");
        }
        else if (bon.Contains(i))
        {
            Console.WriteLine("bon");
        }
    }
}


Measured memory_bytes: 27724
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    string S;
    cin >> S;
    const int N = 753;
    int diff[S.size()-2] = {0};

    for(int i = 0; i < S.size() - 2; i++){
        string substr = S.substr(i,3);
        diff[i] = abs(stoi(S.substr(i,3)) - N);
    }
    sort(diff, diff+S.size()-2);
    cout << diff[0] << endl;
}


Measured memory_bytes: 256
console.log((args=>{
  const N = args|0;
  const e = Array(55555).fill(true);
  const m1 = [];
  for ( let i = 2; i < 55555; i++ ) {
    if ( !e[i] ) continue;
    for ( let j = i+i; j < 55555; j+=i ) {
      e[j] = false;
    }
    if ( i % 5 === 1 ) {
      m1.push(i);
      if ( m1.length === N ) break;
    }
  }
  return m1.join` `;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 33088
#include <stdio.h>
int main()
{
	int n;
	char s[51];
	char a[3]="ABC";
	scanf("%d",&n);
	scanf("%s",s);
	int i,j;
	int count=0;
	for(i=0;i<n-2;i++){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
			count++;
		}
	}
	printf("%d",count);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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; }
typedef long long ll;
typedef pair<int,int> P;

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

//Sieve sieve(1e6);
//auto f = sieve.factor(x);
// for(auto p:f){
//   p.firstは約数
//   p.secondは割れる回数
// }

int main(){
    int n;
    cin >> n;
    Sieve sieve(1e2);
    map<int,int> mp;
    for(int i=1;i<n+1;i++){
        auto f = sieve.factor(i);
        for(auto p:f){
            mp[p.first]+=p.second;
        }
    }
    int c2 = 0;int c4 = 0;int c14 = 0;int c24=0;int c74 =0;
    for(auto p:mp){
        if(p.second>1)c2++;
        if(p.second>3)c4++;
        if(p.second>13)c14++;
        if(p.second>23)c24++;
        if(p.second>73)c74++;
    }
    int ans = 0;
    ans += c4*(c4-1)/2*(c2-2);
    ans += c14*(c4-1);
    ans += c24*(c2-1);
    ans += c74;
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3") 

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

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define test(t)		int t; cin >> t; while(t--)
#define f(i, a, b)	for(int (i) = (a); (i) < (b); ++(i))
#define all(a)		(a).begin(), (a).end()
#define endl 		"\n"
#define maxvec(vec)     *max_element(all(vec))
#define minvec(vec)     *min_element(all(vec))
#define maxarr(arr)     *max_element(arr, arr + n)
#define minarr(arr)     *min_element(arr, arr + n)
#define deb(x)		cout << #x << " is " << x << endl;
#define deb2(x,y)	cout << #x << " is " << x << " and " <<  #y << " is " << y << endl;
#define deba(arr)	cout << #arr << " ~ [ "; for(auto n: arr) cout << n << " "; cout << "]" << endl;
#define debap(arr)	cout << #arr << " ~ [ "; for(auto n: arr) cout << n.first << "-" << n.second << " "; cout << "]" << endl;
#define fast 		ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define mx9		1000000007
#define mx7		10000007
#define mx6		1000006
#define mx5		200005
#define inf		1<<30                                 
#define eps		1e-9
#define mod		1000000007
#define PI		3.141592653589793238462643383279502884L

void solve()
{
    ll n, k;
    cin >> n >> k;
    ll a[n];
    f(i, 0, n)
        cin >> a[i];
    sort(a, a + n);
    ll sum = 0;
    f(i, 0, k)
        sum += a[i];
    cout << sum << endl;
}

int main()
{
    fast;
    // test(t)
        solve();
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>

using namespace std;

int main()
{
	int a,b;
	int route[5] = {0,0,0,0,0};

	for(int i=0;i<3;i++)
	{
		cin >> a >> b;
		route[a]++;
		route[b]++;
	}

	for(int i=1;i<=4;i++)
	{
		if(route[i]>2)
		{
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 256
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
from math import pi,sin,cos
a,b,h,m = iim()
h += m/60

th_h = 2*pi*h/12
th_m = 2*pi*h

ah = a*complex(cos(th_h),sin(th_h))
bm = b*complex(cos(th_m),sin(th_m))
#print(ah,bm)
print(abs(ah-bm))

Measured memory_bytes: 9440
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define rsort(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> V;
const long long MOD=1000000007;
const long long INF = 1e18;
clock_t time_ini = clock();
double time_diff(){
  ll time_tmp = clock();
  const double time = static_cast<double>(time_tmp - time_ini) / CLOCKS_PER_SEC * 1000.0;
  return time;
}
#define saiaku if(time_diff() > 1990)
vector <ll> dp;


void solve(long long N, long long K, std::vector<long long> h){
  ll cnt=0;
  for (ll i = 0; i < N; i++)
  {
    if(K <= h[i]){
      cnt++;
    }
  }
  cout << cnt << "\n";
  
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> h(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&h[i]);
    }
    solve(N, K, std::move(h));
    return 0;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int64_t solve(const vector<pair<int64_t, int64_t>>& vw,
              const vector<vector<int64_t>>& dp, int64_t v, int64_t l) {
    int64_t m = dp.size();

    if (l < 0) {
        return numeric_limits<int64_t>::min();
    }

    if (v < m) {
        return dp[v][l];
    }

    return max(solve(vw, dp, (v - 1) / 2, l),
               solve(vw, dp, (v - 1) / 2, l - vw[v].second) + vw[v].first);
}

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

    vector vw(n, make_pair(0L, 0L));
    for (auto&& t : vw) {
        cin >> t.first >> t.second;
    }

    auto m = min(512L, n);

    vector dp(m, vector(100001L, 0L));
    for (auto j : irange(vw[0].second, 100001L)) {
        dp[0][j] = vw[0].first;
    }
    for (auto i : irange(1L, m)) {
        for (auto j : irange(0L, vw[i].second)) {
            dp[i][j] = dp[(i - 1) / 2][j];
        }
        for (auto j : irange(vw[i].second, 100001L)) {
            dp[i][j] = max(dp[(i - 1) / 2][j],
                           dp[(i - 1) / 2][j - vw[i].second] + vw[i].first);
        }
    }

    int64_t q;
    cin >> q;
    for (auto _ : irange(0L, q)) {
        int64_t v, l;
        cin >> v >> l;
        --v;

        cout << solve(vw, dp, v, l) << "\n";
    }
}

Measured memory_bytes: 409552
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;
string yes = "Yes\n";
string no = "No\n";

int  main()
{
	string s; cin >> s;
	set <int> st;
	rep(i, s.size())
		st.insert(s[i]);
	if (st.size() != s.size())
		cout << "no";
	else
		cout << "yes";
	return (0);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c;
  int temp;

  scanf("%d %d %d",&a,&b,&c);

  if(a > b){
    temp = a;
    a = b;
    b = temp;
  }

  if(b > c){
    temp = b;
    b = c;
    c = temp;
  }

  if(a > b){
    temp = a;
    a = b;
    b = temp;
  }
  printf("%d %d %d\n",a,b,c);

  return 0;
}


Measured memory_bytes: 2108
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> myds;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define F first
#define S second
#define vec(x) vector<x> 
#define pi(x,y) pair<x,y>
#define pqq(x) priority_queue<x> 
#define min_heap(x) priority_queue<x, vector<x>, greater<x> >
#define all(x) x.begin(),x.end()
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repd(i,x,y,k) for(int i=x;i<y;i+=k)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define rev(x) reverse(all(x))
#define uniq(x) x.resize(distance(x.begin(),unique(all(x))))
#define full(x,a) memset(x,a,sizeof(x))
#define lcm(x,y) ((x*y)/__gcd(x,y))
#define mod 1000000007
#define bitcount __builtin_popcountll
#define pb push_back
#define indexof order_of_key
#define valueat find_by_order

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

int gcdextended(int a,int b,int &x,int &y){if(!a){x=0,y=1;return b;}int x1,y1;int ans=gcdextended(b%a,a,x1,y1);x=y1-(b/a)*x1;y=x1;return ans;}
int inv(int a){int x,y;int ans=gcdextended(a,mod,x,y);return(x%mod+mod)%mod;}
int nCr(int n,int k){int res=1;k=(k>n-k)?n-k:k;rep(i,0,k){res*=(n-i);res/=(i+1);}return res;}
int POW(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res%mod*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
//void seive(){prime[0]=0;prime[1]=0;rep(i,2,10002)prime[i]=1;for(int i=2;i*i<=10000;i++){if(prime[i]){for(int j=i*i;j<=10000;j+=i)prime[j]=0;}}} 

int n;

void input(){
	cin>>n;
}

void solve(){
	int ans=1e13;
	for(int i=2;i*i<=n;i++){
		if(n%i==0)
			ans=min(ans,i+n/i-2);
	}
	if(ans==1e13)
		cout<<n-1<<endl;
	else
		cout<<ans<<endl;
}

main(){
	fastio;
	int t;
	t=1;
	while(t--){
		input();
		solve();
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string a,b;
    int n;
    cin>>n;
    cin>>a>>b;
    for (int i=0;i<=n;i++){
        string z=a;
        for(int j=n-i;j<b.size();j++){
            z+=b[j];
        }
        int  t=0;
        bool flag=0;
        for (int j=z.size()-n;j<z.size();j++){
            if (z[j]!=b[t])
                flag=1;
            t++;
        }
        if (!flag)
            return cout<<n+i,0;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

int main() {
  string s;
  cin >> s;

  string s1 = s.substr(0, 2);
  string s2 = s.substr(2);

  if (s1 == "00") {
    if (s2 <= "12" and s2 != "00") {
      cout << "YYMM" << endl;
    } else {
      cout << "NA" << endl;
    }
    return 0;
  }
  if (s1 <= "12") {
    if (s2 <= "12" and s2 != "00") {
      cout << "AMBIGUOUS" << endl;
    } else {
      cout << "MMYY" << endl;
    }
  } else {
    if (s2 <= "12" and s2 != "00") {
      cout << "YYMM" << endl;
    } else {
      cout << "NA" << endl;
    }
  }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};

vector<int> edge[MAX_N];
bool reach[MAX_N];
lint ans[MAX_N];
lint cnt=0;
lint c[MAX_N];

void dfs(int now){
    if(reach[now]) return;
    reach[now]=true;
    ans[now]=c[cnt];
    cnt++;
    rep(i,edge[now].size()){
        dfs(edge[now][i]);
    }
}


int main(void){
    int N;
    cin >> N;
    rep(i,N-1){
        int u,v;
        cin >> u >> v;
        u--,v--;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    rep(i,N) cin >> c[i];
    sort(c,c+N,greater<int>());
    dfs(0);
    cout << accumulate(c+1,c+N,0LL) << endl;
    rep(i,N) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 9012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
//#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin >> n;
  vector<ll> a(n);
  ll m1 = 0, m2 = 0;
  REP(i, n) {
    cin >> a[i];
    if (m1 < a[i]) {
      m2 = m1;
      m1 = a[i];
    } else if (m2 < a[i])
      m2 = a[i];
  }
  REP(i, n) {
    if (a[i] == m1)
      cout << m2 << endl;
    else
      cout << m1 << endl;
  }

  return 0;
}


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

using namespace std;

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

int main() {
    string s; cin >> s;
    map<char, bool> m;
    m['A'] = true;
    m['C'] = true;
    m['G'] = true;
    m['T'] = true;
    int res = 0;
    int c = 0;
    fore(i, 0, s.size()) {
        if(m[s[i]]) c++, res = max(res, c);
        else c = 0;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }
// 桁和
LL Ketawa_s(string s) { LL a = 0; FOR(i, 0, s.length())a += s[i] - '0'; return a; }

//二項係数 nCk mod pを求める
const LL MAX = 510000, p = 998244353; LL fac[MAX], finv[MAX], inv[MAX];
/* 前処理 */void COM_init() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; FOR(i, 2, MAX) { fac[i] = fac[i - 1] * i % p; inv[i] = p - inv[p%i] * (p / i) % p; finv[i] = finv[i - 1] * inv[i] % p; } }
/* 主処理 */LL COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % p) % p; }

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

// -------------------------------------------------------------------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	VL a;
	LL N;
	LL ans = 0, tmp = 0;
	cin >> N;
	FOR(i, 0, N)
		a.push_back(IN<LL>());

	FOR(i, 0, N) {
		ans += a[i] - 1;
	}
	O(ans);


	return 0;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>


int main(void)
{
	int n;
	char mark[100];
	int num;
	int card[4][13] = { 0 };
	int i, j;
	int sim[5] = { 'S', 'H', 'C', 'D' };

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%s", mark);
		scanf("%d", &num);
		for (j = 0; j < 4; j++) {
			if (mark[0] == sim[j]) {
				card[j][num - 1] = 1;
			}
		}
	}


	for (i = 0; i < 4; i++) {
		for (j = 0; j < 13; j++) {
			if (card[i][j] == 0)
				printf("%c %d\n", sim[i], j + 1);
		}
	}

	return 0;
}



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

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

  //ベクトル配列の入力
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s.at(i);
  }
  sort(s.begin(), s.end());

  int ans = 1;
  for (int i = 0; i < n-1; i++) {
    if (s.at(i) != s.at(i+1)) {
      ans++;
    }
  }
  cout << ans << endl;
}


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

const ll MOD = 1000000007;
int n,k,z;
vector<ll> p, m;

void solve_p() {
  sort(p.begin(), p.end(), greater<ll>());
  sort(m.begin(), m.end(), greater<ll>());

  queue<pair<ll,ll>> pq;
  rep(i, (int)p.size()-1) pq.emplace(p[i], p[i]*p[i+1]);
  if(p.size()) pq.emplace(p[p.size()-1], p[p.size()-1]);
  queue<ll> mq;
  for(int i=0; i<(int)m.size()-1; i+=2) mq.push(m[i]*m[i+1]);

  ll ans = 1;
  rep(i, k) {
    if(pq.empty() && mq.empty()) {cout << 0 << endl;return;}
    if(mq.empty()) {
      ans = (ans * pq.front().first) % MOD;
      pq.pop();
    }
    else if(pq.empty()) {
      ans = (ans * (mq.front()%MOD)) % MOD;
      mq.pop();
      i++;
    }
    else if(pq.size()==1) {
      int nokori = k - i;
      if(i==k-1) {
        ans = (ans * pq.front().first) % MOD;
        pq.pop();
      }
      else if (nokori % 2) {
        ans = (ans * pq.front().first) % MOD;
        pq.pop();
      }
      else {
        ans = (ans * (mq.front()%MOD)) % MOD;
        mq.pop();
        i++;
      }
    }
    else if(i==k-1) {
      ans = (ans * pq.front().first) % MOD;
      pq.pop();
    }
    else if(mq.front() > pq.front().second) {
      ans = (ans * (mq.front()%MOD)) % MOD;
      mq.pop();
      i++;
    }
    else {
      ans = (ans * pq.front().first) % MOD;
      pq.pop();
    }
  }
  cout << ans << endl;
}

void solve_m() {
  sort(p.begin(), p.end());
  sort(m.begin(), m.end());
  queue<ll> pq, mq;
  for(ll i : p) pq.push(i);
  for(ll i : m) mq.push(i);

  ll ans = 1;
  rep(i,k) {
    if(pq.empty() && mq.empty()) {ans=0;break;}
    if(pq.empty())                   {ans *= -(mq.front()%MOD); mq.pop();}
    else if(mq.empty())              {ans *=  (pq.front()%MOD); pq.pop();}
    else if(mq.front() < pq.front()) {ans *= -(mq.front()%MOD); mq.pop();}
    else                             {ans *=  (pq.front()%MOD); pq.pop();}
    ans %= MOD;
    if (ans < 0) ans += MOD;
  }
  cout << ans << endl;
}

signed main() {
  cin >> n >> k;

  z = 0;
  rep(i,n) {
    ll a; cin >> a;
    if(a==0) ++z;
    else if(a > 0) p.push_back(a);
    else m.push_back(-a);
  }

  bool minus;
  if(k == n) minus = m.size()%2 == 1;
  else if (p.size()==0) minus = k%2 == 1;
  else minus = false;

  if(minus && z) {cout << 0 << endl; return 0;}

  if(minus) solve_m();
  else solve_p();
}


Measured memory_bytes: 8120
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n; cin>>n;
    vector<pair<ll,ll>> v;
    for(int i=1;i<=n;i++){
        ll a,b; cin>>a>>b;
        ll x=a-b; ll y=a+b;
        v.push_back({x,y});
    }
    sort(v.begin(),v.end());
    set<ll> st;
    st.insert(v[0].second);
    ll ans=0;
    for(int i=1;i<v.size();i++){
        ans=max(ans,abs(v[i].first-v[0].first));
        auto it=st.begin();
        ans=max(ans, abs(*it-v[i].second));
        it=st.end();
        it--;
        ans=max(ans,abs(*it-v[i].second));
        st.insert(v[i].second);
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 15780
#include<bits/stdc++.h>
#define ll long long
using namespace std;
typedef vector<long long> vl;
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define tr(v,it) for(auto it=(v).begin();it!=(v).end();it++)
#define mp make_pair
#define REP(i,a,b) for(i=a;i<=b;i++)

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    ll i,n,a,b,c,d;
    
    cin>>n>>a>>b>>c>>d;
    ll f=0;
    for(i=0;i<n;++i)
    {
        if((c*(n-i-1)-i*d)<=(b-a)&&(b-a)<=(d*(n-i-1)-i*c))
        {
            f=1;
            break;
        }
    }
    
    if(f==1) cout<<"YES\n";
    else cout<<"NO\n";
    
    
    return 0;
}

Measured memory_bytes: 256
R, G, B, N = gets.split(" ").map(&:to_i)
# p R, G, B, N
MAX = 3000
# cnt = 0
# (N/R + 1).times do |r|
#   rest = N - r * R
#   p "rest = #{rest}"
#   (rest / G + 1).times do |g|
#     rest2 = rest - g * G
#     if rest % B == 0
#       p [r, g, rest / B]
#       cnt += 1
#     end
#   end
# end

cnt = 0
(0..MAX).each do |r|
  break if R*r > N
  (0..MAX).each do |g|
    break if R*r + G*g > N
    rest = N - (R*r+G*g)
    if rest % B == 0
      cnt += 1
      # p(r: r, g: g, b: (rest/B), rest: rest, R: R*r, G: G*g, N: N, RG: R*r+G*g, RGN: N - R*r+G*g)
    end
  end
end

puts cnt


Measured memory_bytes: 1788
#include "bits/stdc++.h"
// Custom Header {{{
#define all(x)      x.begin(), x.end()
#define rep(i,n)    for (i64 i = 0; i < (n); ++i)
#define reps(i,s,t) for (i64 i = (s); i <= (t); ++i)
#define repr(i,s,t) for (i64 i = (s); i >= (t); --i)
#define LF          '\n'

#ifdef DBG
#define trace(...) _trace(#__VA_ARGS__, __VA_ARGS__);
#else
#define trace(...)
#endif

using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template<class T, class U>inline bool chmax(T &a, const U &b){return b>a ? (a=b,1) : 0;}
template<class T, class U>inline bool chmin(T &a, const U &b){return b<a ? (a=b,1) : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template<class T>
ostream& operator<< (ostream &os, const vector<T> &vec) {
    rep(i, vec.size()) os << vec[i] << (i+1 == vec.size() ? "" : " ");
    return os;
}

template<class T, class U>
ostream& operator<< (ostream &os, const pair<T, U> &p) {
    return os << p.first << ' ' << p.second;
}

template <class T>
void _trace(const char *s, T&& x)
{
    clog << '{';
    while(*s != '\0' && *s != ',') clog << *(s++);
    clog << ":" << setw(3) << x << '}' << endl;
}

template <class Head, class... Tail>
void _trace(const char *s, Head&& head, Tail&&... tail)
{
    clog << '{';
    while(*s != ',') clog << *(s++);
    clog << ":" << setw(3) << head << "}, ";
    for (++s; !isgraph(*s); ++s);
    _trace(s, std::forward<Tail>(tail)...);
}
// }}}

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

    if (a + b == 15) puts("+");
    else if (a * b == 15) puts("*");
    else puts("x");

    return 0;
}



Measured memory_bytes: 256
N, K = map(int, input().split())
# N ,K = 100000, 5

def min_v(x, k):
    v=1.0
    while v>x/k:
        v /= 2
    return v

V = 0
for n in range(1, N+1):
    V += min_v(n, K)

print('{:.16f}'.format(V/N)) 

Measured memory_bytes: 2940
#include <iostream>
#include <cmath>
using namespace std;
static const int MAX_N = 100000;

int main(void){
    int n;
    int H[MAX_N];

    // 入力
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> H[i];
    }

    // 左から見るしかなさそう??
    int ans = 0;
    int tmp_ans = 0;
    for(int i=0; i<n-1; i++){
        // 同じかそれより小さい
        if(H[i]>=H[i+1]){
            tmp_ans+=1;
        }
        else{
            if(tmp_ans > ans) ans=tmp_ans;
            tmp_ans = 0;
        }
        
    }
    if(tmp_ans>ans) ans=tmp_ans;
    cout << ans;

    return 0;
}

Measured memory_bytes: 640
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;   
    
    long long a[n];
    for(int i=0; i<n; i++){
        cin >> a[i] ;
    }
    
    sort(a, a+n);
    
    long long c=0;
    for(int i=0; i<n-k; i++){
        c += a[i] ;
    }
        
    cout << c << endl;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(){
    int x, y, i, j;
    while(true){
        cin >> x >> y;
        if(x==0 && y==0)
            break;
        for(i=0; i<x; i++){
            for(j=0; j<y; j++){
                if(i==0 || j==0 || j==y-1 || i==x-1){
                    cout << '#';
                }else{
                    cout << '.';
                }
            }
        cout << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3076
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b,c,x,num;
int main()
{
	scanf("%d%d%d%d",&a,&b,&c,&x);
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
			for(int k=0;k<=c;k++)
			if(500*i+100*j+50*k==x)num++;
	printf("%d",num);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
 
#define MAX   10000
#define INFTY (1 << 20)
#define WHITE 0
#define GRAY  1
#define BLACK 2
 
int n;
vector<pair<int, int> > adj[MAX];
 
void dijkstra() {
  priority_queue<pair<int, int> > PQ;
  int color[MAX], d[MAX];
  for ( int i = 0; i < n; i++ ) {
    color[i] = WHITE;
    d[i] = INFTY;
  }
 
  d[0] = 0;
  PQ.push(make_pair(0, 0));
  color[0] = GRAY;
 
  while ( !PQ.empty() ) {
    pair<int, int> f = PQ.top(); PQ.pop();
    int u = f.second;
    color[u] = BLACK;
 
    if ( d[u] < f.first * (-1) ) continue;
 
    for ( int j = 0; j < adj[u].size(); j++ ) {
      int v = adj[u][j].first;
      if ( color[v] == BLACK ) continue;
      if ( d[v] > d[u] + adj[u][j].second ) {
        d[v] = d[u] + adj[u][j].second;
        PQ.push(make_pair(d[v] * (-1), v));
        color[v] = GRAY;
      }
    }
  }
 
  for ( int i = 0; i < n; i++ ) {
    cout << i << " " << ( d[i] == INFTY ? -1 : d[i] ) << endl;
  }
}
 
 
int main() {
  int u, k, c, v;
  cin >> n;
  for ( int i = 0; i < n; i++ ) {
    cin >> u >> k;
    for ( int j = 0; j < k; j++ ) {
      cin >> v >> c;
      adj[u].push_back(make_pair(v, c));
    }
  }
 
  dijkstra();
 
  return 0;
}

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

int solve(string s);

int main() {
    string s;
    int count, a, b;
    a = b = 0;

    cin >> s;

    for(int i = 0; i < s.size(); i++) {
        if(s.at(i) == '0') a++;
        else b++;
    }
    
    if(a > b) count = 2 * b;
    else count = 2 * a;

    // count = solve(s);
    
    cout << count << endl;

    return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

//update k th element,get rmin
template<class T> class segtree{
public:
    int n,size_;
    vector<T> dat;
    function<T(T,T)> fun_;
    T id_;
    segtree()=default;
    segtree(int size,function<T(T,T)> fun,T id,T initial_value){ init(size,fun,id,initial_value); }
    void init(int size,function<T(T,T)> fun,T id,T initial_value){
        size_=size;
        fun_=fun;
        id_=id;
        n=1;
        while(n<size) n*=2;
        dat.assign(2*n-1,0);
        for(int i=0; i<size; ++i) update(i,initial_value);
    }
    void update(int k, T a) {
        k+=n-1; // leaf
        dat[k]=a;
        while(k>0) {
            k=(k-1)/2;
            dat[k]=fun_(dat[k*2+1],dat[k*2+2]);
        }
    }
    void add(int k,T a){ update(k,dat[k+n-1]+a); }
    T query(int a,int b) { return query(a,b,0,0,n); }
    T query(int a,int b,int k,int l,int r) {
        if(r<=a or b<=l) return id_;
        if(a<=l and r<=b) return dat[k];
        int m=(l+r)/2;
        return fun_(query(a,b,k*2+1,l,m),query(a,b,k*2+2,m,r));
    }
};

void solve(){
    int n,q;
    cin >> n >> q;
    segtree<int> seg(n,[](int x,int y){ return x+y; },0,0);
    rep(i,0,q){
        int com,x,y;
        cin >> com >> x >> y;
        if(com==0) seg.add(x-1,y);
        else cout << seg.query(x-1,y) << endl;
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

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

int main() {

int n;
std::cin >> n;
int a[n];
for(int i=0; i<n; i++) std::cin >> a[i];

int b[n];
int t=0;

for(int i=0; i<n; i++){
    if ((a[i]%2)==0){
        b[t]=a[i]; 
     //   cout << b[t] <<endl;
        t++;
    }
}

int hantei=0;
for(int i=0; i<t; i++){
  // cout << hantei <<endl;
    if ((b[i]%3)==0 || (b[i]%5)==0){
        hantei=1;
    }
    else{ hantei=0;
    break;
    }
}

if(t==0) hantei=1;

if(hantei==1){
cout <<"APPROVED"<<endl;
}
else cout <<"DENIED"<<endl;



}


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

int main() {
	int m,n;cin>>m>>n;
	int a[m][n]={0};
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			cin>>a[i][j];
		}
	}
	int s=0;
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			cout<<a[i][j]<<" ";
			s+=a[i][j];
		}
		cout<<s<<endl;
		s=0;
	}
	int b[n]={0};
	for(int j=0;j<n;j++){
		for(int i=0;i<m;i++){
			b[j]+=a[i][j];
		}
		cout<<b[j]<<" ";
	}
	for(int j=0;j<n-1;j++){
		b[n-1]+=b[j];
	}
	cout<<b[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 3084
from bisect import bisect_left

n =int(input())
L = list(map(int,input().split()))
L.sort()

#L[i]+L[j] > ?
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        zz = L[i]+L[j]
        idx = bisect_left(L,zz)
        ans += idx-j-1
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <numeric>
#include <algorithm>
#include <cassert>

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k,n;
    cin >> k >> n;
    int a0, ap, a;
    cin >> a;
    a0 = a;
    
    int max_d = 0;
    
    for(int i = 1; i < n; ++i)
    {
        ap = a;
        cin >> a;
        max_d = max(max_d, a - ap);
    }
    
    max_d = max(max_d, a0 + k - a);
    cout << k - max_d << '\n';

    return 0;
}


Measured memory_bytes: 256
#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 "functional"
#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-8;

//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 >> K;
	string s;
	cin >> s;
	for (int i = 0; i < N; i++) {
		if (s[i] == 'L') {
			if (i&&s[i - 1] == 'L')M++;
		}
		else {
			if (i + 1 < N&&s[i + 1] == 'R')M++;
		}
	}
	cout << min(N - 1, M + K * 2) << endl;
}

Measured memory_bytes: 512