akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, greater_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	fast_io;
	ll n, W;
	cin >> n >> W;
	ll w[101], v[101];
	for (int i = 1;i <= n;i++)
		cin >> w[i] >> v[i];
	ll dp[101][100001];
	for (int i = 0;i <= n;i++)
		for (int j = 0;j <= 100000;j++)
			dp[i][j] = W + 1;
	dp[0][0] = 0;
	for (int i = 1;i <= n;i++)
		for (int j = 0;j <= 100000;j++) {
			if (v[i] <= j)
				dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
			else
				dp[i][j] = dp[i - 1][j];
		}
	ll ans = 0;
	for (int i = 1;i <= 100000;i++)
		if (dp[n][i] <= W)
			ans = i;
	cout << ans << '\n';
}


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

int main(){
  char c;
  cin >> c;
  
  if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n;
    cin >> n;
    vi a(3 * n);
    cin >> a;
    vi f(3 * n), b(3 * n);

    int sum = 0;
    heap<int> pqf;
    REP(i, n) {
        pqf.push(a[i]);
        sum += a[i];
    }
    f[n - 1] = sum;
    REPF(i, n, 3 * n) {
        if (pqf.top() < a[i]) {
            sum -= pqf.top(); pqf.pop();
            sum += a[i]; pqf.push(a[i]);
        }
        f[i] = sum;
    }

    sum = 0;
    priority_queue<int> pqb;
    REP(i, n) {
        pqb.push(a[3 * n - 1 - i]);
        sum += a[3 * n - 1 - i];
    }
    b[2 * n] = sum;
    REPR(i, 2 * n - 1) {
        if (pqb.top() > a[i]) {
            sum -= pqb.top(); pqb.pop();
            sum += a[i]; pqb.push(a[i]);
        }
        b[i] = sum;
    }

    int ans = -INF;
    REPF(i, n, 2 * n + 1) {
        chmax(ans, f[i - 1] - b[i]);
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 9588
# -*- coding: utf-8 -*-
from itertools import product
def inpl(): return list(map(int, input().split()))

N, A, B, C = inpl()
L = [int(input()) for _ in range(N)]

ans = 1e9

def calc(Q, D):
    S = sum(Q)
    res = 10*(len(Q)-1) + abs(D-S)
    return res


for X in product(range(4), repeat=N):
    P = [[] for _ in range(4)]
    for i, x in enumerate(X):
        P[x].append(L[i])
    if min(map(len, P[1:])) == 0:
        continue
    tmp = 0
    for Q, D in zip(P[1:], [A, B, C]):
        tmp += calc(Q, D)
    if tmp < ans:
        ans = min(tmp, ans)

print(ans)

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

int main(){
    int n,m,k;
    k=0;
    cin >> n >> m ;
    vector <int> s(m),c(m);
    string newans="";
    
    rep(i,m){
        cin >> s[i] >> c[i];
    }

    vector <int> ans(n+1,-1);

    rep(i,m){
        
        if (ans[s[i]]!=-1 and ans[s[i]]!=c[i]){
            k=1;
            break;
        }
        else{
            ans[s[i]]=c[i];
        }
    }

    
    if (ans[1]==0 and n!=1){
        k=2;
    }
    if (ans[1]==-1 and n!=1){
        ans[1]=1;
    }
    if (k==0){
        rep(i,n){
            if (ans[i+1]==-1){
                ans[i+1]=0;
            }
            
            newans=newans+to_string(ans[i+1]);
        }
        cout << newans << endl;
    }
    else{
        cout << -1 << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
import math
N, K = map(int,input().split())
if (2*N)*(K+ K+2*N-1) > N*(K+2*N + K+3*N-1):
    print(-1)
    exit()
flag = [1]*(2*N)
for i in range(math.floor(N/2),N):
    a = K + i
    b = K + 2*N -1 -(i-math.floor(N/2))*2
    c = K + 3*N -1 -(i-math.floor(N/2))
    print(a,b,c)
for i in range(math.floor(N/2)):
    a = K + i
    b = K + 2*N -2 -i*2
    c = K + 3*N -1 -i-math.ceil(N/2)
    print(a,b,c)


Measured memory_bytes: 6844
#include <bits/stdc++.h>
using namespace std;
const int maxn = 10000 + 10;
string s[4];
bool no[4][maxn];
bool judge(char a, char b) {
	return !(a == b || a == '?' || b == '?');
}
int main() {
	int ans = 0;
	for (int i = 1; i <= 3; i++) {
		cin >> s[i];
		ans += s[i].size();
	}
	for (int p = 0; p < 6; p++) {
		// for (int i = 1; i <= 3; i++) {
		// 	cout << s[i] << '\n';
		// }
		memset(no, 0, sizeof(no));
		for (int i = 0; i < (int)s[2].size(); i++) {
			for (int j = i; j < (int)s[1].size(); j++) {
				no[1][j - i] |= judge(s[2][i], s[1][j]);
			}
		}
		for (int i = 0; i < (int)s[3].size(); i++) {
			for (int j = i; j < (int)s[2].size(); j++) {
				no[2][j - i] |= judge(s[3][i], s[2][j]);
			}
		}
		for (int i = 0; i < (int)s[3].size(); i++) {
			for (int j = i; j < (int)s[1].size(); j++) {
				no[3][j - i] |= judge(s[3][i], s[1][j]);
			}
		}
		// for (int i = 1; i <= 3; i++) {
		// 	for (int j = 0; j < 7; j++) {
		// 		cout << no[i][j] << ' ';
		// 	} cout << '\n';
		// }
		for (int i = 0; i <= 2000; i++) {
			for (int j = 0; j <= 2000; j++) {
				if ((!no[1][i]) && (!no[2][j]) && (!no[3][i + j])) {
					int len = max(max((int)s[1].size(), i + (int)s[2].size()), i + j + (int)s[3].size());
					ans = min(ans, len);
				}
			}
		}
		next_permutation(s + 1, s + 1 + 3);
	}
	printf("%d\n", ans);
	getchar(); getchar();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

#include <vector>

#include <algorithm>

using std::cin;
using std::cout;
using std::endl;

using std::vector;

using std::sort;

static int
solve(int N, int x, vector<int> &a)
{
  sort(a.begin(), a.end());
  int ret = 0;
  for (int n = 0; n < N && a[n] <= x; n++)
  {
    if (n == N - 1)
    {
      if (x == a[n])
      {
        ret++;
      }
    }
    else
    {
      x -= a[n];
      ret++;
    }
  }
  return ret;
}

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


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

int main()
{
    int n,x;
    cin >> n;
    int ctr = 0;
    for(int i = 1; i <= n; i++)
    {
        cin >> x;
        while(x % 2 == 0)
        {
            x /= 2;
            ctr++;
        }
    }
    cout << ctr << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline int readint() {
	int f=1,x=0; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch<='9'&&ch>='0') x=x*10+ch-'0',ch=getchar();
    return f*x;
}
inline ll readll() {
	ll f=1,x=0; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch<='9'&&ch>='0') x=x*10+ch-'0',ch=getchar();
    return f*x;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
ll n,u,v;
int main(){
	cin>>n;
	ll ans=n*(n+1)*(n+2)/6;
	for(int i=1;i<n;i++){
		cin>>u>>v;
		if(u>v)swap(u,v);
		ans-=u*(n-v+1);
	}
	cout<<ans<<endl;
}
/* stuff to remember
	* int overflow, array bounds
	* special cases (n=1? n=0?)
	* do something instead of nothing and stay organized
	* USE STATIC ARRAYS
	* DEFINING ARRAYS BEFORE main()
	* DO NOT DEFINE ARRAYS IN main()
	* USE INT INSTEAD OF LL,NOTICE THE MLE
*/

Measured memory_bytes: 3732
import java.util.*

data class Edge<T: Comparable<T>>(val from: Int, val to: Int, val weight: T): Comparable<Edge<T>> {
    constructor(from: Long, to: Long, weight: T) : this(from.toInt(), to.toInt(), weight)

    override fun compareTo(other: Edge<T>) = weight.compareTo(other.weight)
}

class Graph<T: Comparable<T>>(val n: Int, val zero: T, val inf: T, val plus: (T, T) -> T) {
    val edges = Array(n) { ArrayList<Edge<T>>() }
}

fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map {it.toInt()}
    val g = Graph(N + 1, 0L, (1e15).toLong()) { a, b -> a + b }

    for (i in 1 .. M) {
        val (A, B) = readLine()!!.split(" ").map { it.toInt() }
        g.edges[A].add(Edge(A, B, 0L))
        g.edges[B].add(Edge(B, A, 0L))
    }

    val vst = Array(N + 1) { false }
    val res = ArrayList<Int>()

    res.add(1)
    vst[1] = true

    fun f() {
        do {
            var updated = false
            for (e in g.edges[res.last()]) {
                if (!vst[e.to]) {
                    vst[e.to] = true
                    res.add(e.to)
                    updated = true
                    break
                }
            }
        } while(updated)
    }

    f()
    res.reverse()
    f()

    println(res.size)
    println(res.joinToString(" "))
}


Measured memory_bytes: 96404
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    ll n;
    cin >> n;
    ll ans = n-1;
    for (ll i = 2; i * i <= n; i++)
    {
        if(n % i == 0){
            ll tmp = i-1;
            tmp += n / i - 1;
            ans = min(ans, tmp);
        }
    }
    cout << ans << endl;
}


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

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod =  998244353;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976
const double PI = 3.1415926535897932;

int main()
{
    int k; cin >> k;
    string s; cin >> s;
    int n = s.size();
    if(n <= k) cout << s << endl;
    else{
        rep(i,k)cout << s[i];
        cout << "...";
    }
}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
using namespace std;

long long calc(long long A, long long B) {
    long long score = A * B;
    long long pow_val = floor(sqrt(score));
    long long ans = 0;
    if (pow_val * pow_val == score) {
        --pow_val;
    }
    long long tmp = pow_val * (pow_val + 1);
    if (tmp < score) {
        ans = pow_val * 2;
    } else {
        ans = (pow_val * 2) - 1;
    }
    if (A <= pow_val) {
        --ans;
    }
    if (B <= pow_val) {
        --ans;
    }
    return ans;
}

int main()
{
    int Q;
    cin >> Q;
    long long ans[Q];
    for (int i = 0; i < Q; ++i) {
        long long A, B;
        cin >> A >> B;
        ans[i] = calc(A, B);
    }
    for (int i = 0; i < Q; ++i) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s; cin >> s;
  ll ans = 0; ll  a = 0;
  for(int i = 0; i < s.size(); i++) {
    if(s[i] == 'A') a ++;
    if(i >= 1) {
        if(s[i - 1] == 'B' && s[i] == 'C') {
           ans += a;
        }
    if((s[i - 1] == 'A' && s[i] == 'C') || (s[i - 1] == 'B' && s[i] == 'B') || (s[i - 1] == 'C' && s[i] == 'C')) {
        a = 0;
    }
    if((s[i - 1] == 'B' && s[i] == 'A')) {
        a = 1LL;
    }
    }
    if(i == 0 && s[i] != 'A') a = 0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 1000005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
    if(c == '-') f = -1;
    c = getchar();
    }
    while(c >= '0' && c <= '9') {
    res = res * 10 + c - '0';
    c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    out(x / 10);
    }
    putchar('0' + x % 10);
}

char s[200005];
int64 ans = 0;
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    scanf("%s",s + 1);
    int64 t = 0;
    int N = strlen(s + 1);
    for(int i = N ; i >= 1 ; --i) {
        if(s[i] == 'W') ++t;
        else ans += t;
    }
    out(ans);enter;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int n;
    cin>>n;
    vector<long long> v1(n);
    vector<long long> v2(n);
    for(int i=0;i<n;i++){
        cin>>v1[i];

    }
    v2[0]=v1[0];
    for(int i=1;i<n;i++){
        v2[i]=v2[i-1]+v1[i];
        v2[i]%=mod;
    }
    long long ans=0;
    for(int i=1;i<n;i++){
        ans+=v2[i-1]*v1[i];
        ans%=mod;
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 6316
N, M = map(int, input().split())


def combination(n, r):
    r = min(r, n - r)
    result = 1
    for i in range(n - r + 1, n + 1):
        result *= i
    for i in range(1, r + 1):
        result //= i
    return result


def factorize(x):
    i = 2
    result = {}
    while True:
        if i**2 > x:
            break
        count = 0
        while x % i == 0:
            x //= i
            count += 1
        if count != 0:
            result[i] = count
        i += 1
    if x > 1:
        result[x] = 1
    return result


ans = 1
mod = 10**9 + 7
result = factorize(M)
for e in result.values():
    comb = combination(e + N - 1, e) % mod
    ans = ans * comb % mod

print(ans)


Measured memory_bytes: 3064
H, W, K = map(int, input().split())
MOD = 10**9 + 7

if W == 1:
    print(1)
    exit()

dp = [[0 for w in range(W)] for h in range(H + 1)]
dp[0][0] = 1


for h in range(H):
    for i in range(2 ** (W-1)):
        if '11' in bin(i):
            continue
        for w in range(W):  # このループが一番のポイント
            if w == 0:
                if (i >> w) & 1:
                    dp[h+1][w] += dp[h][w+1]
                else:
                    dp[h+1][w] += dp[h][w]
            elif 1 <= w < W-1:
                if (i >> (w-1)) & 1:
                    dp[h+1][w] += dp[h][w-1]
                elif (i >> w) & 1:
                    dp[h+1][w] += dp[h][w+1]
                else:
                    dp[h+1][w] += dp[h][w]
            else:
                if (i >> (w-1)) & 1:
                    dp[h+1][w] += dp[h][w-1]
                else:
                    dp[h+1][w] += dp[h][w]
            dp[h+1][w] %= MOD

# print(*dp, sep='\n')

print(dp[H][K-1])


Measured memory_bytes: 42608
class Point {
  constructor(x, y) {
    this.x = x;
    this.y = y;
  }

  print() {
    console.log(this.x.toFixed(8) + ' ' + this.y.toFixed(8));
  }
}

(function main(){
  const n = Number(require('fs').readFileSync('/dev/stdin', 'utf8').trim());
  let p1 = new Point(0, 0);
  let p2 = new Point(100, 0);
  p1.print();
  kock(n, p1, p2);
  p2.print();
})();

function kock(n, p1, p2) {
  const sin60 = Math.sin(60 * Math.PI / 180);
  const cos60 = Math.cos(60 * Math.PI / 180);
  function innerFunc(n, p1, p2) {
    if (!n) return;
    xDiff = p2.x - p1.x;
    yDiff = p2.y - p1.y;
    let s = new Point(p1.x + xDiff / 3, p1.y + yDiff / 3);
    let t = new Point(s.x + xDiff / 3, s.y + yDiff / 3);
    let u = new Point((t.x - s.x) * cos60 - (t.y - s.y) * sin60 + s.x, (t.x - s.x) * sin60 + (t.y - s.y) * cos60 + s.y);
    kock(n-1, p1, s); s.print();
    kock(n-1, s, u);  u.print();
    kock(n-1, u, t);  t.print();
    kock(n-1, t, p2);
  }
  kock = innerFunc;
  innerFunc(n, p1, p2);
}



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

int main() {
    int N, K; 
    cin >> N >> K; 
    int a[314159]; 
  for (int i = 0; i < N; ++i){
  int n;
  cin >> n; a[n]++; 
  }
  sort(a, a + N, greater<int>());
  int S = 0; 
  for (int i = 0; i < K; ++i){
  S += a[i]; 
  }
    cout << N - S << endl; 
}

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef string str;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

ll gcd(const ll a, const ll b) {
    if(b > a) return gcd(b, a);
    else if(b == 1) return 1;
    else if(b == 0) return a;
    else return gcd(b, a % b);
}

map<ll, int> trial_division(ll n) {
    map<ll, int> res;
    // 2の場合のみ先行して処理 (次以降の更新効率を上げるため)
    while(n % 2 == 0) {
        res[2]++;
        n /= 2;
    }

    // 以降, 奇数のみ試し割りを行う
    for(ll f = 3; f * f <= n; f += 2) {
        while(n % f == 0) {
            res[f]++;
            n /= f;
        }
    }

    // 5以上の素数の場合, 上記までに一切割り切れないため, ここでresへ追加する.
    if(n != 1) res[n] = 1;

    return res;
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    ll cnt = g > 1 ? trial_division(g).size() + 1 : 1;
    cout << cnt << "\n";

    return 0;
}


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

std::vector<std::vector<int>> t;
std::vector<int> c;

void dfs(int p, int u) {
    for (int v : t[u]) {
        if (v == p) continue;
        c[v] += c[u];
        dfs(u, v);
    }
}

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

    t.resize(N);
    for(int i = 0; i < N - 1; i++) {
        int a, b;
        std::cin >> a >> b;
        a--;
        b--;
        t[a].push_back(b);
        t[b].push_back(a);
    }

    c.resize(N);
    for (int i = 0; i < Q; i++) {
        int p, x;
        std::cin >> p >> x;
        p--;
        c[p] += x;
    }

    dfs(-1, 0);

    for (int i = 0; i < N; i++)
        std::cout << c[i] << (i < N - 1 ? " " : "\n");
}

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

using namespace std;

int main(){
	string s1,s2,tgt;
	int a1,a2;
	cin>>s1>>s2>>a1>>a2>>tgt;
	if (tgt==s1) a1--;
	if (tgt==s2) a2--;
	cout<<a1<<" "<<a2<<endl;
	return 0;
}

Measured memory_bytes: 256
//<editor-fold desc="I/O Templates">
    private fun readLn() = readLine()!!
    private fun readInt() = readLn().toInt()
    private fun readLong() = readLn().toLong()
    private fun readStrings() = readLn().split(" ")
    private fun readInts() = readStrings().map(String::toInt)
    private fun readLongs() = readStrings().map(String::toLong)
    //</editor-fold>
     
    fun main() {
        val (n, k) = readInts()
        val a = readInts()
        for (i in k until n) {
            println(if (a[i] > a[i - k]) "Yes" else "No")
        }
    }

Measured memory_bytes: 68376
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;

ll n, k, a, d[100002];

int main() {
  while (1) {
    scanf("%lld%lld", &n, &k);
    if (n == 0) break;
    for (int i = 0; i <= n + 2; i++) d[i] = 0;
    bool flag = false;
    ll ans = 0;
    for (ll i = 0; i < k; i++) {
      scanf("%lld", &a);
      if (a == 0) { flag = true; continue; }
      d[a] = 1;
    }
    //for (ll i = 0; i < n + 2; i++) printf("%lld ",d[i]); printf("\n");
    ll counter = 0, temp = -1;
    for (ll i = 1; i <= n + 1; i++) {
      if (d[i] == 1) counter++;
      else if (d[i - 1] == 1) {
        ans = max(ans, counter + temp + 1);
        if (flag && d[i + 1] == 1) temp = counter;
        else temp = -1;
        counter = 0;
      } else temp = -1, counter = 0;
    }
    if (n == k) printf("%lld\n", n);
    else printf("%lld\n", ans);
  }
}



Measured memory_bytes: 3372
import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t 
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]

H, = I()
c = 0
while H > 0:
    H = H//2
    c += 1
ans = 0
for i in range(c):
    ans += 2**i
print(ans)

Measured memory_bytes: 6704
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int max = Integer.MIN_VALUE;
		
		int n = stdIn.nextInt();
		
		int k = stdIn.nextInt();
		
		int index = Integer.MAX_VALUE;
		
		int [] p = new int[n];
		
		for(int i = 0; i < n; i++) {
			p[i] = stdIn.nextInt();
		}
		
		/*for(int i = 0; i < n-k+1; i++) {  //ここTLE
			int sum = 0;
			for(int j = i; j < i+k; j++) {
				sum += p[j];
			}
			
			if(max < sum) {
				max = sum;
				index = i;
			}
			
		}*/
		int sum = 0;
		
		for(int i = 0; i < k; i++) {
			sum += p[i];
		}
		index = k-1;
		
		max = Math.max(sum, max);
		
		int right = 0;		
		for(int i = k; i < n; i++) {
			
			sum -= p[i-k];
			sum += p[i];
			
			if(max < sum) {
				max = sum;
				index = i;
			}
			
		}
		
		
		double ans = 0;
		
		for(int i = 0; i < k; i++) {
			
			ans += p[index--]/2.0+0.5;
			
			
		}
		
		System.out.println(ans);
		
	}

}


Measured memory_bytes: 80968
#include<bits/stdc++.h>
#define ll long long int
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define test(t) int t; cin >> t; while(t--)
#define endl "\n"
#define debug(x) cout << x << "\n"
#define pb push_back
#define mp make_pair
#define MEMS(x,t) memset(x, t, sizeof(x))
#define mod 1000000007
#define forn(i,n) for (ll i = 0; i < n; i++)
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define rrep(i,a,b) for( int i = a; i >= b; i--)
#define map map<ll,ll>
#define fi first
#define se second
#define set set<ll>
#define pp pair<ll,ll>
using namespace std;
bool sortbysec(const pp &a,
              const pp &b)
{
    return (a.second < b.second);
}
int main()
{
    ll n,x,t;
    cin >> n >> x >> t;
    cout << t*((n + x - 1)/x);
}


Measured memory_bytes: 3616
s = input()
t = input()

res = 0
for i in range(len(s) - len(t) + 1):
  count = 0
  for j in range(len(t)):
    if s[i+j] == t[j]:
      count += 1
  res = max(res,count)

print(len(t)- res)
   

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

//mod
const int mod = 1e9 + 7;
int powmod(int x, int y) { //x^y
	int rv = 1;
	for (; y > 0; y >>= 1, x = (long long) x * x % mod)
		if (y & 1)
			rv = (long long) rv * x % mod;
	return rv;
}
int inverce(int x) {
	return powmod(x, mod - 2);
}

//comb
const int factMax = 2e3;
int fact[factMax + 1];
void initializeFact() {
	fact[0] = 1;
	for (int i = 1; i <= factMax; i++)
		fact[i] = (long long) fact[i - 1] * i % mod;
}
int comb(int n, int k) {
	if (k < 0 || n - k < 0)
		return 0;
	int denom = (long long) fact[k] * fact[n - k] % mod;
	return (long long) fact[n] * inverce(denom) % mod;
}

int n;
ll ans = 0;

int main() {

	initializeFact();

	cin >> n;
	for (int l = 1; n - 3 * l >= 0; ++l) {
		ans += comb(n - 2 * l - 1, l - 1);
		ans %= mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3616
#include <iostream>

using namespace std;

int main(){
  int A,B;
  cin >> A >> B;

  if(A==B){
    std::cout << 2*A << std::endl;
  }
  else if(A-B == 1 | B-A ==1){
    std::cout << A+B << std::endl;
  }
  else if(A-B > 1 ){
    std::cout << 2*A -1 << std::endl;
  }
  else if(B-A > 1){
    std::cout << 2*B -1 << std::endl;
  }
    return 0;
}


Measured memory_bytes: 256
from math import factorial

def combi(n, k):
  return factorial(n) // factorial(n-k) // factorial(k)

N, P = map(int, input().split())
A = list(map(int,input().split()))

e = len([a for a in A if a % 2 == 0])
o = N - e

ans = 0
for i in range(P, o+1, 2):
  ans += combi(o, i)
print(ans * pow(2, e))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    string s,t;cin>>s>>t;
    t+=s;
    cout<<t<<endl;
    return 0;
}


Measured memory_bytes: 256
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
P = list(map(int, input().split()))

A = [N*i+1 for i in range(1, N+1)]
B = list(reversed(A))

for i, p in enumerate(P):
    A[p-1] -= N-i
print(*A)
print(*B)


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

#define int long long 


int n,m;
int a[100000];
auto c=[](int &a,int &b){return a<b;};
priority_queue<int> q;


void solve(){
    cin>>n>>m;
    for(int i=0; i<n; i++){
        cin>>a[i];
        q.push(a[i]);
    }
    for(int i=0; i<m; i++){
        int cur=q.top();
        cur/=2;
        q.pop();
        q.push(cur);
    }
    int ans=0;
    while(!q.empty()){

        int a=q.top();
        q.pop();
        ans+=a;
    }
    cout<<ans<<endl;
}

signed main(){
    solve();
}



Measured memory_bytes: 1912
#include<iostream>
#include<algorithm>

using namespace std;

int main(){

  int h[20];
  int n=0;

  while(cin>>h[n]){
    n++;
  }

  sort(h,h+n);

  cout << h[n-1] <<endl<< h[n-2]<< endl <<h[n-3]<<endl;
  
  
  return 0;
}

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

int main(){
    vector<int>A(3);
    for(int i=0;i<3;i++){
        cin >> A.at(i);
    }
    int ans = 0;
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    cout << abs(A.at(0) - A.at(1)) + abs(A.at(2) - A.at(1)) << endl;
    

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin >> n;
  vec a(n);
  for(ll i=0;i<n;i++) cin >> a[i];
  ll r=0;
  ll h=0;
  ll ans=0;
  for(ll l=0;l<n;l++) {
    for(;r<n&&!(h&a[r]);r++) {
      h^=a[r];
    }
    ans+=(r-l);
    h^=a[l];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.map f

[<EntryPoint>]
let main argv =
    let [|n;a;b|] = reads int
    printfn "%i" (min (n * a) b)
    0

Measured memory_bytes: 14044
#include <iostream>
#include <string>
#include <vector>

const int64_t MOD = 1000 * 1000 * 1000 + 7;

template <uint8_t max_value, uint8_t mod_value>
struct index_mod {
  uint8_t mod[max_value];
  constexpr index_mod() : mod() {
    for (size_t i = 0; i < max_value; ++i) {
      mod[i] = i % mod_value;
    }
  }
};

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

  // i番目の文字を見た時に13との剰余がnになる個数を数え上げる
  std::vector<int64_t> dp(2 * 13);

  constexpr index_mod<13 * 10, 13> imod;

  {  // テーブル初期化
    int val = -1;
    if (s[0] != '?') val = s[0] - '0';
    if (val == -1) {
      for (size_t i = 0; i < 10; ++i) {
        dp[i % 13] = 1;
      }
    } else {
      dp[val % 13] = 1;
    }
    // % 13は不要だけど定義に帰るため
  }

  for (size_t i = 1, e = s.length(); i < e; ++i) {
    int val = -1;
    if (s[i] != '?') val = s[i] - '0';
    if (val == -1) {
      for (size_t pre = 0; pre < 13; ++pre) {
        const auto &pre_dp = dp[pre];
        const auto pindex = pre * 10;
        for (size_t here = 0; here < 10; ++here) {
          auto &here_dp = dp[13 + imod.mod[pindex + here]];
          here_dp = here_dp + pre_dp;
        }
      }
    } else {
      for (size_t pre = 0; pre < 13; ++pre) {
        auto &here_dp = dp[13 + imod.mod[pre * 10 + val]];
        const auto &pre_dp = dp[pre];
        here_dp = pre_dp;
      }
    }

    for (size_t i = 0; i < 13; ++i) {
      dp[i] = dp[13 + i] % MOD;
      // dp[i] = dp[13 + i];
      dp[13 + i] = 0;
    }
  }

  std::cout << dp[5] % MOD << std::endl;
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
using namespace std;


int main(){
    int n,m;
    int a[20]={};
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a[i];
    }
    int dp[100000];
    for(int i=0;i<100000;i++){
        dp[i]=1000000;
    }
    dp[0]=0;
    dp[1]=1;
    
    
    for(int i=2;i<=n;i++){
        for(int t=0;t<m;t++){
            if(i-a[t]>=0){dp[i]=min(dp[i],dp[i-a[t]]+1);}
        }
    }
    
    cout<<dp[n]<<endl;
    
    return 0;
}



Measured memory_bytes: 3468
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}
int main()
{
    int x=read();
    int ans=x+x*x+x*x*x;
    cout<<ans<<endl;
}


Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
  int s;
  cin>>s;
  string a,b;
  cin>>a>>b;
  //int s=a.length();
  for(int i=0;i<s;i++)
    cout<<a[i]<<b[i];
  return 0; 
} 

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

lst = [[] for _ in range(10)]
for i in range(n):
    lst[int(s[i])].append(i)

done = []
cnt = 0
for i in range(1000):
    tmp = str(i).rjust(3, '0')
    n1,n2,n3 = int(tmp[0]), int(tmp[1]), int(tmp[2])
    mi = -1
    mx = -1
    if len(lst[n1])!=0:
        mi = lst[n1][0]
    if len(lst[n3])!=0:
        mx = lst[n3][-1]
    
    if mi>=0 and mx>=0:
        for y in lst[n2]:
            if mi<y<mx:
                done.append(tmp)
    else:
        continue
print(len(set(done)))

Measured memory_bytes: 27876
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
N = int(input())

N = N ** 0.5
N = math.floor(N)
print(N**2)



Measured memory_bytes: 38256
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;

#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define vpii vector<pair<ll,ll>>
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1000000000+7;
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
ll factor(ll n){
    vll ans;
	if(n==2)ans.pb(2);
	else
    {for(ll i=2;i*i<=n;i++){if(n%i==0 && n%i!=i){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}ans.pb(n);}
    return ans.sz+1;
}
ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i; 
    return res; } 
  
ll nCr(ll n, ll r){ return fact(n) / (fact(r) * fact(n - r)); } 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 

ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol(const vector<int>& v1, 
               const vector<int>& v2){ 
 return v1[0] < v2[0]; } 

 ll degit(ll n)
 {
 	ll t=0;
 	while(n>0)
 	{
 		t++;
 		n/=10; 	}
 		return t;
 }
ll f(ll a,ll b,ll c)
{
	return (a*a+b*b+c*c+a*b+b*c+c*a);
}
void solve()
{
	ll n;
	cin>>n;
	vll ans(n+1,0);
	for(ll i=1;i<=100;i++)
		for(ll j=1;j<100;j++)
			for(ll k=1;k<=100;k++)
				if(f(i,j,k)<=n)
					ans[f(i,j,k)]++;
	for(ll i=1;i<=n;i++)
		cout<<ans[i]<<endl;
	return;        
}       
int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3676
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<stdio.h>
#include<unordered_map>
#include<map>
#include<stack>
#include<queue>
#include<iterator>
#include<functional>
#include<climits>
#include<set>
#include<utility>

#define ll long long
#define MOD 1000000007

using namespace std;

void solve () {
	int n,k;
	cin >> n >> k;
	int arr[n];
	for (int i = 0;i < n;++i) {
		cin >> arr[i];
	}
	int dp[n];
	fill(dp,dp+n,INT_MAX);
	dp[0] = 0;
	for (int i = 0;i < n;++i) {
		for (int j = i+1;j <= i+k;++j) {
			if (j < n) {
				dp[j] = min(dp[j],dp[i]+abs(arr[j]-arr[i]));
			}
		}
	}
	cout << dp[n-1] << '\n';
	return;

}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}



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

string bubbleSort(vector<char> &Mb,vector<int> &Nb, int A);
string selectionSort(vector<char> &Ms,vector<int> &Ns, int A);

int main(void) {
	
	int A;
	cin >> A;

	vector<char> M(A), Mb(A), Ms(A);
	vector<int> N(A), Nb(A), Ns(A);
	for (int i = 0; i < A; i++) cin >> M.at(i) >> N.at(i);

	for (int i = 0; i < A; i++)
	{
		Mb.at(i) = M.at(i);
		Ms.at(i) = M.at(i);
		Nb.at(i) = N.at(i);
		Ns.at(i) = N.at(i);
	}

	string YN = bubbleSort(Mb, Nb, A);
	for (int i = 0; i < A; i++)
	{
		if (i) cout << " ";
		cout << Mb.at(i) << Nb.at(i);
	}
	cout << endl;
	cout << YN << endl;

	YN = selectionSort(Ms, Ns, A);
	for (int i = 0; i < A; i++)
	{
		if (i) cout << " ";
		cout << Ms.at(i) << Ns.at(i);
	}
	cout << endl;
	cout << YN << endl;

	return 0;
}


string bubbleSort(vector<char> &Mb, vector<int> &Nb, int A) 
{
	vector<int> Ib(A);
	for (int i = 0; i < A; i++) Ib.at(i) = i;

	for (int i = 0; i < A-1; i++)
	{
		for (int j = A-1; i < j; j--)
		{
			if (Nb.at(j) < Nb.at(j - 1)) {
				swap(Nb.at(j), Nb.at(j - 1));
				swap(Mb.at(j), Mb.at(j - 1));
				swap(Ib.at(j), Ib.at(j - 1));
			}
		}
	}

	for (int i = 0; i < A-1; i++)
	{
		if (Nb.at(i) == Nb.at(i + 1))
		{
			if (Ib.at(i) > Ib.at(i + 1))
			{
				return "Not stable";
			}
		}
	}

	return "Stable";
}

string selectionSort(vector<char>& Ms, vector<int>& Ns, int A)
{
	vector<int> Is(A);
	for (int i = 0; i < A; i++) Is.at(i) = i;

	for (int i = 0; i < A - 1; i++)
	{
		int minN = i;
		for (int j = i + 1; j < A; j++)
		{
			if (Ns.at(j) < Ns.at(minN))
			{
				minN = j;
			}
		}

		if (minN != i)
		{
			swap(Ms.at(i), Ms.at(minN));
			swap(Ns.at(i), Ns.at(minN));
			swap(Is.at(i), Is.at(minN));
		}
	}

	for (int i = 0; i < A-1; i++)
	{
		if (Ns.at(i) == Ns.at(i + 1))
		{
			if (Is.at(i) > Is.at(i + 1))
			{
				return "Not stable";
			}
		}
	}

	return "Stable";

}


Measured memory_bytes: 3220
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = 1e18;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

    int C0 = 0, C1 = 0, C2 = 0, C3 = 0;
    for (auto s : S)
    {
        if (s=="AC")
            ++C0;
        if (s=="WA")
            ++C1;
        if (s=="TLE")
            ++C2;
        if (s=="RE")
            ++C3;
    }

    cout << "AC x " << C0 << endl;
    cout << "WA x " << C1 << endl;
    cout << "TLE x " << C2 << endl;
    cout << "RE x " << C3 << endl;

    return 0;
}


Measured memory_bytes: 6280
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int n;
vector<int> a,b,c;
int dp[500001][3];

int f(int i, int prev){
	if(i==n){
		return 0;
	}
	if(dp[i][prev]!=-1){
		return dp[i][prev];
	}
	if(prev != 0){
		dp[i][prev] = max(dp[i][prev],f(i+1,0)+a[i]);
	}
	if(prev != 1){
		dp[i][prev] = max(dp[i][prev],f(i+1,1)+b[i]);
	}
	if(prev != 2){
		dp[i][prev] = max(dp[i][prev],f(i+1,2)+c[i]);
	}
	return dp[i][prev];
	
}

int main(){
	cin>>n;
	memset(dp,-1,sizeof(dp));
	a.resize(n);
	b.resize(n);
	c.resize(n);
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	cout<<max(f(0,0),max(f(0,1),f(0,2)))<<endl;
}

Measured memory_bytes: 13568
#!/usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, A, B = map(int, input().split())

if N * A <= B:
    print(N*A)
else:
    print(B)




Measured memory_bytes: 9056
#include<iostream>
using namespace std;
bool p[11];
bool poss(int x)
{
    while(x>0)
    {
        if(!p[x%10]) return false;
        x=x/10;
    }
    return true;
}
int main()
{
    int n,k;
    cin>>n>>k;
    int x;
    for(int i=0;i<10;i++) p[i]=true;
    for(int i=1;i<=k;i++) { cin>>x ; p[x]=false ; }
    while(true)
    {
        if(poss(n))
        {
            cout<<n;
            return 0;
        }
        else n++;
    }
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;


void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


/* 注意 

    1LL<<60 * N とかのオーバーフローに気を付けろ
    制約がヒントになる、ちゃんと全ての制約を見ろ

*/


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

    int n; cin >> n;
    vector<char> c(n);
    rep(i, n) cin >> c[i];

    vector<vector<ll>> dp(n+5, vector<ll>(n+5, 0));

    dp[0][0] = 1;
    rep(i, n) rep(j, i+1) if (dp[i][j]) {
        if(c[i] == 'U') {
            (dp[i+1][j+1] += dp[i][j]*(i-j)) %= mod;
            (dp[i+1][j] += dp[i][j]) %= mod;
        }
        if(c[i] == 'D') {
            (dp[i+1][j+2] += dp[i][j]*(i-j)*(i-j)) %= mod;
            (dp[i+1][j+1] += dp[i][j]*(i-j)) %= mod;
        }
        if(c[i] == '-') {
            (dp[i+1][j+1] += dp[i][j]) %= mod;
        }
    }

    cout << dp[n][n] << endl;
    return 0;
}



Measured memory_bytes: 3300
object Main extends App {

  import scala.math._

  val In = io.StdIn.readLine().split(" ")
  val a = In(0).toInt
  val b = In(1).toInt

  if ( abs(a-b)*2 <= List(a,b).min *2 ) {
    println("Yay!")
  } else {
    println(":(")
  }

}


Measured memory_bytes: 25412
#include <cstdio>

#define gc getchar
#define pc putchar
#define sp pc(' ')
#define ln pc('\n')

template <class t>
inline void read(t &num) {
    register char c = gc();
    register bool flag = 0;
    num = 0;
    while ((c < '0' || c > '9') && c != '-') c = gc();
    if (c == '-') flag = 1, c = gc();
    while (c >= '0' && c <= '9') num = (num << 1) + (num << 3) + c -'0', c = gc();
    flag && (num = ~(num - 1));
}
template <class t>
inline void print(t num) {
    if (num < 0) pc('-'), num = ~(num - 1);
    if (num >= 10) print(num / 10);
    pc(num % 10 + '0');
}

int main() {
    double s = 0;
    int n;
    read(n);
    for (int i = 1; i <= n; i++) {
        int a;
        read(a);
        s += 1.0 / a;
    }
    printf("%lf\n", 1.0 / s);
}

Measured memory_bytes: 128
import copy

#参考書数、理解度目標　参考書ステータス　今とってる参考書　理解度合計　値段合計
def comall(depth,n,x,a,usum,vsum):
  allok = True
  for i in range(1,len(usum)):
    #print(i, end = " ")
    if usum[i] < x:
      allok = False
      break
  #print()
  if allok:
    #print(vsum)
    return vsum
  else:
    #print(depth)
    if depth >= n:
      return 10000000
    else:
      v1 = comall(depth+1,n,x,a,copy.copy(usum),vsum)#i番目の参考書は買わない
      for i in range(1,len(usum)):
        usum[i] += a[depth][i]
      v2 = comall(depth+1,n,x,a,copy.copy(usum),vsum+a[depth][0])#i番目の参考書は買う
      return min(v1,v2)


def main():
  nmx = input().split()
  n = int(nmx[0])
  m = int(nmx[1])
  x = int(nmx[2])

  c = []
  for i in range(n):
    cn = list(map(lambda x:int(x), input().split() ))
    c.append(cn)
    
  ans = comall(0,n,x,c,[0]*(m+1),0)
  if ans == 10000000:
    print(-1)
  else:
    print(ans)
    
main()

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

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

    const int NMMAX = 50;
    
    int A[NMMAX], B[NMMAX], C[NMMAX], D[NMMAX];
    
    for( int i = 0 ; i < N; ++i){
        cin >> A[i] >> B[i];
    }

    for( int j = 0; j < M; ++j){
        cin >> C[j] >> D[j];
    }

    for( int i = 0; i < N; ++ i){
    int min_dist = abs(A[i] - C[0]) + abs(B[i] - D[0]) , checkpoint = 1;

        for( int j = 1; j < M; ++j){
            const int cur_dist = abs(A[i] - C[j]) + abs(B[i] - D[j]);

            if( min_dist > cur_dist){
                min_dist = cur_dist;
                checkpoint = j + 1;
            }
        }

        cout << checkpoint <<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
int main() {
      int W, H, x, y, r;
      std::cin >> W >> H >> x >> y >> r;
      if( x-r < 0 || x+r > W || y-r < 0 || y + r > H) {
          std::cout << "No" << std::endl;
      } else {
          std::cout << "Yes" << std::endl;
      }
      return 0;
}

Measured memory_bytes: 3100
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>

using namespace std;

int maxn = 100005;


int main()
{
	int N, h[maxn], dp[maxn];
	memset(dp, 0x3f3f3f, sizeof dp);
	dp[1] = 0;
	scanf("%d", &N);
	for(int i = 1; i <= N; i++)
	{
		scanf("%d", &h[i]);
	}
	for(int i = 1; i <= N; i++)
	{
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
		dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
	}
	printf("%d\n", dp[N]);
	return 0;
}

Measured memory_bytes: 896