akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin >> N;
    string x=to_string(N);
    int s=0;
    rep(i,x.size()){
        s+=x[i]-'0';
    }
    if(N%s==0) cout << "Yes" << endl;
    else cout << "No" << endl;



}


Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll [[maybe_unused]] = long long;
using ull [[maybe_unused]] = unsigned long long;
using ld [[maybe_unused]] = long double;

[[maybe_unused]] static constexpr int mod = (int)1e9 + 7;
[[maybe_unused]] static constexpr int inf = 100100100;
[[maybe_unused]] static constexpr ll linf = 1e18;
[[maybe_unused]] static constexpr double eps = 1e-9;
[[maybe_unused]] static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, a, b) for (ll i = a; i < b; ++i)
#define rrrep(i, a, b) for (ll i = a; i >= b; --i)
#define all(obj) begin(obj), end(obj)
#define rall(obj) rbegin(obj), rend(obj)
#define pb push_back
#define fst first
#define snd second


ll D;
ll G;

int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    cin >> D >> G;

    vector<ll> p;
    vector<ll> c;
    rep(i, D) {
        ll p_, c_;
        cin >> p_ >> c_;
        p.pb(p_);
        c.pb(c_);
    }
    ll ans = linf;
    for (ll i = 0; i < (1 << D); ++i) {
        ll s = 0;
        ll n = 0;
        rep(j, D) {
            if (i & (1 << j)) {
                s += 100 * (j + 1) * p[j] + c[j];
                n += p[j];
            }
        }
        if (s >= G) {
            ans = min(ans, n);
            continue;
        }
        rep(j, D) {
            if (i & (1 << j)) continue;
            rep(k, p[j]) {
                    if (s + 100 * (j + 1) * k >= G) {
                    ans = min(ans, n + k);
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

ll in[505][3];
int main() {
	int N, i, j, k;
	scanf("%d", &N);
	for (i = 1; i < N; i++) for (j = 0; j < 3; j++) scanf("%lld", &in[i][j]);

	for (i = 1; i < N; i++) {
		ll st = 0;
		for (j = i; j < N; j++) {
			st = max(st, in[j][1]);
			if (st % in[j][2]) st += in[j][2] - st % in[j][2];
			st += in[j][0];
		}
		printf("%lld\n", st);
	}
	return !printf("0\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }

ll gcd(ll a,ll b) {
  if (a < b) swap(a, b);
  if (a % b == 0) return b;
  return gcd(b, a%b);
}

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

  ll x, y;
  cin >> x >> y;

  cout << (gcd(x, y) == y ? -1 : x) << '\n';







  
  return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

using Flow = int;
struct FlowEdge {
  int src, dst;
  Flow cap;
  int rev;
  FlowEdge(const int s = 0, const int d = 0, const Flow c = 0, const int r = 0) : src(s), dst(d), cap(c), rev(r) {}
};

using FlowEdges = std::vector<FlowEdge>;

class FlowGraph {
  std::vector<FlowEdges> g;

public:
  FlowGraph(const int size = 0) : g(size) {}
  size_t size() const { return g.size(); }
  FlowEdges &operator[](const int i) & { return g[i]; }

  void addEdge(const int src, const int dst, const Flow c = 1) {
    g[src].emplace_back(src, dst, c, g[dst].size());
    g[dst].emplace_back(dst, src, 0, g[src].size() - 1);
  }
};

template<Flow inf = std::numeric_limits<Flow>::max() / 8> Flow fordFulkerson(FlowGraph g, const int source, const int sink) {
  std::vector<int> used(g.size());
  std::function<Flow(int, Flow)> dfs = [&](int v, Flow f) -> Flow {
    if (v == sink) return f;
    used[v] = true;
    for (auto &e : g[v]) {
      if (used[e.dst] || e.cap <= 0) continue;
      Flow d = dfs(e.dst, min(f, e.cap));
      if (d <= 0) continue;
      e.cap -= d;
      g[e.dst][e.rev].cap += d;
      return d;
    }
    return 0;
  };
  Flow s = 0;
  for (;;) {
    std::fill(used.begin(), used.end(), false);
    Flow f = dfs(source, inf);
    if (f == 0) return s;
    s += f;
  }
}

main {
  int n, m;
  cin >> n >> m;
  FlowGraph g(n);
  while (m--) {
    int a, b, c;
    cin >> a >> b >> c;
    g.addEdge(a, b, c);
  }
  cout << fordFulkerson(g, 0, n - 1) << endl;
}

Measured memory_bytes: 3176
#include<iostream>
#include<sstream>
#include<iomanip>
#include<bitset>
#include<map>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
using namespace std;
int main(){
  int x,y;
  cin>>x>>y;
  if(x==2||y==2)ou("No");
  else if(x==4||x==6||x==9||x==11){
    if(y==4||y==6||y==9||y==11)ou("Yes");
    else ou("No");
  }
  else {
    if(y==4||y==6||y==9||y==11)ou("No");
    else ou("Yes");
  }
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		sc.close();
		String[] s = {"Positive", "Zero", "Negative"};
		int ans = 0;
		if(a>0 && b>0) {
			ans=0;
		} else if(a<=0 && b>=0) {
			ans=1;
		} else if(a<0 && b<0) {
			int c=b-a;
			if(c%2==0) {
				ans=2;
			} else {
				ans=0;
			}
		} 
		out.println(s[ans]);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,D;
    cin >> N >> D;
    vector<vector<int>> X(N,vector<int>(D));
    REP(i,N)REP(j,D)cin >> X.at(i).at(j);
    vector<int> A(N*N);
    REP(i,N)REP(j,N){
        int l = 0;
        REP(k,D){
            int tmp = (X.at(i).at(k)-X.at(j).at(k));
            tmp *= tmp;
            A.at(i*N+j) += tmp;
        }
    }
    int answer = 0;
    REP(i,N*N)if(A.at(i) != 0 && (int)sqrt(A.at(i))*sqrt(A.at(i)) == A.at(i))answer++;
    cout <<answer/2<< "\n";
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main()
{

int i, n;
long int max, min, input, sum;

cin >> n;
sum = 0;

for( i=1; i<=n; i++ )
{
  cin >> input;
  sum = sum + input;
  if( i == 1 )
  {
    max = input;
    min = input;
  }
  else
  {
    if( input > max )
    {
      max = input;
    }
    else if( input < min )
    {
      min = input;
    }  
  }
}

cout << min << " " << max << " " << sum << endl;


return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long LL;
#define debug(x) cerr << #x << "=" << x << endl;
#define lgx cerr << "-----------" << endl;

int main (){
    int N,M;
    cin >> N >> M;
    LL ans=1800*M+100*N;
    for(int i=0;i<M;i++){
        ans*=2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//***********************
    //*** writer : Alan Hu **
    //***********************
    #include<iostream>
    #include<vector>
    #include<string>
    #include<set>
    #include<map>
    #include<algorithm>
    #include<queue>
    #include<list>
    #include<stack>
    #include<cstdio>
    #include<fstream>
    #include<numeric>
    #include<functional>
    #include<utility>
    #include<memory>
    #include<cstring>
    #include<cmath>
    using namespace std;
     
    #define CLEAN(a,b) memset(a,b,sizeof(a))
    #define mp make_pair
    #define pb push_back
    #define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
     
    typedef long long ll;
    typedef pair<int, int> pii;
     
    int main()
    {
    	int a=0,b=0;
    	string s;
    	cin>>s;
    	for (int i=0;i<s.size();i++)
    	{
    		if (s[i]=='+') a++;
    		else b++;
    	}
    	cout<<a-b<<endl;
    	return 0;
    }

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,a,b,c;
int l[25];

int calc(int mask, int step){
  int ret = 1<<28;
  FOR(use,1,1<<n)if((use&mask)==0){
    int x = 0, cnt = 0;
    REP(i,n)if(use>>i&1)x+=l[i],cnt++;
    int mp = (cnt-1) * 10;
    if(step==0)mp += abs(x-a);
    if(step==1)mp += abs(x-b);
    if(step==2)mp += abs(x-c);
    if(step<2){
      CHMIN(ret, mp+calc(mask|use, step+1));
    }else{
      CHMIN(ret, mp);
    }
  }
  return ret;
}

int main(){
  scanf("%d%d%d%d",&n,&a,&b,&c);
  REP(i,n)scanf("%d",l+i);
  printf("%d\n",calc(0,0));
  return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
lst1 = list(readline().rstrip().decode('utf-8'))


res = lst1.copy()
res = "".join(res)
ct = res.count("1")
res = int(res,2)
if ct == 0:
    for i in range(n):
        print(1)
    exit()
if ct == 1:
    amari_of_m = -1
else:
    amari_of_m = res%(ct-1)
amari_of_p = res%(ct+1)

def pow(n,p,mod): #繰り返し二乗法(nのp乗)
    res = 1
    while p > 0:
        if p % 2 == 0:
            n = n ** 2 % mod
            p //= 2
        else:
            res = res * n % mod
            p -= 1
    return res % mod

def func(res):
    ans = 1
    while True:
        ct = 0
        for i in range(len(bin(res))):
            if res>>i&1:
                ct += 1
        if res%ct == 0:
            print(ans+1)
            return
        else:
            res %= ct
            ans += 1

for i in range(n):
    if lst1[i] == "1" and amari_of_m == -1:
        print(0)
        continue
    else:
        resres = pow(2,n-i-1,ct-1) if lst1[i] == "1" else pow(2,n-i-1,ct+1)
    if lst1[i] == "1":
        resres = amari_of_m - resres
        resres %= ct-1
    else:
        resres = amari_of_p + resres
        resres %= ct+1
    if not resres:
        print(1)
    else:
        func(resres)


Measured memory_bytes: 93460
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define fi first
#define se second

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

int n;
string s;

signed main(){
  int n,k;
  cin>>n>>k;
  double sum=0;
  for(int i=1;i<=n;i++){
    int x=i,p=0;
    while(x<k){
      x*=2;
      p++;
    }
    sum += pow(0.5,(double)p)*1.0/n;
  }
  printf("%.12f\n",sum);
}

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

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

  int L, R, maxL = 1, minR = N;
  for (int i = 0; i < M; i++) {
    cin >> L >> R;
    maxL = max(L, maxL);
    minR = min(R, minR);
  }

  int ans = max(minR - maxL + 1, 0);
  cout << ans << endl;

  return 0;
}


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

class Program {
  static void Main() {
    var n = int.Parse(Console.ReadLine());
    var v = Console.ReadLine().Split().Select(int.Parse).ToArray();
    var c = Console.ReadLine().Split().Select(int.Parse).ToArray();
    var a = 0;
    for (int i = 0; i < n; i++) {
      if (v[i] - c[i] > 0) a += v[i] - c[i];
    }
    Console.WriteLine(a);
  }
}

Measured memory_bytes: 13268
# Something on It
S = gets.chomp.to_s
count = 0
for i in 0..S.length-1 do
    if S[i] == "o"
        count = count + 1
    end
end
if count == 3
    puts 1000
elsif count == 2
    puts 900
elsif count == 1
    puts 800
else 
    puts 700
end

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

using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
const int MOD = 1e9+7;

template<int MOD> struct Fp {
  ll val;
  constexpr Fp(ll v = 0) noexcept : val(v % MOD) { if (val < 0) val += MOD; }
  constexpr int getmod() { return MOD; }
  constexpr Fp operator - () const noexcept { return val ? MOD - val : 0; }
  constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
  constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
  constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
  constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
  constexpr Fp& operator += (const Fp& r) noexcept {
    val += r.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }
  constexpr Fp& operator -= (const Fp& r) noexcept {
    val -= r.val;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr Fp& operator *= (const Fp& r) noexcept {
    val = val * r.val % MOD;
    return *this;
  }
  constexpr Fp& operator /= (const Fp& r) noexcept {
    ll a = r.val, b = MOD, u = 1, v = 0;
    while (b) {
      ll t = a / b;
      a -= t * b; swap(a, b);
      u -= t * v; swap(u, v);
    }
    val = val * u % MOD;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr bool operator == (const Fp& r) const noexcept { return this->val == r.val; }
  constexpr bool operator != (const Fp& r) const noexcept { return this->val != r.val; }
  friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept { return os << x.val; }
  friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, ll n) noexcept {
    if (n == 0) return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1) t = t * a;
    return t;
  }
};

using mint = Fp<MOD>;

const int MAX = 2e5+1;
ll fac[MAX], finv[MAX], inv[MAX];

void comb_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll comb(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
  int N, K; cin >> N >> K;
  comb_init();

  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  sort(A.begin(), A.end());

  mint sum[N+1];
  sum[0] = 0;
  rep(i, N)
    sum[i+1] = sum[i] + A[i];

  mint ans = 0;
  rep(l, K, N+1) {
    ans += ((sum[N] - sum[l-1]) - sum[N - l + 1]) * comb(l-2, K-2);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x 2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  int n,k,count=0;
  cin >> n >> k;
  while(n!=0){
    n/=k;
    count++;
  }
  cout << count << endl;
  return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    vector<ll> x,y;
    for(int i=0;i<n;++i){
        int xi,yi;
        cin>>xi>>yi;
        x.push_back(xi+yi);
        y.push_back(xi-yi);
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    
    ll xf = x[0];
    ll xb = x.back();
    ll yf = y[0];
    ll yb = y.back();
    cout << max(abs(xb - xf),abs(yb - yf)) << endl;
    return 0;
    
}


Measured memory_bytes: 6572
#include <bits/stdc++.h>
#define int long long 
using namespace std;
int f[100100],g[100100],a[100100];
char opt,lst;
int x,y,ans,cnt,n;
signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&x);
		lst=opt;
		if(i!=n)cin>>opt;
		if(lst=='-'){
			x=-x;
			a[++cnt]=x;
		}
		if(y<=0&&x>0)a[++cnt]=x;
		if(y>0&&x>0)a[cnt]+=x;
		y=x;
	}
	f[1]=a[1];
	for(int i=cnt;i>=1;i--)g[i]=g[i+1]+abs(a[i]);
	for(int i=2;i<=cnt;i++)f[i]=f[i-1]+a[i];
	ans=f[cnt];
	for(int i=1;i<cnt;i++)
		if(a[i+1]<0)
			ans=max(ans,f[i+1]-a[i+2]+g[i+3]);
	printf("%lld\n",ans);
} 

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

int N, M, X;
const int MAX_M = 100 + 10;
int A[MAX_M];

int main() {
    cin >> N >> M >> X;
    for (int i = 0; i < M; i++) cin >> A[i];

    int to_zero = 0;
    int j = 0;
    for (int i = 0; i < X; i++) {
        if (j < M && A[j] == i) {
            to_zero++;
            j++;
        }
    }
    int to_N;
    for (int i = X; i <= N; i++) {
        if (j < M && A[j] == i) {
            to_N++;
            j++;
        }
    }

    cout << min(to_zero, to_N) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#define maxn 100010
using std::sort;
using std::string;
char s[maxn][12];
string S[maxn];
long long ans = 0;
int main() {
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%s", s[i]), sort(s[i], s[i] + 10), S[i] = string(s[i]);
	sort(S + 1, S + n + 1);
	for(int i = 1, c = 0; i <= n; ++i) {
		++c;
		if(S[i] != S[i + 1]) ans += (long long) c * (c - 1) / 2, c = 0	;
	}
	printf("%lld", ans);
}

Measured memory_bytes: 6912
#include<iostream>
#include<string>
using namespace std;
int main(){
	int x,y,a=1,b=1;
	cin>>x>>y;
	if(x==2)a=2;
	if(x==4||x==6||x==9||x==11)a=3;
	if(y==2)b=2;
	if(y==4||y==6||y==9||y==11)b=3;
	if(a==b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

#define MOD (1000000000+7)

int N;
string s1;
string s2;

int main()
{
	cin >> N;
	cin >> s1;
	cin >> s2;

	long long ans = 1;
	int f = 0;
	int v = 0;
	for( int i = 0; i < N; i++ ) {
		if( s1[i] == s2[i] ) {
			if( f == 0 ) {
				ans = ans * 3 % MOD;
				f = 1;
			}
			else {
				if( v ) {
					ans = ans * 2 % MOD;
				}
			}
			v = 1;
		}
		else {
			if( f == 0 ) {
				ans = ans * 6 % MOD;
				f = 1;
			}
			else {
				if( v ) {
					ans = ans * 2 % MOD;
				}
				else {
					ans = ans * 3 % MOD;
				}
			}
			v = 0;
			i++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define db cout<<"db: "
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define all(v) v.B,v.E
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 200005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    cin>>t;
    while(t--)
    {
        cin>>n;
        ll ans=0;
        vii left,right;
        rep(i,0,n)
        {
            int k,l,r;
            cin>>k>>l>>r;
            if(l>r) left.pb({l-r,k});
            else if(r>l) right.pb({r-l,k});
            ans+=min(l,r);
        }
        sort(all(left));
        sort(all(right));

        set<int> free;
        rep(i,1,n+1)free.insert(i);
        for(i=sz(left)-1;i>=0;i--)
        {
            auto it  = free.upper_bound(left[i].S) ;
            if(it!=free.B)
            {
                it=prev(it);
                free.erase(it);
                ans+=left[i].F;
            }
        }
        
        rep(i,1,n+1)free.insert(i);
        for(i=sz(right)-1;i>=0;i--)
        {
            auto it  = free.upper_bound(right[i].S) ;
            if(it!=free.E)
            {
                free.erase(it);
                ans+=right[i].F;
            }
        }
        cout<<ans<<"\n";
    }

    return 0;
}

Measured memory_bytes: 14264
n,k = map(int, input().split())
s = input()
count = 0 #境界の数
for i in range (0,n-1):
    if (s[i] != s[i+1]):
        count += 1
answer = min(len(s) - count - 1 + k*2, len(s) - 1)
print(answer)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
const int MAX = 2e5 ;
const int INF = 1e9 + 1e5 + 2;
const int mod= 1e9+7;
#define eps 1e-15
typedef long long ll;
int main()
{
    ll x;

    cin>>x;

    ll ans=0;

    ll y=x/500;

    ans+=y*1000;

    x-=y*500;

    ll z=x/5;

    ans+=z*5;

    cout<<ans;










}


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

typedef long long ll;

using namespace std;

int main(void)
{
    int a, b;
    cin >> a >> b;

    vector<ll> enemy(a);

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

    sort(enemy.begin(), enemy.end(), greater<ll>());

    ll cnt = 0;

    for (int i = 0; i < a; i++) {
        if (b == 0) {
            cnt += enemy[i];
        } else {
            b--;
        }
    }

    cout << cnt << endl;

    return 0;
}

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


int main(){
  int n,f,even=0,odd=0;
  cin>>n>>f;
  rep(i,n){
    int t;
    cin>>t;
    if (t%2==0) even++;else odd++;
  }
  if (odd==0) {
    if (f==0) cout<<(1ll<<n)<<endl;
    else cout<<0<<endl;
  }else{
      cout<<(1ll<<(n-1))<<endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
	int x;
	char a[25];
	
	scanf("%s", a);
	x=strlen(a);
	
	for(int i=0; i<x; i++){
		if (a[i]==',')printf(" ");
		else
		printf("%c", a[i]);
	}
		
}

Measured memory_bytes: 1612
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(int i=start;i<end;i++)
#define N 100001
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl;
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<endl;
#define pi M_PI

const int INF = 1e9 + 5;
int main()
{
	fastio();
	int n,k;cin>>n>>k;
	int h[n];
	loop(i,0,n)
	{
		cin>>h[i];
	}
	vector<int> dp(n, INF);
	dp[0] = 0;
	loop(i,0,n)
	{
		loop(j,i+1,i+k+1)
		{
			if(j<n)
				dp[j] = min(dp[j],dp[i]+abs(h[i]-h[j]));
		}
	}
	cout<<dp[n-1]<<endl;

	return 0;
}	

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll d[100100];
vector<P> g[100100];
priority_queue<P, vector<P>, greater<P> > pq;

int main(void){
	int n,m,l,r,i;
	ll c;
	fill(d,d+100100,INFLL);
	d[0] = 0ll;
	pq.push(P(d[0],0));
	cin >> n >> m;
	for(i=1; i<n; ++i){
		g[i].push_back(P(0ll,i-1));
	}
	for(i=0; i<m; ++i){
		cin >> l >> r >> c;
		--l; --r;
		g[l].push_back(P(c,r));
	}
	while(!pq.empty()){
		l = pq.top().second;
		c = pq.top().first;
		pq.pop();
		if(c>d[l]){
			continue;
		}
		for(i=(g[l].l_ength()-1); i>=0; --i){
			r = g[l][i].second;
			c = g[l][i].first;
			if(d[r] > d[l] + c){
				d[r] = d[l] + c;
				pq.push(P(d[r],r));
			}
		}
	}
	cout << ((d[n-1]<INFLL)?d[n-1]:(-1ll)) << endl;
	return 0;
}


Measured memory_bytes: 10232
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

vector<vector<int> > v(100000);
bool maki[100000];
deque<int> ans;

void dfs1(int n){
    int s=v[n].size();
    for(int i=0;i<s;i++){
        if(!maki[v[n][i]]){
            ans.push_front(v[n][i]);
            maki[v[n][i]]=1;
            dfs1(v[n][i]);
            return;
        }
    }
    return;
}
void dfs2(int n){
    int s=v[n].size();
    for(int i=0;i<s;i++){
        if(maki[v[n][i]])continue;
        else{
            ans.pb(v[n][i]);
            maki[v[n][i]]=1;
            dfs2(v[n][i]);
            return;
        }
    }
    return;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    int a,b;
    int niko;
    memset(maki,0,sizeof(maki));
    for(int i=0;i<m;i++){
        cin>>a>>b;
        a--;b--;
        v[a].pb(b);
        v[b].pb(a);
        if(a==0)niko=b;
    }

    ans.pb(0);
    ans.pb(niko);
    maki[0]=maki[niko]=1;
    dfs1(0);
    dfs2(niko);
    cout << ans.size() <<endl;
    while(!ans.empty()){
        cout << (ans.front())+1 <<" ";
        ans.pop_front();
    }
    cout <<endl;
    return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  int v[n];
  int c[n];
  cin >> n;
  for (int i=0; i<n; i++) {
    int l;
    cin >> l;
    v[i] = l;
  }
  for (int i=0; i<n; i++) {
    int l;
    cin >> l;
    c[i] = l;
  }
  int count = 0;
  for (int i = 0; i< n; i++) {
  	if (v[i]-c[i]>0) count += v[i]-c[i];
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    string S, T;
    cin >> S >> T;
    
    int index = -1;
    for(int i=0; i<S.length()-T.length()+1; i++) {
        if(S.substr(i,1) == T.substr(0,1) || S.substr(i,1) == "?") {
            string temp_S;
            for(int j=0; j<T.length(); j++) {
                if(S.substr(i+j,1) == "?") {
                    temp_S += T.substr(j,1);
                }
                else {
                    temp_S += S.substr(i+j,1);
                }
            }
            if(temp_S == T) index = i;
        }
    }
    
    if(index == -1) {
        cout << "UNRESTORABLE" << endl;
    }
    else {
        string result = S.substr(0, index) + T + S.substr(index+T.length());
        replace(result.begin(), result.end(), '?', 'a');
        cout << result << endl;
    }

    return 0;
    
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test lli t;cin>>t;while(t--)
#define vll vector<lli>
#define mll map<lli,lli>
#define vvll vector<vector<lli>>
#define vpll vector<pair<lli,lli>>
#define vvpll vector<vector<pair<lli,lli>>>
#define mpll map<pair<lli,lli>,lli>
#define pll pair<lli,lli>
#define sll stack<lli>
#define qll queqe<lli>
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ff first
#define ss second
#define mod 1000000007
#define ma 1000000000000000000
#define mi -1000000000000000000
int main()
{
  
  fastio
  int x;
  cin>>x;
  if(x<=599)
    cout<<8;
  else if(x<=799)
    cout<<7;
  else if(x<=999)
    cout<<6;
  else if(x<=1199)
    cout<<5;
  else if(x<=1399)
    cout<<4;
  else if(x<=1599)
    cout<<3;
  else if(x<=1799)
    cout<<2;
  else
    cout<<1;

  return 0;
}

Measured memory_bytes: 3608
import Control.Applicative
import Control.Monad
import Data.Bool (bool)

main :: IO ()
main = do
  [n, d] <- f
  solve d <$> replicateM n f >>= print
  where
    f = map read <$> words <$> getLine

solve :: Int -> [[Int]] -> Int
solve d = foldl f 0
  where
    f ct [x, y] = bool ct (ct + 1) $ d * d >= x * x + y * y


Measured memory_bytes: 165608
#include<bits/stdc++.h>
using namespace std;
#define int long long int

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;


#define mod 1000000007
#define INF 1e9+100
#define ff first
#define ss second
#define cy cout<<"YES"<<endl;
#define cn cout<<"NO"<<endl;
#define urs(r...)          typename decay<decltype(r)>::type
#define fi(i,n)                for(urs(n) i=0;i<n;i++)
#define rep(i,n)               for(urs(n) i=1;i<=n;i++)
#define pb push_back
#define gap ' '
#define endl '\n'
#define mex 300000
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>*/
main()
{
	int i,j,n,m,t;
	int r;
   cin>>n>>m;
   int a[m+2];
   fi(i,m) cin>>a[i];
   int sum=accumulate(a,a+m,0);
   if(sum>n) cout<<-1<<endl;
   else cout<<n-sum<<endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <map>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

LL comb(LL val, LL cnt);

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    REP(i,N)cin>>S[i];

    vector<int> count(5,0);
    REP(i,N){
        if(S[i][0]=='M'){count[0]++;}
        if(S[i][0]=='A'){count[1]++;}
        if(S[i][0]=='R'){count[2]++;}
        if(S[i][0]=='C'){count[3]++;}
        if(S[i][0]=='H'){count[4]++;}
    }

    LL ans = 0;
    int count_kind= 0;
    REP(i,5){
        if(count[i]>0)count_kind++;
    }
    if(count_kind < 3){
        cout << ans << endl;
        return 0;
    }

    vector<LL> target_count(count_kind,0LL);
    int l=0;
    REP(i,5){
        if(count[i]>0){
            target_count[l]=count[i];
            l++;
        }
    }


    for(int i=0; i<count_kind; i++){
        for(int j=i+1; j<count_kind; j++){
            for(int k=j+1; k<count_kind; k++){
                ans += target_count[i]*target_count[j]*target_count[k];
            }
        }
    }

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

LL comb(LL val, LL cnt){
    LL ans = 1;
    for(int j=1; j<=cnt; j++){
        ans *= val - (j-1);
        ans /= j;
    }
    return ans;
}

Measured memory_bytes: 6320
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    val aList = readLine()!!.split(' ').map(String::toLong).sortedDescending()
    val sum = aList.sum()

    if (aList[m - 1].toDouble() >= sum.toDouble() / (4.toDouble() * m.toDouble())) {
        println("Yes")
    } else {
        println("No")
    }
}


Measured memory_bytes: 38048
#include <iostream>
using namespace std;
int main(){
	while(1){
		int n,x;
		int c=0;
		cin>>n>>x;
		if(n==0 && x==0){
			break;
		}else{
			for(int i=1;i<=n-2;i++){
				for(int j=i+1;j<=n-1;j++){
					for(int k=j+1;k<=n;k++){
						if(i+j+k==x){
							c++;
						}
					}
				}
			}
		}
		cout<<c<<endl;
	}
	return 0;
}

Measured memory_bytes: 3012
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double t = sc.nextDouble();
        double a = sc.nextDouble();
        double[] h = new double[n];
        double[] tem = new double[n];
        int ans = 0;
        double min = 9999;
        double sabun = 0;

        for(int i = 0;i<n;i++){
            h[i] = sc.nextDouble();
            tem[i] = t-h[i]*0.006;
            sabun = Math.abs(a-tem[i]);
            if(min>sabun){
                min= sabun;
                ans = i+1;
            }
        }
        System.out.println(ans);




        
    }
}


Measured memory_bytes: 26452
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
typedef long long ll;

const int N = 1e5 + 5;

inline ll read() {
    ll res = 0;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar());
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res;
}

namespace KMP
{
const int MAXN = 10 + 5;;
const int MAXM = 10 + 5;

int next[MAXN]; char tar[MAXN], par[MAXN];

int n, m;
inline int KMP() {
	memset(next, 0, sizeof(next));

    // KMP Losing Func, pi
	n = strlen(tar + 1), m = strlen(par + 1);
    for (int i = 2; i <= m; i++) {
        int k = next[i - 1];
        while (k && par[k + 1] != par[i]) k = next[k];
        if (par[k + 1] == par[i]) next[i] = k + 1;
        else next[i] = 0;
    }

	int q = 0, ans = 0;
	for (int i = 1; i <= n; i++) {
		while (q > 0 && par[q + 1] != tar[i]) q = next[q];
		if (par[q + 1] == tar[i]) q++;
		if (q == m) {
            ans++, q = 0;
        }
	}

    return ans;
}

void solve() {
    scanf("%s", par + 1);
    scanf("%s", tar + 1);
    printf("%d\n", KMP());
}
}

double n, m, x, y, ansx, ansy, max;
int cnt;

int main() {
    scanf("%lf %lf %lf %lf", &n, &m, &x, &y);
    ansx = std::min(x * m, (n - x) * m);
    ansy = std::min(y * n, (m - y) * n);
    max = std::max(ansx, ansy);
    if (max == ansx) {
        if (x != n / 2) cnt++;
        double tmp = ansx / n;
        if (tmp <= m / 2) cnt++;
    } else {
        if (y != m / 2) cnt++;
        double tmp = ansy / m;
        if (tmp <= n / 2) cnt++;
    }
    printf("%lf %d\n", n * m / 2, x == n / 2 && y == m / 2 ? 1 : 0);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
		int n; cin >> n;
		if(n==0)break;
		int mi=1e9; int ma=0;
		for(int i=0;i<n;i++){
			int a[5];
			int sum=0;
			for(int j=0;j<5;j++){
				cin >> a[j];
				sum+=a[j];
			}
			mi=min(mi,sum);
			ma=max(ma,sum);
		}
		cout << ma << " " << mi << endl;
	}
}


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

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

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int ans, n, m1, m2, m3, m4;
int a[N];
int cnt0[N];
int cnt1[N];

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

    for (int i = 0; i < n; i += 2) {
        int m = a[i];
        ++cnt0[m];
        if (m == m1) continue;
        if (cnt0[m] > cnt0[m1]) {
            m2 = m1;
            m1 = m;
        } else if (cnt0[m] > cnt0[m2]) {
            m2 = m;
        }
    }
    for (int i = 1; i < n; i += 2) {
        int m = a[i];
        ++cnt1[m];
        if (m == m3) continue;
        if (cnt1[m] > cnt1[m3]) {
            m4 = m3;
            m3 = m;
        } else if (cnt1[m] > cnt1[m4]) {
            m4 = m;
        }
    }
    if (m2 == m1) m2 = 0;
    if (m4 == m3) m4 = 0;
    if (m1 != m3) {
        ans = n - cnt0[m1] - cnt1[m3];
    } else {
        ans = min(n - cnt0[m1] - cnt1[m4],
                  n - cnt0[m2] - cnt1[m3]);
    }
    cout << ans << endl;
    return 0;
}


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

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define FOR(i,l,r) for(long long i=l; i<r; i++)
#define FOR_REV(i,r,l) for(long long i=r; i>=l; i--)
#define pb push_back
#define mp make_pair

bool check_pall (string s, int l, int r)
{
    while (l<r)
    {
        if (s[l] != s[r])
        {
            return false;
        }
        l++;
        r--;
    }
    return true;
}

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

    int len = s.length();

    if (check_pall(s,0,len-1) && check_pall(s,0,(len/2)-1) && check_pall(s,((len+3)/2)-1, len-1))
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


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


int main() {
 int n;
 cin>>n;
 vector<int> vec(n) ;
 for (int i = 0; i < n; i++)
 {
   cin>>vec[i];
 }
 vector<int> ren(n);
 for (int i = 0; i < n; i++)
 {
   /* code */
   ren[vec[i]-1]=i+1;
 }
 for (int i = 0; i < n; i++)
 {
   cout << ren[i] <<endl;
 }
}


Measured memory_bytes: 3988
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
#define ll long long
//#define d double
#define F first
#define S second
#define FastIO ios_base::sync_with_stdio(false),cin.tie(0)
#define fix std::fixed<<setprecision(10)
#define M 100000007
#define f(n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define vi vector<int>
#define pb push_back
#define si set<int>
#define cl(n,m) (ceil(double(n)/double(m)))
#define T() int t; cin>>t; while(t--)

int main()
{
    string s,t;
    cin>>s>>t;
    unsigned ll int count=0,end=-1;

    set<char>se;

    for(int i=0;i<s.length();i++)
        se.insert(s[i]);

    for(int i=0;i<t.length();i++)
        if(se.find(t[i])==se.end())
    {
        cout<<-1;
        return 0;
    }

    vector<vector<ll>>alpha=vector<vector<ll>>(26,vector<ll>());
    for(int i=0;i<s.length();i++)
        alpha[s[i]-'a'].pb(i);

   int i=0,index=-1;
   while(i<t.length())
   {

       char c=t[i];
       auto it=lower_bound(alpha[c-'a'].begin(),alpha[c-'a'].end(),index);

       if(it!=alpha[c-'a'].end())
       {
           index=*it+1;
       }
       else
       {
           count++;
           index=alpha[c-'a'][0]+1;
       }
       i++;
   }

unsigned ll int ans=(count)*(s.length())+index;
    cout<<ans;
}


Measured memory_bytes: 1724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    vector< vector<ll> > d(2, vector<ll>(s.size() + 1));
    d.at(0).at(0) = 1;
    for (ll i = 0; i < ll(s.size()); ++i) {
        if (s.at(i) - '0') d.at(0).at(i + 1) += d.at(0).at(i) * 2, d.at(1).at(i + 1) += d.at(0).at(i);
        else d.at(0).at(i + 1) += d.at(0).at(i);
        d.at(0).at(i + 1) %= MOD;
        (d.at(1).at(i + 1) += d.at(1).at(i) * 3) %= MOD;
    }
    cout << (d.at(0).back() + d.at(1).back()) % MOD << '\n';
    return 0;
}


Measured memory_bytes: 2896
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rrep(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll a, b; cin >> a >> b;
  cout << a* b;

  return 0;
}

Measured memory_bytes: 3648
s=list(input())
n=len(s)

ans=[0]*n
count=0

for i in range(n):
    if s[i]=='L':
        if count%2==0:
            ans[i]+=count//2
            ans[i-1]+=count//2
            count=0
            continue
        else:
            ans[i]+=count//2
            ans[i-1]+=count//2+1
            count=0
            continue
    count+=1
    
for i in range(n-1,-1,-1):
    if s[i]=='R':
        if count%2==0:
            ans[i]+=count//2
            ans[i+1]+=count//2
            count=0
            continue
        else:
            ans[i]+=count//2
            ans[i+1]+=count//2+1
            count=0
            continue
    count+=1
print(" ".join(map(str,ans)))

Measured memory_bytes: 11176
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct {
  int num[100];
}Record;

Record push(int);
int size = 0;

int main () {
  char c[100];
  Record data;
  int i, j = 0, sum = 0, x = 1;
  
  while(scanf("%s",c) != EOF) {
    sum = 0;
    x = 1;
    
    if(c[0] == '+') {
      for(i = size - 2 ; i < size ; i++) sum+=data.num[i];
      for(j = i - 2 ; j < i ; j++) size--;
      data = push(sum);
    }
    
    else if(c[0] == '-') {
      i = size - 1;
      sum = data.num[size-2] - data.num[size-1];
      for(j = i - 2 ; j < i ; j++) size--;
      data = push(sum);
    }
    
    else if(c[0] == '*') {
      for(i = size - 2 ; i < size ; i++) x*=data.num[i];
      for(j = i - 2 ; j < i ; j++) size--;
      data = push(x);
    }
    else data = push(atoi(c));     
  }
  printf("%d\n",data.num[0]);
  return 0;
}

Record push(int n) {
  Record data;
  data.num[size] = n;
  size++;

  return data;
}



Measured memory_bytes: 2108
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
	int N = scan.nextInt();
	int num = 0;
	int ans = 0;

	if (N % 1000 == 0) {
		System.out.println(0);
	}else {
		System.out.println(1000 - N % 1000);
	}

	}
}

Measured memory_bytes: 35732
#include<iostream>
#include<algorithm>
#define INF 1<<28
using namespace std;
 
int memo[10000];
 
int solve(int n){

  if(!n) return 0;
  if(n < 0) return INF;
  if(memo[n]) return memo[n];

  return memo[n] = min(INF, min(solve(n-1000)+1520, min(solve(n-1200)+1870, min(solve(n-1500)+2244, min(solve(n-200)+380, min(solve(n-300)+550, solve(n-500)+850))))));
}
 
int main(){
  int n;
  for(int i=0;i<5001;i+=100) solve(i);
  while(cin >> n, n) cout << memo[n] << endl;
}

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

namespace ABC113
{
    class B
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');

            int T = int.Parse(input[0]);
            double A = double.Parse(input[1]);

            double[] H = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();

            double min = double.MaxValue;
            double h = 0;
            int index = 0;
            double keisu = 0.006;
            for (int i = 0; i < N; i++)
            {
                h = T - H[i] * keisu;
                if (Math.Abs(A - h) < min)
                {
                    min = Math.Abs(A - h);
                    index = i + 1;
                }
            }
            Console.WriteLine(index);
        }
    }
}


Measured memory_bytes: 11280