akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<60;



int main() {
    int H, N;
    cin >> H >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; ++i) cin >> A[i] >> B[i];

    vector<vector<long long>> dp(N+1, vector<long long>(H+1, INF));
    dp[0][0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= H; ++j) {
            chmin(dp[i+1][j], dp[i][j]);
            chmin(dp[i+1][min(j+A[i], H)], dp[i+1][j] + B[i]);
        }
    }

    cout << dp[N][H] << endl;
}

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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;

vector<lli> G[100001];
lli d_a[100001];
bool done_a[100001];
void rec_a(lli cur, lli distance) {
    d_a[cur] = distance;
    done_a[cur] = true;
    distance++;

    REP(i, 0, G[cur].size()) {
        if (done_a[G[cur][i]])
            continue;
        rec_a(G[cur][i], distance);
    }
    return;
}
lli d_b[100001];
bool done_b[100001];
void rec_b(lli cur, lli distance) {
    d_b[cur] = distance;
    done_b[cur] = true;
    distance++;

    REP(i, 0, G[cur].size()) {
        if (done_b[G[cur][i]])
            continue;
        rec_b(G[cur][i], distance);
    }
    return;
}

int main() {
    lli n;
    cin1(n);
    REP(i, 0, n-1) {
        lli a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    rec_a(1, 0);
    rec_b(n, 0);

    lli a_cnt = 0;
    lli b_cnt = 0;
    lli same_cnt = 0;
    REPE(i, 1, n) {
        if (d_a[i] < d_b[i]) {
            a_cnt++;
        }
        else if (d_a[i] > d_b[i]) {
            b_cnt++;
        }
        else {
            same_cnt++;
        }
    }
    if (a_cnt + same_cnt > b_cnt)
        cout << "Fennec" << endl;
    else
        cout << "Snuke" << endl;


}


Measured memory_bytes: 12160
#include<iostream>
#include <string>
#include <vector>
#include <cmath>
#define ll long long

using namespace std;

int main(){
  ll N, Y, a=0, b=0, c, A, B;
  bool ng = true;
  cin >> N >> Y;

  A = Y / 10000;
  while (a <= A && ng) {
    b = 0;
    B = (Y - a*10000) / 5000;
    while (b <= B && ng) {
      c = (Y -a*10000 - b*5000) / 1000;
      if (a + b + c == N) {
        cout << a << " "<< b << " "<< c << endl;
        ng = false;
      }else{
        b++;
      }
    }
    a++;
  }

  if (ng) {
    cout << "-1 -1 -1" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
from numpy import *
I=input
N=int(I())
S=array(list('-'+I()))
Q=int(I())
query = map(int,I().split())
D=S=='D';M=S=='M';C=S=='C'
d=D.cumsum(dtype=int64);m=M.cumsum(dtype=int64)
for K in query:
  x=d.copy();x[K:]-=d[:-K];x*=M
  x[K+1:]-=D[1:-K]*(m[K:-1]-m[:-K-1])
  print(sum(cumsum(x)*C))

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

int main(){
  #define int long
  int N;cin>>N;
  vector<int>A(N);for(int i=0;i<N;i++)cin>>A[i];
  vector<int>X(N,-1);
  vector<int>cumsum(N,-1);
  cumsum[0]=A[0];cumsum[1]=A[1];
  for(int i=2;i<N;i++)cumsum[i]=cumsum[i-2]+A[i];
  int sum=0;
  for(int i=0;i<N;i++)sum+=A[i];
  
  for(int i=0;i<N;i++){
    //cout<<(cumsum[N+(i%2)-2]-cumsum[(i-1)%N])+cumsum[(i-2)%N]<<" "
    if(i==0)cout<<sum-cumsum[N-2]*2<<" ";
    else if(i==1)cout<<sum-(cumsum[N-1]-cumsum[0])*2<<" ";
    else cout<<sum-((cumsum[(N+(i%2)-2)%N]-cumsum[(i-1)%N])+cumsum[(i-2)%N])*2<<" ";
  }
}

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

typedef long long ll;

int main(){
	ll n, i, x;
	cin>>n>>x;
	ll a[n];
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	ll count=0;
	for(i=0;i<n;i++){
	//	cout<<x<<"\n";
		if(x>=a[i]){
			x-=a[i];
			count++;
		}else{
			break;
		}
	}
	if(x!=0 && count==n){
		if(count!=0)
		count--;
	}
	cout<<count;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  if(S.at(0)==S.at(1)&&S.at(2)==S.at(3)&&S.at(0)!=S.at(2)){
    cout<<"Yes"<<endl;
  }
  else if(S.at(0)==S.at(2)&&S.at(1)==S.at(3)&&S.at(0)!=S.at(1)){
    cout<<"Yes"<<endl;
  }
  else if(S.at(0)==S.at(3)&&S.at(2)==S.at(1)&&S.at(0)!=S.at(2)){
    cout<<"Yes"<<endl;
  }
  else  cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.nextLine();
    int n = str.length();
    int m = 0;
    int a = 0;
    HashSet<Integer> set = new HashSet<Integer>();
    for(int i=0;i<n;i++){
      m = str.codePointAt(i);
      set.add(m);
    }
    for(a=97;a<123;a++){
      if(set.contains(a)==false){
          System.out.println(Character.toChars(a));
          return;
      }
    }
    System.out.println("None");
  }
}

Measured memory_bytes: 26180
#include<stdio.h>

#define N 10000
#define NIL -1

struct Node{
  int parent,left,right;
};

struct Node T[N];
int n,Dep[N],Hei[N];

void Depth(int u,int d){
  
  if(u==NIL) return;
  
  Dep[u]=d;
  Depth(T[u].left,d+1);
  Depth(T[u].right,d+1);
}

int Height(int u){
  int h1=0,h2=0;

  if(T[u].left!=NIL) h1=Height(T[u].left)+1;
  if(T[u].right!=NIL) h2=Height(T[u].right)+1;

  if(h1>h2) return Hei[u]=h1;
  else return Hei[u]=h2;
}

int Sibling(int u){

  if(T[u].parent==NIL) return NIL;

  if(T[T[u].parent].left!=u && T[T[u].parent].left!=NIL){
    return T[T[u].parent].left;
  }

  if(T[T[u].parent].right!=u && T[T[u].parent].right!=NIL){
    return T[T[u].parent].right;
  }

  return NIL;
}

void print(int u){
  int count=0;
  
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",Sibling(u));

  if(T[u].left!=NIL) count++;
  if(T[u].right!=NIL) count++;

  printf("degree = %d, ",count);
  printf("depth = %d, ",Dep[u]);
  printf("height = %d, ",Hei[u]);

  if(T[u].parent==NIL) printf("root\n");
  else if(T[u].left==NIL && T[u].right==NIL) printf("leaf\n");
  else printf("internal node\n");
}

int main(){
  int i,v,l,r,root=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].parent=NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);

    T[v].left=l;
    T[v].right=r;

    if(l!=NIL) T[l].parent=v;
    if(r!=NIL) T[r].parent=v;
  }

  for(i=0;i<n;i++){
    if(T[i].parent==NIL) root=i;
  }

  Depth(root,0);
  Height(root);

  for(i=0;i<n;i++){
    print(i);
  }

  return 0;
}


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

int main()
{
    vector<int> v(3);
    rep(i, 3)cin >> v[i];
    sort(v.begin(), v.end());
    if (v[0] == v[1] && v[1] != v[2]) {
        cout << "Yes" << endl;
    }
    else if (v[0] != v[1] && v[1] == v[2]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;

using ll = long long;
using vl = vector<ll>;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    ll n;
    cin >> n;
    vl p(n);
    unordered_map<ll, ll> mp;
    set<ll> s;
    rep(i, n) {
        cin >> p[i];
        mp[p[i]] = i;
        s.insert(p[i]);
    }

    set<ll> idx;
    ll ans = 0;
    while (!s.empty()) {
        ll now = *s.rbegin();
        s.erase(now);

        ll i = mp[now];
        vl l(2, -1), r(2, n);
        {
            auto itr = idx.lower_bound(i);
            rep(j, 2) { // r
                if (itr == idx.end()) break;
                r[j] = *itr;
                itr++;
            }
        }
        {
            auto itr = idx.lower_bound(i);
            rep(j, 2) { // l
                if (itr == idx.begin()) break;
                itr--;
                l[j] = *itr;
            }
        }

        ll l1 = i - l[0], l2 = l[0] - l[1];
        ll r1 = r[0] - i, r2 = r[1] - r[0];
        ans += (l1 * r2 + l2 * r1) * now;

        idx.insert(i);
    }
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 9764
#include <bits/stdc++.h>
using namespace std;
void fast()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
}
int main()
{
    fast();
    long long k ;
    cin >> k ;
    long long n = 100 ;
    int p = 0;
    while(n<k)
    {
        n=(1.0/100)*n +n ;
        p++;
    }
    cout << p;






}


Measured memory_bytes: 3652
from itertools import permutations
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
l=list(permutations([i for i in range(1,n+1)]))
a=0
b=0
for i in range(len(l)):
  if list(l[i])==p:
    a=i
  if list(l[i])==q:
    b=i
print(abs(a-b))

Measured memory_bytes: 8052
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto x = aryread();
    foreach (i; 0 .. 3)
    {
        if (x[i] % 2 == 0)
        {
            writeln(0);
            return;
        }
    }
    x.sort();
    writeln(x[0] * x[1]);

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3656
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct S {//辺の情報を入れる変数
	int from, to, cost;
};
struct H {
	int x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(ld a, ld b, ld c, ld d) {
	return sqrt(pow(a - c, 2) + pow(b - d, 2));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	string s;
	cin >> s;
	for (int i = 1; i < s.size(); i++) {
		if (s[i - 1] == 'A'&&s[i] == 'C') {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	getchar(); getchar();
}

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

ans=0
for i in range(1000):
  t=str(i)
  u="0"*(3-len(t))+t
  j=0
  p=u[0]
  for x in s:
    if x==p:
      j+=1
      if j==3:
        ans+=1
        break
      p=u[j]
    
print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <stdio.h>

int main(){
	int a, b, c;
	std::cin >> a >> b;
	if(b%a==0) c = a+b;
	else c = b-a;
	std::cout << c << std::endl;
	return 0;
}


Measured memory_bytes: 256
// 2011/01/07 Tazoe

#include <iostream>
using namespace std;

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

	int fre[7];
	for(int i=1; i<=6; i++)
		fre[i] = 0;

	for(int i=0; i<n; i++){
		double hei;
		cin >> hei;

		if(hei<165.0)
			fre[1]++;
		else if(hei<170.0)
			fre[2]++;
		else if(hei<175.0)
			fre[3]++;
		else if(hei<180.0)
			fre[4]++;
		else if(hei<185.0)
			fre[5]++;
		else
			fre[6]++;
	}

	for(int i=1; i<=6; i++){
		cout << i << ':';
		for(int j=0; j<fre[i]; j++)
			cout << '*';
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
#define IINF 9999999999999;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int n;
vector<int> d;

int main() {
    int N;
    cin >> N;
    int a[N];
    rep(i, N) {
        cin >> a[i];
    }
    int ans = 0;
    rep(i, N) {
        rep(j, N) {
            int temp = abs(a[i] - a[j]);
            ans = max(ans, temp);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHEEM
                                      //ALLAH IS WATCHING ME

//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█


#include<bits/stdc++.h>

#define ull    unsigned long long
#define ll   long long
#define ses   "\n"

using namespace std;

//main function is here.... ....
int main(){
ll a,b,c;
cin>>a>>b>>c;
if(a+b+c>=22){
    cout<<"bust";
}
else{
    cout<<"win";
}
}

//Alhamdulillah


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

using namespace std;

const int N = 4e5 + 10;
const int M = 2e3 + 10;
const int Mod = 1e9 + 7;

int n, a[N], b[N], cnt[N];
int fac[N], inv[N], f[M << 1][M << 1];

int add(int a, int b) {
  return (a += b) >= Mod ? a - Mod : a;
}

int sub(int a, int b) {
  return (a -= b) < 0 ? a + Mod : a;
}

int mul(int a, int b) {
  return 1ll * a * b % Mod;
}

int fast_pow(int a, int b) {
  int res = 1;
  for (; b; b >>= 1, a = mul(a, a)) {
    if (b & 1) {
      res = mul(res, a);
    }
  }
  return res;
}

int C(int a, int b) {
  return mul(fac[a], mul(inv[b], inv[a - b]));
}

void init(int n) {
  fac[0] = inv[0] = 1;
  for (int i = 1; i <= n; i++) {
    fac[i] = mul(fac[i - 1], i);
  }
  inv[n] = fast_pow(fac[n], Mod - 2);
  for (int i = n - 1; i >= 1; i--) {
    inv[i] = mul(inv[i + 1], i + 1);
  }
}

int main() {
  init(N - 1);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &a[i], &b[i]);
    f[M - a[i]][M - b[i]]++;
  }
  for (int i = 1; i < M * 2; i++) {
    for (int j = 1; j < M * 2; j++) {
      f[i][j] = add(f[i][j], add(f[i - 1][j], f[i][j - 1]));
    }
  }
  int res = 0;
  for (int i = 1; i <= n; i++) {
    res = add(res, f[M + a[i]][M + b[i]]);
    res = sub(res, C((a[i] + b[i]) * 2, a[i] * 2));
  }
  printf("%d\n", mul(res, fast_pow(2, Mod - 2)));
  return 0;
}

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

int abs(int a) { // aの絶対値
    return a > -a ? a : -a ;
}

int gcd(int a, int b) { // aとbの最大公約数
    return b == 0 ? a : gcd(b, a%b) ;
}

int main() {

    int N, X;

    cin >> N >> X;

    vector<int> x(N);

    for(int i = 0; i < N ; ++i )cin >> x[i];

    int D = abs(x[0] - X);

    for(int i = 1; i < N ; ++i )D = gcd(D, abs(x[i] - X));

    cout << D << endl;

    return 0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Graph;
const int M = 1e9 + 7;
const ll INF = 1e9;
const int MAX_V = 100000 + 5;
const int MAX_N = 1e5 + 5;

int main() {
    ll n, m, v, p;
    cin >> n >> m >> v >> p;
    vector<ll> a(n);
    vector<ll> cusum(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    ll sum = 0;
    rep(i, n) {
        sum += a[i];
        cusum[i] = sum;
    }
    ll ans = 0;
    ll border = a[p - 1];
    rep(i, n) {
        if (i < p) {
            ans++;
        } else if (a[i] + m < border) {
            continue;
        } else {
            ll idx = i + 1;
            ll key_area = n - idx + p;
            if (v <= key_area) {
                ans++;
            } else {
                ll distr = m * (v - key_area);
                ll max = a[i] + m;
                ll p_sum = cusum[i - 1] - cusum[p - 2];
                if (max * (i - p + 1) - p_sum >= distr)
                    ans++;
            }
        }
    }
    out(ans);
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

const int MAX = 3e5+10;

int N, A[MAX];
ll s[MAX];

ll sub(int k) {
    ll ok = 0, ng = MAX;
    while (ng - ok > 1) {
        ll mid = (ng + ok) / 2;
        if (s[mid]/mid >= k) ok = mid;
        else ng = mid;
    }
    return ok;
}

vi solve() {
    map<ll, ll> m;
    REP (i, N) m[A[i]]++;
    vi cnt;
    for (auto iter = m.begin(); iter != m.end(); iter++) {
        cnt.push_back(iter->second);
    }
    sort(ALL(cnt));
    s[1] = cnt.size();
    FOR (i, 2, N+1) {
        s[i] = s[i-1] + (cnt.end() - lower_bound(ALL(cnt), i));
    }

    vi ans;
    FOR (i, 1, N+1) ans.push_back(sub(i));
    return ans;
}

int main() {
    cin >> N;
    REP (i, N) cin >> A[i];
    FORE (x, solve()) cout << x << endl;
}

Measured memory_bytes: 31212
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>
#include <cstdint>
#include <complex>

#define rep(i,n) for (int i = 0; i < (n); ++i)

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

const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 998244353;

const double pi = 3.1415926535897932384626433832795028841971;
vector<complex<double> > dft(vector<complex<double> > a) {
    int n = a.size();
    if (n == 1) return a;

    vector<complex<double> > a0(n/2);
    vector<complex<double> > a1(n/2);

    for (int i = 0; i < n/2; i++) a0[i] = a[i * 2];
    for (int i = 0; i < n/2; i++) a1[i] = a[i * 2 + 1];

    vector<complex<double> > dft_a0 = dft(a0);
    vector<complex<double> > dft_a1 = dft(a1);

    vector<complex<double> > dft_a(n);
    for (int i = 0; i < n; i++) {
        complex<double> zeta = complex<double>(cos(2 * pi * i / n), sin(2 * pi * i / n));
        dft_a[i] = dft_a0[i % (n/2)] + zeta * dft_a1[i % (n/2)];
    }

    return dft_a;
}

vector<complex<double> > idft(vector<complex<double> > dft_a) {
    int n = dft_a.size();
    vector<complex<double> > arranged = dft(dft_a);

    vector<complex<double> > swaped(n);
    for (int i = 0; i < n; i++) swaped[i] = arranged[(n-i) % n];

    vector<complex<double> > a(n);
    for (int i = 0; i < n; i++) a[i] = swaped[i] / complex<double>(n, 0);

    return a;
}

vector<complex<double> > conv(vector<complex<double> > a, vector<complex<double> > b) {
    int deg = a.size() + b.size();
    int n = 1;
    while (n < deg) n <<= 1;
    a.resize(n); b.resize(n);

    vector<complex<double> > dft_a = dft(a);
    vector<complex<double> > dft_b = dft(b);

    vector<complex<double> > dft_c(n);
    for (int i = 0; i < n; i++) {
        dft_c[i] = dft_a[i] * dft_b[i];
    }
    vector<complex<double> > c = idft(dft_c);

    return c;
}

int main() {
    ll n, m; cin >> n >> m;
    vector<int> a(n); rep(i, n) cin >> a[i];
    int amax = 0;
    rep(i, n) amax = max(amax, a[i]);
    map<int, ll> mp; rep(i, n) mp[a[i]] += 1;

    vector<complex<double>> x(amax+1), y(amax+1);
    rep(i, n) {
        x[a[i]] = mp[a[i]];
        y[a[i]] = mp[a[i]];
    }
    vector<complex<double>> z;
    z = conv(x, y);
    ll cnt = 0;
    ll ans = 0;
    for (int i = amax * 2; i > 0; i--) {
        ll z_count = ll(z[i].real() + 0.10);
        if (cnt + z_count < m) {
            cnt += z_count;
            ans += (ll)i * (ll)z_count;
        } else {
            ans += (ll)i * (ll)(m - cnt);
            break;
        }
    }
    cout << ans << endl;




    return 0;
}


    

Measured memory_bytes: 55096
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+3;
vector<int> g[N];
int used[N],cnt;
int main(){
	ios::sync_with_stdio(false);
  	cin.tie(0);cout.tie(0);
	string u,s1,s2;
  	int a,b;
  	cin>>s1>>s2;
  	cin>>a>>b;
  	cin>>u;
  	if(u==s1)cout<<a-1<<" "<<b;
  	else cout<<a<<" "<<b-1;
}

Measured memory_bytes: 256
encode = {"A"=>"00000","B"=>"00001","C"=>"00010","D"=>"00011","E"=>"00100","F"=>"00101","G"=>"00110","H"=>"00111","I"=>"01000",
  "J"=>"01001","K"=>"01010","L"=>"01011","M"=>"01100","N"=>"01101","O"=>"01110","P"=>"01111","Q"=>"10000",
  "R"=>"10001","S"=>"10010","T"=>"10011","U"=>"10100","V"=>"10101","W"=>"10110","X"=>"10111","Y"=>"11000",
  "Z"=>"11001"," "=>"11010","."=>"11011",","=>"11100","-"=>"11101","'"=>"11110","?"=>"11111"}
decode ={"101"=>" ","000000"=>"'","000011"=>",","10010001"=>"-","010001"=>".","000001"=>"?","100101"=>"A","10011010"=>"B",
  "0101"=>"C","0001"=>"D","110"=>"E","01001"=>"F","10011011"=>"G","010000"=>"H","0111"=>"I","10011000"=>"J",
  "0110"=>"K","00100"=>"L","10011001"=>"M","10011110"=>"N","00101"=>"O","111"=>"P","10011111"=>"Q","1000"=>"R","00110"=>"S","00111"=>"T",
  "10011100"=>"U","10011101"=>"V","000010"=>"W","10010010"=>"X","10010011"=>"Y","10010000"=>"Z"}
while line = gets
  if line.chomp==""
    puts ""
    next
  end
  input=line.chomp.split("")
  str =""
  input.each do |c|
    str+=encode[c]
  end
  str = str.split("")
  i=0
  j=7
  ans =""
  while i<str.size
    tmp = str[i..i+j].join("")
    if decode.include?(tmp)
      ans << decode[tmp]
      i+=j+1;
      j=7
    elsif tmp==""
      break
    else
      j-=1
    end
  end
  puts ans
end

Measured memory_bytes: 2776
using System;

class Program{
    static void CountingSort(int[] A, int[] B, int k){
        var C=new int[k+1];
        for(var j=0; j<A.Length; j++){
            C[A[j]]++;
        }
        /*
        var remain=B.Length-1;
        for(; k>=0; k--){
            while(C[k]>0){
                B[remain]=k;
                remain--;
                C[k]--;
            }
        }
        */
        for(var i=1; i<=k; i++){
            C[i]=C[i]+C[i-1];
        }
        for(var j=A.Length-1; j>=0; j--){
            B[C[A[j]]-1]=A[j];
            C[A[j]]--;
        }
    }

    public static void Main(){
        var n=int.Parse(Console.ReadLine());
        var s=Console.ReadLine().Split(' ');
        var A=new int[n];
        var k=-1;
        for(var i=0; i<n; i++){
            A[i]=int.Parse(s[i]);
            if(A[i]>k){
                k=A[i];
            }
        }

        var B=new int[n];
        CountingSort(A, B, k);

        var ss=new System.Text.StringBuilder();
        for(var i=0; i<B.Length; i++){
            ss.Append(B[i]);
            if(i<B.Length-1){
                ss.Append(" ");
            }
        }
        Console.WriteLine(ss);
    }
}

Measured memory_bytes: 230780
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<cmath>
#include<cctype>
#include<stack>
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = 1000 + 10;
int main()
{
	ios::sync_with_stdio(false);
	int a, b, c;
	while (cin >> a >> b >> c)
	{
		if (a == 5 && b == 5 && c == 7)
			cout << "YES" << endl;
		else if (a == 5 && b == 7 && c == 5)
			cout << "YES" << endl;
		else if (a == 7 && b == 5 && c == 5)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,k,v[51];
long long ans;
int main() {
    cin>>n>>k;
    for (int i=0; i<n; i++) cin>>v[i];
    for (int i=0; i<n; i++) {
        for (int j=i; j<=n; j++) {
            //u take all from [i,j)
            multiset<int> s;
            long long cur=0;
            int ops=n-(j-i);
            if (ops>k) continue;
            for (int l=0; l<n; l++) {
                if (l<i or l>=j) s.insert(v[l]);
            }
            for (int l=0; l<k-ops; l++) {
                if (*s.begin()<0) s.erase(s.begin());
            }
            for (auto &e: s) cur+=e;
            ans=max(ans,cur);
        }
    }
    cout<<ans<<'\n';
}

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

//省略形
#define rep(i,n) for(auto i=0; i<n ; ++i)
#define REP(i,a,b) for(auto i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//よく使う定数
const int INF = 1e9;
const int MOD = 1e9+7;
//逆元
const int INV = 1e9+5;

//UnionFindTree
struct union_find{
  vector<int> data;
  union_find(int size) : data(size , -1) { }

  void merge(int x , int y){
    x = root(x); y = root(y);
    if(x == y) return;
    if(data[y] < data[x]) swap(x , y);
    data[x] += data[y];
    data[y] = x;
    return; 
  }

  bool same(int x , int y){
    x = root(x) , y = root(y);
    return x == y;
  }

  int root(int x){
    return data[x] < 0 ? x : (data[x] = root(data[x]));
  }

  int size(int x){
    return -data[root(x)];
  }
};

//プロトタイプ宣言
void faster(void);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);
template <class T>
T modpow(T , T , T);
bool is_palindrome(string);

//メモ
//最大公約数:__gcd　|　最小公倍数:__lcm
//回文は反転させて一致すればよい


int main(){
  int n,cnt=0,p_cnt=0,q_cnt=0;
  cin >> n;
  vi a(n),p(n),q(n);
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];
  rep(i,n) a[i] = i+1;
  do {
    bool p_flag=true , q_flag=true;
    cnt++;
    rep(i,n){
      if(a[i]!=p[i]) p_flag = false;
      if(a[i]!=q[i]) q_flag = false;
    }
    if(p_flag) p_cnt = cnt;
    if(q_flag) q_cnt = cnt;
  }while(next_permutation(all(a)));
  cout << abs(p_cnt-q_cnt);
}























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//繰り返し自乗法
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//繰り返し自乗法(剰余)
template <class T>
T modpow(T x , T y , T mod){
  if(y == 0) return 1;
  if(y%2 == 1){
    ll temp = modpow(x,y-1,mod);
    return temp*x%mod;
  }
  else{
    ll temp = pow_mod(x,y/2,mod);
    return temp*temp%mod;
  }
}

bool is_palindrome(string s){
    string t(s.rbegin(),s.rend());
    return s == t;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define contests_de_diya_kar 0
#define PB push_back
#define MP make_pair
#define int long long
#define MOD ((long long) (1000*1000*1000 + 7))
#define inf (int) 2e15
#define exit(a, b) return cout << a, b;
#define eps (double)1e-8
#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define vi vector<int>
#define vb vector<bool>
#define all(v) v.begin(), v.end()
#define ll long long 
#define pii pair<int, int>
#define mii map<int, int> 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

signed main () {
	start_routine;
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif

	int a;
	int b;
	cin >> a >> b;

	if (a + b == 15) {
		cout << "+" << endl;
	}
	else if (a * b == 15) {
		cout << "*" << endl;
	}
	else cout << "x" << endl;
	end_routine;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
int main()
{
 long int x,y,i;

scanf("%ld",&x);
y=1;
while(y<x)
{
    if(y*2<=x)
    {
    y=y*2;
    }
    else{
        break;
    }
}
printf("%ld",y);
    return 0;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
    return x;

}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->left;
  }
    return x;
  
}

Node treeSearch(Node x, int k){
  if(x == NIL || k == x->key)
    return x;
  if(k < x->key)
    return treeSearch(x->left,k);
  else return treeSearch(x->right,k);

}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL)
    return treeMinimum(x->right);
  y = x->parent;
  while(y != NIL && x == y->right){
    x=y;
    y = y->parent;
    return y;
  }

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

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

 void inorder(Node u){
   if( u == NIL)return;
   inorder(u->left);
   printf(" %d",u->key);
   inorder(u->right);
 }
 void preorder(Node u){
  if( u == NIL )return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
 
}
 
 
 int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  
  return 0;
}



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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main(){
   string s;
   cin >> s;
   int n = s.size();
   s += 'G';
   string s2; 
   rep(i, 0, n){
       if(s[i]=='B'&&s[i+1]=='C'){
           i++;
           s2 += 'D';
       }else{
           s2 += s[i];
       }
   }
   ll cnta = 0;
   ll ans = 0;
   int m = s2.size();
   s2 += 'B';
   rep(i, 0, m){
       if(s2[i]=='A'){
           cnta++;
       }else if(s2[i]=='D'){
           ans += cnta;
       }else{
           cnta = 0;
       }
   }
   cout << ans << endl;
}

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

int main(){
    string s;
    cin >> s;
    ll cnt = 0;
    int Bcount = 0;
    rep(i,s.size()){
        if(s[i] == 'B')Bcount++;
        else cnt += Bcount;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<cassert>
using namespace std;
int ans[100];
int main(){
  while(1){
    long long n;
    cin>>n;
    if(n==0)break;
    for(int i=0;i<100;i++)ans[i]=0;
    for(int i=0;i<100;i++){
      int a=n%10;n/=10;
      if(i&&ans[i-1]==10){
	if(i%2==1)a++;
	else a--;
	ans[i-1]-=10;
      }
      if(i%2==1)a*=-1;
      if(a>=0)ans[i]+=a;
      else ans[i]+=(10+a),ans[i+1]++;
    }

    long long c=0;
    for(int i=99;i>=0;i--){
      c=c*10LL+(long long)ans[i];
      //cout<<ans[i]<<endl;
    }
    cout<<c<<endl;
  }
  return 0;
}

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

using namespace std;

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

    char c1 = S[0], c2 = S[1], c3 = S[2];

    if (c1 == c2) {
        if (c1 == c3) {
            cout << "No" << endl;
            return 0;
        } else {
            cout << "Yes" << endl;
            return 0;
        }
    } else {
        cout << "Yes" << endl;
        return 0;
    }


}

Measured memory_bytes: 3604
import java.io.*;
class Main{

    public static void main(String[] args)throws IOException{
	BufferedReader br =
	    new BufferedReader(new  InputStreamReader(System.in));
	String buf;
	double[][] data=new double[2][3];
	double x,y;
	while(true){
	    buf=br.readLine();
	    if(buf==null) break;
	    if(buf.length()==0)break;
	    String[] buf2=buf.split(" ");
	    for(int i=0;i<data.length;i++){
		for(int j=0;j<data[i].length;j++){
		    data[i][j]=Double.parseDouble(buf2[i*3+j]);
		}
	    }
	    double a,b,c,d;
	    a=(data[0][2] * data[1][1] - data[0][1] * data[1][2]);
	    b=(data[0][0] * data[1][1] - data[1][0] * data[0][1]);
	    c=(data[0][2] * data[1][0] - data[1][2] * data[0][0]);
	    d=(data[0][1] * data[1][0] - data[0][0] * data[1][1]);
	    x = a / b;
	    y = c / d;
	    if(x==-0)x=0;if(y==-0)y=0;
	    System.out.print(String.format("%.3f",x));
	    System.out.print(" ");
	    System.out.println(String.format("%.3f",y));
	}
    }
}

Measured memory_bytes: 11000
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=9999999999;


int main(){
    string s;
    cin>>s;
    int k;
    cin>>k;
    set<string> ss;
    int n=s.length();
    for(int i=0;i<n;i++){
        string buf;
        for(int l=0;l<5;l++){
            if(i+l>=n) break;
            buf+=s[i+l];
            ss.insert(buf);
        }
    }
    auto itr=ss.begin();
    for(int i=0;i<k-1;i++){
        itr++;
    }
    cout<<*itr<<endl;
}

Measured memory_bytes: 4812
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())

S = [input().rstrip() for _ in range(N)]
T = input().rstrip()

first = 1
last = 1
for s in S:
    if s.replace('?','z') < T:
        first += 1
    if s.replace('?','a') <= T:
        last += 1

print(' '.join(str(x) for x in range(first,last+1)))

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

#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))

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

int main(){
string A,B; cin>>A>>B;
if(A.size()<B.size()){
    cout<<"LESS"<<endl;
}else if(A.size()>B.size()){
    cout<<"GREATER"<<endl;
}else{
    for(int i=0;i<A.size();i++){
        if(A.at(i)>B.at(i)){
            cout<<"GREATER"<<endl;
            break;
        }
        if(A.at(i)<B.at(i)){
            cout<<"LESS"<<endl;
            break;
        }
        if(i==A.size()-1){
            cout<<"EQUAL"<<endl;
        }

    }
}

}
  

Measured memory_bytes: 3632
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
    double s,d,t;cin>>d>>t>>s;
    d/=s;
    if(d<=t)cout<<"Yes";
    else cout<<"No";
    cout<<"\n";
}
int main()
{
   fastio
   //Test_cases
   solve();
  return 0;
}
//**always check if you are not killing input in between
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//string2=string1.substr(pos,length);if len no specified then till end
//void fill (ForwardIterator first, ForwardIterator last, const T& val);
//The range filled is [first,last), which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.


//If wrong on pretest 2 means logically wrong
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,b[109],s=0;
    cin>>n;

    for(int i=0;i<n-1;i++)cin>>b[i];
s=b[0];
    for(int i=1;i<n-1;i++)
    {
        if(b[i]>b[i-1])s+=b[i-1];
        else s+=b[i];
    }
    s+=b[n-2];
    cout<<s<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;
signed main(){
    int h , m , h1 , m1 , k;
    cin >> h >> m >> h1 >> m1 >> k;
    int st = h * 60 + m;
    int en = h1 * 60 + m1;
    cout << en - st - 1 - (k-1);
    return 0;
}


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

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define all(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

using ll = long long;

int main() {
    bool ans = false;
    IN(int, n);
    REPS(i, 9){
        REPS(j, 9){
            if(i*j == n){
                ans = true;
            }
        }
    }
    Yes(ans);
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//		String W	 = in.readLine();
//		int num = Integer.parseInt(W.split(" ")[0]);

		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		long money = 100;
		long ans = 0;


		for(int i = 1; ; i++) {
			money*=1.01;
			if(money >=X) {
				ans = i;
				break;
			}
		}




		System.out.println(ans);


	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}



}


Measured memory_bytes: 35844
n,x=map(int,input().split())
y=list(map(int,input().split()))
y.append(x)
sorted(y)
a=y.index(x)
from fractions import gcd
from functools import reduce
def gcd_list(numbers):
    return reduce(gcd, numbers)
list=[]
for i in range(len(y)-1):
    list.append(abs(int(y[i])-int(y[i+1])))
print(gcd_list(list))


Measured memory_bytes: 14252
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int n, x, m;
vector<int> l, r, s;
vector<int> ret(1, -1);

void solve(vector<int>& a, int k)
{
    if(k == n){
        bool ok = true;
        for(int i=0; i<m; ++i){
            if(accumulate(a.begin()+l[i]-1, a.begin()+r[i], 0) != s[i])
                ok = false;
        }

        if(ok){
            if(accumulate(a.begin(), a.end(), 0) > accumulate(ret.begin(), ret.end(), 0))
                ret = a;
        }
        return;
    }

    for(a[k]=0; a[k]<=x; ++a[k]){
        solve(a, k+1);
    }
}

int main()
{
    cin >> n >> x >> m;
    l = r = s = vector<int>(m);
    for(int i=0; i<m; ++i)
        cin >> l[i] >> r[i] >> s[i];

    vector<int> a(n);
    solve(a, 0);

    if(ret[0] == -1){
        cout << -1 << endl;
    }else{
        cout << ret[0];
        for(int i=1; i<n; ++i)
            cout << ' ' << ret[i];
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1220
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
#include <vector>

using namespace std;

int main()
{
    int s, keta[4];
    cin >> s;
    keta[0] = s % 10;
    s /= 10;
    keta[1] = s % 10;
    s /= 10;
    keta[2] = s % 10;
    s /= 10;
    keta[3] = s % 10;
    if((keta[0] == keta[1]) || (keta[1] == keta[2]) || (keta[2] == keta[3]))
    {
        cout << "Bad" << endl;
    }
    else
    {
        cout << "Good" << endl;
    }
    
}

Measured memory_bytes: 256
n,m= map(int, input().split())
x= [list(map(int, input().split())) for i in range(m)]

for i in range(m):
    x[i].append(i)

# 県ごとに格納
v=[[] for i in range(n+1)]
# 答えを格納
ans=[0 for i in range(m)]

for i in range(m):
    v[x[i][0]].append(x[i])

for i in range(n+1):
    v[i].sort()
#print(v)
for i in range(n+1):
    for j in range(len(v[i])):
        # 上６桁
        l=str(0)*(6-len(str(i)))+str(i)
        ans[v[i][j][2]]=l+str(0)*(6-len(str(j+1)))+str(j+1)

for i in range(m):
    print(ans[i])

Measured memory_bytes: 91992
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;

int main(){
	int n; cin >> n; std::vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(rbegin(a), rend(a));
	
	long li[2] = {}, c = 0;
	for(int i = 0; i < n - 1; i++){
		if(a[i] == a[i + 1]){
			li[c] = a[i]; i++;
			c++;
		}
		
		if(c == 2) break;
	}
	
	cout << li[0] * li[1] << endl;
	return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	ios_base::sync_with_stdio(false);
	int n,k;
	cin >> n >> k;
	int dl = 0;
	while (n) {
		++dl;
		n /= k;
	}
	cout << dl << endl;
}

Measured memory_bytes: 256