akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define tnum long long

#define loop(i,end) for(int i = 0; i < end; i++)

tnum *inputNumbers(tnum num) {
	tnum *ret;
	ret = (tnum *)malloc(num * sizeof(tnum));
	loop(i, num) {
		scanf("%lld", &ret[i]);
	}
	return ret;
}


/*main code*/


int main(int argc, char *argv[]) {
	tnum n;
	tnum *a;
	tnum *k;
	int knum = 0;
	int *vtok;
	tnum *vtor;
	char *vtokused;
	char *vtorused;

	scanf("%lld", &n);

	a = inputNumbers(n);

	k = (tnum *)calloc(n, sizeof(tnum));
	vtok = (int *)calloc(n, sizeof(int));
	vtokused = (char *)calloc(n, sizeof(char));
	vtor = (tnum *)calloc(n, sizeof(tnum));
	vtorused = (char *)calloc(n, sizeof(char));

	loop(i, n) {
		tnum cv = a[i];
		int ck = vtok[cv];
		if (vtokused[cv] == 0) {
			k[knum] = 0;
			vtok[cv] = knum;
			vtokused[cv] = 1;
			ck = knum;
			knum++;
		}
		k[ck]++;
	}

	tnum res = 0;
	loop(j, knum) {
		tnum t;
		t = k[j];
		//ktor[j] = t * (t - 1) / 2;
		res += t * (t - 1) / 2;
	}

	loop(i, n) {
		tnum cv = a[i];
		int ck = vtok[cv];
		tnum t = k[ck];
		tnum res2 = res - t + 1;// t * (t - 1) / 2 + (t - 1) * (t - 2) / 2;
		
		printf("%lld\n", res2);
	}

	return 0;
}

Measured memory_bytes: 5120
def readinput():
    s=input()
    return s

def main(s):
    sList=[]
    i=0
    j=0
    rflg=True
    lflg=False
    while(j<len(s)):
        if s[j]=='L' and rflg==True:
            rflg=False
            lflg=True
        elif s[j]=='R' and lflg==True:
            lflg=False
            rflg=True
            sList.append(s[i:j])
            i=j
        j+=1
    sList.append(s[i:j])
    
    #print(sList)

    ans=[]
    for sub in sList:
        nr=sub.count('R')
        nl=sub.count('L')
        mr=nr//2+nr%2 + nl//2
        ml=nr//2      + nl//2+nl%2
        il=sub.find('L')
        ir=il-1
        #print(ir,il,sub)
        for i in range(nr-1):
            ans.append(0)
        ans.append(mr)
        ans.append(ml)
        for i in range(nl-1):
            ans.append(0)
        #print(ans)
    return ans

if __name__=='__main__':
    s=readinput()
    ans=main(s)
    print(' '.join(map(str,ans)))


Measured memory_bytes: 17576
#include <stdio.h>
#include <string.h>

int main() {
	int len, zero = 0, one = 0;
	char s[100010];
	scanf("%s", s);
	len = strlen(s);
	for (int i = 0; i < len; i++) {
		if (s[i] == '0')
			zero++;
		else
			one++;
	}
	len = zero;
	if (zero > one)
		len = one;
	printf("%d\n", 2 * len);
	return 0;
}

Measured memory_bytes: 256
n,x=map(int,input().split())
l=list(map(int,input().split()))
def gcd(n,m):
  a=max(n,m)
  b=min(n,m)
  while b!=0:
    a,b=b,a%b
  return a
a=abs(l[0]-x)
for i in range(n):
  a=gcd(a,abs(l[i]-x))
print(a)



Measured memory_bytes: 14252
def gcd(x,y):
    if x<y:
        x,y = y,x
    while y>0:
        x,y = y,x%y
    return x
A,B,C,D = map(int,input().split())
c1 = B//C
d1 = B//D
CD = C*D//gcd(C,D)
cd1 = B//CD
c2 = (A-1)//C
d2 = (A-1)//D
cd2 = (A-1)//CD
b = B-(c1+d1-cd1)
a = A-1-(c2+d2-cd2)
print(b-a)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<endl
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

ll calc(ll k,ll d) {
  return k*(k+1)/2*d;
}

void Main() {
  srand((unsigned)time(NULL));
  ll n=26;
  int T;
  R T;
  ll c[n];
  rep(i,n) R c[i];
  ll a[T][n];
  rep(i,T)rep(j,n) R a[i][j];
  set<ll> s[n];
  rep(i,n) s[i].in(-1),s[i].in(T);
  ll q[T];
  ll d[n];
  mem(d);
  ll ans=0;
  rep(i,n) {
    iter(s[i]) it1=s[i].begin();
    iter(s[i]) it2=it1;it2++;
    ans-=calc(*it2-*it1-1,c[i]);
  }
  rep(k,T) {
    ll x;
    R x;
    x--;
    q[k]=x;
    /*
    s[x].in(k);
    ans+=a[k][x];
    rep(i,n) d[i]-=c[i];
    d[x]=0;
    rep(i,n) ans+=d[i];
    */
    s[x].in(k);
    ans+=a[k][q[k]];
    iter(s[q[k]]) it2=s[q[k]].lower_bound(k);
    iter(s[q[k]]) it1=it2,it3=it2;it1--,it3++;
    ans-=calc(*it2-*it1-1,c[q[k]]);
    ans-=calc(*it3-*it2-1,c[q[k]]);
    ans+=calc(*it3-*it1-1,c[q[k]]);
  }
  ll N;
  R N;
  while(N--) {
    ll x,y;
    cin >> x >> y;
    x--,y--;
    {
      ans-=a[x][q[x]];
      iter(s[q[x]]) it2=s[q[x]].lower_bound(x);
      iter(s[q[x]]) it1=it2,it3=it2;it1--,it3++;
      ans+=calc(*it2-*it1-1,c[q[x]]);
      ans+=calc(*it3-*it2-1,c[q[x]]);
      ans-=calc(*it3-*it1-1,c[q[x]]);
      s[q[x]].erase(it2);
    }
    {
      q[x]=y;
      s[q[x]].in(x);
      ans+=a[x][q[x]];
      iter(s[q[x]]) it2=s[q[x]].lower_bound(x);
      iter(s[q[x]]) it1=it2,it3=it2;it1--,it3++;
      ans-=calc(*it2-*it1-1,c[q[x]]);
      ans-=calc(*it3-*it2-1,c[q[x]]);
      ans+=calc(*it3-*it1-1,c[q[x]]);
    }
    pr(ans);
  }
}

int main(){Main();return 0;}


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

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

	int d = a / b;
	int r = a % b;
	double f = (double)a / b;

	cout << d << " " << r << " ";
	cout << fixed << setprecision(10) << f << endl;
}



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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;

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

  if(S*T >= D){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef pair<ut,ut> prs;
const int SIZE=200005;
const LL p=7+1e9;
const LL INF=1<<30;
const LL INFLL=1LL<<30;
inline void IN(ut &x){cin >> x;}
inline void INA(ut n,ut x[]){REP(i,n) cin >> x[i];}
inline void INE(ut m,VI edges[]){
	ut a,b;
	REP(i,m){
		cin >> a >> b;
		edges[a].PB(b);
		edges[b].PB(a);
	}
}
inline void INEC(ut m,Vpr edges[]){
	ut a,b,c;
	REP(i,m){
		cin >> a >> b >> c;
		edges[a].PB(pr(c,b));
		edges[b].PB(pr(c,a));
	}
}
LL nums[SIZE];
LL N,A,B;
bool solve(LL x){
	LL times=x;
	REP(i,N){
		times-=max(0LL,(nums[i]-x*B+A-B-1))/(A-B);
	}
	return times>=0;
}
int main(){
	cin >>N >>A >> B;
	REP(i,N) cin >> nums[i];
	LL s=1,e=1e9;
	while(s<=e){
		LL f=(s+e)/2;
		if(solve(f)) e=f-1;
		else s=f+1;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
long long n;
int main () {
	long long ans = LLONG_MAX;
	scanf ("%lld", &n);
	for (long long i = 1; 1LL * i * i <= n; ++i) {
		if (n % i == 0) {
			long long j = n / i;
			ans = min (ans, i + j - 2LL);
		}
	}
	printf ("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
 int a,b;
 char ch;
 scanf("%d %c %d",&a,&ch,&b);
 if(ch=='+') printf("%d\n",a+b);
 else printf("%d\n",a-b);

}


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

using namespace std;

typedef long long ll;
typedef long double ld;

bool check(vector<ll> &a, vector<ll> &b, ll k, ll ans) {
    for (size_t i = 0; i < a.size(); ++i) {
        k -= a[i] - min(a[i], ans / b[i]);
    }
    return k >= 0;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    ll n = 200000, k = 1000000000000000000;
    cin >> n >> k;
    vector<ll> a(n);
    vector<ll> b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(begin(a), end(a));
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    sort(begin(b), end(b));
    reverse(begin(b), end(b));
    ll l = 0, r = 1e12;
    while (l + 1 < r) {
        ll mid = (r + l) / 2;
        if (check(a, b, k, mid)) {
            r = mid;
        } else {
            l = mid + 1;
        }
    }
    if (check(a, b, k, l)) {
        cout << l;
    } else {
        cout << r;
    }
}


Measured memory_bytes: 3328
from heapq import heapify, heappop, heappush

# 次の桁の生成ルール ex. 1 -> 10, 11, 12
def next_int(n):
    nums = {0: [0, 1],
            1: [0, 1, 2],
            2: [1, 2, 3],
            3: [2, 3, 4],
            4: [3, 4, 5],
            5: [4, 5, 6],
            6: [5, 6, 7],
            7: [6, 7, 8],
            8: [7, 8, 9],
            9: [8, 9]}
    return nums[n]

K = int(input())
queue = [1, 2, 3, 4, 5, 6, 7, 8, 9]  # とりあえず 1 桁目を初期値にとる
heapify(queue)

for _ in range(K-1):
    now = heappop(queue)  # 最小値を取り出す
    # 取り出した値を使って次の桁を生成し queue に投げる
    for next_i in next_int(now%10):
        heappush(queue, now*10 + next_i)

print(queue[0])  # K 回目に取り出す最小値


Measured memory_bytes: 12208
orders = [int(input()) for _ in range(5)]

rest = []
time = 0
for order in orders:
    if order % 10 == 0:
        time += order
    else:
        rest.append(order)

rest_mods = list(map(lambda x: x % 10, rest))

if len(rest_mods) > 0:
    min_mods_index = rest_mods.index(min(rest_mods))
    for i in range(len(rest)):
        time += rest[i]
        if i != min_mods_index:
            time += 10 - rest[i] % 10
else:
    time += sum(rest)
print(time)


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for (int i = n - 1; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define INF bit(60)
#define pb push_back
#define mod 1000000007

using namespace std;
using uif = uint_fast64_t;
using ll = long long int;
using tTree = __gnu_pbds::tree<ll, __gnu_pbds::null_type, less<ll>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

#define FACSIZE 200002

ll invfac[FACSIZE];
ll fac[FACSIZE];

template <class T>
bool chmax(T &, const T &);
template <class T>
bool chmin(T &, const T &);
ll gcd(ll, ll);
ll powLL(ll x, ll y);

ll mod_pow(ll, ll);
ll mod_add(ll, ll);
ll mod_mul(ll, ll);
ll mod_div(ll, ll);
ll comb(ll, ll);
void make_fact(ll);
void make_invfact(ll);
void fact_init();

int main(void)
{
  ll n;
  cin >> n;
  vector<ll> P(n);
  rep(i, n)
  {
    ll x;
    cin >> x;
    P[x - 1] = i + 1;
  }

  rep(i, n)
  {
    cout << 30000LL * (i + 1LL) << " ";
  }
  cout << endl;
  rep(i, n)
  {
    cout << 30000LL * (n - i - 1LL) + P[i] << " ";
  }
  cout << endl;

  return 0;
}

ll mod_pow(ll x, ll r)
{
  if (r == 0)
    return 1;
  else if (r == 1)
    return x % mod;
  else if (r % 2 == 0)
  {
    ll t = mod_pow(x, r / 2) % mod;
    return mod_mul(t, t);
  }
  else
  {
    ll t = mod_pow(x, r / 2) % mod;
    ll k = mod_mul(t, t);
    return (k % mod) * (x % mod);
  }
}
ll mod_add(ll a, ll b)
{
  return ((a % mod) + (b % mod)) % mod;
}

ll mod_mul(ll a, ll b)
{
  return ((a % mod) * (b % mod)) % mod;
}

ll mod_div(ll a, ll b)
{
  return mod_mul(a, mod_pow(b, mod - 2));
}

void fact_init()
{
  make_fact(FACSIZE - 1);
  make_invfact(FACSIZE);
}

void make_fact(ll n)
{
  fac[0] = 1;
  rep(i, n)
  {
    fac[i + 1] = mod_mul(fac[i], i + 1);
  }
}

void make_invfact(ll n)
{
  invfac[n] = mod_pow(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--)
  {
    invfac[i] = mod_mul(invfac[i + 1], i + 1);
  }
}

ll comb(ll n, ll r)
{

  return mod_mul(mod_mul(fac[n], invfac[r]), invfac[n - r]);
}
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;
}

ll qp(ll a, ll b)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * mod_mul(ans, a) % mod;
    a = 1LL * mod_mul(a, a) % mod;
  } while (b >>= 1LL);
  return ans;
}
ll qp(ll a, ll b, ll mo)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * (ans % mo) * (a % mo);
    a = 1LL * (a % mo) * (a % mo);
  } while (b >>= 1LL);
  return ans;
}
ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}
ll powLL(ll x, ll y)
{
  ll ans = 1LL;
  for (ll i = 0LL; i < y; i++)
    ans *= x;
  return ans;
}


Measured memory_bytes: 768
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	const ll mo=1000000007;
	int n;
	cin>>n;
	string x,y;
	cin>>x>>y;
	ll ans=1;
	int st=0,fin=n-2;
	if(x[n-1]==y[n-1])
	{
		st=2;
		ans*=3;
	}
	else
	{
		fin--;
		st=1;
		ans*=6;
	}
	for(int i=fin;i>=0;)
	{
		if(st==1)
		{
			if(x[i]==y[i])
			{
				st=2;
				i--;
			}
			else
			{
				i-=2;
				ans*=3;
			}
		}
		else
		{
			if(x[i]==y[i])
			{
				i--;
				ans*=2;
			}
			else
			{
				i-=2;
				ans*=2;
				st=1;
			}
		}
		ans%=mo;
	}
	cout<<ans%mo<<'\n';
}










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

int main(void){
	int n,m;
	double x,h,s,t;
	
	while(1){
		scanf("%d %d",&n,&m);
		if(n==0 && m==0)break;
		
		s=0.0;
		
		x=(double)n;
		h=(double)m;
		
		t=sqrt(pow(x/2.0,2)+pow(h,2));
		
		s=x*x+4*x*t/2+0.0000005;
		
		
		
		printf("%.6lf\n",s);
	}
	
	return 0;
}

Measured memory_bytes: 636
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef int64_t lint;
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using lb = long double;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SI(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define debug(x) cerr << #x << ": " << x << "\n"//手動デバッグ
#define debugV(x) for(int i=0;i<((ll)(x).size());i++)cerr << #x <<"at:"<<i<< ": " << x[i] << "\n"//手動デバッグ 
#define YES(c) cout<<((c)?"YES\n":"NO\n"),0
#define Yes(c) cout<<((c)?"Yes\n":"No\n"),0
#define O(p) cout<<p<<"\n",0
#define OS(p) cout<<p<<" ",0
#define ON(p) cout<<p,0
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define endl "\n"//endlを置き換える
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定

const int dy[4]={1,0,-1,0};
const int dx[4]={0,1,0,-1};//^>v<

template<class T=int> T in(){
    T x;
    cin>>x;
    return (x);
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
//------------------------------------------------------------
struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};





//------------------------------------------------------------
int main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
//------------------------------------------------------------
    int n,m;cin>>n>>m;
    UnionFind uf(n);
    while(m--){
        int a,b;cin>>a>>b;
        uf.unite(a-1,b-1);
    }
    ll ans=0;
    rep(i,n){
        ans=max(ans,ll(uf.size(i)));
    }
    //O(uf.find(1));
    O(ans);
    
    
    
    
    
//------------------------------------------------------------
	return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
int main(){
  int X, Y;
  cin >> X >> Y;
  bool ok = false;
  for (int i = 0; i < 100; i++){
    for (int j = 0; j < 100; j++){
      if ((i + j) == X && (i * 2 + j * 4) == Y){
        ok = true;
      }
    }
  }
  if (ok){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>

#define INF 10e9
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

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

    cout << min(a*n, b) << endl;
}










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

using namespace std;

int main() {
	// your code goes here

	int n;
	cin>>n;
	
	int a[n];
	
	for(int i=0;i<n;i++)
		cin>>a[i];
		
		
	sort(a,a+n);
	
	int ind = n/2;
	int ans=0;
	for(int i=a[ind] ; i>a[ind-1] ; i--,ans++);
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    long[] a = new long[N];
    long[] b = new long[N];

    for (int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
    }

    long sum_rest = 0;
    long rest;

    for (int i = N-1; i >= 0; i--) {
      a[i] += sum_rest;
      rest = a[i] % b[i];
      sum_rest += (b[i] - rest) % b[i];
    }

    System.out.println(sum_rest);
  }
}


Measured memory_bytes: 88864
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Map<Character, Integer> map = new HashMap<>();
    for (int i = 0; i < N; i++) {
      String s = sc.next();
      char c = s.charAt(0);
      if (c == 'M' || c == 'A' || c == 'R' || c == 'C' || c == 'H') {
        map.put(c, map.getOrDefault(c, 0)+1);
      }
    }

    int n = map.size();
    if (n < 3) {
      System.out.println(0);
      return;
    }
    
    int[] count = new int[n];
    int idx = 0;
    for (int value : map.values()) {
      count[idx++] = value;
    }
    
    long ans = 0;
    int p = 1 << n;
    for (int i = 0; i < p; i++) {
      ans += calc(count, i);
    }
    
    System.out.println(ans);
  }
  
  private static long calc(int[] count, int i) {
    long mul = 1;
    int shift = 0;
    int bit = 0;
    while (i != 0) {
      if (i % 2 == 1) {
        bit++;
        mul *= count[shift];
      }
      i /= 2;
      shift++;
    }
    return bit == 3 ? mul : 0;
  }
}

Measured memory_bytes: 44832
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  ll a, b;
  cin >> a >> b;
  if (a*b<=0) cout << "Zero" << endl;
  else if (a>0&&b>0) cout << "Positive" << endl;
  else {
    ll minus = b-a+1;
    if (minus%2==0) cout << "Positive" << endl;
    else cout << "Negative" << endl;
  }
}

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

using namespace std;

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

const long long MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int N, Y;
  cin >> N >> Y;
  for (int i = 0; i <= N; ++i) {
    for (int j = 0; j <= N - i; ++j) {
      int rest = Y - i * 10000 - j * 5000;
      int k = N - i - j;
      if (N - i - j < 0 || rest < 0) break;
      if (rest == k * 1000) {
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
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 U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long N, M, K;
	cin >> N >> M >> K;
	vector<long long> A(N), B(M);
	for (auto&& x : A) cin >> x;
  for (auto&& x : B) cin >> x;
  A.insert(A.begin(), 0);
  B.insert(B.begin(), 0);
  REP(i, A.size()-1) A[i+1] += A[i];
  REP(i, B.size()-1) B[i+1] += B[i];
  long long res = 0;
  long long idx = M;
  for (long long i = 0; i < N+1; i++) {
    while (idx > 0 && A[i] + B[idx] > K) {
      idx--;
    }
    if (A[i] + B[idx] <= K) {
      chmax(res, i + idx);
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 7880
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int d = 1;
bool D[10001];
int H[10001], topo[10001];
pair<int, int> E[20002];
void dfs(int A) {
	if (!D[A]) {
		D[A] = true;
		topo[A] = d;
		d++;
		for (int i = H[A]; i; i = E[i].second) {
			dfs(E[i].first);
		}
	}
}

const int cm = 1 << 18;
char cn[cm], *ci = cn, ct;
inline int getint() {
	int A = 0;
	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int main() {

	fread_unlocked(cn, 1, cm, stdin);

	int N = getint();
	for (int i = 2; i < 2 * N; i += 2) {
		int a = getint(), b = getint();
		E[i] = mp(a, H[b]);
		H[b] = i;
		E[i + 1] = mp(b, H[a]);
		H[a] = i + 1;
	}

	int C[10000];
	int goukei = 0;
	rep(i, N) {
		C[i] = getint();
		goukei += C[i];
	}
	sort(C, C + N);

	dfs(1);

	const int dm = 1 << 17;
	char dn[dm], *di = dn;
	int X = goukei - C[N - 1];
	int keta = 0;
	char c[10];
	while (X) {
		*(c + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--) *di++ = (*(c + i));
	*di++ = '\n';
	rep1(i, N) {
		X = C[N - topo[i]];
		keta = 0;
		while (X) {
			*(c + keta) = '0' + X % 10;
			X /= 10;
			keta++;
		}
		for (int i = keta - 1; i >= 0; i--) *di++ = (*(c + i));
		*di++ = ' ';
	}

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

Measured memory_bytes: 896
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

long[] t;
bool[] b;
void main()
{
    long N = lread;
    t = new long[](N + 1);
    b = new bool[](N + 1);

    foreach (i; 0 .. N)
        t[i + 1] = lread();
    solve(1).max(-1).writeln();

}

long solve(long n)
{
    if (b[n])
        return long.min;
    if (n == 2)
        return 0;
    b[n] = true;
    return solve(t[n]) + 1;

}


Measured memory_bytes: 5756
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef unsigned long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 2222;
const double EPS = 1e-8;
const int MOD = 1000 * 1000 * 1000 + 7;

const int BITS = 10;

string bin(LL x)
{
    string s  = "";
    FOR(i, 0, BITS)
        if (x & (1LL << i))
            s += '1';
        else s += '0';
    reverse(ALL(s));
    return s;
}


int main()
{
    LL A, B;
    cin >> A >> B;
    
    LL x = 0;
    RFOR(i, 62, 0)
    {
        LL a = A & (1LL << i);
        LL b = B & (1LL << i);
        
        if (a != b)
        {
            x = 1LL << i;
            break;
        }
    }
    if (x == 0)
    {
        cout << 1 << endl;
        return 0;
    }
    
   // cout << bin(x) << endl;
   // cout << bin(A) << " " << bin(B) << endl;
    
    
    A &= (x << 1) - 1;
    B &= (x << 1) - 1;
    
   // cout << bin(A) << " " << bin(B) << endl;
    
    unsigned long long ans = 2 * (x - A);
    
    //cout << ans << endl;
    
    LL y = 0;
    FOR(i, 0, 61)
    {
        if (x == (1LL << i))continue;
        LL yy = x | (1LL << i);
        if (yy <= B)y = (1LL << i);
    }
    
    if (y == 0)
    {
        ans ++;
        if (A == 0)ans--;
    }
    else
    {
        ans += y * 2;
        if (min(x + y * 2 - 1, 2 * x - 1) + 1 > (x + A))
            ans -= min(x + y*2 - 1, 2 * x - 1) - (x + A) + 1;
    }
    
    
    
    cout << ans << endl;
    
    
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll ans = A * C;
    chmax(ans, A * D);
    chmax(ans, B * C);
    chmax(ans, B * D);
    if ((A <= 0 && 0 <= B) || (C <= 0 && 0 <= D)) {
        chmax(ans, 0LL);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

    int n = s.size();

    bool ok = (s[0] == '1' && s[n - 1] == '0');

    for (int i = 0; i < n - 1; i++) {
        if (s[i] != s[n - i - 2]) {
            ok = false;
            break;
        }
    }

    if (!ok) {
        cout << -1 << endl;
    } else {
        int par = n - 1;

        for (int i = n - 2; i >= 0; i--) {
            cout << i + 1 << ' ' << par + 1 << endl;

            if (s[i] == '1') {
                par = i;
            }
        }
    }
}


Measured memory_bytes: 1600
/**
 * Author: Deb Natkh Maxim (debnatkh@gmail.com)
 * Date: 24.03.2019
 */

#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
using namespace std;

const int MAXN = 100, MAXA = 1e5 + 10;
int dp[MAXN + 1][MAXA];
int arr[MAXN];

bool check(char c) {
    return (c == 'A' || c == 'T' || c == 'G' || c == 'C');
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    string s;
    cin >> s;
    int leng = 0, ans = 0;
    for (auto c : s) {
        if (check(c)) leng++;
        else {
            ans = max(ans, leng);
            leng = 0;
        }
    }
    ans = max(ans, leng);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
function mygetDate($y,$m,$d){
    if($y%3==0){
        $d_sum = 20*($m-1)+$d;
    }
    else{
        $d_sum=0;
        for($i=1;$i<$m;$i++){
            if($i%2==0){
                $d_sum+=19;
            }
            else{
                $d_sum+=20;
            }
        }
        $d_sum+=$d;
    }
    return($d_sum);
}

$piled_days =array_fill(0,1001,0);
$a = mygetDate(1,10,19);
$b = mygetDate(3,10,20);

for($i=1;$i<1000;$i++){
    if($i%3==0){
        $piled_days[$i]+=($piled_days[$i-1]+$b);
    }
    else{
        $piled_days[$i]+=($piled_days[$i-1]+$a);
    }    
}
$millennium=$piled_days[999]+1;

fscanf(STDIN,"%d\n",$n);
for($i=0;$i<$n;$i++){
    fscanf(STDIN,"%d %d %d\n",$y,$m,$d);    
    $sum = $piled_days[$y-1] + mygetDate($y,$m,$d);
    echo $millennium-$sum,"\n";
}


?>

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

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

	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << H * W - (h * W) - (w * (H - h));
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;
typedef pair<int, int> ipair;

int main(int argc, char **argv) {
    int r, D;
    llong X;
    cin >> r >> D >> X;

    for(int i = 2001; i <= 2010; ++i) {
        X = r * X - D;
        cout << X << endl;
    }
    
}

Measured memory_bytes: 256
local mfl, mce, mmi = math.floor, math.ceil, math.min
local SegTree = {}
SegTree.create = function(self, ary, func, emptyvalue)
  self.n, self.func, self.emptyvalue = #ary, func, emptyvalue
  local stagenum, mul = 1, 1
  self.cnt, self.stage, self.size = {1}, {{}}, {}
  while mul < self.n do
    mul, stagenum = mul * 2, stagenum + 1
    self.cnt[stagenum], self.stage[stagenum] = mul, {}
  end
  for i = 1, stagenum do
    self.size[i] = self.cnt[stagenum + 1 - i]
  end
  self.stagenum = stagenum
  for i = 1, self.n do
    self.stage[stagenum][i] = ary[i]
  end
  for i = self.n + 1, mul do
    self.stage[stagenum][i] = emptyvalue
  end
  for i = stagenum - 1, 1, -1 do
    for j = 1, self.cnt[i] do
      self.stage[i][j] = func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])
    end
  end
end
SegTree.getRange = function(self, left, right)
  local ret = self.emptyvalue
  local tasks = {{1, left, right}}
  while 0 < #tasks do
    local task = tasks[#tasks]
    table.remove(tasks)
    local stage, l, r = task[1], task[2], task[3]
    if (l - 1) % self.size[stage] ~= 0 then
      local newr = mce((l - 1) / self.size[stage]) * self.size[stage]
      table.insert(tasks, {stage + 1, l, mmi(r, newr)})
      l = newr + 1
    end
    if self.size[stage] <= r + 1 - l then
      local pos = mce(l / self.size[stage])
      ret = self.func(ret, self.stage[stage][pos])
      l = l + self.size[stage]
    end
    if l <= r then
      table.insert(tasks, {stage + 1, l, r})
    end
  end
  return ret
end

SegTree.new = function(ary, func, emptyvalue)
  local obj = {}
  setmetatable(obj, {__index = SegTree})
  obj:create(ary, func, emptyvalue)
  return obj
end

local n = io.read("*n", "*l")
local str = io.read()
local t = {}
local idx = 1
for v in str:gmatch("%d+") do
  table.insert(t, {idx, tonumber(v)})
  idx = idx + 1
end
local segtree = SegTree.new(t, function(a, b) return a[2] < b[2] and a or b end, {0, n + 1})
local tasks = {{1, n}}
local ret1, ret2 = 0, 0
local big = 1000000000
while 0 < #tasks do
  local l, r = tasks[#tasks][1], tasks[#tasks][2]
  table.remove(tasks)
  local p = segtree:getRange(l, r)
  local val = p[2] * (p[1] + 1 - l) * (r + 1 - p[1])
  ret2 = ret2 + val
  ret1, ret2 = ret1 + mfl(ret2 / big), ret2 % big
  if p[1] ~= l then
    table.insert(tasks, {l, p[1] - 1})
  end
  if p[1] ~= r then
    table.insert(tasks, {p[1] + 1, r})
  end
end
ret2 = 0 < ret1 and string.format("%09d", ret2) or ret2
ret1 = 0 < ret1 and ret1 or ""
print(ret1 .. ret2)


Measured memory_bytes: 58468
import java.util.*;

class Main {
    public static void main(String[] args) {
        final long MOD = 1_000_000_007L;
        final Scanner sc = new Scanner(System.in);
        final int N = Integer.parseInt(sc.next());
        int B[] = new int[60];
        for (int i = 0; i < N; i++) {
            long A = Long.parseLong(sc.next());
            for (int j = 0; j < 60; j++) {
                B[j] += (int) (A % 2);
                A /= 2;
                if (A == 0)
                    break;
            }
        }
        sc.close();

        long sum = 0L;
        for (int j = 0; j < 60; j++) {
            sum += (long) B[j] * (N - B[j]) * Math.pow((double) 2, (double) j) % MOD;
            sum %= MOD;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 63712
#include<bits/stdc++.h>
using namespace std;
 int main(){
   int A,B;
   cin >> A >> B;
   if ((A+B)%2 == 0) {
   cout << (A + B)/2 << endl;
   }
   if ((A+B)%2 == 1){
   cout << (A + B)/2 + 1 <<endl;
   }
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,n;
  cin >> N;
  n = N;
  int sum = 0;
  for(int i = 0;i < 10;i++){
    sum += n % 10;
    n /= 10;
    if(n == 0) break;
  }
  if(N % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (inputString)
{
    const dataArray = inputString.split(/\r\n|\r|\n/);
    let dataCount = 1;

    dataArray.forEach(function(val,index){
        const x = Number(val);
            if(x !== 0){
                const result = 'Case ' + dataCount + ': ' + x;
                dataCount++;
                console.log(result);
                }
        });

});


Measured memory_bytes: 22656
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265358979

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

int main(void) {
	long long int n;
	long long int a[101];
	long long int A = 0, B = 0;
	long long int p = 1;

	cin >> n;
	FOR(i, 1, n) {
		cin >> a[i];
	}

	sort(a, a + n + 1);


	RFOR(i, n, 1) {
		if (p == 1) {
			A += a[i];
			p = 0;
		}
		else {
			B += a[i];
			p = 1;
		}
	}

	cout << A - B << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() { 
  int n;  
  while(1) { 
    int a=0, b=0;  
    cin >> n;  
    if(n==0) break; 
    for(int i=0; i<n; i++) { 
      int x, y;   
      cin >> x >> y;     
      if(x>y) a+=x+y;    
      else if(x<y) b+=x+y;   
      else {   
	a+=x; 
	b+=y;  
      }  
    }  
    cout << a << " " << b << endl;
  }  
  return 0;
}


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

int main(){
	int N,i,k,v;
	cin >> N;
	int A[N];
	for (i=0;i<=N-1;i++){
		cin >> A[i];
	}
	for (k=0;k<=N-1;k++){
			if (k==N-1){
				cout << A[k]<<endl;
			}else{
				cout << A[k]<<" ";
			}
		}
	
	for (i=1;i<=N-1;i++){
		v=A[i];
		int j=i-1;
		while(j>=0 && A[j]>v){
			A[j+1]=A[j];
			j--;
		}
		A[j+1]=v;
		for (k=0;k<=N-1;k++){
			if (k==N-1){
				cout << A[k]<<endl;
			}else{
				cout << A[k]<<" ";
			}
		}
		
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	char c=getchar();int t=0,f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int n,k;
int main(){
	n=read(),k=read();
	printf("%d\n",n-k+1);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll d,g;
  cin >>d >>g;
  ll p[d],c[d];
  for(ll i=0;i<d;i++) cin >>p[i]>>c[i];
  ll ans=1e8;
  for(ll i=0;i<(1<<d);i++){
    ll ans1=0,sum=0;
    for(ll j=0;j<d;j++){
      if(i&(1<<j)) {
        sum+=(100*(j+1)*p[j]+c[j]);
        ans1+=p[j];
      }
    }
    ll k=g-sum;
    if(k<=0) ans=min(ans,ans1);
    else{
      for(ll j=d-1;j>=0;j--){
       if(i&(1<<j)) continue;
       if(k<=0) break;
       ll q=k/(100*(j+1));
       if(q<p[j]){
         ans1+=q;
         k-=(q*100*(j+1));
       }
       else{
         ans1+=(p[j]-1);
         k-=((p[j]-1)*100*(j+1));
       }
      }
      if(k<=0) ans=min(ans,ans1);
    }
  }
  cout <<ans<<endl;
  return 0;
  }


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-10;
const vi emp;

string s;

int main(){
	while(cin>>s){
		int joi=0,ioi=0;
		for(int i=0;i<s.size()-2;i++){
			string t=s.substr(i,3);
			if(t=="JOI") joi++;
			if(t=="IOI") ioi++;
		}
		cout<<joi<<endl<<ioi<<endl;
	}
}

Measured memory_bytes: 3144
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll N,A,B;cin>>N>>A>>B;
    vector<ll> X(N),D(N);
    for(int i=0;i<N;++i){
        cin >> X[i];
        if(i>0) D[i-1] = X[i] - X[i-1];
    }

    ll ans = 0;
    for(int i=0;i<N-1;++i){
        ans += min(D[i]*A,B);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1792
N,M = map(int,input().split())
numlist = list(map(int,input().split()))
numlist.sort()
diflist = []

for i in range(M-1):
    diflist.append(numlist[i + 1] - numlist[i])
diflist.sort()
diflist.reverse()

delnum = N - 1
del diflist[:delnum]
sumnum = sum(diflist)

if M <= N:
    print("0")
else:
    print(sumnum)


Measured memory_bytes: 13968
#include <bits/stdc++.h>
using namespace std; typedef long long ll; typedef unsigned long long ull; const int mod = 1e9 + 7;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
//#define int ll

int n, h[100001], dp[100001];

signed main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> h[i];
	}
	dp[0] = h[0] = 0;
	dp[1] = 0;
	dp[2] = dp[1] + abs(h[2] - h[1]);
	for (int i = 3; i <= n; i++)
	{
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[n];
}

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

const ll INF = 1LL << 60;

int solve() {
    int N, M; cin >> N >> M;
    if (N == 0) return 0;
    
    vector<vector<ll>> dist_l(N, vector<ll>(N, INF));
    vector<vector<ll>> dist_s(N, vector<ll>(N, INF));
    REP(i, N) dist_l[i][i] = 0;
    REP(i, N) dist_s[i][i] = 0;
    REP(_, M) {
        int x, y; ll t; char sl; cin >> x >> y >> t >> sl;
        if (sl == 'S') {
            dist_s[x - 1][y - 1] = min(dist_s[x - 1][y - 1], t);
            dist_s[y - 1][x - 1] = min(dist_s[y - 1][x - 1], t);
        } else {
            dist_l[x - 1][y - 1] = min(dist_l[x - 1][y - 1], t);
            dist_l[y - 1][x - 1] = min(dist_l[y - 1][x - 1], t);
        }
    }


    REP(i, N) REP(j, N) REP(k, N)
        dist_s[j][k] = min(dist_s[j][k], dist_s[j][i] + dist_s[i][k]);
    REP(i, N) REP(j, N) REP(k, N)
        dist_l[j][k] = min(dist_l[j][k], dist_l[j][i] + dist_l[i][k]);


    int R; cin >> R;
    vector<int> dests;
    REP(_, R) {
        int r; cin >> r;
        dests.push_back(r - 1);
    }


    vector<vector<ll>> dp(R, vector<ll>(N, INF));
    dp[0][dests[0]] = 0;

    REP2(i, 1, R) REP(j, N) REP(k, N) {
        dp[i][j] = min(dp[i][j], dp[i-1][k] + dist_l[dests[i-1]][k] + dist_s[k][j] + dist_l[j][dests[i]]);
        if (j == k)
            dp[i][j] = min(dp[i][j], dp[i-1][k] + dist_l[dests[i-1]][dests[i]]);

    }

    ll ans = INF;
    REP(i, N) ans = min(ans, dp[R-1][i]);
    cout << ans << endl;

    return 1;
}

int main() {
    while (solve());
    return 0;
}

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

int N;
const int MAX_N = 100 + 10;
int F[MAX_N][10];
int P[MAX_N][11];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> F[i][j];
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 11; j++) {
            cin >> P[i][j];
        }
    }

    int ans = -1.0e9;
    for (int i = 1; i < (1<<10); i++) {
        bitset<10> joisino(i);

        int now = 0;
        for (int j = 0; j < N; j++) {
            int cnt = 0;
            for (int k = 0; k < 10; k++) {
                if (joisino[k] == 1 && F[j][k] == 1) {
                    cnt++;
                }
            }
            now += P[j][cnt];
        }

        ans = max(ans, now);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int n , a , has[32];

int main(){
  scanf("%d",&n);
  int xo = 0;
  rep(i,0,n) {
    scanf("%d",&a);
    xo ^= a;
    has[__builtin_ctz(a)]++;
  }
  int ans = 0;
  per(i,0,31) if(xo >> i & 1) {
    if(has[i]) {
      xo ^= (1 << (i + 1)) - 1;
      ans++;
    }
  }
  if(xo == 0) printf("%d\n",ans);
  else puts("-1");
  return 0;
}


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

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

    int X, Y, Z;
    cin >> X >> Y >> Z;

    X -= Z;

    cout << X / (Y + Z) << endl;
}

Measured memory_bytes: 3656
/*input
7
3 6
1 2
3 1
7 4
5 7
1 4
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long n,d1[100005],d2[100005],dad[100005];
vector<int> v[100005];
void dfs(int u, int par=0, int dis=0){
	d1[u]=dis;
	dad[u]=par;
	for(auto i:v[u])
		if(i!=par)
			dfs(i,u,dis+1);
}
void dfs2(int u, int par=0, int dis=0){
	d2[u]=dis;
	for(auto i:v[u])
		if(i!=par)
			dfs2(i,u,dis+1);
}
int dfs3(int u, int par){
	int ans=1;
	for(auto i:v[u])
		if(i!=par)
			ans+=dfs3(i,u);
	return ans;
}
int main(){
	ios_base::sync_with_stdio(0);
	long long q,m,k,h,ans=0,sum=0,p=1e9,x,y;
	cin>>n;
	for(int i=0;i<n-1;++i){
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(1);
	dfs2(n);
	for(int i=1;i<=n;++i){
		if(d2[i]<d1[i] && d1[i]-d2[i]<p){
			p=d1[i]-d2[i];
			ans=i;
		}
	}
	//for(int i=1;i<=n;++i) cout<<d1[i]<<" "; cout<<'\n';
	//for(int i=1;i<=n;++i) cout<<d2[i]<<" "; cout<<'\n';
	//sum=dfs3(ans,dad[ans]);
	for(int i=1;i<=n;++i){
		if(d2[i]<d1[i]) sum++;
	}
	//cout<<ans<<" "<<sum<<'\n';
	if(sum>=n-sum) cout<<"Snuke";
	else cout<<"Fennec";
}

Measured memory_bytes: 12800
import sys

n, m = map(int, input().split(" "))

if abs(n - m) > 1:
    print(0)
    sys.exit()


if n == m:
    a = n
    for i in range(2,n):
        a = (a * i) % 1000000007
    print((a * a * 2) % 1000000007)
elif n < m:
    a = n
    for i in range(2,n):
        a = (a * i) % 1000000007
    print((a * a * m) % 1000000007)
else:
    a = m
    for i in range(2,m):
        a = (a * i) % 1000000007
    print((a * a * n) % 1000000007)





Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> firstRow = Arrays.asList(br.readLine().split(" "));
            int height = Integer.parseInt(firstRow.get(0));
            int width = Integer.parseInt(firstRow.get(1));

            List<String> inputStringList = new ArrayList<>();
            for (int i = 0; i < height; i++) {
                inputStringList.add(br.readLine());
            }

            StringBuilder printForStartLineAndEndLine = new StringBuilder();
            for (int i = 0; i < width + 2; i++) {
                printForStartLineAndEndLine.append("#");
            }

            System.out.println(printForStartLineAndEndLine);
            for (String str : inputStringList) {
                System.out.println("#" + str + "#");
            }
            System.out.println(printForStartLineAndEndLine);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 22996