akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;

typedef long long ll;

#define sz(v) (int)v.size()

void PLAY() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(10);
}

const int MAX = 2e5 + 100;

vector<int> adj[MAX];
int cnt;
bool vis[MAX];
void dfs(int node) {
	if (vis[node])
		return;
	vis[node] = true;
	cnt++;
	for (auto e : adj[node])
		dfs(e);
}


int main() {
	PLAY();


	int n, m;
	cin >> n >> m;
	set<pair<int, int>> st;
	while (m--) {
		int u, v;
		cin >> u >> v;
		if (u > v) swap(u, v);
		if (st.count({ u, v })) continue;
		st.insert({ u, v });
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	int res = 0;
	for (int i = 1; i <= n; i++) {
		if (!vis[i]) {
			cnt = 0;
			dfs(i);
			res = max(res, cnt);
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 30344
def encode(n):
    ns = []
    mcxi = ['m','c','x','i']
    v = 1000
    for i in range(4):
        m = 0
        while n >= v:
            n -= v
            m += 1
        v = int(v/10)
        if m > 0:
            ns.append(str(m)+mcxi[i])
    return ''.join(ns).replace('1','')

def decode(s):
    coe = 1
    n = 0
    for c in s:
        if c in map(str, range(2,10)):
            coe = int(c)
        elif c == 'm':
            n += coe * 1000
            coe = 1
        elif c == 'c':
            n += coe * 100
            coe = 1
        elif c == 'x':
            n += coe * 10
            coe = 1
        elif c == 'i':
            n += coe * 1
            coe = 1
    return n

n = int(input())
for i in range(n):
    ns = input().split()
    s = decode(ns[0]) + decode(ns[1])
    print(encode(s))

Measured memory_bytes: 6752
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
  		
      	String s = sc.next();
      	List<Character> ss = new ArrayList<Character>();
      	int count = 0;
      
      	for(int i = 0;i < s.length();i++){
          	ss.add(s.charAt(i));
        }
      	
      	for(int i = 0; i < ss.size()-1;i++){
          if(ss.get(i) != ss.get(i+1)){
          	ss.remove(i);
            ss.remove(i);
            count += 2;
             
            if(i-2 >= -1) i -= 2;
            else i -=1;
          }
        }
          
        System.out.println(count);
	}
}


Measured memory_bytes: 40680
#include <bits/stdc++.h>
using namespace std;
int a[100001],f[100001];
int main()
{
        int i,j,n,k,m=INT_MAX,flag=0,flag1=0;
        scanf("%d %d",&n,&k);
        for(i=1;i<=n;i++)
        {
                scanf("%d",&a[i]);
                m=min(m,a[i]);
        }
        for(i=m;i<=k;i++)
        {
                f[i]=0;
                for(j=1;j<=n;j++)
                {
                        if((i-a[j])<0)
                                continue;
                        if(f[i-a[j]]==0)
                                f[i]=1;
                }
        }
        if(f[k]==1)
                printf("First");
        else
                printf("Second");
        return 0;
}

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


#define     SPEED       ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	ll          long long int
#define 	pb          push_back
#define 	pii         pair<int,int>
#define 	vi          vector<int>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(i=0;i<n;i++)
#define 	repe(i,a,b) for(i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search
#define 	mp          make_pair

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

ll dp[100005][3],a[100105][3],n,k;

ll f(ll x,ll p)
{
	if(x>=n)
		return 0;
	if(dp[x][p]==-1)
	{
		ll i;
		rep(i,3)
		{
			if(i==p)
				continue;
			dp[x][p]=max(f(x+1,i)+a[x][i], dp[x][p]);
		}
	}
	// cout<<x<<"&&^"<<p<<dp[x][p]<<"%^\n";
	return dp[x][p];
}


int main()
{
	SPEED;
	ll t,c=0,i,j,m,cs=0;
	t=1;

	//cin>>t;
	string s;
	while(t--)
	{
		cin>>n;
		// n=s.length();
		rep(i,n)
		{
			cin>>a[i][0]>>a[i][1]>>a[i][2];
			dp[i][0]=-1;
			dp[i][1]=-1;
			dp[i][2]=-1;

		}
		// dp[0]=0;
		// repe(i,1,n)
		// {
		// 	dp[i]=1e18;
		// 	for (j = 1;  j<=k && i-j>=0 ; ++j)
		// 	{
		// 		dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]), dp[i]);
		// 	}
		// 	// cout<<i<<"&(*"<<dp[i]<<"&\n";
		// }
		c=max(f(1,0)+a[0][0],f(1,1)+a[0][1]);
		cout<<max(c,f(1,2)+a[0][2]);
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )
#define SORT(x) sort(x.begin(), x.end())

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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


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

    int N; cin >> N;
    string s; cin >> s;
    int r = 0, b = 0;
    rep(i, N) {
        if(s[i] == 'R') r++;
        else b++;
    }

    if(r > b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

using namespace std;

const int mod = 1e9 + 7;

using int64 = long long;
const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

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


int main() {
  int64 A, B;
  cin >> A >> B;
  cout << prime_factor(__gcd(A, B)).size() + 1 << endl;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
  val (N, K) = readInts()
  println(if (N % K == 0) 0 else 1)
}

fun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)
fun gcd(a: Long, b: Long): Long = if (a < b) gcd(b, a) else if (b == 0L) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)
fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }


Measured memory_bytes: 37856
/*
    CP Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* Shortcuts */
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(), x.end()
#define VAL(x) cout << #x << ": " << (x) << endl;
#define LOG(x) cout << (x) << endl;
#define SZ(x) (int)(x.size())
#define REP(i, a, b) for(int i = a; i < b; i++)

/* typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, k;
    cin>>n>>k;
    vi ht;
    int h;
    REP(i,0,n){
        cin>>h;
        ht.PB(h);
    }

    vi dp(n, 1000000005);

    dp[n-1] = 0;

    for(int i = n-1; i >= 0; i--){
        for(int j = i - 1; j >= 0 && j >= i - k; j--){
            dp[j] = min(dp[j], abs(ht[i] - ht[j]) + dp[i]);
        }
    }

    LOG(dp[0]); 


    return 0;
}


Measured memory_bytes: 1144
n = gets.to_i
h = gets.split.map(&:to_i)
i = 0; count = 0; tmp = 0; ans = 0;
loop do
  if tmp >= h[i]
    count += 1
  else
    ans = count if count > ans
    count = 0
  end
  tmp = h[i];
  if i == n-1
    ans = count if count > ans
    break
  end
  i += 1
end
puts ans

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

int main() {
  int n;
  cin >> n;
  int a[n];
  int b[n];
  int ans=0;
  int max;
  int max_second;

  for (int i=0;i<n;i++){
    cin >> a[i];
    b[i]=a[i];
  }
  std::sort(b,b+n,greater<int>());
  max=b[0];
  max_second=b[1];

  for(int i=0;i<n;i++){
    int ans=b[0];
    if(b[0]==a[i]) ans=b[1];
    cout << ans <<endl;
  }



  return 0;
}

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

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

  cout << b * (t / a) << endl;
  return 0;
}


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

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

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,n,s) for(int i=(int)(s);i<(int)(n);++i)
#define RREP(i,n,s) for(int i=(int)(s);i>=(int)(n);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int n; cin >> n;
    if (n < 1000) {
        cout << "ABC" << endl;
    } else {
        cout << "ABD" << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,n,f=0;scanf("%d",&n);
  long long a;
  for(i=0;i<n;i++){
    scanf("%lld",&a);
    if(a%2==1)f=1;
  }
  if(f==0)puts("second");
  else puts("first");
  return 0;
}

Measured memory_bytes: 128
N=int(input())

xy = [list(map(int,input().split()))for i in range(N)]
res = 0
for i in range(N):
    for j in range(N):
        res = res + ((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2)**(1/2)

print(res/N)

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

using namespace std;


int main(void)
{
    const vector<int> l = {
        1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
        1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
    };

    int k;
    cin >> k;
    cout << l[k - 1] << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 200007
char s[MAXN];
int cnt=0;
int mo1=0, mo2=0;
inline int qpow(int a, int b, int p) {
	int ans=1;
	for(;b;b>>=1) {
		if(b&1) ans = (long long)ans*a%p;
		a=(long long)a*a%p;
	}
	return ans;
}
inline int popcnt(int x) {
	x=(x&0x55555555)+((x>>1)&0x55555555);
	x=(x&0x33333333)+((x>>2)&0x33333333);
	x=(x&0x0f0f0f0f)+((x>>4)&0x0f0f0f0f);
	x=(x&0x00ff00ff)+((x>>8)&0x00ff00ff);
	x=(x&0x0000ffff)+((x>>16)&0x0000ffff);
	return x;
}
int main() {
	int n; scanf("%d", &n);
	scanf("%s", s);
	for(int i=0; i<n; i++) {
		if(s[i]=='1') cnt++;
	}
	for(int i=0; i<n; i++) {
		mo1=(mo1*2+(s[i]-'0'))%(cnt+1);
	}
	if(cnt>1) {
		for(int i=0; i<n; i++)
		mo2=(mo2*2+(s[i]-'0'))%(cnt-1);
	}
	for(int i=0; i<n; i++) {
		int now;
		if(s[i]=='0') {
			now=(mo1+qpow(2,n-i-1,cnt+1))%(cnt+1);
		} else {
			if(cnt==1) {puts("0"); continue;}
			now=(mo2-qpow(2,n-i-1,cnt-1)+cnt-1)%(cnt-1);
		}
		int f=1;
		while(now>0) {
			now = now%popcnt(now);
			f++;
		}
		printf("%d\n", f);
	}
}


Measured memory_bytes: 1924
#include <algorithm>
#include <iostream>
#include <limits>
#include <vector>
using namespace std;


typedef int T; // cost type
typedef int U; // flow type

T INF = numeric_limits<T>::max(); // <limits>

struct edge {
    int to, rev;
    T cost;
    U cap;
    edge(int to, U cap, int rev, T cost) : to(to), rev(rev), cost(cost), cap(cap) {}
};

struct primal_dual {
    int N;
    vector<vector<edge> > graph;
    vector<int> prev_v, prev_e;
    vector<T> min_cost;

    primal_dual() {}
    primal_dual(int _N) { init(_N); }

    void init(int _N) {
        N = _N;
        graph.resize(N);
        prev_v.resize(N);
        prev_e.resize(N);
        min_cost.resize(N);
    }

    void add_edge(int u, int v, U cap, T cost) {
        graph[u].push_back(edge(v, cap, graph[v].size(), cost));
        graph[v].push_back(edge(u, 0, graph[u].size()-1, -cost));
    }

    T min_cost_flow(int s, int t, U F) {
        T val = 0;
        while (F > 0) {
            fill(min_cost.begin(), min_cost.end(), INF);
            min_cost[s] = 0;

            bool updated = true;
            while (updated) {
                updated = false;
                for (int v = 0; v < N; ++v) {
                    if (min_cost[v] == INF) continue;
                    for (int j = 0; j < graph[v].size(); ++j) {
                        edge& e = graph[v][j];
                        T cost = min_cost[v] + e.cost;
                        if (cost < min_cost[e.to] && e.cap > 0) {
                            updated = true;
                            min_cost[e.to] = cost;
                            prev_v[e.to] = v;
                            prev_e[e.to] = j;
                        }
                    }
                }
            }

            if (min_cost[t] == INF) {
                return (T)-1; // fail
            }

            U f = F;
            for (int v = t; v != s; v = prev_v[v]) {
                f = min(f, graph[prev_v[v]][prev_e[v]].cap);
            }

            F -= f;

            val += (T)f * min_cost[t];

            for (int v = t; v != s; v = prev_v[v]) {
                edge& e = graph[prev_v[v]][prev_e[v]];
                e.cap -= f;
                graph[v][e.rev].cap += f;
            }

        }
        return val;
    }
};

int V, E, F;
primal_dual pd;

int main() {
    cin >> V >> E >> F;
    pd.init(V);
    for (int j = 0; j < E; ++j) {
        int u, v, c, d;
        cin >> u >> v >> c >> d;
        pd.add_edge(u, v, c, d);
    }

    cout << pd.min_cost_flow(0, V-1, F) << endl;
    return 0;
}

Measured memory_bytes: 3164
/*I wanna be the very best, like no one ever was...*/

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

ll power(ll a, ll n){
    int res=1;
    while(n){
        if(n%2==1)
            res=(res*a)%MOD;
        a=(a*a)%MOD;

        n=n/2;
    }
    return res;
}
ll inv(ll x) {
    return power(x,MOD-2);
}


ll c(ll n , ll r){
    ll up=1;
    ll down = 1;
    r = min(r, n-r);
    for(int i=0;i<r;i++){
        up=(up*(n-i))%MOD;
        down=(down*(i+1))%MOD;
    }
    return up*inv(down)%MOD;
}


int main() {
    io;
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
    ll n, a,b;
    cin>>n>>a>>b;
	ll ans=(power(2,n)-c(n,a)-c(n,b)-1)%MOD;
    cout<<(ans+MOD)%MOD;

 
 
 
    
 
    return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)
 
def ok(s):
    n = len(s)
    for i in range(n//2):
        if s[i] != s[n-1-i]:
            return False
    return True
 
if ok(s) and ok(s[:n//2]) and ok(s[n//2+1:]):
        print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>
#define MAXN 100000

using namespace std;
int a[MAXN+80];
int main()
{
	int i,j,n,L;
	scanf("%d%d",&n,&L);
	for(i=1;i<=n;i++)
		scanf("%d",a+i);
	for(i=1;i<n&&a[i]+a[i+1]<L;i++);
	if(i==n)
	{
		printf("Impossible\n");
		return 0;
	}
	puts("Possible");
	for(j=1;j<i;j++)
		printf("%d\n",j);
	for(j=n-1;j>i;j--)
		printf("%d\n",j);
	printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 1152
A = list(map(int, input().split()))
A1 = A.count(1)
A9 = A.count(9)
A7 = A.count(7)
A4 = A.count(4)
if A1 == A9 == A7 == A4 == 1:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
// Aizu Vol0 0061: Rank Checker
// 2017.7.30

#include <stdio.h>
#include <stdlib.h>

#define MAX 100

typedef struct { int p, s, r; } TERM;

TERM term[MAX + 5];
int rank[MAX + 5];

int main()
{
	int i, j, k;
	int p, s;
	int max;
	
	for (i = 1; i <= MAX; i++) term[i].p = i, term[i].s = 0;
	max = 0;
	while (1) {
		scanf("%d,%d", &p, &s);
		if (p == 0) break;
		if (p > max) max = p;
		term[p].s += s;
	}
	for (i = 1; i < max; i++) {
		k = i;
		for (j = i + 1; j <= max; j++) {
			if (term[j].s > term[k].s) k = j;
		}
		if (k != i) {
			p = term[i].p, term[i].p = term[k].p, term[k].p = p;
			s = term[i].s, term[i].s = term[k].s, term[k].s = s;
		}
	}
	term[1].r = 1;
	for (i = 2; i <= max; i++) {
		if (term[i].s == term[i-1].s) term[i].r = term[i-1].r;
		else term[i].r = term[i-1].r + 1;
	}
	for (i = 1; i <= max; i++) rank[term[i].p] = term[i].r;

	while (scanf("%d", &p) == 1) {
		printf("%d\n", rank[p]);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    ll N, T;
    cin >> N >> T;
    // vector<ll> v(N);
    ll res = 0;
    ll t; cin >> t;
    rep(i, 1, N)
    {
        ll t2; 
        cin >> t2;
        res += min(T, t2 - t);
        t = t2;
    }
    cout << res + T;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdlib>
#include<cmath>
using namespace std;
int main(){
  int N; cin>>N;
  int P=0;
  vector<vector<int>> S(N,vector<int>(2));
  for(int i=0; i<N; i++){
    for(int j=0;j<2; j++){
      cin>>S.at(i).at(j);
    }
    P+=(S.at(i).at(1)-S.at(i).at(0)+1);
  }
  cout<<P<<endl;
}
      


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N) 
  {
    cin >> A[i];
  }
  ll tate = 0;
  ll yoko = 0;
  ll ans = 0;
  sort(RALL(A));
  rep(i,N-3)
  {
    if(A[i]==A[i+1])
    {
      if(A[i]==A[i+2]&&A[i]==A[i+3]&&tate==0)
      {
        ans = A[i]*A[i];
        cout << ans << endl;
        return 0;
      }
      else if(tate==0)
      {
        tate = A[i];
        A[i+1] = -1;
        A[i] = -1;
      }
      else
      {
        yoko = A[i];
        ans = tate * yoko;
        cout << ans << endl;
        return 0;
      }
      
    }
  }
  if(yoko==0&&A[N-2]==A[N-1])
  {
    yoko = A[N-2];
    ans = tate * yoko;
    cout << ans << endl;
    return 0;
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 4032
from itertools import product


def main():
    A = int(input())
    B = int(input())
    C = int(input())
    X = int(input())

    coins_500 = range(A+1)
    coins_100 = range(B+1)
    coins_50 = range(C+1)

    ans = 0
    for c in product(coins_500, coins_100, coins_50):
        if c[0]*500+c[1]*100+c[2]*50 == X:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import sys
S = input()
N = len(S)

if S == S[::-1]:
    if S[0:(N-1)//2] == S[0:(N-1)//2][::-1]:
        if S[((N+3)//2)-1:N] == S[((N+3)//2)-1:N][::-1]:
            print("Yes")
            sys.exit()


print("No")

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		int k = sc.nextInt()-1;
		int b = sc.nextInt()-1;

		out.println(k*b);
		out.flush();

	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 20692
#include <algorithm>
#include <cstdio>

// Perform cycle decomposition of the original array regarded as a permutation.
// Let
//   cycle length: l
//   cycle members: x1,...,xl
//   cycle minimum: m
//   global minimum: M
// Repositioning the elements of a cycle takes either
//   (x1 + ... + xl - m) + m * (l - 1) (swapping within the cycle) or
//   (x1 + ... + xl - m) + M * (l - 1) + 2 * (m + M) (swapping using the global minimum)
// Take the smaller of the two.

static const size_t n_max = 1000;
static std::pair<int, size_t> A[n_max];
static size_t C[n_max];
static bool visited[n_max];

int main() {
  size_t n;
  scanf("%zu\n", &n);
  for (size_t i = 0; i < n; i++) {
    scanf("%d", &A[i].first);
    A[i].second = i;
  }
  std::sort(A, A + n);
  int M = A[0].first;
  int cost = 0;
  for (size_t i = 0; i < n; i++) {
    if (visited[i])
      continue;
    visited[i] = true;
    C[0] = i;
    size_t l = 1;
    auto m = A[i].first, s = A[i].first;
    while (!visited[A[C[l-1]].second]) {
      C[l] = A[C[l-1]].second;
      visited[C[l]] = true;
      m = std::min(m, A[C[l]].first);
      s += A[C[l]].first;
      l++;
    }
    if (l == 1)
      continue;
    cost += std::min((s - m) + m * (l - 1), (s - m) + M * (l - 1) + 2 * (m + M));
  }
  printf("%d\n", cost);
  return 0;
}

Measured memory_bytes: 2716
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <tuple>
#include <vector>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end())
            cout << " ";
    }
    cout << endl;
}

int gcd(int x, int y) {
    int tmp;
    if(x > y)
        return gcd(y, x);
    int r;
    while((r = x % y)) {
        x = y;
        y = r;
    }
    return y;
}

bool isPrime(int n) {
    if(n < 2)
        return false;
    else if(n == 2)
        return true;
    else if(n % 2 == 0)
        return false;
    double sq = sqrt(n);
    for(int i = 3; i <= sq; i += 2) {
        if(n % i == 0)
            return false;
    }
    return true;
}

int main() {
    int N;
    cin >> N;
    int a, co = 0;

    rep(i, N) {
        cin >> a;
        if(isPrime(a))
            co++;
    }
    cout << co << endl;
}



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

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

    int diff = S.size() - T.size();
    int ans = T.size();
    for(int i = 0; i <= diff; i++) {
        int change = 0;
        for(int j = 0; j < T.size(); j++) {
            if(S.at(j + i) != T.at(j)) {
                change++;
            }
        }
        ans = min(ans, change);
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
    int n, count = 0;
    string s;
    cin >> n >> s;
    for(int i = 2; i < n; i++) {
        if(s[i - 2] == 'A' && s[i - 1] == 'B' && s[i] == 'C') count++;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        List<Work> work = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int time = Integer.parseInt(sc.next());
            int limit = Integer.parseInt(sc.next());
            work.add(new Work(time, limit));
        }
        sc.close();
        work.sort(Comparator.comparingInt(x -> x.limit));
        int ans = 0;
        for (int i = 0; i < n; i++) {
            ans += work.get(i).time;
            if (ans > work.get(i).limit) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }

    static class Work {
        int time;
        int limit;

        Work(int time, int limit) {
            this.time = time;
            this.limit = limit;
        }
    }
}

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

using namespace std;

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

    vector<int> C(N);                          // 0-index
    vector<vector<int>> A(N, vector<int>(M));  // 0-index

    for (int i = 0; i < N; i++) {
        cin >> C.at(i);
        for (int j = 0; j < M; j++) {
            cin >> A.at(i).at(j);
        }
    }

    // 考え方メモ
    // 今度こそbit全探索だ！！！
    // C.at(i)を買うか買わないかを1or0フラグとして考える

    vector<int> understandingLevel(M, 0);

    int minOfPrice = 10000000;  // 最大値は10^5 * 12 -> 10^7でおく
    for (int bits = 0; bits < (1 << (int)C.size()); bits++) {
        int sum = 0;
        understandingLevel.assign(M, 0);
        for (int i = 0; i < (int)C.size(); i++) {
            int mask = 1 << i;
            if (bits & mask) {  // i番目のbitが立っていれば加算する
                sum += C.at(i);
                for (int j = 0; j < M; j++) {
                    understandingLevel.at(j) += A.at(i).at(j);
                }
            }
        }

        // for (int j = 0; j < M; j++) {
        //     cout << understandingLevel.at(j) << endl;
        // }
        // cout << sum << endl;
        // cout << bitset<4>(bits) << endl;
        // cout << endl;

        int numOfUnderstandingOver10 = 0;
        for (int j = 0; j < M; j++) {
            if (understandingLevel.at(j) >= X) {
                numOfUnderstandingOver10++;
            }
        }
        if (numOfUnderstandingOver10 == M) {
            minOfPrice = min(minOfPrice, sum);
        }
    }

    if (minOfPrice == 10000000) {
        cout << -1 << endl;
    } else {
        cout << minOfPrice << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
const lli INF = 1e18L + 5;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


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

    vector<vector<int>> c(m + 1, vector<int>(n + 1, 0));
    vector<vector<char>> b(m + 1, vector<char>(n + 1, 'a'));

    for (int i = 1; i <= m; ++i)
    {
        for (int j = 1 ; j <= n; ++j){
            if(s[i-1]==t[j-1]){
                c[i][j] = c[i-1][j-1] + 1;
                b[i][j] = 'd';
            }
            else if(c[i-1][j] >= c[i][j-1]){
                c[i][j] = c[i-1][j];
                b[i][j] = 'u';
            }
            else{
                c[i][j] = c[i][j-1];
                b[i][j] = 'l';
            }
        }
    }
    // cout << m << n;

    // for (int i = 0; i <= m; ++i)
    // {
    //     for (int j = 0 ; j <= n; ++j){
    //         cout << b[i][j]<< " ";
    //     }cout << endl;
    //     }

    int i = m , j = n;
    string ans;
    
    while(i&&j){
        if(b[i][j] == 'd')
        ans.insert(ans.begin(),s[i-1]);

        if(b[i][j] == 'd') --i,--j;
        else if( b[i][j] == 'u') --i;
        else --j;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 44544
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

vector<vector<int>> adj;
vector<vector<int> >lol;
int vis[100005];
int parent[1000005];
int ans[1000004];

void dfs(int ver,int dest)
{
    parent[ver]=dest;
    ans[dest]++;
    vis[ver]=1;
    for(auto i:adj[ver])
    {
        if(!vis[i])
        {
            dfs(i,dest);
        }
    }
}

signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n,m,k;
    cin>>n>>m>>k;
    adj.resize(n+1);
    lol.resize(n+1);
    int x,y;
    
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }   

    for(int i=0;i<k;i++)
    {
        cin>>x>>y;
        lol[x].push_back(y);
        lol[y].push_back(x);
    }   
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            dfs(i,i);
        }
    }

    for(int i=1;i<=n;i++)
    {
        int cnt=ans[parent[i]];
        cnt-=adj[i].size();
        for(auto j:lol[i])
        {
            if(parent[j]==parent[i])
                cnt--;
        }
        cout<<cnt-1<<" ";
    }


} 



Measured memory_bytes: 20096
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];
    ll ans = 1ll<<60;
    for (int x = -100; x <= 100; x++) {
        ll sum = 0;
        for (int i = 0; i < N; i++) {
            ll d = x - A[i];
            sum += d*d;
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    int M;
    Scd(M);
    N = 1<<M;
    multiset<int,greater<int>> s;
    Rep(i,N){
        int a;
        Scd(a);
        s.insert(a);
    }


    priority_queue<pii> sl;
    sl.push({M,*s.begin()});
    s.erase(s.begin());

    int si = 1;
    while( sl.size() ){
        pii a = sl.top();
        sl.pop();
        if( a.first == 0 ) continue;
        a.first--;

        auto to = s.lower_bound(a.second-1);
        if( to == s.end() ) {
            printf ("No\n");
            return 0;
        }

        pii b = {a.first,*to};
        s.erase(to);
        // printf ("%d,%d -> ", a.first, a.second );
        // printf ("%d,%d\n", b.first, b.second );
        sl.push(a);
        sl.push(b);
    }

    printf ("Yes\n");


    return 0;
}





Measured memory_bytes: 15736
n = int(input())
v = list(map(int,input().split()))

set_even = set(v[0::2]) 
set_odd = set(v[1::2]) 
dic_even={i:0 for i in set_even}
dic_odd={i:0 for i in set_odd}

for i in range(n):
  if i%2==0:
    dic_even[v[i]]+=1
  else:
    dic_odd[v[i]]+=1
    
even = sorted(dic_even.items(),key = lambda x: x[1],reverse=True)
odd = sorted(dic_odd.items(),key = lambda x: x[1],reverse=True)
ans = 0

if len(even)==1 and len(odd)==1:
  if even[0][0] == odd[0][0]:
    ans = even[0][1]
  else:
    ans = 0
elif len(even)==1 and len(odd)>1:
  if even[0][0] == odd[0][0]:
    ans = n//2-odd[1][1]
  else:
    ans = n//2-odd[0][1]
elif len(even)>1 and len(even)==1:
  if even[0][0] == odd[0][0]:
    ans = n//2 -even[1][1]
  else:
    ans = n//2 -even[0][1]
else:
  if even[0][0] == odd[0][0]:    
    cdt_1 = even[0][1] + odd[1][1]
    cdt_2 = even[1][1] + odd[0][1]
    ans = n- max(cdt_1,cdt_2)
  else:
    ans = n - (even[0][1] + odd[0][1])
print(ans)

Measured memory_bytes: 24748
package main

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

func main() {
	L, R, d := getStdinInt3()
	D := 0
	cnt := 0
	for i := 0; i <= R; {
		if L <= i && i <= R {
			cnt++
		}
		D += d
		i += d
	}
	fmt.Printf("%d\n", cnt)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2156
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 2 => 2 1 => 1
		// 3 => 2 3 1 => 3
		// 4 => 2 3 4 1 => 6
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long ret = N * (N - 1) / 2;
		System.out.println(ret);
	}
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int a, b;
    cin >> a >> b;
    cout << a * b - a - b + 1 << endl;
    return 0;
}

Measured memory_bytes: 3620
N,K=map(int,input().split())
sunuke=[]
for i in range(K):
  di=int(input())
  A=list(map(int,input().split()))
  for j  in range(di):
    if A[j] not in sunuke:
      sunuke+=[A[j]]
ans=N-len(sunuke)

print(ans)


Measured memory_bytes: 9176
import sys
input = sys.stdin.readline

n, k = [int(x) for x in input().split()]
s = set()
for _ in range(k):
    d = int(input())
    a = [int(x) for x in input().split()]
    for i in a:
        s.add(i)
ans = 0

for i in range(n):
    if i + 1 not in s:
        ans += 1

print(ans)

Measured memory_bytes: 67692
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int a,b,k;
  cin>>a>>b>>k;
  set<int> s;
  rep(i,0,k){
  if(a+i<=b)  s.insert(a+i);
   if(b-i>=a) s.insert(b-i);
  }
  for(auto d:s){
    cout<<d<<" "; 
  }
}

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

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A * N, B) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 2e9
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;

ll D = 60;

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

  map<ll, ll *> mp;
  mp[0] = new ll[n];
  REP(i, n)
  {
    cin >> mp[0][i];
    mp[0][i]--;
  }

  FOR(i, 1, D)
  {
    mp[i] = new ll[n];
    REP(j, n)
    {
      mp[i][j] = mp[i - 1][mp[i - 1][j]];
    }
  }

  ll v = 0;
  for (auto m : mp)
  {
    if (k & (1LL << m.first))
    {
      v = m.second[v];
    }
  }

  cout << v + 1 << endl;

  return 0;
}

Measured memory_bytes: 99012
#include <stdio.h>

int main (void)
{
    int A, B, K;
    int i;

    scanf("%d %d %d", &A, &B, &K);

    for (i = 0; i < K; i++) {
        if (i % 2 == 0) {
            if (A % 2 == 1) A -= 1;
            B += A / 2;
            A /= 2;
        } else {
            if (B % 2 == 1) B -= 1;
            A += B / 2;
            B /= 2;
        }
    }

    printf("%d %d\n", A, B);

    return 0;
}


Measured memory_bytes: 128
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		List<Double> list = new ArrayList();
		for (int i = 0; i < N; i++) {
			list.add(Double.parseDouble(sc.next()));
		}

		double ans = list.stream().mapToDouble(s -> 1.0 / s).sum();

		ans = 1.0 / ans;
		
		PrintWriter out = new PrintWriter(System.out);
		out.println(ans);
		out.flush();
	}

}


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

namespace ProgramingStudying2
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var h = Console.ReadLine().Split().Select(int.Parse).ToList();
            var dp = new int[n];
            dp[1] = Math.Abs(h[0] - h[1]);
            for(int i = 2; i < n; i++)
            {
                dp[i] = Math.Min(dp[i - 1] + Math.Abs(h[i] - h[i - 1]), dp[i - 2] + Math.Abs(h[i] - h[i - 2]));
            }
            Console.WriteLine(dp[n - 1]);
        }
    }
}

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

using namespace std;
typedef long long ll;

unordered_set<string> us;
ll N;

int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        string s;
        cin >> s;
        if(us.count(s) > 0) continue;
        us.insert(s);
    }
    cout << us.size() << endl;
    return 0;
}

Measured memory_bytes: 17700
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    s = int(n ** 0.5) + 1
    for i in range(s,0,-1):
        if n % i == 0:
            return i + n//i - 2

    return n - 1


print(main())





Measured memory_bytes: 5464
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld eps = 1e-12;
constexpr int inf = numeric_limits<int>::max() / 2;
constexpr int mod = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    vector<int> f(100010, 0), sum(100010,0);
    for(int i=2;i<=100000;i++)
    {
        ll p = 1;
        for(int j=2;j*j<=i;j++)
        {
            if(i%j) continue;
            p *= j;
            if(p>=2*i)
            {
                break;
            }
            if(j*j!=i)
            {
                p *= (i/j);
            }
            if(p>=2*i)
            {
                break;
            }
        }
        if(p>=2*i) f[i] = 1;
    }
    for(int i=2;i<=100000;i++) sum[i] = sum[i-1] + f[i];
    int q;cin>>q;
    while(q--)
    {
        int n;cin>>n;
        cout << sum[n] - sum[1] << endl;
    }
}



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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

    ll n;
    cin >> n;
    vl t = vl(5);
    for (int i = 0; i < 5; ++i) {
        cin >> t[i];
    }
    sort(ALL(t));

    ll ans = 5;
    ll a = n / t[0];
    if(n % t[0] != 0) a++;
    ans += a - 1;

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


Measured memory_bytes: 256
#include <iostream> 
#include <cstdlib>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++) 

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

    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }

    int Counter = 0;
    int j = vec[0];
    Counter += 1;
    if (j == 2) {
        cout << Counter << endl;
    } else {
        for (int i = 0; i < N; i++) {
            j = vec[j-1];
            Counter += 1;
            if (j == 2) {
                cout << Counter << endl;
                return 0;
            }
        }
        cout << "-1" << endl;
    }
}



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

using namespace std;

int n, t;
vector< vector<int> > edges(100);
vector< pair<int,int> > ans(100);
vector< bool > vis(100, false);

void dfs(int v){
  t++;
  vis[v] = true;
  ans[v].first = t;
  for(int i : edges[v])
    if(vis[i] == false)
      dfs(i);
  t++;
  ans[v].second = t;
}

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

  for(int i = 0; i < n; i++){
    int k;
    cin >> k >> k;
    for(int j = 0; j < k; j++){
      int to;
      cin >> to;
      edges[i].push_back(to-1);
    }
  }

  t = 0;
  for(int i = 0; i < n; i++){
    if(vis[i] == false)
      dfs(i);
  }
  for(int i = 0; i < n; i++){
    cout << i + 1 << ' ' <<  ans[i].first << ' ' << ans[i].second << endl;
  }
}

Measured memory_bytes: 3108