akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ll n;cin>>n;ll arr[n];
for(ll i=0;i<n;i++){
    cin>>arr[i];
}
ll sum[n+1];sum[0]=0;
for(ll i=1;i<=n;i++){
    sum[i]=sum[i-1]+arr[i-1];
}
ll ans=1000000;
for(ll i=1;i<n;i++){
    ans=min(ans,abs(sum[n]-sum[i]-sum[i]));
}
cout<<ans<<endl;
}


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

int main(){
  int N,X,sum=0,count=0;
  cin >> N >> X;
  vector<int> M(N);
  for(int i=0;i<N;i++){
    cin >> M.at(i);
    sum+=M.at(i);
    count++;
    }
  sort(M.begin(),M.end());
  int C=X-sum;
  count+=C/M.at(0);
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<complex>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    const int lim = 200000;
    int table[lim] = {0};
    table[0] = table[1] = 1;
    rrep(i, 2, sqrt(lim)) {
        int j = i + i;
        while (j < lim) {
            table[j] = 1;
            j += i;
        }
    }
    vector<int> v;
    rep(i, lim) if (table[i] == 0) v.push_back(i);
    //rep(i, v.size()) cout << v[i] << " "; cout << endl;
    int n;
    while (cin >> n && n) {
        int ans = 0;
        rep(i, n) ans += v[i];
        cout << ans << endl;
    }
}





Measured memory_bytes: 3960
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

Int len[200005];
Int a[200005];
int main(){
    int N; cin >> N;
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }
    for (int i = 0; i < N; i++){
        len[a[i]] = len[a[i] - 1] + 1;
    }
    Int ma = 0;
    for (int i = 1; i <= N; i++){
        ma = max(len[i], ma);
    }
    cout << N - ma << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;
// int64_t INF = 9223372036854775807;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s;
    cin >> s;
    // 頭の一桁を1つ落とすのが得策
    // もしくは最初から全てが9の場合
    int64_t res = 0;
    rep(i,s.size()){
        res += s.at(i)-'0';
    }
    int64_t logicalMax = 9*(s.size()-1)+(s.at(0)-'0'-1);
    res = max(res, logicalMax);
    cout << res << endl;
}

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

using namespace std;

long long strSum(string str);

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

	long long sum = 0;
	for (int i = 0; i < 1 << str.size()-1; i++) {
		long long c = 0;
		string tmp = str;
		for (int j = 0; j < str.size() - 1; j++) {
			if (1 & i >> j) {
				tmp.insert(j+1+c, "+");
				c++;
			}
		}
		sum += strSum(tmp);
	}
	cout << sum << endl;

}
long long strSum(string str) {
	long long sum = 0;
	long long tmp = 0;
	for (auto c : str) {
		if (c == '+') {
			sum += tmp;
			tmp = 0;
		} else {
			tmp *= 10;
			tmp += (c-'0');
		}
	}
	return sum + tmp;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

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

    const int maxnum = 80*80*2+2;
    Vvec<int> sub(H*W, vector<int>(maxnum, 0));
    sub[0][80*80+A[0][0]-B[0][0]] = 1;
    sub[0][80*80-A[0][0]+B[0][0]] = 1;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            int index = i*W+j;
            for(int k=0; k<maxnum; k++){
                int C = A[i][j]-B[i][j];
                if(i!=0 && k-C>=0 && k-C<maxnum) sub[index][k] |= sub[index-W][k-C];
                if(i!=0 && k+C>=0 && k+C<maxnum) sub[index][k] |= sub[index-W][k+C];
                if(j!=0 && k-C>=0 && k-C<maxnum) sub[index][k] |= sub[index-1][k-C];
                if(j!=0 && k+C>=0 && k+C<maxnum) sub[index][k] |= sub[index-1][k+C];
            }
        }
    }

    int ans = 1e+9;
    for(int k=0; k<maxnum; k++){
        if(sub[H*W-1][k]) ans = min(ans, abs(k-80*80));
    }
    cout << ans << endl;
}

Measured memory_bytes: 320640
A,B,K = map(int, input().split())
res = []
for i in range(A,min(A+K,B)):
    res.append(i)
for i in range(max(B-K+1,A),B+1):
    res.append(i)
res = list(set(res))
res.sort()
for i in res:
    print(i)

Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
void setcomb() {
	fac[0] = 1;
	ifac[0] = 1;
	for (ll i = 0; i < 300000; i++) {
		fac[i + 1] = fac[i] * (i + 1) % M; // n!(mod M)
		ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
	}
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n, const Monoid &M1) : M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}
};

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n*a, b) << endl;
}

Measured memory_bytes: 4992
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

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

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

const ll p = (1e+9) + 7;

ll add(ll a, ll b) {
	return (a + b) % p;
}

ll sub(ll a, ll b) {
	return (a + p - b) % p;
}

ll mul(ll a, ll b) {
	return ((a%p)*(b%p)) % p;
}

ll power(ll a, ll b) {
	if (b == 0) {
		return 1;
	}
	else if (b == 1) {
		return a % p;
	}
	else if (b % 2 == 0) {
		ll c = power(a, b / 2);
		return (c*c) % p;
	}
	else {
		ll c = power(a, b / 2);
		return (((c*c) % p)*a) % p;
	}
}

ll divi(ll a, ll b) {
	return mul(a, power(b, p - 2));
}



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

	ll dp[100001] = { 0LL }, A[100001] = { 0LL }, AB[100001] = { 0LL }, emp[100001] = { 0 };
	int l = s.length();
	emp[0] = 1;

	REP(i, l) {
		if (s[i] == 'A') {
			dp[i + 1] = dp[i];
			A[i + 1] = add(A[i], emp[i]);
			AB[i + 1] = AB[i];
			emp[i + 1] = emp[i];
		}
		else if (s[i] == 'B') {
			dp[i + 1] = dp[i];
			A[i + 1] = A[i];
			AB[i + 1] = add(AB[i], A[i]);
			emp[i + 1] = emp[i];
		}
		else if (s[i] == 'C') {
			dp[i + 1] = add(dp[i], AB[i]);
			A[i + 1] = A[i];
			AB[i + 1] = AB[i];
			emp[i + 1] = emp[i];
		}
		else {
			dp[i + 1] = add(mul(dp[i], 3LL), AB[i]);
			A[i + 1] = add(mul(A[i], 3LL), emp[i]);
			AB[i + 1] = add(mul(AB[i], 3LL), A[i]);
			emp[i + 1] = mul(emp[i], 3);
		}
	}

	cout << dp[l] << endl;


	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
    int n, m;
    cin>>n>>m;
    ll a[n];
    for(int i=0;i<n;i++)
            cin>>a[i];
    sort(a, a+n);
    vector<pair<int, int> > ve;
    for(int i=0;i<m;i++)
    {
        ll ae, be;
        cin>>ae>>be;
        ve.push_back({be, ae});
    }
    sort(ve.begin() , ve.end());
    reverse(ve.begin() , ve.end());
    ll c=INT_MAX;
    ll buf=0;
    for(auto i:ve)
    {
        if(true)
        {
            ll cont=0;
            c=i.first;
            for(;a[buf]<c&& cont<i.second;buf++,cont++)
                a[buf]=c;

        }
    }
    ll sum=accumulate(a, a+n, (ll)0);
    cout<<sum;
}


Measured memory_bytes: 2168
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#define MAX 305
using namespace std;
 
int C[MAX],V[MAX],D[MAX],L[MAX];
int n,cost;
int dp[MAX][MAX];
 
 
int recv(int i,int j){
  if(dp[i][j] != -1) return dp[i][j];
  if(i == n )return 0;
  int res =0;
  //if(j < C[i])return recv(i+1,j);
  //else{
    for(int k=0;k*C[i]<=j;k++){
      res = max(res,k*V[i]+recv(i+1,j-k*C[i]));
    }
    //}
   
  return dp[i][j]=res;
}
int recd(int i,int j){
  if(dp[i][j] != -1) return dp[i][j];
  if(i == n )return 0;
  int res =0;
  //if(j < C[i])return recd(i+1,j);
  //else{
    for(int k=0;k*C[i]<=j;k++){
      res = max(res,k*D[i]+recd(i+1,j-k*C[i]));
    }
    //}
   
  return dp[i][j]=res;
}
int recl(int i,int j){
  if(dp[i][j] != -1) return dp[i][j];
  if(i == n )return 0;
  int res =0;
  //if(j < C[i])return recl(i+1,j);
  //else{
    for(int k=0;k*C[i]<=j;k++){
      res = max(res,k*L[i]+recl(i+1,j-k*C[i]));
    }
    //}
   
  return dp[i][j]=res;
}
 
 
 
int main(){
 
  int iori,chihaya=0,makoto=0,miki=0;
 
 
  while( cin >> n >> cost ){
 
    for(int i=0;i<n;i++){
      char ch = getchar();
      while((ch=getchar())!='\n');
      cin >> C[i] >> V[i] >> D[i] >> L[i];
    }
 
    memset(dp,-1,sizeof(dp));
    chihaya = (iori,makoto,miki,chihaya,recv(0,cost));
    //cout << "DEBUG V = " << chihaya << endl;
    /*
    for(int i=0;i < 10;i++){
      for(int j=0;j<10;j++)cout << dp[i][j] << " " ;
      cout << endl;
    }
    */
    memset(dp,-1,sizeof(dp));
    makoto = recd(0,cost);
    //cout << "DEBUG D = " << makoto << endl;
    memset(dp,-1,sizeof(dp));
    miki = recl(0,cost);
    //  cout << "DEBUG L = " << miki << endl;
 
    iori=max(chihaya,max(makoto,miki));
 
    cout << iori << endl;
 
  }
  return 0;
}

Measured memory_bytes: 1556
#include <iostream>
using namespace std;
#define FOR(i,a) for(i=0;i<a;i++)
int a[1000][1000][3];
int i,j;
int main() {
	int n,m;
	cin>>m>>n;
	int k;
	cin>>k;
	FOR(i,m){
		FOR(j,n){
			char p;
			cin>>p;
			if(i!=0 and j!=0){
				a[i][j][0]=a[i][j-1][0]+a[i-1][j][0]-a[i-1][j-1][0];
				a[i][j][1]=a[i][j-1][1]+a[i-1][j][1]-a[i-1][j-1][1];
				a[i][j][2]=a[i][j-1][2]+a[i-1][j][2]-a[i-1][j-1][2];
			}
			else if(i!=0){
				a[i][j][0]=a[i-1][j][0];
				a[i][j][1]=a[i-1][j][1];
				a[i][j][2]=a[i-1][j][2];
			}
			else if(j!=0){
				a[i][j][0]=a[i][j-1][0];
				a[i][j][1]=a[i][j-1][1];
				a[i][j][2]=a[i][j-1][2];
			}
			if(p=='J'){
				a[i][j][0]++;
			}
			if(p=='O'){
				a[i][j][1]++;
			}
			if(p=='I'){
				a[i][j][2]++;
			}
		}
	}
/*	FOR(i,m){
		FOR(j,n){
			cout<<a[i][j][0]<<" ";
		}
		cout<<endl;
	}*/
	FOR(i,k){
		int q,w,e,r;
		cin>>q>>w>>e>>r;
		FOR(j,3){
			int ans=a[e-1][r-1][j];
			if(q-2>=0 and w-2>=0){ans=ans+a[q-2][w-2][j]-a[e-1][w-2][j]-a[q-2][r-1][j];}
			else if(w-2>=0){ans=ans-a[e-1][w-2][j];}
			else if(q-2>=0){ans=ans-a[q-2][r-1][j];}
			cout<<ans;
			if(j<2){
				cout<<" ";	
			}
			else{
				cout<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 12760
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007;
vector<vector<int> >dp;
vector<vector<char>>v;
int mxpath(int row,int col){
        if(dp[row][col]!=-1){
            return dp[row][col];
        }
        int path=0;
        if(row>0){
            path +=mxpath(row-1,col);
        }
        if(col>0){
            path += mxpath(row,col-1)%mod;
            path %=mod;
        }
        return dp[row][col] = path;

}
void solve(){
    int r,c;cin>>r>>c;
    v.resize(r,vector<char>(c));
    dp.resize(r,vector<int>(c,-1));
    for(int i=0;i<r;i++){

        for(int j=0;j<c;j++){
            cin>>v[i][j];
            if(v[i][j]=='#'){
                dp[i][j]=0;
            }
        }
    }
    dp[0][0]=1;
    cout<< mxpath(r-1,c-1)<<"\n";
}

int main(){
    cin.tie(0);
    cout.tie(0);
    cin.sync_with_stdio(0);
    cout.sync_with_stdio(0);


    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int a,b,c;
	cin>>a>>b>>c;
	for(int k=1;k<=b;++k)
		if(a*k%b==c){
			cout<<"YES\n";
			return 0;
		}
	cout<<"NO\n";
}




Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = A+B;
        if (K%2 == 0) {
            System.out.println(K/2);
        } else {
            System.out.println("IMPOSSIBLE");
        }
    }
}

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

int main(){
    int n,l;
    cin >> n;
    string t;
    string h;
    int pt = 0;
    int ph = 0;
    int get = 0;

    for(int i = 0 ; i < n ; i++){
        cin >> t >> h;
        if(t == h){
            pt += 1;
            ph += 1;
        }
        else{
            if(t.length() < h.length()){
                l = t.length();
            }else{
                l = h.length();
            }
            for(int j = 0; j < l ; j++){
                if(t[j] > h[j]){
                    pt += 3;
                    get = 1;
                    break;
                }
                else if(t[j] < h[j]){
                    ph += 3;
                    get = 1;
                    break;
                }
                //else(t[l-1] == h[l-1]){
                    //if (t.length < h.length){
                        //ph += 3;
                    //}
                    //else{
                        //pt += 3;
            }

            if(get == 0){
                if (t.length() < h.length()){
                    ph += 3;
                }
                else{
                    pt += 3;
                }
            }
            get = 0;
        }
    }
    cout << pt << " " << ph << endl;
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define int long long
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 OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
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> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
    return 0;
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n, m, k := io.NextInt(), io.NextInt(), io.NextInt()
	a := io.NextInts(n)
	b := io.NextInts(m)
	ans := solve(k, a, b)
	io.Println(ans)
}

func solve(k int, a, b []int) (ans int) {
	a = append([]int{0}, a...)
	b = append([]int{0}, b...)
	for i := 1; i < len(a); i++ {
		a[i] = a[i-1] + a[i]
	}
	for i := 1; i < len(b); i++ {
		b[i] = b[i-1] + b[i]
	}
	max := 0
	for i := 0; i < len(a); i++ {
		if a[i] > k {
			break
		}
		j := sort.Search(len(b), func(j int) bool { return a[i]+b[j] > k })
		count := i + j - 1
		if count > max {
			max = count
		}
	}
	return max
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// NextInts returns n integers from stdin
func (io *Io) NextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = io.NextInt()
	}
	return ret
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 28276
n=int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
li=make_divisors(n)

ans=float('inf')
for i in range(len(li)):
    for j in range(i,len(li)):
        if li[i]*li[j]==n:
            ans=min(ans,max(len(str(li[i])),len(str(li[j]))))
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    /*int cnt=0;
    int t;cin>>t;
    while(t--){




        cout<<"Case #"<<++cnt<<": "<<ans<<endl;
    }*/

    ll n;cin>>n;
    V<ll>a(3*n);
    for(ll i=0;i<3*n;i++){
        cin>>a[i];
    }
    ll sum=0;ll cnt=0;
    sort(all(a));reverse(all(a));
    for(ll i=1;i<3*n;i+=2){
        cnt++;
        sum+=a[i];
        if(cnt==n)break;
    }
    cout<<sum<<Endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------

















































Measured memory_bytes: 2560
a, b = map(int, input().split())

l = [0, 0, 0]

if(a == 1 or a == 3 or a == 5 or a == 7 or a == 8 or a == 10 or a == 12):
    l[0] = 1
elif(a == 2):
    l[2] = 1
else:
    l[1] = 1

if((b == 1 or b == 3 or b == 5 or b == 7 or b == 8 or b == 10 or b == 12)
   and l[0]):
    print("Yes")
elif(b == 2 and l[2]):
    print("Yes")
elif((b == 4 or b == 6 or b == 9 or b == 11) and l[1]):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef pair<long long, long long> P;
int main() {
	long long N, M; cin >> N >> M;
	vector<vector<char>>A(N, vector<char>(M));
	for (long long i = 0; i < N; i++) {
		for (long long j = 0; j < M; j++) {
			cin >> A.at(i).at(j);
		}
	}
	vector<long long>line;
	for (long long i = 0; i < N; i++) {
		bool check = true;
		for (long long j = 0; j < M; j++) {
			if (A.at(i).at(j) != '.') check = false;
		}
		if (check)line.push_back(i);
	}
	vector<long long>low;
	for (long long i = 0; i < M; i++) {
		bool check = true;
		for (long long j = 0; j < N; j++) {
			if (A.at(j).at(i) != '.') check = false;
		}
		if (check) low.push_back(i);
	}
	long long k = 0;
	for (long long i = 0; i < N; i++) {
		if (!line.empty() && k < line.size()) {
			if (line.at(k) == i) {
				k++;
				continue;
			}
		}
		long long l = 0;
		for (long long j = 0; j < M; j++) {
			if (!low.empty() && l < low.size()) {
				if (low.at(l) == j) {
					l++;
					continue;
				}
			}
			cout << A.at(i).at(j);
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().strip().split()))
ans = 0
for i in range(1, n):
    if(a[i-1] > a[i]):
        ans += abs(a[i-1]-a[i])
        a[i] += abs(a[i-1]-a[i])
print(ans)


Measured memory_bytes: 32400
n=int(input())
p=list(map(int,input().split()))
count=0
for i in range(n-2):
  a,b,c=p[i],p[i+1],p[i+2]
  l=[a,b,c]
  l.sort()
  if l[1]==p[i+1]:
    count+=1
print(count)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a, b, c;
	cin >> a >> b >> c;
	cout << ( b - a == c - b ? "YES" : "NO" ) << "\n";

	return 0;
}


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

int main(void){
    
    list<char> A;
    list<char> B;
    list<char> C;
    
    string S_A,S_B,S_C;
    cin >> S_A >> S_B >> S_C;
    for(int i=0;i<S_A.size();i++) A.push_back(S_A[i]);
    for(int i=0;i<S_B.size();i++) B.push_back(S_B[i]);
    for(int i=0;i<S_C.size();i++) C.push_back(S_C[i]);
    
    char t = A.front();
    A.pop_front();
    
    while(1){
        
        if(t == 'a'){
            if(A.size() == 0){
                cout << 'A' << endl;
                return 0;
            }   
            t = A.front();
            A.pop_front();
            
        }
        else if(t == 'b'){
            if(B.size() == 0){
                cout << 'B' << endl;
                return 0;
            }
            t = B.front();
            B.pop_front();
            
        }
        else{
            if(C.size() == 0){
                cout << 'C' << endl;
                return 0;
            }
            t = C.front();
            C.pop_front();
        }
    }
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll ;
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 ll mod=1e9+7;

void test_case()
{
	ll n,m;
	cin>>n>>m;
	vector<string>v;
	string s;
	for(ll i=0;i<n;i++)
	{
		cin>>s;
		v.push_back(s);
	}
	sort(v.begin(),v.end());
	
	for(auto x:v)cout<<x;
	
}

int main()
{
    fast;
    
//    ll t;
//    cin>>t;
//    while(t--)
    test_case();
    
    
 
   
}

		
	
	
	
	


Measured memory_bytes: 3664
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.Reader;
import java.io.InputStreamReader;
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Star Orpheus
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            long a = in.nextLong(),
                    b = in.nextLong(),
                    c = in.nextLong();
            if ((a & 1) == 0 || (b & 1) == 0 || (c & 1) == 0) {
                out.println(0);
                return;
            }
            out.println(Long.min(a * b, Long.min(b * c, a * c)));
        }

    }

    static class FastScanner {
        final static int BUFFER_SIZE = 65536;
        BufferedReader br;
        char[] buf = new char[BUFFER_SIZE];
        int len = 0;
        int it = 0;
        boolean end = false;

        boolean delim(char c) {
            return c == ' ' || c == '\n' || c == '\r';
        }

        void fillBuffer() {
            try {
                len = br.read(buf);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        void ensureBuffer() {
            if (it == len) {
                it = 0;
                fillBuffer();
                if (len == -1) end = true;
            }
        }

        void moveNext() {
            while (!end) {
                ensureBuffer();
                if (!delim(buf[it])) return;
                while (it < len && delim(buf[it])) it++;
            }
        }

        public long nextLong() {
            moveNext();
            if (buf[it] == '-') {
                it++;
                return -nextLong();
            }
            if (buf[it] == '+') {
                it++;
                return nextLong();
            }
            long result = 0;
            while (!end) {
                int l = it;
                while (it < len && !delim(buf[it])) {
                    result = (result * 10) + buf[it] - '0';
                    it++;
                }
                ensureBuffer();
                if (delim(buf[it])) break;
            }
            return result;
        }

        public FastScanner(String file) {
            try {
                br = new BufferedReader(new FileReader(file), BUFFER_SIZE);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is), BUFFER_SIZE);
        }

    }
}



Measured memory_bytes: 8404
open System
let rec f n res =
  if n = 0 then res else f (n - 1) (List.append res [Console.ReadLine()])
  
let tmp = Array.map int (Console.ReadLine().Split(' '))
let lst = f tmp.[0] []
let s_lst = List.sort lst
Console.WriteLine (List.fold (fun acc x -> acc + x) "" s_lst)


Measured memory_bytes: 15456
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
	if (a > b) swap(a, b);
	while (a != 0) tie(a, b) = make_pair(b%a, a);
	return b;
}
int main() {
	int N;
	vector<int> can; can.clear();
	unordered_map<int, int> m; m.clear();
	cin >> N;
	for(int i = 0, ai; i < N; i++) {
		cin >> ai;
		m[ai]++;
	}
	int pre = 0;
	for (const auto &it: m) {
		if (it.second >= 2) pre = gcd(pre, it.first);
		else can.push_back(it.first);
	}
	int ans = 1, tmp;
	sort(can.begin(), can.end());
	for (const int &t: can) {
		tmp = pre;
		for (const int &i: can) {
			if (i == t) continue;
			tmp = gcd(tmp, i);
//			if (tmp <= ans) break;
		}
		ans = max(ans, tmp);
	}
	if (can.empty()) ans = pre;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    long long l, r;
    cin >> l >> r;
    if(r - l + 1 >= 2019)
        cout << 0 << endl, exit(0);

    long long ans = 19999;
    for(long long i = l; i <= r; ++i) {
        for(long long j = l; j < i; ++j) {
            ans = min(ans, (i * j) % 2019);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def solve(N, K, A):
    tmp = K
    ret = 0
    for a in A:
        # print(a, tmp)
        if a != tmp:
            tmp = K

        if a == tmp:
            tmp -= 1

        if tmp == 0:
            ret += 1
            tmp = K
    return ret


def main():

    N = int(input())
    A = inpl()
    if 0 in A:
        print(0)
        exit()
    ans = 1
    for a in A:
        ans *= a
        if ans > 10**18:
            print(-1)
            break
    else:
        print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 21808
using System;
using System.Collections.Generic;


namespace ConsoleApplication20
{
    class Program
    {
        static void Main(string[] args)
        {
            

            while (true)
            {
                string[] str = Console.ReadLine().Split(' ');
                int h = int.Parse(str[0]);
                int w = int.Parse(str[1]);
                
                if (h == 0 && w == 0)
                {
                    break;
                }
               
                for (int i = 0; i < h; i++)
                {
                    for (int j = 0; j < w; j++)
                    {
                        Console.Write("#");
                        
                    }
                    Console.WriteLine();
                    
                }
                Console.Write("\n");
            }
        }
    }
}

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

int main(){
  
  	int n , k , tmp_i;
	cin >> n >> k;
  	double tmp, rate = 0;
  	for(int i = 1 ; i <=n ; i++){
	  tmp = 1.0;
      for(tmp_i = i ; tmp_i < k; tmp_i*=2 ){
      	tmp /= 2;
      }
      rate += tmp;
    }
    rate/= n;
    cout.precision(12);
    cout <<   rate << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <map>

using namespace std;

long long ans[10];

int main() {
    int h, w, n, i, j, k;
    map <pair<int, int>, int> mp;
    map <pair<int, int>, int>::iterator it;
    
    scanf("%d %d %d", &h, &w, &n);
    
    for (i = 0; i < n; i++) {
        int x, y;
        
        scanf("%d %d", &x, &y);
        
        for (j = -2; j <= 0; j++) {
            for (k = -2; k <= 0; k++) {
                int x2 = x + j;
                int y2 = y + k;
                
                if (x2 >= 1 && x2 + 2 <= h && y2 >= 1 && y2 + 2 <= w) mp[make_pair(x2, y2)]++;
            }
        }
    }
    
    for (it = mp.begin(); it != mp.end(); it++) ans[it->second]++;
    
    ans[0] += (long long)(h - 2) * (w - 2) - mp.size();
    
    for (i = 0; i <= 9; i++) printf("%lld\n", ans[i]);
    
    return 0;
}


Measured memory_bytes: 56448
N, M = map(int, input().split())
drink = []
ans = 0
drink_sum = 0
for _ in range(N):
	array = list(map(int, input().split()))
	drink.append(array)
drink.sort()
for i in range(N):
	if drink_sum + drink[i][1] > M:
		ans += (M - drink_sum)* drink[i][0]
		break
	drink_sum += drink[i][1]
	ans += drink[i][1] * drink[i][0]
print(ans)

Measured memory_bytes: 60760
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

vi dp;
vvi edges;

int dfs(int x) {
  if (dp[x] != -1) return dp[x];

  int mx = 0;
  rep(i, edges[x].size()) {
    int next = edges[x][i];
    mx = max(mx, dfs(next));
  }
  return dp[x] = mx + 1;
}

int main() {
  int N, M; cin >> N >> M;
  edges.resize(N);
  vi x(M), y(M);
  rep(i, M) {
    cin >> x[i] >> y[i];
    x[i]--; y[i]--;
    edges[x[i]].pb(y[i]);
  }
  dp.assign(N, -1);
  int ans = 0;
  rep(i, N) {
    ans = max(ans, dfs(i));
  }
  cout << ans-1 << endl;
  return 0;
}


Measured memory_bytes: 10112
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
    int[] x = new int[5];
    int ans = 0;
    for(int i=0;i<5;i++) {
      x[i] = sc.nextInt();
      if(x[i] == 0){
        ans = i;
      }
    }

		System.out.println(ans+1);
	}
}


Measured memory_bytes: 35640
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
//#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n;

int doGcd(int a, int b) {
	if (a % b == 0)
		return b;
	else
		return doGcd(b, a % b);
}

int gcd(int a, int b) {
	if (a > b)
		return doGcd(a, b);
	else
		return doGcd(b, a);
}

int main()
{
	scanf("%d", &n);
	
	long long sum = 0;
	for (int i = 1 ; i <= n ; i++) {
		for (int j = 1 ; j <= n ; j++) {
			int gij = gcd(i, j);
			for (int k = 1 ; k <= n ; k++) {
				int g = gcd(gij, k);
				sum = sum + g;
			}
		}
	}
	
	printf("%lld\n", sum);
	
	return 0;
}

Measured memory_bytes: 1736
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
#define ll long long
#define N 1000010


int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a<b)swap(a,b);
    printf("%d",max(a+a-1,a+b));
    return 0;
}


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


int A,B,C;

int main(){
    cin >> A >> B >> C;
    if(A==B && B==C && C==A) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
    "7 5 1" => "YES",
    "2 2 1" => "NO",
    "1 100 97" => "YES",
    "40 98 58" => "YES",
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: usize,
        b: usize,
        c: usize,
    }

    let mut ans = "NO";

    for i in 0..b + 1 {
        if a * i % b == c {
            ans = "YES";
            break;
        }
    }

    ans.to_string()
}


Measured memory_bytes: 4352
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string[] s1 = Console.ReadLine().Split(' ');
        string[] s2 = (string[])s1.Clone();

        bub(n,ref s1);
        sel(n,ref s2);

        string res1 = String.Join(" ",s1);
        string res2 = String.Join(" ", s2);

        Console.WriteLine(res1);
        Console.WriteLine("Stable");

        Console.WriteLine(res2);

        if(res1 == res2)
        {
			Console.WriteLine("Stable");

		}
        else
        {
            Console.WriteLine("Not stable");
        }

        return;
    }

    static void bub(int n,ref string[] s)
	{
		for (int i = 0; i < n; i++)
		{
			for (int j = n - 1; j > i; j--)
			{
				if (s[j][1] < s[j - 1][1])
				{
					string temp = s[j];
					s[j] = s[j - 1];
					s[j - 1] = temp;
				}
			}
		}
	}

    static void sel(int n, ref string[] s)
	{
		for (int i = 0; i < n; i++)
		{
			int minj = i;
			for (int j = i; j < n; j++)
			{
				if (s[j][1] < s[minj][1])
					minj = j;
			}
			string temp = s[i];
			s[i] = s[minj];
			s[minj] = temp;
		}
	}
}

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

typedef long long ll;

ll power(ll a, ll n, ll mod){
	ll p = 1;
	while(n>0){
		if(n%2) p *= a;
		a = a*a % mod;
		p %= mod;
		n = n>>1;
	}
	return p;
}

int main(){
	const int MOD = 1e9+7;
	int N,K;
	cin >> N >> K;
	vector<int> A(N);
	rep(i,N)cin >> A[i];
	sort(A.begin(),A.end());

	vector<int> fact(N+1);
	fact[0] = fact[1] = 1;
	for(ll i=2; i<=N; i++){ fact[i] = fact[i-1] * i % MOD; }

	vector<int> finv(N+1);
	finv[0] = finv[1] = 1;
	for(int i=2; i<=N; i++){ll inv=power(i,MOD-2,MOD); finv[i] = inv * finv[i-1] % MOD; }
	
	ll ans = 0;
	for(int i=K; i<=N; i++){
		ll comb = fact[i-1] * (finv[K-1] * (ll)finv[i-K] % MOD) % MOD;
		ans += comb * A[i-1] % MOD;
		ans %= MOD;
	}
	reverse(A.begin(),A.end());
	for(int i=K; i<=N; i++){
		ll comb = fact[i-1] * (finv[K-1] * (ll)finv[i-K] % MOD) % MOD;
		ans -= comb * A[i-1] % MOD;
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1408
N = input()
A=[]
for i in N:
    A.append(i)

hon = ["2","4","5","7","9"]
pon = ["0","1","6","8"]
bon = ["3"]
if A[-1] in hon:
    print("hon")
elif A[-1] in pon:
    print("pon")
else:
    print("bon")

Measured memory_bytes: 8928
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n, k;
	std::cin >> n >> k;
	int mx = 0, g = 0;
	while(n--) {
		int x;
		std::cin >> x;
		g = gcd(g, x);
		mx = std::max(mx, x);
	}
	std::cout << (k % g == 0 && k <= mx ? "POSSIBLE\n" : "IMPOSSIBLE\n");
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define f first
#define s second
#define INF 2000000
using namespace std;
typedef long long ll;
pair<int,pair<int,int> >st[1<<18];
int tree[4][1<<19];

int get(int a,int b,int n,int l,int r,int f){
  if(r<=a||b<=l)return -INF;
  if(a<=l&&r<=b)return tree[f][n];
  int m=(l+r)/2;
  return max(get(a,b,n*2+1,l,m,f),get(a,b,n*2+2,m,r,f));
}

void koshin(int i,int x,int f){
  i+=(1<<18)-1;
  tree[f][i]=x;
  while(i){
    i=(i-1)/2;
    tree[f][i]=max(tree[f][i*2+1],tree[f][i*2+2]);
  }
}

int main(){
  int n,d;
  cin>>n>>d;
  for(int i=0;i<n;i++) cin>>st[i].s.f>>st[i].s.s>>st[i].f;
  sort(st,st+n);
  for(int i=0;i<(1<<19);i++)
    for(int j=0;j<4;j++)tree[j][i]=-INF;
  for(int i=0;i<n;i++){
    koshin(i,st[i].s.f,0);
    koshin(i,st[i].s.s,1);
    koshin(i,-st[i].s.f,2);
    koshin(i,-st[i].s.s,3);
  }
  int j=0;
  ll an=0;
  for(int i=0;i<n;i++){
    while(j!=n&&st[j].f-st[i].f<=d)j++;
    ll w=get(i,j,0,0,(1<<18),0)+get(i,j,0,0,(1<<18),2);
    ll h=get(i,j,0,0,(1<<18),1)+get(i,j,0,0,(1<<18),3);
    if(h>0&&w>0)an=max(an,h*w);
  }
  cout<<an<<endl;
  return 0;
}

Measured memory_bytes: 12428
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace Atcoder_Answer
{
    class Program
    {
        const Int32 mod = 1000000007;

        static void Main(string[] args)
        {
            string S = ReadLine();

            if (S[1] == 'R')
            {
                WriteLine("ABC");
            }
            else WriteLine("ARC");
        }

        #region Functions
        public decimal floor(float d) => Math.Floor((decimal)d);
        #endregion
    }

    public static class Extension
    {
        #region 拡張:bool
        #region キャスト関連
        public static int ToInt(this bool Bool)
        {
            if (Bool) return 1;
            else return 0;
        }

        public static string ToString(this bool Bool, string TrueStr, string FalseStr)
        {
            if (Bool) return TrueStr;
            else return FalseStr;
        }
        #endregion
        #endregion

        #region 拡張:int
        #region キャスト関連
        public static char ToAlphaBets(this int Base) => (char)Base;
        #endregion
        #endregion

        #region 拡張:char
        #region 変換関連
        public static char NextAlpha(this char Char) => (char)((Char) + 1); //次の文字を取得
        #endregion
        #endregion

        #region 拡張:int[]
        public static long Sum(this int[] Array)
        {
            int Ret = 0;
            for (int loop = 0; loop < Array.Length; loop++) Ret += Array[loop];
            return Ret;
        }
        #endregion

        #region 拡張: string
        public static string Multi(this string THIS, int Value)
        {
            string RetValue = "";

            for (int loop = 0; loop < Value; loop++) RetValue += THIS;

            return RetValue;
        }
        #endregion

        #region 拡張: List<string>
        public static string Sum(this List<string> THIS, string Split)
        {
            string RetValue = "";

            for (int loop = 0; loop < THIS.Count; loop++)
            {
                RetValue += THIS[loop];
            }

            return RetValue;
        }
        #endregion
    }
}

Measured memory_bytes: 17364
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<vector>
#include<queue>
#include<set>
#define ll long long
using namespace std;


int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
	int a[105]={0};
	int n,k,d,t,ans=0;
	cin>>n>>k;
	for(int i=1;i<=k;i++){
		cin>>d;
		for(int j=1;j<=d;j++){
			cin>>t;
			if(!a[t]){
				a[t]++;ans++;
			}
		}
	}
	cout<<n-ans;
    return 0;
}



Measured memory_bytes: 3620