akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main()
{
    long x;
    long ans;
    // scanf("%d", &x);
    cin >> x;
    rep(i, 1001) rep(j, 1001)
    {
        if (pow(i, 5) - pow(j, 5) == x)
        {
            cout << i << " " << j << endl;
            return 0;
        }
        else if (pow(i, 5) + pow(j, 5) == x)
        {
            cout << i << " " << -j << endl;
            return 0;
        }
    }
    // printf("%d\n", x * x * x);
}

Measured memory_bytes: 4100
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<time.h>
using namespace std;
typedef long long ll;
int n,m,v,p,a[100005],b[100005],ans,pth_min;
bool judge(int pth){
	ll res=0;
	int i;
	for(i=1;i<=n;i++)
		b[i]=min(m,pth-a[i]);
	sort(b+1,b+n+1);
	if(b[p]<0)
		return 0;
	for(i=1;i<=n;i++)
		res+=i<=p-1?m:b[i];
	return res>=(ll)m*v;
}
int solve(){
	int l=0,r=2e9,mid,res=-1;
	while(l<=r){
		mid=((ll)l+r)>>1;
		if(judge(mid))
			r=mid-1,res=mid;
		else
			l=mid+1;
	}
	return res;
}
int main(){
	scanf("%d%d%d%d",&n,&m,&v,&p);
	int i;
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	pth_min=solve();
	for(i=1;i<=n;i++)
		ans+=a[i]+m>=pth_min;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 4612
#include<bits/stdc++.h>
using namespace std;
#define N 200010
int n,va[N],c[N],ans,s,f[N],ss[N],nm[N];
int main(){
	cin>>n;
	for(int i=1;i<N;i++)
		nm[i]=nm[i-(i&-i)]+1;
	for(int i=1;i<N;i++)nm[i]--;
	for(int i=1;i<n;i++){
		int x,y,z;
		cin>>x>>y>>z;
		va[x]^=z;
		va[y]^=z;
	}
	for(int i=0;i<n;i++)
		c[va[i]]++;
	for(int i=1;i<=15;i++){
		ans+=c[i]/2;
		if(c[i]%2==1)s|=(1<<(i-1));
	}
	for(int i=1;i<(1<<15);i++)
		for(int j=0;j<15;j++)
			if(i&(1<<j))ss[i]^=(j+1);
	for(int i=1;i<(1<<15);i++)
		if(!ss[i])
			for(int j=i;j;j=(j-1)&i)
				if(!ss[j]&&!ss[i-j])
					nm[i]=min(nm[i],nm[i-j]+nm[j]);
	cout<<ans+nm[s];
}

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

int N;
int x[111], y[111], h[111];

int abs(int a){
	if(a < 0) return -a;
	else return a;
}

int main(){
	scanf("%d", &N);
	int max_h = 0;
	for(int i = 0; i < N; i++){
		scanf("%d %d %d", &x[i], &y[i], &h[i]);
		max_h = max(max_h, h[i]);
	}
	for(int i = 0; i <= 100; i++){
		for(int j = 0; j <= 100; j++){
			int cx, cy, H;
			bool flag = true;
			for(int k = 0; k < N; k++){
				if(h[k] != 0){
					cx = i, cy = j;
					H = h[k] + abs(cx - x[k]) + abs(cy - y[k]);
					break;
				}
			}
			for(int k = 0; k < N; k++){
				if(H - abs(cx - x[k]) - abs(cy - y[k]) <= 0 && h[k] == 0) continue;
				if(H - abs(cx - x[k]) - abs(cy - y[k]) != h[k]) flag = false;
			}
			if(flag && H >= max_h && H >= 1){
				printf("%d %d %d\n", cx, cy, H);
				return 0;
			}
		}
	}
	return 0;
}


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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;



int main() {
  ll n,m;
  	ci(n>>m);
  vll A(n);
  FOR(i,0,n){
    ci(A[i])
  }
  SORT(A);
  ll ans=A[n-1];
  
  FOR(i,0,n-m+1){
    ans=min(ans,A[m+i-1]-A[i]);
  }
  co(ans)
}
  

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>

using namespace std;
string str[10005];

int main()
{
	
	long long int n, m, a[2000000],r,g,b,res=0,a_fin=0,b_start=0,a_fin_b_start=0;
	cin >>n;
	for (int i = 0; i < n; i++) {
		cin >> str[i];
		for (int j = 0; j < str[i].length() - 1; j++) {
			if (str[i].substr(j, 2) == "AB") {
				res++;
			}
		}
		if (str[i][0] == 'B' && str[i][str[i].length() - 1] == 'A') {
			a_fin_b_start++;
		}
		else if (str[i][0] == 'B') {
			b_start++;
		}
		else if (str[i][str[i].length() - 1] == 'A') {
			a_fin++;
		}
	}
	if (a_fin_b_start == 0) {
		cout<< res+min(a_fin, b_start);
		return 0;
	}
	if (a_fin > 0&&b_start>0) {
		a_fin--;
		b_start--;
		res += a_fin_b_start+1;
		res += min(a_fin, b_start);
	}
	else if(a_fin > 0 || b_start > 0) {
		res += a_fin_b_start;
	}
	else {
		res+= a_fin_b_start-1;
	}
	cout << res;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>

using namespace std;
typedef long long ll;
vector<double> p;
double DP[3001][3001];
int N;

double probHead(int i, int heads) {
	if (i >= p.size()) {
		if (heads >= (N + 1) / 2) { return 1; }
		return 0;
	}
	if (DP[i][heads] != -1) { return DP[i][heads]; }

	double h = probHead(i + 1, heads + 1)*p[i];
	double t = probHead(i + 1, heads)*(1 - p[i]);

	DP[i][heads] = h + t;
	return DP[i][heads];
}

int main() {
	cin >> N;
	p.resize(N);
	for (auto &x : p) { cin >> x; }
	for (int i = 0; i < 3001; i++)
		for (int j = 0; j < 3001; j++)
			DP[i][j] = -1;

	cout << setprecision(9) << fixed << probHead(0, 0) << endl;
}

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

int countLatticePoint(int w, int h)
{
	for (int x = 1; x < w; x++)
	{
		if (w % x == 0 && h % (w / x) == 0) return w / x - 1;
	}
	return 0;
}

int main()
{
	int w, h;
	cin >> w >> h;
	cout << w + h - countLatticePoint(w, h) << endl;

	return 0;
}

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

using namespace std;

priority_queue<int> L, R;
long long sum, sl, sr;

void push(int x) {
	if (L.empty() || x < L.top()) L.push(x), sl += x;
	else R.push(-x), sr += x;
	if (L.size() > R.size() + 1) {
		sl -= L.top(), sr += L.top();
		R.push(-L.top()), L.pop();
	}
	if (L.size() < R.size()) {
		sl += -R.top(), sr -= -R.top();
		L.push(-R.top()), R.pop();
	}
}

void ans() {
	int x = L.top();
	printf("%d %lld\n", x, x * (long long)L.size() - sl + sr - x * (long long)R.size() + sum);
}

int main() {
	int q;
	scanf("%d", &q);
	while (q--) {
		int op, a, b;
		scanf("%d", &op);
		if (op == 1) {
			scanf("%d%d", &a, &b);
			push(a);
			sum += b;
		} else {
			ans();
		}
	}
	
	return 0;
}

Measured memory_bytes: 4192
/*input
3 1
1 2
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=1e6+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const ld PI=3.14159265358979323846;
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
vector<int> v[maxn];
bool vis[maxn];
void dfs(int u){
    vis[u]=1;
    for(int x:v[u]){
        if(!vis[x]) dfs(x);
    }
}
int main(){
    int n,m;
    cin>>n>>m;
    REP(i,m){
        int a,b;
        cin>>a>>b;
        --a;
        --b;
        v[a].pb(b);
        v[b].pb(a);
    }
    int cnt=0;
    REP(i,n) if(!vis[i]) dfs(i),cnt++;
    cout<<cnt-1;
}


Measured memory_bytes: 31204
#include <iostream>
#include <cmath>
#include <limits>
#include <set>

using namespace std;


int main(){

    int N, K;
    cin >> N >> K;
    int di, dj;
    int l = 0;
    int it;
    set<int> A;
    for(int i = 0; i < K; i++){
        cin >> di;
        for(int j = 0; j < di; j++){
            cin >> dj;
            A.insert(dj);
        }
    }

    auto itr = A.begin();

    for(int k = 1; k <= N; k++){
        itr = A.find(k);
        if(itr == A.end()) l++;
        itr = A.begin();
    }

    cout << l << endl;

    return 0;
}

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


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var sx = n[0];
        var sy = n[1];
        var tx = n[2];
        var ty = n[3];

        StringBuilder ans = new StringBuilder("");
        //1
        for (int i = sy; i < ty; i++)
        {
            ans.Append("U");
        }

        for (int i = sx; i < tx; i++)
        {
            ans.Append("R");
        }

        //2        
        for (int i = ty; i > sy; i--)
        {
            ans.Append("D");
        }

        for (int i = tx; i > sx; i--)
        {
            ans.Append("L");
        }

        //3
        ans.Append("L");
        for (int i = sy; i <= ty; i++)
        {
            ans.Append("U");
        }
        for (int i = sx; i <= tx; i++)
        {
            ans.Append("R");
        }
        ans.Append("D");


        //4
        ans.Append("R");
        for (int i = ty; i >= sy; i--)
        {
            ans.Append("D");
        }
        for (int i = tx; i >= sx; i--)
        {
            ans.Append("L");
        }
        ans.Append("U");

        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13352
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

ll gcd(ll m, ll n) {
    if (m < n) gcd(n, m);
    ll r;
    while (r = m % n) {
        m = n;
        n = r;
    }
    return n;
}

int main() {
    ll n, x;
    cin >> n >> x;
    ll ans;
    for(ll i=0; i<n; i++) {
        ll tmp;
        cin >> tmp;
        if(i==0) ans = abs(tmp - x);
        else ans = gcd(ans, abs(tmp - x));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool flag[100005];
string a[100005];
int main()
{
	int n;
	cin>>n;
	map<vector<int>,vector<int> >mp;
	long long sum=0;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
	{
		vector<int>cnt(26);
		for(int j=0;j<a[i].size();j++)
			cnt[a[i][j]-'a']++;
		mp[cnt].push_back(i);
	}
	for(int i=0;i<n;i++)
	{
		
		vector<int>cnt(26);
		for(int j=0;j<a[i].size();j++)
			cnt[a[i][j]-'a']++;
		if(!flag[i]&&mp[cnt].size()!=1)
		{
			for(int j=0;j<mp[cnt].size();j++)
				flag[mp[cnt][j]]=true;
			sum+=mp[cnt].size()*(mp[cnt].size()-1)/2;
		}
	}
	cout<<sum;

	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int ans = 700 + 100*count(s.begin(), s.end(), 'o');
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define mp make_pair
#define pb push_back
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

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

	vector<ll> A(100010, 0), B(100010, 0);
	for (int i = 0; i < N+1; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];

	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ll can1 = B[i] - A[i];
		if (can1 <= 0) {
			ans += B[i];
			A[i] -= B[i];
		} else {
			ans += A[i];	
			A[i] = 0;
			ll can2 = can1 - A[i+1];
			if (can2 <= 0) {
				ans += can1;
				A[i+1] -= can1;
			} else {
				ans += A[i+1];
				A[i+1] = 0;
			}
		}
	}

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


Measured memory_bytes: 1792
<?php
$price = explode(" ",fgets(STDIN));
fscanf(STDIN,"%d",$amount);

$tmp_num = $price[0]*8;
if($tmp_num > $price[1]*4){
  $tmp_num = $price[1]*4;
}
if($tmp_num > $price[2]*2){
  $tmp_num = $price[2]*2;
}

$one_l = $tmp_num / 2;

if($tmp_num > $price[3]){
  $tmp_num = $price[3];
}

if($amount == 1)
{
  echo $one_l;
}
else if($amount % 2 == 0){
  echo $tmp_num * ($amount / 2);
}
else{
  echo $tmp_num * (($amount - 1) / 2) + $one_l;
}

Measured memory_bytes: 3576
(* Vicfred
 * https://atcoder.jp/contests/abc170/tasks/abc170_a
 * implementation
 * *)
open Printf
open Scanf

let main =
    let xs = Array.init 5 @@ fun _ -> scanf"%d " @@ fun x -> x in
    for i = 0 to 4 do
        if xs.(i) = 0 then
            printf "%d\n" @@ i + 1
    done



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

string s[3];

int main(){

   while(cin>>s[0]>>s[1]>>s[2]){

       int turn=0;
       char ans='A';

       while(1){

            if(s[turn].size()==0){

                ans=ans+turn;
                break;

            }else{

                int temp=s[turn][0]-'a';
                s[turn].erase(s[turn].begin());
                turn=temp;
            }


       }

       cout<<ans<<endl;


   }




return 0;
}


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

const int N_MAX = 3000;

int n;
int a[N_MAX + 2];

int ans;

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        ans += a[i] - 1;
    }

    cout << ans << '\n';

    return 0;
}


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

int main(){
    string s,t;
    cin >> s >> t;
    map<char,char> mp1,mp2;
    bool ok=true;
    rep(i,s.size()){
        if(mp1.count(s[i]) && mp1[s[i]]!=t[i])ok=false;
        if(mp2.count(t[i]) && mp2[t[i]]!=s[i])ok=false;
        mp1[s[i]]=t[i];
        mp2[t[i]]=s[i];
    }

    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int x,y,z,k;
  cin >> x >> y >> z >> k;
  vector<ll> a(x), b(y), c(z);
  REP(i,x) cin >> a[i];
  REP(i,y) cin >> b[i];
  REP(i,z) cin >> c[i];
  vector<ll> ab;
  REP(i,x) REP(j,y) ab.push_back(a[i] + b[j]);
  sort(ALL(ab), greater<ll>());
  vector<ll> abc;
  REP(i,min(k,x*y)) REP(j,min(k,z)) abc.push_back(ab[i] + c[j]);
  sort(ALL(abc), greater<ll>());
  REP(i,k) cout << abc[i] << '\n';
  
  return 0;
}


Measured memory_bytes: 43368
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a>=13)cout<<b<<endl;
	else if(a>=6 && a<=12)cout<<b/2<<endl;
	else cout<<"0"<<endl;
	return 0;
}



Measured memory_bytes: 256
n, k = list(map(int, input().split()))
mod = int(1e9 + 7)

q = [0] * (k + 1)
for i in range(1, k+1)[::-1]:
    q[i] = pow(k//i, n, mod)
    for j in range(2, k // i + 1):
        if i * j > k:
            continue
        q[i] -= q[i * j]
s = 0
for i, qq in enumerate(q):
    s += i * qq
    s %= mod
print(s)

Measured memory_bytes: 11288
#include <bits/stdc++.h>
using namespace std;
typedef long long 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 sum = 0;
  ll count = 0;
  ll m = 1000;
  for(ll bit = 0; bit < (1<<d); bit++){
    sum = 0;
    count = 0;
    for(ll i = 0; i < d; i++){
      if(bit & (1<<i)){
        sum = sum + 100*(i+1)*p[i] + c[i];
        count += p[i];
      }
    }
    if(sum >= g){
          if(count < m){
            m = count;
          }
        }
    else{
      for(ll i = d-1; i >= 0; i--){
         if(bit & (1<<i)){
           continue;
         }
         for(ll j = 1; j <= p[i]; j++){
           count++;
           sum += 100*(i+1);
           if(sum >= g){
             m = min(m, count);
             break;
           }
         }
         if(sum < g){
           continue;
         }
      }
    }
  }
  cout << m << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    ll l, r;
    cin >> l >> r;
    ull ans = 0;
    if (r-l < 2019) {
        ans = 2018;
        for(ull i = l; i < r; i++) for(ull j = i+1; j <r+1; j++) ans = min(ans,i * j % 2019);
    }

    cout << ans << '\n';

    return 0;
}


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

using namespace::std;

int main(void){
  int num;
  string input;

  cin >> num;
  cin.ignore();

  getline(cin, input);

  stringstream ss(input);
  vector<int> v;

  string buf;

  while(!ss.eof()){
    ss >> buf;
    v.push_back(stoi(buf));
  }


  //int max = *max_element(v.begin(),v.end());
  int res = 0;
  for(auto x:v)res+=x-1;
  /*
  int cnt=1;
  bool f=true;
  while(f){
    f=false;
    int m = max*cnt-1;
    for(auto x:v){
      if(m%x != x-1)f=true;
    }
  }
  */


  cout << res << endl;

  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(){
    int k,flag = 0;
    int a,b,i;
    
    scanf("%d",&k);
    scanf("%d %d",&a,&b);
    
    for(i = a; i <= b; i++){
        if(i % k == 0){
            flag = 1;
            break;
        }
    }
    if(flag == 1) printf("OK\n");
    else printf("NG\n");
    return 0;
}


Measured memory_bytes: 1644
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>

#define rep(i,n) for(int i=0;i<n;i++)
#define llint long long int

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	if (k == 1) {
		cout << 0 << endl;
	}
	else {
		cout << n - k << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n;
    cin >> n;
    vector <string> s(n,"");
    for(long i = 0; i<n; i++){
        cin >> s[i];
    }
    sort(s.begin(),s.end());
    // cout << endl;
    // for(long i = 0; i<n;i++){
    //     cout << s[i] << endl;
    // }
    // cout << endl;
    vector <string> uniq;
    vector <long> num;
    long cntMax = 0;
    for(long i = 0; i<n; i++){
        // cout << endl;
        // cout << s[i] << endl;
        if(i==0){
            uniq.push_back(s[i]);
            num.push_back(0);
        }else{
            // cout << uniq.back() << endl;
            // cout << num.back() << endl;
            if(uniq.back().compare(s[i])==0){
                num.back()++;
            }else{
                uniq.push_back(s[i]);
                num.push_back(0);
            }
        }
        if(num.back()>cntMax){
            cntMax=num.back();
        }
    }
    //cout << cntMax << endl;
    vector <long> maxIndex;
    for(long i = 0; i<num.size(); i++){
        // cout << num[i] << endl;
        // cout << uniq[i] << endl;
        if(num[i]==cntMax){
            maxIndex.push_back(i);
        }
    }
    for(long i = 0; i<maxIndex.size(); i++){
        cout << uniq[maxIndex[i]] << endl;
    }
    #if 0
    for(long i =0; i<n; i++){
        cout << s[i] << endl;
    }
    #endif
    return 0;
}

Measured memory_bytes: 19044
import java.util.*;
import java.io.*;
import java.math.BigInteger;

public class Main {

	static char[] arr;
	static int k;
	static int[] pow26;

	public static int dp(int i, int j) {
		if (j == arr.length) {
			return pow26[arr.length + k - i];
		}
		if (i == k)
			return 1;

		return 25 * dp(i + 1, j) + dp(i, j + 1);
	}

	static long[] fac, facinv;

	static final int mod = (int) 1e9 + 7;

	public static long nck(int n, int k) {
		if (k > n)
			return 0;
		return fac[n] * facinv[k] % mod * facinv[n - k] % mod;
	}

	public static long modpow(long a, long e) {
		if (e == 0)
			return 1;
		long p = modpow(a, e / 2);
		if (e % 2 == 0)
			return (p * p) % mod;
		else
			return a * p % mod * p % mod;
	}

	public static long modInv(long a) {
		return modpow(a, mod - 2);
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		k = sc.nextInt();
		arr = sc.next().toCharArray();
		fac = new long[arr.length + k + 1];
		fac[0] = 1;
		for (int i = 1; i < fac.length; i++) {
			fac[i] = i * fac[i - 1] % mod;
		}
		facinv = new long[arr.length + k + 1];
		facinv[0] = 1;
		for (int i = 1; i < facinv.length; i++) {
			facinv[i] = modInv(i) * facinv[i - 1] % mod;
		}
		long ans = 0;
		int s = arr.length;
		for (int i = 0; i <= k; i++) {
			ans += modpow(25, i) * nck(i + s - 1, i) % mod * modpow(26, k - i) % mod;
			ans %= mod;
		}
		pw.println(ans);
		pw.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

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

		public int[] nextIntArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = Integer.parseInt(next());
			}
			return arr;
		}

	}

}


Measured memory_bytes: 64984
#include<stdio.h>
int main()
{
	int a,b,m,n;
	scanf("%d",&n);
	a=n/100;
	b=n%100;
	if(a>=1 && a<=12 && b>=1 && b<=12)
	{
		printf("AMBIGUOUS\n");
	}
	else if(a>=1 && a<=12)
	{
		printf("MMYY\n");
	}
	else if(b>=1 && b<=12)
	{
		printf("YYMM\n");
	}
	else if(a<1 || a>12 && b<1 || b>12)
	{
		printf("NA\n");
	}
	
}

Measured memory_bytes: 128
#include<iostream>
#include<climits>
#include<cmath>
using namespace std;
int main()
{ int n;
cin >> n;
int *arr=new int[n];
for(int j=0; j<n; j++)
{
cin >> arr[j];
}


int *dp=new int[n];
dp[0]=0;

for(int i=1; i<n; i++)
{ int op1=INT_MAX;
int op2=INT_MAX;
if(i-1>=0)
{ op1=abs(arr[i]-arr[i-1])+dp[i-1];
}
if(i-2>=0)
{ op2=abs(arr[i]-arr[i-2])+dp[i-2];
}

dp[i]=min(op1,op2);

}

cout << dp[n-1] << endl;}









Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>


int main() {
    int x,y,z;
    scanf("%d %d %d", &x, &y, &z);
    int ans = ( x - z ) / ( y + z );
    printf ("%d\n", ans);
    return 0;
}


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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp1=0, tmp2=0;
vector<ll> A;

signed main(){
    cin >> N;
    cin >> tmp1 >> tmp2;
    //cout << tmp1 << " " << tmp2 << endl;
    for(int i=0;i<N-1;i++) {
        ll a, b, d1, d2;
        cin >> a >> b;
        d1 = tmp1+a-1;
        d1 /= a;
        if(tmp1<=d1*a&&tmp2<=d1*b) {
            tmp1 = d1*a;
            tmp2 = d1*b;
            continue;
        }
        d2 = tmp2+b-1;
        d2 /= b;
        tmp1 = d2*a;
        tmp2 = d2*b;
    }
    cout << tmp1+tmp2 << endl;
    return 0;
}

Measured memory_bytes: 3600
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())

B = list(int(input()) for i in range(N))

def check(A, B):
    for k in range(N):
        for j in range(3):
            if A[j] == B[k]:
                A[j] = 0
    return A

A1 = check(A1, B)
A2 = check(A2, B)
A3 = check(A3, B)

if sum(A1) == 0 or sum(A2) == 0 or sum(A3) == 0:
    print("Yes")
elif (A1[0] + A2[0] + A3[0] == 0) or (A1[1] + A2[1] + A3[1] == 0) or (A1[2] + A2[2] + A3[2] == 0):
    print("Yes")
elif (A1[0] + A2[1] + A3[2] == 0) or (A1[2] + A2[1] + A3[0] == 0):
    print("Yes")
else:
    print("No")


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

int count[200001];
int main()
{
	int n;
	scanf("%d", &n);
	int a[200000];
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", a + i);
		count[a[i]]++;
	}
	long long all = 0;
	for (int i = 1; i <= n; ++i)
	{
		all += (long long)(count[i]) * (long long)(count[i] - 1) / 2;
	}
	for (int i = 0; i < n; ++i)
	{
		long long before = count[a[i]];
		long long after = count[a[i]] - 1;
		printf("%lld\n", all - before * (before - 1) / 2 + after * (after - 1) / 2);
	}
	return 0;
}


Measured memory_bytes: 3584
from math import *

def trycut(val):
	if val == 0 : return float('inf')
	ret = 0
	for i in range(n):
		ret += (a[i]+val-1)//val -1
	return ret 

n,k=map(int,input().split())
a = [int(i) for i in input().split()]

low = 0
high = max(a)
ans  =-1

while low <= high:
	mid = (low + high)//2
	cut = trycut(mid)
	if cut <= k:
		high = mid-1
		ans = mid
	else:
		low =  mid+1
print(ans)




Measured memory_bytes: 30996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

ll dp[110][100010];
void solve(long long N, long long W, std::vector<long long> w, std::vector<long long> v)
{
    for (int i = 1; i <= N; i++)
    {
        for (int j = 0; j <= W; j++)
        {
            if (j >= w[i - 1])
            {
                dp[i][j] = max({dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1], dp[i - 1][j]});
            }
            else
            {
                dp[i][j] = max({dp[i][j], dp[i - 1][j]});
            }
        }
    }

    // for (int i = 0; i <= N; i++)
    // {
    //     for (int j = 0; j <= W; j++)
    //     {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    cout << dp[N][W] << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long W;
    scanf("%lld", &W);
    std::vector<long long> w(N);
    std::vector<long long> v(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &w[i]);
        scanf("%lld", &v[i]);
    }
    solve(N, W, std::move(w), std::move(v));
    return 0;
}


Measured memory_bytes: 79360
from math import sin
from math import cos
from math import pi
a, b, C = (int(x) for x in input().split())

angle = pi/180 * C

S = a * b * sin(angle)/2

c = (a ** 2 + b ** 2 - 2*a*b*cos(angle)) ** (1/2)

L = a + b + c

h = 2 * S / a

print(float(S))
print(float(L))
print(float(h))


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

//#define DEBUG

int main(void)
{
    FILE* fp;
#ifdef DEBUG
    fp=fopen("input.txt","r");
#else
    fp=stdin;
#endif
  
    double x=0,y=0,theta=M_PI/2.0;
    while(1){
        //input
        int hosu,degree;
        fscanf(fp,"%d,%d\n",&hosu,&degree);
        if(hosu==0 && degree==0){ break; }
        
        //next position
        x+=(double)hosu*cos(theta);
        y+=(double)hosu*sin(theta);
        theta+=-(double)degree*M_PI/180.0;
    }
    //result
    printf("%d\n%d\n",(int)x,(int)y);
    return 0;
}

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

int main(){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  
  vector<int> v(3);

  v[0] = a * x + b * y;
  if (x < y){
    v[1] = c * 2 * x + b * (y - x);
    v[2] = c * 2 * y;
  } else {
    v[1] = c * 2 * y + a * (x - y);
    v[2] = c * 2 * x;
  }
  ll ans = 5e10;
  rep(i, 3){
    if (v[i] < ans) ans = v[i];
  }
  cout << ans << endl;

  return 0;
}

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

#ifndef MAX
#define MAX 400000
#endif

//Range Add Query+Range Sum Query
template<class T>
class RAQ_RSQ {
public:
	int n;
	T dat[MAX], lazy[MAX], ZERO;
	void init(int n_) {
		ZERO = T();
		n = 1; while (n < n_)n <<= 1;
		for (int i = 0; i < 2 * n - 1; i++) {
			dat[i] = lazy[i] = ZERO;
		}
	}
	inline void push(int k, int s) {
		dat[k] = dat[k] + lazy[k] * s;
		if (k < n - 1) {
			lazy[k * 2 + 1] = lazy[k * 2 + 1] + lazy[k];
			lazy[k * 2 + 2] = lazy[k * 2 + 2] + lazy[k];
		}
		lazy[k] = ZERO;
	}
	inline void update_node(int k) {
		dat[k] = dat[k * 2 + 1] + dat[k * 2 + 2];
	}
	inline void update(int a, int b, T x, int k, int l, int r) {
		push(k, r - l);
		if (r <= a || b <= l)return;
		if (a <= l&&r <= b) {
			lazy[k] = lazy[k] + x; push(k, r - l); return;
		}
		update(a, b, x, k * 2 + 1, l, (l + r) / 2);
		update(a, b, x, k * 2 + 2, (l + r) / 2, r);
		update_node(k);
	}
	inline T query(int a, int b, int k, int l, int r) {
		push(k, r - l);
		if (r <= a || b <= l)return ZERO;
		if (a <= l&&r <= b)return dat[k];
		T lb = query(a, b, k * 2 + 1, l, (l + r) / 2);
		T rb = query(a, b, k * 2 + 2, (l + r) / 2, r);
		update_node(k);
		return lb + rb;
	}
	inline void update(int a, int b, T x) {
		update(a, b, x, 0, 0, n);
	}
	inline void update(int a, T x) {
		update(a, a + 1, x);
	}
	inline T query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
	inline T query(int a) {
		return query(a, a + 1);
	}
};

vector<int>E[200000];
int par[200000],d[200000],sub[200000];
int chain[200000],vid[200000];
int node_num;

void dfs(int v,int p,int dep){
	par[v]=p;d[v]=dep;
	sub[v]=1;
	for(int u:E[v]){
		if(u==p)continue;
		dfs(u,v,dep+1);
		sub[v]+=sub[u];
	}
}
void hld(int v,int k){
	chain[v]=k;
	vid[v]=node_num++;
	int Max=0,id=-1;
	for(int u:E[v]){
		if(u==par[v])continue;
		if(Max<sub[u]){
			Max=sub[u];
			id=u;
		}
	}
	if(id==-1)return;
	hld(id,chain[v]);
	for(int u:E[v]){
		if(u==id||u==par[v])continue;
		hld(u,u);
	}
}
ll res=0;
void query(int u,int v,function<void(int,int)>f){
	while(1){
		if(d[chain[u]]>d[chain[v]])swap(u,v);
		if(chain[u]==chain[v]){
			f(min(vid[u],vid[v])+1,max(vid[u],vid[v])+1);
			break;
		}
		else{
			f(vid[chain[v]],vid[v]+1);
			v=par[chain[v]];
		}
	}
}

RAQ_RSQ<ll>seg;
int main(){
	int n;scanf("%d",&n);
	rep(i,n){
		int k;scanf("%d",&k);
		rep(j,k){
			int c;scanf("%d",&c);
			E[i].push_back(c);
		}
	}
	dfs(0,-1,0);
	hld(0,0);
	seg.init(n);
	int q;scanf("%d",&q);
	rep(i,q){
		int t;scanf("%d",&t);
		if(t==0){
			int v,w;scanf("%d%d",&v,&w);
			query(0,v,[&](int l,int r){seg.update(l,r,w);});
		}
		else{
			int u;scanf("%d",&u);
			res=0;
			query(0,u,[&](int l,int r){res+=seg.query(l,r);});
			printf("%lld\n",res);
		}
	}
}


Measured memory_bytes: 24868
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr double EPS = 1e-9;



int main() {

    int x;
    cin>>x;
    for(ll a=0;a<3000;a++){
        ll A=pow(a,5);
        ll B5=A-x;
        int minus=1;
        if(B5<0){
            B5*=-1;
            minus=-1;
        }
        ld po = pow(B5,1.0/5.0);
        // if(a==0)cout<<A<<" "<<B5<<" "<<po<<" "<<minus<<endl;
        ll B1=pow(ceil(po),5);
        ll B2=pow(floor(po),5);
        if(A-minus*B1==x){
            // cout<<A<<" "<<B5<<" "<<po<<" "<<minus<<endl;
            cout<<a<<" "<<minus*ceil(po)<<endl;
            return 0;
        }
        if(A-minus*B2==x){
            cout<<a<<" "<<minus*floor(po)<<endl;
            return 0;
        }
    }

}



Measured memory_bytes: 4216
#include<iostream>

using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define ENDL '\n'
#define all(a) begin(a),end(a)
#define sz(a) (int)(a.size())
#define deb(a) cout << #a << ": "  << a << ENDL
#define fore(i, a, b) for(int i(a), ThkMk(b); i < ThkMk; ++i)
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli> ii;

lli dp[21][(1 << 21)];

lli MOD = 1e9 + 7;

vector<vector<lli>> graph;

lli n;

lli solve(lli boy, lli mask) {
    if(boy == n) return 1LL;
    lli &ans = dp[boy][mask];
    if(ans != -1) return ans;
    ans = 0;
    fore(i, 0, n) {
        if(graph[boy][i] and (!(mask & (1 << i))))
            ans = (ans + solve(boy + 1, mask | (1 << i))) % MOD;
    }
    return ans;
}

int main()
{   _
    fore(i, 0, 21) fore(j, 0, (1 << 21)) dp[i][j] = -1;
    cin >> n;
    graph.resize(n);
    fore(i, 0, n) {
        graph[i].assign(n, 0);
        fore(j, 0, n) cin >> graph[i][j];
    }
    cout << solve(0, 0) << ENDL;
    return 0;
}


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

using namespace std;

main(){
  int n;
  while(cin >> n && n){
    string str;
    cin >> str;
    int a[100];
    int b[100];
    for(int i=0;i<n;i++){
      cin >> a[i] >> b[i];
      --a[i]; --b[i];
    }
    for(int i=n-1;i>=0;--i){
      char tmp = str[a[i]];
      str[a[i]] = ((str[b[i]]-'a'+b[i]-a[i]) % 26) + 'a';
      str[b[i]] = ((tmp-'a'+b[i]-a[i]) % 26) + 'a';
    }
    cout << str << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define nn '\n'
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n,x; cin >> n >> x;
    VI l(n); REP(i,n) cin >> l[i];
    VI l2(n); partial_sum(l.begin(), l.end(), l2.begin());
    out(UPPER(l2,x)+1);

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int a=scan.nextInt();
    int b=scan.nextInt();
    int c=scan.nextInt();
    int ans=c+b-a;
    if(ans<0){
      System.out.println(0);
    }else{
      System.out.println(c+b-a);
    }
  }
}

Measured memory_bytes: 22996
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
// ll dp[310][310][310] = {};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H,W;
    cin >> H >> W;
    string C[310];
    rep(i,0,H) cin >> C[i];
    ll ans = 0;
    rep(w,0,W-1){
        ll val[310][610] = {}; // 左がiで左-右がj
        rep(i,0,H){
            rep(j,0,H){
                if(C[i][w] == C[j][w+1]){
                    ll diff = (i - j) * (-1) + H;
                    // ll max_val = min(H-i-1 , H-j-1);
                    val[0][diff]++;
                    val[H-1-i+1][diff]--;
                }
            }
        }
        rep(j,0,2*H+1){
            rep(i,0,H+1){
                val[i+1][j] += val[i][j];
            }
        }


        ll dp[310][310] = {};
        rep(i,0,H+1){
            rep(j,0,H+1){
                dp[i][j] = INF;
            }
        }
        dp[0][0] = 0;
        rep(i,0,H+1){
            rep(j,0,H+1){
                ll v1 = H-1-i, v2 = H-1-j;
                ll c1 = 0, c2 = 0, c3 = 0;
                dp[i+1][j] = min(dp[i+1][j], dp[i][j] + val[i][i-j+H]);
                dp[i][j+1] = min(dp[i][j+1], dp[i][j] + val[i][i-j+H]);
            }
        }
        ans += dp[H][H];
    }
    print(ans);

}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define bug(x) cout << #x << " = " << x << endl
using namespace std;
typedef long long int ll;

int main(){
    char frame[205][205]={0};
    int h,w;
    cin>>h>>w;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++) cin>>frame[i][j];
    }
    for(int i=0;i<=w+1;i++) frame[0][i]=frame[h+1][i]='#';
    for(int i=1;i<=h;i++) frame[i][0]=frame[i][w+1]='#';
    for(int i=0;i<=h+1;i++){
        for(int j=0;j<=w+1;j++) cout<<frame[i][j];
        cout<<endl;
    }
	return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;


int main(){

  ll s;cin>>s;
  ll v=1000000000;

  ll x=(v-s%v)%v;
	ll y=(s+x)/v;

	cout<<"0 0 "<<v<<" 1 "<<x<<" "<<y<<endl;

  return 0;
}


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

using namespace std;

int main(int argc, char *argv[])
{
    int max, ttl, temp;
    char c;
    vector<char> v;
    map<char, int> m_left, m_right;

    ttl = 0;
    temp = 0;

    cin >> max;
    for(int i = 0; i < max; i++){
        cin >> c;
        v.push_back(c);
        map<char, int>::iterator it = m_left.find(c);
        if(it == m_left.end()){
            m_left.insert(make_pair(c, 1));
        }else{
            m_left[c]++;
        }
    }

    vector<char>::iterator v_it = v.begin();

    while(v_it != v.end()){
        c = *v_it;
        map<char, int>::iterator it = m_right.find(c);
        if(m_left[c] > 1){
            if(it == m_right.end()){
                m_right.insert(make_pair(c, 0));
                temp++;
            }
            m_right[c]++;
            m_left[c]--;
        }else if(m_left[c] == 1){
            if(it == m_right.end()){
                m_right.insert(make_pair(c, 0));
            }else{
                temp--;
            }
            m_right[c]++;
            m_left[c]--;
        }
        if(ttl < temp){
            ttl = temp;
        }
        v_it++;
    }

    cout << ttl << '\n';
    return 0;
}

Measured memory_bytes: 256
n=int(input())
s=input()
l=[]
counter=0
for i in range(n):
    if s[i]=="(":
        counter+=1
    else:
        counter-=1
    l.append(counter)
suml=l[-1]
for i in range(n):
    if l[i]<0:
        s="("+s
        for j in range(n):
            l[j]+=1
        suml+=1
if suml>0:
    s+=")"*suml
print(s)


Measured memory_bytes: 3060
import java.util.*;

public class Main {


//    public static int gcd(int x, int y){
//        if (y==0) return x;
//        return gcd(y, x%y);
//    }

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a > b){
            System.out.println(a+a-1);
        }else if (a == b){
            System.out.println(a+b);
        }else{
            System.out.println(b+b-1);
        }

    }
}




Measured memory_bytes: 23892
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node{
    int parent, left, right;
};

Node T[MAX];
int n, D[MAX];

void print(int u){
    cout << "node " << u << ": ";
    cout << "parent = " <<T[u].parent << ", ";
    cout << "depth = " <<D[u] << ", ";

    if(T[u].parent == NIL) cout << "root, ";
    else if(T[u].left == NIL) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";

    for(int i = 0, c =  T[u].left; c != NIL; i++, c = T[c].right){
        if(i>0)cout << ", ";
        cout << c;        
    }
    cout << "]" << endl;
}

void rec(int u, int p){
    D[u] = p;
    if(T[u].right != NIL) rec(T[u].right, p);
    if(T[u].left != NIL) rec(T[u].left, p+1);
}

int main(){

    cin >> n;
    for(int i = 0; i < n; i++){
        T[i].parent = T[i].left = T[i].right = NIL;
    }
    for(int i = 0; i < n; i++){
        int v, k, c,l;
        cin >> v >> k;
        for(int j = 0; j < k; j++){
            cin >> c;
            if(j==0)T[v].left = c;
            else T[l].right = c;
            l = c;
            T[c].parent = v;
        }
    }
    int root;
    for(int i = 0; i < n; i++){
        if(T[i].parent == NIL) root = i;
    }
    rec(root, 0);

    for(int i = 0; i < n; i++){
/*
        cout << "Node: " << i;
        cout << " Parent: " << T[i].parent;
        cout << " Left: " << T[i].left;
        cout << " Right: " << T[i].right;
        cout << endl;
*/
        print(i);
    }
    return 0;
}


Measured memory_bytes: 7660
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	unsigned int res = 1;
	FOR(i, 0, n-1) {
		res *= (k - 1);
	}
	res *= k;

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256