akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
const int MAX_N = 100000;
int set[MAX_N];
ll height[MAX_N];
ll c[MAX_N];

void init(int n) {
  for(int i = 0; i < n; i++) {
    set[i] = i;
    height[i] = 0;
    c[i] = 1;
  }
}

int find(int i) {
  int x = set[i];
  if(x == i) return i;
  return (set[i] = find(x));
}

ll unite(int x, int y) {
  int parx, pary;
  parx = find(x);
  pary = find(y);
  if(parx == pary) return 0;
  ll cx = c[parx];
  ll cy = c[pary];
  if(height[parx] < height[pary]) {
    set[parx] = pary;
    c[pary] = cx + cy;
  } else {
    set[pary] = parx;
    if(height[parx] == height[pary]) height[parx]++;
    c[parx] = cx + cy;
  }
  return cx * cy;
}


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  init(n);
  int bx[m], by[m];
  for(int i = 0; i < m; i++) {
    cin >> bx[i];
    cin >> by[i];
    bx[i]--;
    by[i]--;
  }
  ll ans[m];
  ans[m - 1] = n * (n - 1) / 2;
  for(int i = m - 2; i >= 0; i--) {
    ll diff = unite(bx[i + 1], by[i + 1]);
    ans[i] = ans[i + 1] - diff;
  }
  for(int i = 0; i < m; i++) {
    cout << ans[i] << "\n";
  }
  return 0;
}



Measured memory_bytes: 4864
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        public struct Result
        {
            public int y0;
            public int x0;
            public int y1;
            public int x1;
        }
        public struct Vector
        {
            public int x;
            public int y;
            public Vector(int x, int y)
            {
                this.x = x;
                this.y = y;
            }
        }
        static void SolveA(string[] args)
        {
            var hw = ReadAndParseIntArr();
            int h = hw[0];
            int w = hw[1];
            int[,] a = new int[h, w];
            int sum = 0;
            for(int i=0;i<h;++i)
            {
                var tmp = ReadAndParseIntArr();
                for(int j=0;j<tmp.Length;++j)
                {
                    a[i, j] = tmp[j];
                    sum += tmp[j];
                }
            }
            List<Vector> path = new List<Practice.Program.Vector>();
            for(int i=0;i<h;++i)
            {
                if( i % 2 == 0)
                {
                    for(int j=0;j<w;++j)
                    {
                        path.Add(new Vector(j, i));
                    }
                }
                else
                {
                    for(int j=w-1;j>=0;--j)
                    {
                        path.Add(new Vector(j, i));
                    }
                }
            }
            List<Result> resultList = new List<Practice.Program.Result>();
            for(int i=0;i<path.Count - 1;++i)
            {
                Vector pos = path[i];
                if(a[pos.y, pos.x] % 2 == 0) { continue; }
                Vector nextPos = path[i + 1];
                a[pos.y, pos.x]--;
                a[nextPos.y, nextPos.x]++;
                resultList.Add(new Result() { x0 = pos.x, y0 = pos.y, x1 = nextPos.x, y1 = nextPos.y });
            }

            Console.WriteLine(resultList.Count);
            foreach(Result res in resultList)
            {
                Console.WriteLine($"{res.y0+1} {res.x0+1} {res.y1+1} {res.x1+1}");
            }
        }
    }
}

Measured memory_bytes: 28072
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<functional>
using namespace std;
int main()
{
    int n,m,k;
    int ans[500],ri[500],kat[500];
    int i,j,l,o;

    scanf("%d%d",&n,&m);
    for(i = 1; i <= n * 2; i++) ans[i] = ri[i] = i;
    for(i = 1; i <= m; i++){
        scanf("%d",&k);

        if(k == 0){
            j = 1,o = n + 1;
            for(l = 1; l <= n * 2; l++){
                if(l % 2 == 1){
                    ans[l] = ri[j];
                    j++;
                }
                else{
                    ans[l] = ri[o];
                    o++;
                }
            }
        }
        else{
            for(l = 1; l <= k; l++){
                kat[l] = ans[l];
            }
            for(l = 1,j = k + 1; j <= n * 2; l++,j++){
                ans[l] = ans[j];
            }
            for(l = n * 2 - k + 1,j = 1; l <= n * 2; l++,j++){
                ans[l] = kat[j];
            }
        }

        for(l = 1; l <= n * 2; l++) ri[l] = ans[l];
    }
    for(i = 1; i <= n * 2; i++) printf("%d\n",ans[i]);

    return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
int n[1010];
int main(){
  int a,b;
  cin >> a >> b;
  for(int i = 0;i < a;i++){
    cin >> n[i];
  }
  
  sort(n,n+a,greater<int>());
  int length = 0;
  for(int i = 0;i < b;i++){
    length += n[i];
  }
  cout << length << endl;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

#define MAX 300000
ll sum[MAX];

ll get(int L,int R) {
  ll res = sum[R-1];
  if( L - 1 >= 0 ) res -= sum[L-1];
  return res;
}

ll f(int L,int R,int M) {
  return llabs(get(L,M)-get(M,R));
}

tuple<ll,ll> calc(int L,int R) {
  int pL = L, pR = R;
  assert( R - L >= 2 );
  rep(_,120) {
    if( f(pL,pR,((L+R*2)/3)) > f(pL,pR,((L*2+R)/3)) ) {
      R = ( L + R * 2 ) / 3LL;
    } else {
      L = ( L * 2 + R ) / 3LL;
    }
  }
  int M = ( L + R ) / 2LL;

  ll a = get(pL,M);
  ll b = get(M,pR);
  if( !( a <= b ) ) swap(a,b);
  return tuple<ll,ll>(a,b);
}

int main() {
  int n;
  cin >> n;
  vector<ll> A(n);
  rep(i,n) cin >> A[i];
  sum[0] = A[0];
  REP(i,1,n) sum[i] = sum[i-1] + A[i];

  ll mini = LLONG_MAX;
  REP(i,2,n) {
    int L1 = 0, R1 = i; // [L1,R1)
    int L2 = i, R2 = n; // [L2,R2)
    if( R2-L2 < 2 ) continue;
    //cout << i << "-th:" << endl;
    tuple<ll,ll> a = calc(L1,R1); // 0->min, 1->max
    tuple<ll,ll> b = calc(L2,R2);
    //cout << "  a = " << get<0>(a) << ":" << get<1>(a) << endl;
    //cout << "  b = " << get<0>(b) << ":" << get<1>(b) << endl;
    mini = min(mini,max(get<1>(a),get<1>(b))-min(get<0>(a),get<0>(b)));
  }
  cout << mini << endl;
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  string s;
  cin>>s;
  int ans=s.size()-1;
  for(int i=0;i<26;i++){
    if(s.find((char)('a'+i))==string::npos) continue;
    string t=s;
    int tmp=0;
    while(1){
      bool flg=1;
      for(int j=0;j<(int)t.size();j++)
	flg&=t[j]==('a'+i);
      if(flg) break;
      tmp++;
      string u;
      for(int j=0;j<(int)t.size()-1;j++)
	if(t[j]==('a'+i)||t[j+1]==('a'+i)) u.push_back(('a'+i));
	else u.push_back(t[j]);
      t=u;
    }
    ans=min(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

class UnionFind {
    public:
        vector<int> rank, p, size;

        UnionFind() {}
        UnionFind(int s) {
            rank.resize(s, 0);
            p.resize(s, 0);
            size.resize(s, 0);
            rep (i, s) init(i);
        }

        void init(int x) {
            p[x] = x;
            rank[x] = 0;
            size[x] = 1;
        }

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

        void unite(int x, int y) {
            link(root(x), root(y));
        }

        void link(int x, int y) {
            if (rank[x] > rank[y]) {
                p[y] = x;
                size[x] += size[y];
            } else {
                p[x] = y;
                size[y] += size[x];
                if (rank[x] == rank[y]) {
                    rank[y]++;
                }
            }
        }

        int root(int x) {
            if (x != p[x]) {
                p[x] = root(p[x]);
            }
            return p[x];
        }

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    UnionFind uf = UnionFind(n + m);
    rep (i, n) {
        int k;
        cin >> k;
        rep (j, k) {
            int l;
            cin >> l;
            l--;
            uf.unite(l, m + i);
        }
    }
    int r = uf.root(m);
    rep (i, n) {
        if (r != uf.root(m + i)) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}



Measured memory_bytes: 2560
n = int(input())
x = []
u = []
ans = 0
for i in range(n):
    x1,u1 = [str(i) for i in input().split()]
    x.append(x1)
    u.append(u1)
for i in range(n):
    if u[i] == 'BTC':
        ans += float(x[i]) * 380000.0
    else:
        ans += int(x[i])
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
using namespace std;
int read(){
	int sum=0,f=1;
	char s=getchar();
	while (s<'0' or s>'9'){
		if (s=='-')f=-1;
		s=getchar();
	}
	while (s>='0' and s<='9'){
		sum=sum*10+s-'0';
		s=getchar();
	}
	return sum*f;
}
int n,m,k;
int main(){
	n=read();
	m=read();
	k=read();
	n=max(m,n);
	if (k%n)cout<<k/n+1<<endl;
	else cout<<k/n<<endl;
	return 0;
}



Measured memory_bytes: 256
import sys
from collections import deque

input = sys.stdin.readline

N, M = list(map(int,input().split()))
neighbor = [[] for i in range(N)]
for i in range(M):
	a, b = list(map(int,input().split()))
	neighbor[a-1].append(b-1)

rflag = False
for s in range(N):
	pre = [-1]*N
	start = s
	queue = [start]
	while len(queue)>0:
		nq = []
		for i in queue:
			for j in neighbor[i]:
				if pre[j]==-1:
					pre[j] = i
					nq.append(j)
					if j==start:
						rflag = True
						break
				# else:
				# 	pre[j] = i
				# 	print(pre)
				# 	break

			if rflag: break
		if rflag: break
		queue = nq
	if rflag: break

if not rflag:
	print(-1)
else:
	v = [0]*N
	v[j] = 1
	roop = [j]
	i = j
	while pre[i]!=j:
		pret = pre[i]
		roop.append(pret)
		v[pret] = 1
		i = pret
	roop = roop+[j]
	roop = roop[::-1]

	update = True
	while update:
		update = False
		for i,vi in enumerate(roop):
			if i==len(roop)-1: break
			for ni in neighbor[vi]:
				if ni!=roop[i+1] and v[ni]==1:
					pre[ni] = vi

					v = [0]*N
					v[ni] = 1
					roopn = [ni]
					j = ni
					while pre[j]!=ni:
						pret = pre[j]
						roopn.append(pret)
						v[pret] = 1
						j = pret
					roopn = roopn+[ni]
					update = True
					roop = roopn[::-1]
					break

			if update: break

	K = len(roop)-1
	print(K)
	print(*map(lambda x:x+1,roop[:-1]), sep='\n')

Measured memory_bytes: 42736
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	
	string s;
	cin>>s;
	
	int sum=0;
	
	for (auto c:s){
		sum=(sum+c-48)%9;
	}
	
	if (!sum) cout<<"Yes"; else cout<<"No";
	
}

Measured memory_bytes: 3760
#include <iostream>
#include <vector>
#include <boost/range/algorithm/count_if.hpp>

using namespace std;
using ll = long long;
using ull = unsigned long long;

struct T {
  ull height;
  bool good;
};

int main() {
  ull N, M;
  cin >> N >> M;
  vector<T> H;
  H.reserve(N);
  
  for(ull i = 0; i < N; ++i) {
    ull Hi;
    cin >> Hi;
	H.push_back({ Hi, true });
  }

  for(ull j = 0; j < M; ++j) {
  	int Aj, Bj;
    cin >> Aj >> Bj;
    if(H[Aj-1].height <= H[Bj-1].height) H[Aj-1].good = false;
    if(H[Aj-1].height >= H[Bj-1].height) H[Bj-1].good = false;
  }

  auto const ans = boost::range::count_if(H, [](T const& t)->auto{return t.good;});
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4464
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N,W;
  cin >> N >> W;
  vp vw(N);
  rep(i,N) {
    int a,b;
    cin >> a >> b;
    vw[i] = P(a,b);
  }
  int bw = vw[0].first;
  vvi dp(N,vi(310,0));
  rep(x,N) {
    int va = vw[x].second;
    int we = vw[x].first - bw;
    vvi dp2(N,vi(310,0));
    rep(i,x+1) {
      rep(j,310) {
        if(i == 0) {
          if(j == we) {
            dp2[i][j] = max(dp[i][j],va);
          } else {
            dp2[i][j] = dp[i][j];
          }
        } else {
          if(j-we>=0) {
            dp2[i][j] = max(dp[i][j],dp[i-1][j-we]+va);
          } else {
            dp2[i][j] = dp[i][j];
          }
        }
      }
    }
    dp = dp2;
  }
  int ans = 0;
  rep(i,N) {
    rep(j,310) {
      if(1ll * bw * (i+1) + j <= 1ll * W) {
        ans = max(ans,dp[i][j]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;
typedef tuple<long long, long long, long long> tllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 998244353LL;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
bool compTuple(const tllint& arg1, const tllint& arg2) { return get<2>(arg1) > get<2>(arg2); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void) {
    llint n, x, m;
    cin >> n >> x >> m;

    llint now = x;
    vector<llint> visited(m, 0);
    vector<llint> path;
    while(visited[now]==0) {
        visited[now] = 1;
        path.push_back(now);
        now *= now;
        now %= m;
    }

    llint ans = 0;
    llint s = find(path.begin(), path.end(), now) - path.begin();
    llint r = path.size() - s;
    if(n<=r+s) {
        for(int in=0;in<n;++in) {
            ans += path[in];
        }
    }
    else {
        for(int is=0;is<s;++is) {
            ans += path[is];
        }
        llint sum = 0;
        for(int is=s;is<path.size();++is) sum += path[is];
        llint rep = (n - s) / r;
        llint g = (n - s) % r;
        ans += sum * rep;
        for(int ig=s;ig<g+s;++ig) {
            ans += path[ig];
        }
    }

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


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

typedef long double LD;
typedef long long ll;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

#define pb              push_back
#define mp              make_pair
#define F               first
#define S               second
#define mod             1000000007
#define INF             2147483647
#define endl            "\n"
#define FasterIO        ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0) ;
#define precision(a)    cout << fixed << setprecision(a)
#define bug(a,b)        cout<<a<<"\t"<<b<<"\n";
#define Case(a,b)       cout<<"Case "<<a<<": "<<b<<"\n";
#define reset(a,b)      memset(a,b,sizeof(a));
#define For(x,n)        for(int i=x; i<n; i++)

const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);

int strtoint(string str){
    stringstream ss(str);
    int x = 0;
    ss >> x ;
    return x ;
}
string intostr(int x){
    stringstream ss;
    ss << x;
    string str = ss.str();
    return str;
}
void rem(string &s, const string &c) {
	auto pos = s.find(c);
	if (pos == string::npos) {
		cout << -1 << endl;
		exit(0);
	}
	s.erase(0, pos + 1);
}
void println (int n){
    cout<<n<<"\n";
}
void printvec(vector <int> &a){
    for (int i=0;i<a.size();i++){
        cout<<a[i]<<" ";
    }
    cout<<"\n";
}

void printgraph(vector <int> g[],int e){
    for (int i=0;i<e;i++){
        cout<<i<<" --> ";
        for (int j=0;j<g[i].size();j++){
            cout<<g[i][j]<<" ";
        }
        cout<<"\n";
    }
}

void printmap (map <int,int> &mymap){
    for (auto itr = mymap.begin(); itr != mymap.end(); ++itr) {
        cout << '\t' << itr->first
             << '\t' << itr->second << '\n';
    }
    cout << "\n";
}

int dp[3005][3005];

void solve(){
    string  s,t;
    cin>>s;
    cin>>t;

    int n=s.length(), m=t.length();

    for (int i=0;i<=n;i++){
        for (int j=0;j<=m;j++){
            if (i==0 || j==0){
                dp[i][j]=0;
                continue;
            }

            if (s[i-1]==t[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
            }

            dp[i][j]=max(dp[i][j],dp[i-1][j]);
            dp[i][j]=max(dp[i][j],dp[i][j-1]);

        }
    }
    vector <char> ans;

    int cI = n, cJ=m;

    while (cI>0 && cJ>0){
        if (dp[cI][cJ] == dp[cI-1][cJ]){
            cI--;
            continue;
        }
        if (dp[cI][cJ]==dp[cI][cJ-1]){
            cJ--;
            continue;
        }
        ans.pb(s[cI-1]);
        cI--;cJ--;
    }

    reverse(ans.begin(),ans.end());

    for (char c : ans){
        cout<<c;
    }
    cout<<endl;


}


int main(){
    //FasterIO;

    solve();
    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
deque<int> A[1010];
int step[1010];
int M;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		FOR(j,N-1) {
			cin>>x;
			A[i].push_back(x-1);
		}
	}
	M=N*(N-1)/2;
	
	queue<int> Q;
	FOR(i,N) Q.push(i);
	
	int num=0;
	while(Q.size()) {
		int ok=0;
		
		queue<int> Q2;
		
		while(Q.size()) {
			i=Q.front();
			Q.pop();
			if(step[i]<=num && A[i].size() && A[A[i].front()].front()==i && step[A[i].front()]<=num) {
				step[i]=step[A[i].front()]=num+1;
				Q2.push(i);
				Q2.push(A[i].front());
				A[A[i].front()].pop_front();
				A[i].pop_front();
				M--;
			}
		}
		num++;
		if(M==0) break;
		swap(Q,Q2);
	}
	
	if(M) cout<<-1<<endl;
	else cout<<num<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 4736
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        a: usize,
        p: usize,
    }
    println!("{}", (a * 3 + p)/2);
}


Measured memory_bytes: 2164
#include<bits/stdc++.h>
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














string S;
//---------------------------------------------------------------------------------------------------
#define yes "Yes"
#define no "No"
string solve() {
	int n = S.length();

	if (n % 2 == 1) return no;
	rep(i, 0, n / 2) if (S.substr(i * 2, 2) != "hi") return no;

	return yes;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> S;
	cout << solve() << endl;
}







Measured memory_bytes: 256
//
// Created by sanyinchen on 17/4/24.
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_9_B
//

#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

void _print(vector<int> res) {
    for (int i = 1; i < res.size(); i++) {
        cout << " " << res[i];
    }
    cout << endl;
}

void maxHeap(vector<int> &heap, int i) {

    int left = 2 * i;
    int right = 2 * i + 1;
    int lagest = i;
    if (left < heap.size() && left >= 1) {
        if (heap[left] > heap[lagest]) {
            lagest = left;
        }
    }

    if (right < heap.size() && right >= 1) {
        if (heap[right] > heap[lagest]) {
            lagest = right;
        }
    }

    if (lagest != i) {
        swap(heap[lagest], heap[i]);
        maxHeap(heap, lagest);
    }

}

void buildHeap(vector<int> &heap) {
    for (int i = heap.size() / 2; i >= 1; i--) {
        maxHeap(heap, i);
    }
}

vector<int> heapSort(vector<int> heap) {
    buildHeap(heap);
    _print(heap);
//    while (heap.size() > 1) {
//
//        cout << " " << heap[1];
//        swap(heap[1], heap[heap.size() - 1]);
//        heap.pop_back();
//        maxHeap(heap, 1);
//    }
}


int main() {
    //freopen("../files/in.txt", "r", stdin);
    int n, temp;
    cin >> n;
    vector<int> input;
    input.push_back(0);
    for (int i = 0; i < n; i++) {
        cin >> temp;
        input.push_back(temp);
    }
    heapSort(input);

    return 0;
}

Measured memory_bytes: 8912
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;
int n, k ; 
vector<ll> v ; 
vector<ll> dp ; 
ll dfs(int x){
	if ( x == n-1 )
		return 0 ; 
	if ( dp[x] != 1e18 ) return dp[x] ; 
	ll val = 1e18 ; 
	for(int i=1;i<=k;i++){
		if ( x+i < n )
			val = min(val,abs(v[x]-v[x+i]) + dfs(x+i));
	}
	dp[x] = val ; 
	return dp[x] ; 
}

int main(){
	cin >> n >> k ; 
	v.resize(n) ; 
	dp.resize(n,1e18) ; 
	for(ll &x : v){
		cin >> x ; 
	}
	cout << dfs(0) << endl;
    return 0 ;
}


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

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

  map<ll,int> pf;
  for (ll i=2;i*i<=n;i++) {
    while(n%i==0) {
      n/=i;
      pf[i]++;
    }
  }
  if (n!=1) pf[n]=1;

  int ans = 0;
  for (auto p : pf) {
    int x = p.second;
    int b = 1;
    while(b<=x) {
      x-=b;
      b++;
      ans++;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef pair<ll, ll> PLL;

#define REP(i, j) for(int i=0;i<j;i++)
#define DREP(i, j) for(int i=j;i>=0;i--)
#define FOR(i, b, e) for(int i=b; i<=e; i++)
#define FORD(i, b, e) for(int i=b; i>=e; i--)
#define SIZE(x) ((int)x.size())
#define LAST(x) (x[SIZE(x)-1])
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sp ' '
#define ent '\n'

const int nax = 10e+5;
vector<int> t[nax];
int x, y, n, m;
int dp[nax];
int edges[nax];
bitset<nax> v;

void dfs(int x){
    v[x]=true;
    for(int b : t[x]){
        dp[b] = max(dp[b], dp[x]+1);
        edges[b]--;
        if(!edges[b])dfs(b);
    }
}

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

    cin >> n >> m;

    while(m--){
        cin >> x >> y;
        t[x].pb(y);
        edges[y]++;
    }

    for(int i=1; i<=n;i++)if(!v[i] && !edges[i])dfs(i);
    int maxi=-1;
    for(int i=1;i<=n;i++)maxi=max(maxi, dp[i]);

    cout << maxi;

    return 0;
}


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

using namespace std;
#define ll long long

const int N = 105;
int x[N];

int main() {
    double ave;
    ll ans = 0;
    int n;
    scanf("%d", &n);
    double sum = 0;
    for(int i = 0; i < n; ++i){
        scanf("%d", x + i);
        sum += x[i];
    }
    ave = round(double(sum/n));
    for(int i = 0; i < n; ++i){
        ans += (ave - x[i]) * (ave - x[i]);
    }
    cout << ans << "\n";

    return 0;
}


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

int main() {
    int N;
    cin >> N;
    long long A[N][3];
    for(int i=0; i<N; i++)
        for(int j=0; j<3; j++)
            cin >> A[i][j];

    long long c[N][3];
    for(int i=0; i<N; i++)
        for(int j=0; j<3; j++)
            c[i][j] = A[i][j];
    for(int i=N-2; i>=0; i--) {
        for(int j=0; j<3; j++) {
            int mx = 0;
            for(int k=0; k<3; k++) {
                if(k != j && mx < (c[i][j] + c[i+1][k])) {
                    mx = (c[i][j] + c[i+1][k]);
                }
            }
            c[i][j] = mx;
        }
    }
    long long mm =  max(c[0][0], c[0][1]);
    cout << max(mm,  c[0][2]);


    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define MAX 500005
#define BMAX 250005
#define INFI 2100000000
int cnt = 0;
int S[MAX];
int L[BMAX], R[BMAX];

void Merge(int left, int mid, int right){
    int n1 = mid-left;
    int n2 = right-mid;
    for(int i=0;i<n1;i++){
        L[i] = S[left+i];
    }
    for(int i=0;i<n2;i++){
        R[i] = S[mid+i];
    }
    L[n1] = INFI;
    R[n2] = INFI;
    int i=0,j=0;
    for(int k=0;k<n1+n2;++k){
        cnt++;
        if(L[i]<=R[j]){
            S[left+k] = L[i];
            i++;
        }
        else{
            S[left+k] = R[j];
            j++;
        }
    }
}

void MergeSort(int left, int right){
    if(left+1 < right){
        int mid = (left+right)/2;
        MergeSort(left,mid);
        MergeSort(mid,right);
        Merge(left,mid,right);
    }
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;++i) scanf("%d",&S[i]);
    MergeSort(0,n);
    for(int i=0;i<n-1;++i){
        printf("%d ",S[i]);
    }
    printf("%d\n",S[n-1]);
    printf("%d\n",cnt);
    return 0;

}



Measured memory_bytes: 7024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    string s, res = "";
    cin >> s;
    for (auto el: s) {
        if (el != 'B') res += el;
        else if (!res.empty()) res.pop_back();
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

vector<ll> factorial(ll n)
{
	vector<ll> v(n+1, 0);
	for (ll i = 2; i*i <= n; ++i)
		while (n%i==0) {++v[i];n/=i;};

	return v;
}

int main(int argc, char **argv)
{
	ll N; cin >> N;

	ll res{0};

	for (ll n = 1; n <= N; ++n)
	{
		if (n % 2 == 0) continue;
		ll tmp{0};
		for (ll i = 1; i <= n; ++i)
		{
			if (n % i == 0) ++tmp;
		}
		if (tmp == 8) ++res;
	}
	std::cout << res << std::endl;
}


Measured memory_bytes: 256
n=int(input())
if n%2==0:
  m=(n**2-2*n)//2
  print(m)
  for i in range(1,n+1):
    for j in range(i,n+1):
      if j == i or j== n+1-i:continue
      print(i,j)
else:
  m=n-1+((n-1)**2-(n-1)*2)//2
  print(m)
  for i in range(1,n):
    for j in range(i+1,n+1):
      if j == n-i: continue
      print(i,j)

Measured memory_bytes: 3612
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int x;
	scanf("%d", &x);
	int y = x / 100, z = x % 100;
	printf("%d\n", y * 5 >= z);

	Please AC;
}


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

int main(void)
{
  int N, K;

  scanf("%d%d", &N, &K);
  if (N == K || K == 1) {
    printf("0\n");
    return 0;
  }
  N -= K;
  printf("%d\n", N);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define lll __int128
#define lp(i, a, b) for (int i = a; i < b; i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 1e9
#define INFL 1e18
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vl vector<ll>
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define pii pair<int, int>
#define pb push_back
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);

int main() {
	fast_io;
	int n,m; cin>>n>>m;
	vi v(n); in(v);
	sort(all(v));
	bool is=true;
	int total=0;
	lp(i,0,n)
		total+=v[i];
	for(int pos=n-1,cnt=m;pos>=0 && cnt>0;pos--,cnt--){
		if(v[pos]<(total/(4.0*m))){
			is=false;
			break;
		}
	}
	if(is)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>

#define max 100005 

using namespace std;

int n,m,timer;
bool visited[max];
int prenum[max],parent[max],lowest[max];
vector<int> G[max];
set<int> S;

void dfs(int current, int prev) {
	prenum[current]=lowest[current]=timer;
	timer++;
	visited[current]=true;
	
	int next,i;
	
	for(i=0;i<G[current].size();i++) {
		next=G[current][i];
		if(visited[next]==false) {
			parent[next]=current;
			
			dfs(next,current);
			
			lowest[current]=min(lowest[current],lowest[next]);
		} else if(next!=prev) {
			lowest[current]=min(lowest[current],prenum[next]);
		}
	}
}

void art_Points() {
	int i;
	for(i=0;i<n;i++) {
		visited[i]=false;
	}
	timer=1;
	
	dfs(0,-1);
	
	int np=0;
	
	for(i=1;i<n;i++) {
		int p=parent[i];
		if(p==0) np++;
		else if(prenum[p]<=lowest[i]) S.insert(p);
	}
	if(np>=2) S.insert(0);
	for(set<int>::iterator it=S.begin();it!=S.end();it++) {
		cout<<*it<<endl;
	}
}

int main() {
	int i,d1,d2;
	
	scanf("%d %d",&n,&m);
	
	for(i=0;i<m;i++) {
		scanf("%d %d",&d1,&d2);
		G[d1].push_back(d2);
		G[d2].push_back(d1);
	}
	
	art_Points();
	
	return 0;
}


Measured memory_bytes: 6984
#include<cstdio>
#include<algorithm>
using namespace std;
int n, m;
int w[5100][210];
long long S[5100], A[5100];
struct AA {
	int st[5100][2];
	int top;
	void Put(int num, int x) {
		int prev = 0;
		while (top && st[top][0] <= x){
			S[st[top][1]] -= st[top][0] - prev;
			prev = st[top][0];
			top--;
		}
		if (top)S[st[top][1]] += prev - x;
		top++;
		st[top][0] = x, st[top][1] = num, S[num] += x;
	}
}T[210];
int main() {
	int i, j;
	scanf("%d%d", &n, &m);
	for (i = 1; i < n; i++)scanf("%lld", &A[i]);
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= m; j++) {
			scanf("%d", &w[i][j]);
		}
	}
	long long res = 0;
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= m; j++) {
			T[j].Put(i, w[i][j]);
		}
		long long s = 0;
		for (j = i; j >= 1; j--) {
			s += S[j];
			res = max(res, s);
			s-=A[j - 1];
		}
	}
	printf("%lld\n", res);
}

Measured memory_bytes: 10880
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    string s;
    cin >> s;
    if ((s[2] == s[3]) and (s[4] == s[5]))
    {
        Yes(1);
    }
    else
    {
        Yes(0);
    }
}

Measured memory_bytes: 256
#include<cstdio>
using ull = unsigned long long;

int main(){
    ull S;
    scanf("%llu", &S);
	ull ok = 1e9;//解が存在する値
	ull ng = 0;//解が存在しない値
	while(ok - ng > 1){
		ull mid = ok + ng >> 1;
		if(mid*mid >= S) ok = mid;
		else ng = mid;
	}
    ull a = ok, d = ok;
    if(a*(d-1) >= S) d--;
    printf("0 0 %llu %llu 1 %llu\n", a, a*d - S, d);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define repi(m, itr) for (auto itr = m.begin();itr != m.end();++itr)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// 
int N;
string W[110];
string ans = "Yes";

int main(){
    cin >> N;
    rep(i, 0, N){
        cin >> W[i];
        rep(j, 0, i){
            if(W[j] == W[i]){
                ans = "No";
            }
        }
    }
    
    rep(i, 1, N){
        if(W[i-1].back() != W[i].front()){
            ans = "No";
        }
    }

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




Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, _begin, _end) for (__typeof(_end) end = _end, begin = _begin,  i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0, _len = (end); i < (_len); i += 1)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define readint ({int t;cin >> t;t;})
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class ATOrT {
public:

void solve(std::istream& cin, std::ostream& cout) {
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(N*A, B) << endl;
}


};


#undef int
int main() {
	ATOrT solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	in.tie(0); ios::sync_with_stdio(0); out<<fixed<<setprecision(20);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
long long n,k;
long long a,b,c;
long long ans=0;
int main()
{
    scanf("%lld%lld",&n,&k);
        long long now=n/k;
        ans+=now*now*now;
        if(k%2==0){
        now=(n+(k/2))/k;
                ans+=now*now*now;}
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pp push_back
#define fr first
#define sc second

using namespace std;

ll n;
pair<ll,ll>a[2002];
ll dp[2002][2020];
ll solve(int i,int j){
    if(i > n)return 0;
    ll &ret = dp[i][j];
    if(ret + 1)return ret;
    ret = 0;
    ll v = a[i].fr;
    ll d1 = abs(a[i].sc - j);
    ll d2 = abs(a[i].sc - (n - (i - j)));
    ret = max(ret , solve(i + 1 , j) + d2 * v);
    ret = max(ret , solve(i + 1 , j + 1) + d1 * v);
    return ret;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0) ,cout.tie(0);
    memset(dp,-1,sizeof dp);
    cin >> n;
    for(int i = 1;i <= n;i++)
        cin >> a[i].fr , a[i].sc = i;
    sort(a + 1 , a + n + 1);
    reverse(a + 1 , a + n + 1);
    cout << solve(1,1) << '\n';
    return 0;
}


Measured memory_bytes: 35396
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>

int main() {

        int n;
        std::cin >> n;
        if (n % 2 == 0) {
                std::cout << n << std::endl;
        }
        else {
                std::cout << 2 * n << std::endl;
        }
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    string s;
    cin>>s;
    int ans=0;
    string ans1,ans2;
    rep(i,s.length()){
        if(s[i]!=s[s.length()-i-1])ans++;
    }
  cout<<ans/2<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;

int main(){

    int h,w,k;
    cin >> h >> w >> k;

    vector<vector<char>> c(h,vector<char>(w));

    rep(i,h){
        rep(j,w){
            cin >> c[i][j];
        }
    }

    int ans = 0;

    for(int bit1 = 0; bit1 < (1 << h); bit1++){

        for(int bit2 = 0; bit2 < (1 << w); bit2++){
            int cnt = 0;

            for(int i = 0; i < h; i++){
                
                for(int j = 0; j < w; j++){
                    if((bit1 >> i & 1) == 1 && (bit2 >> j & 1) == 1 && c[i][j] == '#')cnt++;
                }
            }
            if(cnt == k)ans++;

        }


    }

    cout << ans << endl;


    

}

Measured memory_bytes: 3580
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  int a[N];
  REP(i,N)cin>>a[i];
  int M=0;
  int ans[N];
  REP(i,N)ans[i]=0;
  for(int i=N;i>0;i--){
    int temp=0;
    for(int j=2;i*j<=N;j++){
      temp+=ans[i*j-1];
    }
    temp%=2;
    if(a[i-1]!=temp){
      ans[i-1]=1;
      M++;
    }
  }
  cout<<M<<endl;
  REP(i,N){
    if(ans[i])cout<<i+1<<" ";
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 2432
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define IOS ios::sync_with_stdio(false),cin.tie(0)
using namespace std;
typedef long long ll;


int main() {
	IOS;
	ll n, a, b;
	cin >> n >> a >> b;

	
	if (n == 1) {
		if (a == b)cout << 1 << endl;
		else cout << 0 << endl;
	}
	else {
		if (a > b)cout << 0 << endl;
		else cout << (n - 2)*(b - a) + 1 << endl;
	}
}


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


int main() {
  int n;
  cin >> n ;
  
  
  vector<int>vec(n);
  for(int i=0;i<n;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  
  int sum=0;
  for(int i=0;i<n-1;i++){
    sum+=vec.at(i);
  }
  
  if(sum>vec.at(n-1)){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main()
{
	int n,k,h[100000];
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>h[i];
	
	sort(h,h+n,greater<int>());
	
	int v;
	for(v=0;h[v]>=k;v++);
	
	cout<<v<<endl;
	
	return 0;
}


Measured memory_bytes: 640
//code by PARTH_4399 for competitive programming
#include<bits/stdc++.h>
using namespace std;
#define l long // -2^31 to +2^31-1 (upper limit ~ 2*(10^9))
#define ul unsigned long // 0 to +2^32-1
#define ll long long // -2^63 to +2^63-1 (upper limit ~ 9*(10^18))
#define ull unsigned long long // 0 to +2^64-1
#define mod(x, m) ((((x)%(m))+(m))%(m))
#define vi vector<int>
#define pi pair<int,int>
#define F first
#define S second
#define PB push_back
#define MP make_pair
//const double pi=acos(-1.0); // cout<<fixed<<setprecision(n)<<pi; - for n decimal digits, use <iomanip.h>
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//code
	ll int n,i,f=0,max=0;
	cin>>n;
	ll int a[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(i=1;i<n;i++)
	{
		if(a[i]<=a[i-1])
		a[i-1]--;
		if(a[i]<a[i-1])
		{
			f=1;
			break;
		}
		if(a[i-1]>max)
		max=a[i-1];
		if(a[i]<max)
		{
			f=1;
			break;
		}
	}
	if(f==1)
	cout<<"No";
	else
	cout<<"Yes";
	return 0;
}

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

using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    int sum=0;
    vector<int> hoge(n);
    int cnt=0;
    
    for(int i=0;i<n;i++){
        cin>>hoge.at(i);
        sum+=hoge.at(i);
    }
    
    for(auto a:hoge){
        if((double)a>=(double)sum/((double)m*4)) cnt++;
    }
    
    if(cnt>=m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 256