akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    long MOD = 998244353L;
    long[][] dp = new long[3001][3001];
    void solve(Scanner sc, PrintWriter pw) {
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        dp[A][B] = 1;
        for (int c = A; c <= C; c++) {
            for (int d = B; d <= D; d++) {
                if (c == A && d == B) {
                    continue;
                }
                long ans = 0;
                if (c > A) {
                    long part = dp[c - 1][d];
                    ans = (part * d);
                }
                if (d > B) {
                    long part = dp[c][d - 1];
                    ans = (ans + (part * c));
                }
                if (c > A && d > B) {
                    ans = (ans - (dp[c - 1][d - 1] * (c - 1) * (d - 1)));
                }
                dp[c][d] = ((ans %MOD) + MOD) % MOD;
            }
        }
        pw.println(dp[C][D]);
    }

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
}


Measured memory_bytes: 107276
#include<bits/stdc++.h>
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int h, w, ans;
bool a[110][110];//input
bool b[110][110];
void f(int i, int j) {
	if (i < 0 || h + 1 < i)return;
	if (j < 0 || w + 1 < j)return;
	if (b[i][j] || a[i][j])return;
	b[i][j] = 1;

	if (a[i + 1][j])ans++;
	else f(i + 1, j);
	if (a[i - 1][j])ans++;
	else f(i - 1, j);

	if (a[i][j + 1])ans++;
	else f(i, j + 1);
	if (a[i][j - 1])ans++;
	else f(i, j - 1);
	
	if (i % 2 == 0) {
		if (a[i - 1][j - 1])ans++;
		else f(i - 1, j - 1);
		if (a[i + 1][j - 1])ans++;
		else f(i + 1, j - 1);
	}
	else {
		if (a[i + 1][j + 1])ans++;
		else f(i + 1, j + 1);
		if (a[i - 1][j + 1])ans++;
		else f(i - 1, j + 1);
	}
}
signed main() {
	cin >> h >> w; swap(h, w);
	for1(i, h)for1(j, w)cin >> a[i][j];//"j,i"
	f(0, 0); cout << ans << endl;
}


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

int main()
{
    string s;
    cin >> s;
    ll q;
    cin >> q;
    ll t, f;
    char  c1;
    string c;
    bool rev = false;
    for(ll i = 0; i < q; i++){
        scanf("%lli", &t);
        if(t == 1){
            rev = !rev;
        }else{
            scanf("%lli", &f);
            scanf(" %c", &c1);
            c = {c1};
            if(f == 1){
                if(rev) s.insert(s.size(), c);
                else s.insert(0, c);
            }else{
                if(rev) s.insert(0, c);
                else s.insert(s.size(), c);
            }
        }
    }

    if(rev) reverse(s.begin(), s.end());
    

    cout << s << endl;



    return 0;
}

Measured memory_bytes: 900
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-3;
const double PI = acos(-1);

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

int main(){
	int m, n, t, p, f;
	stringstream ss;
	string s;
	vi v;
	while(cin>>m && m){
		cin.ignore();
		vector<pii> score(m);
		rep(j, m){
			getline(cin,s);
			ss.clear();
			ss<<s;
			ss>>n;
			v.clear();
			while(ss>>t) v.pb(t);
			//rep(i, v.size()) cout<<" "<<v[i];
			//cout<<endl;
			p = t = 0;
			f = 1;
			for(int i = 0; i < v.size() && f <= 10; i++, f++){
				t = v[i];
				if(t == 10){
					if(i+1<v.size())t += v[i+1];
					if(i+2<v.size())t += v[i+2];
					p += t;
					//<<t<<" "<<p<<endl;
					continue;
				}
				t+=v[i+1];
				i++;
				if(t == 10){
					if(i+1< v.size()) t+= v[i+1];
				}
				p+=t;
				//cout<<t<<" "<<p<<endl;
			}
			score[j] = mp(p, -n);
		}
		sort(rall(score));
		rep(i, m){
			cout<<-score[i].se<<" "<<score[i].fi<<endl;
		}
	}
}

Measured memory_bytes: 1272
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#define MOD 1000000007

int i;

struct edge {
    int to;
    int cost;
};

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


int main(void) {
    int n,m;
    cin >> n >> m;
    int lm=1,rm=100000;
    for(i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        if(a>=lm){
            lm=a;
        }
        if(b<=rm){
            rm=b;
        }
    }
    cout << max((rm-lm+1),0) << endl;
    return 0;
}


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

using namespace std;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for(int i = 0;i < n;++i)
long long N,Y;
long long A=0;
int main()
{
  string a;
  int l=0,c=0;
  vector<int>s;
  cin>>N>>Y;
  int a1=0,a2=0,a3=0;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N-i;j++){
      if(i*10000+j*5000+(N-i-j)*1000==Y){
        cout<<i<<" "<<j<<" "<<N-i-j;
        return 0;
      }
    }
  }
  cout<<"-1 -1 -1";
  
  return 0;
}

Measured memory_bytes: 3600
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<string>
#include <vector>

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

using namespace std;

int main(){
	int A, B, X, Y, Z;
	scanf("%d %d", &A, &B);
	X = A + B;
	Y = A - B;
	Z = A*B;
	int ans;
	ans = max(X, Y);
	ans = max(ans, Z);

	printf("%d\n", ans);


	return 0;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	int* a = new int[n];
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int min_x = 0;
	for (int i = 0;i < n;i++) {
		min_x += a[i];
	}
	min_x /= n;
	int ansl, ansr;
	ansl = ansr = 0;
	for (int i = 0;i < n;i++) {
		ansl += (a[i] - min_x) * (a[i] - min_x);
		ansr += (a[i] - min_x - 1) * (a[i] - min_x - 1);
	}
	cout << min(ansl, ansr) << endl;
}

Measured memory_bytes: 3180
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int               long long
#define ff                first
#define ss                second
#define md                1000000007
#define md1               998244353
#define inf               1000000000000000
#define minf              -1000000000000000
#define pb                push_back
#define in                insert
#define mkp               make_pair
#define mpll              map<ll,ll>
#define len(p)            (ll)p.size()
#define pll               pair<ll,ll>
#define all(v)            v.begin(),v.end()
#define mem(a,t)          memset(a,t,sizeof(a))
#define endl              "\n"
#define ar                array
#define vl                vector<ll>
#define vpll              vector<pair<ll,ll>>
#define f(i,yha,wha)      for(ll i=yha;i<wha;i++)
#define rf(i,wha,yha)     for(ll i=wha;i>=yha;i--)
#define f0(n)             for(ll i=0;i<n;i++)
#define f1(n)             for(ll i=1;i<=n;i++)
#define fg(i,yha,wha,gap) for(ll i=yha;i<wha;i+=gap)


void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
ll pw(ll x, ll y)
{
    if (y == 0)
        return 1;
    if (y == 1)
        return x;
    ll ans = pw(x, y / 2);
    ans = ans * ans;
    if (y % 2 == 1)
        ans = ans * x;
    return ans;
}






void solve()
{
    int n, m, x;
    cin >> n >> m >> x;
    int cases = (1 << n);
    int ans = 1e15;
    vector<vector<int>> v(n, vector<int>(m + 2));
    for (int i = 0; i < n; i++) {
        cin >> v[i][0];
        for (int j = 1; j <= m; j++) {
            cin >> v[i][j];
        }
    }
    for (int i = 1; i < cases; i++) {
        vector<int> standing(m + 1);
        int cost = 0;
        for (int j = 0; j < n; j++) {
            if (i & (1ll << j)) {
                cost += v[j][0];
                for (int k = 1; k <= m; k++) {
                    standing[k] += v[j][k];
                }
            }
        }
        bool check = true;
        for (int i = 1; i <= m; i++) {
            if (standing[i] < x) {
                check = false;
                break;
            }
        }
        if (check) {
            ans = min(ans, cost);
        }
    }
    if (ans != 1e15)
        cout << ans << endl;
    else
        cout << -1 << endl;

}

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


Measured memory_bytes: 3660
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    char s[120],t[120],tmp[2],u[120];
    scanf("%s%s",s,t);
    for (int i=0; i<strlen(s); i++){
        if (strcmp(s,t)==0){
            printf("Yes\n");
            return 0 ;
        } else {
            tmp[0]=s[0];
            strcpy(u,s);
            strncpy(s,u+1,strlen(s)-1);
            s[strlen(s)-1]=tmp[0];
            s[strlen(s)]='\0';
        }
    }
    printf("No\n");
	return 0 ;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 vector <int> a(3);
  cin>>a.at(0)>>a.at(1)>>a.at(2);
  sort(a.begin(),a.end());
  int k;
  cin>>k;
  for(int i=0;i<k;i++){
  a.at(2) *= 2;
  }
  cout<<a.at(0) + a.at(1) + a.at(2)<<endl; 
}

Measured memory_bytes: 3568
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main(int argc, char const *argv[])
{
	long n, k, *x, ans, *r, *l, r1=1, l1=1, p=0;
	scanf("%ld%ld", &n, &k);
	x=(long *)malloc(sizeof(long)*n);
	r=(long *)malloc(sizeof(long)*(k+1));
	l=(long *)malloc(sizeof(long)*(k+1));
	for (int i = 0; i < n; ++i) scanf("%ld", &x[i]);
	while (x[p]<0) p++;
	r[0]=0;
	l[0]=0;
	for (int i = p; i < p+k; i++)
	{
		if (i>=n) break;
		r[r1]=x[i];
		r1++;
	}
	for (int i = 0; i < k; ++i)
	{
		if (p-1-i<0) break;
		l[l1]=-x[p-1-i];
		l1++;
	}
	ans=LONG_MAX;
	for (int i = 0; i <= k; ++i)
	{
		if (k-i<l1 && i<r1)
		{
			if (l[k-i]+2*r[i]<ans)
			{
				ans=l[k-i]+2*r[i];
			}
			if (2*l[k-i]+r[i]<ans)
			{
				ans=2*l[k-i]+r[i];
			}
		}

	}
	free(x);
	free(r);
	free(l);
	printf("%ld\n", ans);
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define trace1(a) cout << a << 'n';
#define trace2(a, b) cout << a << ' ' << b << 'n';
#define trace3(a, b, c) cout << a << ' ' << b << ' ' << c << 'n';
#define trace4(a, b, c, d) cout << a << ' ' << b << ' ' << c << ' ' << d << 'n';
#define trace5(a, b, c, d, e) cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << 'n';
#define trace6(a, b, c, d, e, f) cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << ' ' << f << 'n';
#define range(n) for(int i = 0; i < n; i++)
#define printArr(harry, tam) range(tam) cout << harry[i] << " n"[i == tam -1];
#define maxn -2000000 //negative value to break code and force you to put right constraint
#define mod 1000000007
#define md(x) (x) % mod;
#define sc scanf
#define pr printf
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ps push
#define prt(x) cout << (#x) << " is " << (x) << endl
#define EPS 1e-9
#define INF 1000000000
#define INFd 1e9
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<double> vd;

int main(){
  ll n,m;
  cin>>n>>m;
  map<ll,ll> m1;
  for(ll i=0;i<m;i++)
    {
        ll x,y;
        cin>>x>>y;
        m1[x]++;
        m1[y]++;
    }
    for(auto i:m1)
    {
        if((i.se%2)!=0)
        {
          cout<<"NO";
          return 0;
        }
    }
    cout<<"YES";

}


Measured memory_bytes: 5632
import java.math.*;
import java.util.*;

public class Main {
    static int gcd(int a, int b) {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l[] = new int[n];
        int GCD = 0;
        for (int i = 0; i < n; i++) {
            int tmp = sc.nextInt();
            if (i == 0){
                GCD = tmp;
                continue;
            }
            GCD = gcd(GCD, tmp);
        }
        int cnt = 0;
        while (GCD % 2 == 0) {
            GCD/=2;
            cnt++;
        }
        
        
        System.out.println(cnt);
    }
}


Measured memory_bytes: 21844
/***************************************************************
	File name: D.cpp
	Author: huhao
	Create time: Fri 17 Jan 2020 04:56:43 PM CST
***************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=r*10+c-48;
		c=getchar();
	}
	return r*t;
}
#define i64 long long
#include<assert.h>
const int N=100010;
const i64 inf=1ll<<60;
i64 n,s,x[N],p[N],s1[N],t1,s2[N],t2,ans,a[N],t,a1[N],a2[N];
int main()
{
	n=read(); s=read();
	fr(i,1,n){ x[i]=read(); p[i]=read(); }
	s1[++t1]=s2[++t2]=inf; a1[t1]=a2[t2]=s;
	fd(i,n,1) if(x[i]<s){ s1[++t1]=p[i]; a1[t1]=x[i]; }
	fr(i,1,n) if(x[i]>s){ s2[++t2]=p[i]; a2[t2]=x[i]; }
	fr(i,1,n)
		if(s1[t1]>=s2[t2])
		{
//			printf("1\n");
			a[++t]=a2[t2]; s1[t1]=std::min(s1[t1]+s2[t2],inf); t2--;
		}
		else
		{
//			printf("2\n");
			a[++t]=a1[t1]; s2[t2]=std::min(s1[t1]+s2[t2],inf); t1--;
		}
	a[++t]=s;
//	fr(i,1,n+1) printf("%lld%c",a[i],i==n+1?'\n':' ');
	fr(i,2,n+1) ans+=std::abs(a[i]-a[i-1]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4864
#include <cstdio>
#include <cctype>
#include <utility>
#include <string>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;
	while (isspace(c)) {c = gcu();}
	if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	string s;
	for (int a, b; scan(s, a, b);)
		outl(s, ' ', a + b, ' ', a * 200 + b * 300);
}


Measured memory_bytes: 2524
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
	int res = 1;
	x = x % p;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res % p;
}
int lcm(int a, int b)
{
	return a / __gcd(a, b) * b;
}
int dp[2001];
int solvedp(int sum){
  if(sum==0){
	  return 1;
  }
  if(dp[sum]!=-1){
	  return dp[sum];
  }
  int ans = 0;
  for (int i = 3; i <= sum;i++){
	  ans = ans+solvedp(sum - i);
	  ans %= mod;
  }
  return dp[sum]=ans;
}
void solve()
{
	memset(dp, -1, sizeof(dp));
	int n;
	cin >> n;
	cout << solvedp(n);
	//cout << ans << endl;
}
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int tc;
	tc = 1;
	//cin >> tc;
	while (tc--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cmath> 
#include <cctype>
#include <vector>
#include <map> 
#include <iomanip>//cout << fixed << setprecision(x) 
using namespace std;

const int maxn = 100000 + 5;
const int INF = 0x3f3f3f3f;

int main()
{
	string str;
	
	cin >> str;
	
	if (str.length() == 2)
		cout << str << endl;
	else if (str.length() == 3)
		cout << str[2] << str[1] << str[0] << endl;

	return 0;	
}

Measured memory_bytes: 256
import math
n,m=map(int,input().split())
ans=list()
for i in range(1,int(math.sqrt(m))+1):
  if m%i==0:
    ans.append(i)
    ans.append(m//i)
ans.sort(reverse=True)
for x in ans:
  if x <= m//n:
    print(x)
    break

Measured memory_bytes: 9140
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	set_union
# CreatedDate:  2020-06-09 16:02:02 +0900
# LastModified: 2020-06-09 16:04:20 +0900
#


import os
import sys
#import numpy as np
#import pandas as pd


def main():
    n=int(input())
    a=list(map(int,input().split()))
    m=int(input())
    b=list(map(int,input().split()))
    c=a+b
    c=list(set(c))
    c.sort()
    for ab in c:
        print(ab)


if __name__ == "__main__":
    main()



Measured memory_bytes: 52156
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
    int a,b;
    cin >> a >> b;
    cout << max(0,a-b) << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

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

int main() {

  int N;
  cin >> N;

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

  sort(L.begin(),L.end());
  int ans = 0;
  for(int i = 0;i < 2*N;i+=2) {
    ans += L.at(i);
  }

  cout << ans << endl;
}



Measured memory_bytes: 256
#include <set>
#include <unordered_set>
#include <vector>
#include <iostream>
using namespace std;

int dy[4] = {-1, 1, 0, 0};
int dx[4] = {0, 0, -1, 1};
int h, w;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> h >> w;
    vector<string> g(h);
    for (int i = 0; i < h; i++) {
        cin >> g[i];
    }
    unordered_set<int> q;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (g[i][j] == '#') {
                q.insert(i * w + j);
            }
        }
    }
    int total = q.size();
    int ct = 0;
    while (total < w * h) {
        unordered_set<int> nxt;
        for (auto i : q) {
            int y = i / w;
            int x = i % w;
            for (int k = 0; k < 4; k++) {
                int yy = y + dy[k];
                int xx = x + dx[k];
                int code = yy * w + xx;
                if (yy >= 0 && xx >= 0 && yy < h && xx < w && 
                        g[yy][xx] == '.' && nxt.find(code) == nxt.end() 
                        && q.find(code) == q.end()) {
                    nxt.insert(code);
                    g[yy][xx] = '#';
                }
            }
        }
        q.clear();
        q = nxt;
        ct++;
        total += nxt.size();
        if (total >= w * h) {
            break;
        }
    }
    cout << ct;
    return 0;
}


Measured memory_bytes: 43024
import re

A = ">'(=+)#\\1~$"
B = ">\^(Q=)+~~$" 

for i in range(int(input())):
    s = input()
    r = re.match(A, s)
    if re.match(A, s): print('A')
    elif re.match(B, s): print('B')
    else: print('NA')




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

using namespace std;

int main() {
int a,b,c,x,y;
cin>>a>>b>>c>>x>>y;
int A =a*x+b*y;
int B=min(x,y);
int C=c*B*2;
int H=max(x,y);
if(max(x,y)==x&&x!=y){
   int D=(x-B)*a;
   int I=c*H*2;
   int E=min(A,min(I,(C+D)));
   cout<<E<<endl;
}
else{
int F=(y-B)*b;
int J= c*H*2;
int G=min(A,min(J,(C+F)));
cout<<G<<endl;

}


   return 0;
}






Measured memory_bytes: 3628
#!/usr/bin/python3

while True:
    n = int(input())
    if (n == 0):
        break
    mat = [ [] for _ in range(n) ]
    row = [ 0 for _ in range(n) ]
    col = [ 0 for _ in range(n) ]
    for i in range(n):
        ln = list(map(int, input().split(' ')))
        mat[i] = ln
        row[i] = sum(ln)
        for j in range(n):
            col[j] += ln[j]

    total = sum(col)

    for i in range(n):
        ls = mat[i]
        ls.append(row[i])
        print(''.join(['%5d' % x for x in ls]))

    col.append(sum(col))
    print(''.join(['%5d' % x for x in col]))

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

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i=0; i<N; i++)
    cin >> p.at(i);
  
  int maxp = 0, maxidx=-1;
  for (int i=0; i<N; i++)
    if (p.at(i) > maxp) {
      maxidx = i;
      maxp = p.at(i);
    }
  
  int sump = 0;
  for (int i=0; i<N; i++) {
    if (i == maxidx)
      sump += p.at(i)/2;
    else
      sump += p.at(i);
  }
  cout << sump << endl;
}

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

using namespace std;
	
const int maxn=1e5*3+20;
int b[maxn];

int main()
{
	long long a,d,c;
	cin >> a >> d >> c;
	if(a==1 && d!=c)
		cout << 0;
	else if(d>c)
		cout << 0;
	else 
		cout << ((a-1)*c+d) - ((a-1)*d+c) +1;
}

 



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
    char str1[] = "hi";
    char str3[] = "hihi";
    char str4[] = "hihihi";
    char str5[] = "hihihihi";
    char str6[] = "hihihihihi";
    char str2[10];
    int n;
     
    scanf("%s",str2);
    
    n=strlen(str2);
  
    if(n==2){  
     //2
     if(strstr(str2,str1)==0)
     {
         printf("No\n");
     }
     else
     {
         printf("Yes\n");
     }
    }else if(n==4){  
     //4
     if(strstr(str2,str3)==0)
     {
         printf("No\n");
     }
     else
     {
         printf("Yes\n");
     }
    }else if(n==6){  
     //6
     if(strstr(str2,str4)==0)
     {
         printf("No\n");
     }
     else
     {
         printf("Yes\n");
     }
    }else if(n==8){  
     //8
     if(strstr(str2,str5)==0)
     {
         printf("No\n");
     }
     else
     {
         printf("Yes\n");
     }
    }else if(n==10){  
     //10
     if(strstr(str2,str6)==0)
     {
         printf("No\n");
     }
     else
     {
         printf("Yes\n");
     }
    }else{
       printf("No\n");
    }
  
  

    return 0;
};

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.PriorityQueue;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] inputs;
		inputs = br.readLine().split(" ");
		int n = Integer.parseInt(inputs[0]); // 県の個数
		int m = Integer.parseInt(inputs[1]); // 市の個数

		// 県、年でソート
		PriorityQueue<City> city = new PriorityQueue<>(m, new Comparator<City>() {

			@Override
			public int compare(City o1, City o2) {
				if ( o1.pref != o2.pref ) {		// 県でソート
					return o1.pref - o2.pref;
				} else {						// 同じ県の時は年でソート
					return o1.year - o2.year;
				}
			}
		});
		for ( int id = 1; id <= m; id++ ) {
			inputs = br.readLine().split(" ");
			city.add(new City(id, Integer.parseInt(inputs[0]), Integer.parseInt(inputs[1])));
		}

		// 県ごとに年でナンバー付けしてidでソート
		PriorityQueue<City> city2 = new PriorityQueue<>(m, new Comparator<City>() {

			@Override
			public int compare(City o1, City o2) {
				return o1.id - o2.id;
			}
		});
		int p = 0;
		int num = 0;
		while ( city.size() > 0 ) {
			City c = city.poll();
			// 新出の県の場合
			if ( p != c.pref ) {
				p = c.pref;
				num = 1;
			} else {
				num++;
			}

			c.num = num;
			city2.add(c);
			// System.out.println("id:" + c.id + " pref:" + c.pref + " year:" + c.year);
		}

		StringBuilder sb = new StringBuilder();
		while ( city2.size() > 0 ) {
			City c = city2.poll();
			// System.out.println("id:" + c.id + " pref:" + c.pref + " num:" + c.num);
			String pcode = String.format("%06d", c.pref);
			String ncode = String.format("%06d", c.num);
			sb.append(pcode).append(ncode).append("\n");
		}
		System.out.println(sb);
		br.close();
	}
}

class City {

	int	id		= 0;
	int	pref	= 0;
	int	year	= 0;
	int	num		= 0;

	public City(int id, int pref, int year) {

		this.id = id;
		this.pref = pref;
		this.year = year;
	}
}


Measured memory_bytes: 125876
n = int(input())
h = list(map(int, input().split()))

cnt = 1
for i in range(1, n):
	now = h[i]
	jud = 0
	for j in range(i):
		if now < h[j]:
			jud = 1
			break
	if jud == 0:
		cnt += 1

print(cnt)


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int invalidDigit[10];
int res = 1 << 30;
int n;

void findMinNumber(int now)
{
	if (now >= n)
	{
		res = min(now, res);
		return;
	}

	for (int i = 0; i < 10; i++)
	{
		if (!invalidDigit[i])
		{
			if (now == 0 && i == 0)
			{
				continue;
			}

			findMinNumber(10 * now + i);
		}
	}
}

int main()
{	
	int k; cin >> n >> k;
	for (int i = 0; i < k; i++)
	{
		int x; cin >> x;
		invalidDigit[x] = true;
	}

	findMinNumber(0);

	cout << res;
	return 0;
}


Measured memory_bytes: 3548
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < (int)(n);++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll,ll>
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

ll n;

void fastik() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	cout.tie(nullptr);
}

//ifstream &cin
void solve(){

}

ll get(ll x){
    return (n+x-1)/x;
}

int main() {
    fastik();
    //ifstream cin("input.txt");
    /*ll t=1;cin>>t;
    while(t--){
       solve();
    }*/
    cin >> n;
    vll a(5);
    forn(i,5){cin >> a[i];}
    ll ans = (n+a[0]-1)/a[0];
    ll cur = a[0];
    fore(i,1,4){
        if(a[i] < cur){
            cur = a[i];
            ans = max(get(cur),get(a[i]) + i);
        }else{
            ans++;
        }
    }
    cout << ans;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=Integer.parseInt(sc.next());
		double x[]=new double[n];
		double y[]=new double[n];
		for(int i=0;i<n;i++) {
			x[i]=Double.parseDouble(sc.next());
		}
		for(int i=0;i<n;i++) {
			y[i]=Double.parseDouble(sc.next());
		}
		double m1=0;
		double m2=0;
		double m3=0;
		double c=0;
		for(int i=0;i<n;i++) {
			m1+=Math.abs(x[i]-y[i]);
		}

		for(int i=0;i<n;i++) {
			m2+=Math.pow(Math.abs(x[i]-y[i]),2);
		}
		m2=Math.sqrt(m2);

		for(int i=0;i<n;i++) {
			m3+=Math.pow(Math.abs(x[i]-y[i]),3);
		}
		m3=Math.cbrt(m3);

		for(int i=0;i<n;i++) {
			if(c<Math.abs(x[i]-y[i])) {
				c=Math.abs(x[i]-y[i]);
			}
		}
		System.out.println(m1);
		System.out.println(m2);
		System.out.println(m3);
		System.out.println(c);
	}

}



Measured memory_bytes: 26488
x = int(input())

if 400 <= x <= 599:
    print('8')
elif 600 <= x <= 799:
    print('7')
elif 800 <= x <= 999:
    print('6')
elif 1000 <= x <= 1199:
    print('5')
elif 1200 <= x <= 1399:
    print('4')
elif 1400 <= x <= 1599:
    print('3')
elif 1600 <= x <= 1799:
    print('2')
elif 1800 <= x <= 1999:
    print('1')

Measured memory_bytes: 9184
#include<stdio.h>
int main()
{
    int h,n,p,k,sum=0;
    scanf("%d%d",&h,&n);
    
    while(n--){
        scanf("%d",&p);
        
        k=p;
        sum=sum+p;
    }
    
    if(h<=sum)printf("Yes");
    else printf("No");
    
    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
  
int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    int h,a;
    cin>>h>>a;
    cout<<(h+a-1)/a;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	char S[200000], a='\0', b='\0';
	int i, count=0;
	scanf("%s", S);
	for(i=0; S[i] != '\0'; i++){
		if((a != S[i]) || a == '2' || a == '3'){
    		count++;
			if(a == '2') a++;
			else a = S[i];
    	}
    	else a = '2';
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 384
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

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

    int jpy = 0;
    double btc = 0;
    REP(i, N){
        double x; cin >> x;
        string u; cin >> u;

        if(u == "BTC") btc+= x;
        if(u == "JPY") jpy+= x;
    }

    cout << btc * 380000 + jpy;

    return 0;
//    cout << S.substr(0,4) << endl;
//    cout << S.substr(5,2) << endl;
//    cout << S.substr(8,2) << endl;
}

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

int main(){
    int n, k; cin >> n >> k;
    vector<int> num(n,0);
    
    rep(i,k){
        int d; cin >> d;

        rep(j,d){
            int a; cin >> a; a--;
            num[a]++;
        }

    }

    ll ans = 0;
    rep(i,n){
        if(num[i] == 0) ans++;
    }

    cout << ans << endl;


}

Measured memory_bytes: 3628
#include<stdio.h>
int main()
{
int j,K,A,B,c=0;
scanf("%d %d %d",&K,&A,&B);
for(j=1;j<=1000;j++)
{
if(K*j>=A && K*j<=B)
 {
 printf("OK\n");
 c=c+1;
 break;
 }
}
if(c==0)
printf("NG\n");
return 0;
}


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

template<class T> inline void chmax(T & a, T b) { if (a < b) a = b; }
template<class T> inline void chmin(T & a, T b) { if (a > b) a = b; }

const long long INF = 1LL << 60;
using namespace std;

int dp[101000][3];

int main() {
	int N; cin >> N;
	int a[101000][3];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			scanf("%d", &a[i][j]);
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j == k) continue;
				chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
			}
		}
	}

	int res = 0;
	for (int i = 0; i < 3; i++) {
		chmax(res, dp[N][i]);
	}

	cout << res << endl;

	return 0;
}

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

int main() {
  
  int N;
  cin >> N;
  vector<int> card(N + 3);
  for (int i = 0; i < N; i++) {
    cin >> card.at(i);
  }
  
  sort(card.begin(), card.end());
  reverse(card.begin(), card.end());
  
  int A;
  for (int i = 0; i < (N + 1) / 2; i++) {
    A += card.at(2 * i) ;
    A -= card.at(2 * i + 1);
  }
  cout << A << endl;
}

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

int n,puz[9][9],mark[30][9];
int i,j,set;
char c;

void marking(int x,int y){
	if(mark[x][y]<set)mark[x][y]=set;
	else mark[x][y]++;
}

int main(){
	set=1;
	for(scanf("%d",&n);n>0;n--){
		if(set>10)printf("\n");
		set+=10;
		for(i=0;i<9;i++){
			for(j=0;j<9;j++){
				scanf("%d",&puz[i][j]);
				marking(i/3+(j/3)*3,puz[i][j]-1);
				marking(10+i,puz[i][j]-1);
				marking(20+j,puz[i][j]-1);
			}
		}
		for(i=0;i<9;i++){
			for(j=0;j<9;j++){
				if(mark[i/3+(j/3)*3][puz[i][j]-1]==set && mark[10+i][puz[i][j]-1]==set && mark[20+j][puz[i][j]-1]==set)c=' ';
				else c='*';
				printf("%c%d",c,puz[i][j]);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for(int i = a; i < b; i++)

using namespace std;
typedef long long ll;
int num;

bool isparindrome(int n){
	int size = 0;
	int m = n;
	while(m){
		m /= 10;
		size++;
	}
	rep(i, 0, size/2){
		if((n/(int)pow((double)10, i))%10 != (n/(int)pow((double)10, size-i-1))%10) return false;
	}
	return true;
}

int main(){
	cin >> num;
	int d1, d2;
	d1 = num;
	d2 = num;
	while(!isparindrome(d1)){
		d1--;
	}
	while(!isparindrome(d2)){
		d2++;
	}
	int ans;
	if(num-d1 <= d2-num) ans = d1;
	else ans = d2;
	cout << ans << endl;
	
}

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

int main(void){
int sum = 0;
int m[6] = {1, 5, 10, 50, 100, 500};
for(int i = 0; i < 6; i++){
int a;
cin >> a;
sum += a*m[i];
}
if(sum < 1000)cout << 0 << endl;
else cout << 1 << endl;
return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define in1(n) cin>>n;
#define in2(n, k) cin>>n>>k;
#define in3(n, k, s) cin>>n>>k>>s;
#define scn(t) scanf("%d", &t)
#define scnld(t) scanf("%ld", &t)
#define scnlld(t) scanf("%lld", &t)
#define scnc(t) scanf("%c", &t)
#define scns(t) scanf("%s", t)
#define scnf(t) scanf("%f", &t)
#define scnlf(t) scanf("%lf", &t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define nloop(i, j, k, in) for (int i = j; i < k; i += in)
#define rloop(i, j, k, in) for (int i = j; i >= k; i -= in)
#define rep(i, j) nloop(i, 0, j, 1)
#define rrep(i, j) rloop(i, j, 0, 1)
#define inar(n, a) \
    rep(i, n)\
        cin>>a[i];
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define fast  \
    ios_base::sync_with_stdio(false);\
    cin.tie(NULL);
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
const double pi = acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

int main()
{
    fast
    int n;
    cin>>n;
    n = n%10;
    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
        cout<<"hon";
    else if( n == 0|| n == 1 || n == 6 || n == 8)
        cout<<"pon";
    else if( n== 3)
    {
        cout<<"bon";
    }
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Nmax = 1e5;
int N;
ll A[Nmax];

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

	map<ll, int> cnt;
	for(int i=0; i<N; i++) cnt[A[i]]++;

	ll ans = 0;
	for(auto p: cnt){
		ll x = p.first;
		int m = p.second;
		if(m >= x) ans += m-x;
		else ans += m;
	}

	cout << ans << endl;

	return 0;
}


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



int main(){
    int n;
    double nb_dig = 0;
    cin>>n;
    vector<long long> v(n);
    for(int i = 0;i<n;++i){
        cin>>v[i];
        nb_dig += log10(v[i]);
    }
    sort(v.begin(),v.end());
    if(!v[0]){
        cout<<0;
        return 0;
    }
    if(nb_dig>19){
        cout<<-1;
        return 0;
    }
    long long res = 1;
    for(int i = 0;i<n;++i){
        if(v[i]>(long long)(1e+18)/res){
            cout<<-1;
            return 0;
        }
        res *= v[i];
    }
    cout<<res;
    return 0;
}

Measured memory_bytes: 4104
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;

ll n;
vector<ll> p;
vector<ll> e;

void factorize(ll m){
  ll M=m;
   for(ll i=2;i<=sqrt(m)+1;i++){
    if(M%i==0){
      p.push_back(i);
      int beki=0;
      while(M%i==0){
        M/=i;
        beki++;
      }
      e.push_back(beki);
    }
   }
  if(p.empty()){
    p.push_back(m);
    e.push_back(1);
  }
  if(M!=1){
   p.push_back(M);
   e.push_back(1);
  }
}

int main(){
  ll q;
  cin >> q;
  cin >> n;
  factorize(n);
  ll ans=1;
  rep(i,p.size()){
   while(e[i]>=q){
     ans*=p[i];
     e[i]-=q;
   }
  }
  cout << ans << endl;
return 0;}

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

double leye, reye;
int A[2], B[2], C[2], D[2];

int main() {
    for (int i = 0; i < 40; i++) { 
            cin >> leye;
            if (leye >= 1.1) A[0]++;
            else if (leye >= 0.6 && leye < 1.1) B[0]++;
            else if (leye >= 0.2 && leye < 0.6) C[0]++;
            else if (leye < 0.2) D[0]++;
            
            cin >> reye;
            if (reye >= 1.1) A[1]++;
            else if (reye >= 0.6 && reye < 1.1) B[1]++;
            else if (reye >= 0.2 && reye < 0.6) C[1]++;
            else if (reye < 0.2) D[1]++;
    }
    
    cout << A[0] << " " << A[1] << endl;
    cout << B[0] << " " << B[1] << endl;
    cout << C[0] << " " << C[1] << endl;
    cout << D[0] << " " << D[1] << endl;
    
    return 0;
}

Measured memory_bytes: 1228
#include<stdio.h>
 
int main() {
    int n, a, b, c;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d %d %d", &a, &b, &c);
        if (a*a == b*b + c*c || b*b == c*c + a*a || c*c == a*a + b*b) {
            printf("YES\n");
        }
        else {
            printf("NO\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2040
N,M = map(int, input().split())

dp = [-1] * N
for i in range(M):
    s, c = map(int, input().split())
    s -= 1
    if dp[s] != -1 and dp[s] != c:
        print(-1)
        exit()
    dp[s] = c

if N != 1:
    if dp[0] == 0:
        print(-1)
        exit()

    if dp[0] == -1:
        dp[0] = 1

    for i in range(1, N):
        if dp[i] == -1:
            dp[i] = 0

else:
    if dp[0] == -1:
        dp[0] = 0

print(''.join(map(str, dp)))

Measured memory_bytes: 9172
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;

int main()
{
    int n;
    int i, key, ans = 0;
    
    cin >> n;
    
    int a[n+2];
    
    key = 0;
    a[0] = 0;
    a[n+1] = 0;
    
    for(i = 1; i <= n; i++) {
        cin >> a[i];
        if(i != 1) {
            ans += abs(key - a[i]);
            key = a[i];
        }
    }
    
    ans += abs(key);
    
    cout << ans << endl;
    
    for(i = 0; i < n-1; i++) {
        ans = ans + abs(a[i] - a[i+1]) + abs(a[i+1] - a[i+3]) - abs(a[i] - a[i+2]) - abs(a[i+2] - a[i+3]);
        cout << ans << endl;
    }
    
    return 0;
}


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

using namespace std;

const int maxn=5e5+5;
const int sentinel=2e9+5;

int l[maxn/2+5],r[maxn/2+5],cnt;

void merge(int a[],int left,int mid,int right)
{
	int n1=mid-left;
	int n2=right-mid;
	for(int i=0;i<n1;i++){
		l[i]=a[left+i];
	}
	for(int i=0;i<n2;i++){
		r[i]=a[mid+i];
	}
	l[n1]=r[n2]=sentinel;
	int i=0,j=0;
	for(int k=left;k<right;k++){
        cnt++;
		if(l[i]<=r[j]){
			a[k]=l[i++];
		}else{
			a[k]=r[j++];
		}
	}
}

void mergesort(int a[],int left,int right)
{
	if(left+1<right){
		int mid=((right+left)>>1);
		mergesort(a,left,mid);
		mergesort(a,mid,right);
		merge(a,left,mid,right);
	}
}

int main()
{
	int a[maxn],n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	mergesort(a,0,n);
	for(int i=0;i<n;i++){
		if(i){
			cout<<" ";
		}
		cout<<a[i];
	}
	cout<<endl;
    cout<<cnt<<endl;
	return 0;
}
/*
10
8 5 9 2 6 3 7 1 10 4
*/



Measured memory_bytes: 6960
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math
import collections
import heapq

INF = 10 ** 10

Q, = map(int, sys.stdin.readline().rstrip().split(" "))
b_all = 0
sum_value = 0
k_value = 0
tree = None
qs = [list(map(int, sys.stdin.readline().rstrip().split(" "))) for _ in range(Q)]

left = []
right = []
a_s = []
current_median = None
heapq.heappush(left, INF)
heapq.heappush(right, INF)
a_current = 0
for query in qs:
    if query[0] == 1:
        _, a, b = query
        a_s.append(a)
        b_all += b

        last_left, last_right = -left[0], right[0]
        heapq.heappush(left, -a)
        heapq.heappush(right, a)
        heapq.heappush(left, -heapq.heappop(right))
        heapq.heappush(right, -heapq.heappop(left))
        current_median = -left[0]
        if last_left <= a and a <= last_right:
            pass
        else:
            # a_current += abs(left[0] + right[0])
            a_current += min(abs(last_right - a), abs(last_left - a))
    else:
        print(current_median, a_current+b_all)

exit(0)


Measured memory_bytes: 69664
def main():
    from bisect import bisect_right as bs

    n, *l = map(int, open(0).read().split())
    l.sort()
    ans = 0
    for i, x in enumerate(l):
        for y in l[i + 1:]:
            k = y - x
            z = bs(l, k)
            if i - z >= 1:
                ans += (i - z)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
n=int(input())
l=[]
for _ in range(n):
    a,b,c=map(int,input().split())
    l.append((a,b,c))
dp=[[0 for i in range(3)]for i in range(n+1)]
for i in range(1,n+1):
    dp[i][0]=l[i-1][0]+max(dp[i-1][1],dp[i-1][2])
    dp[i][1]=l[i-1][1]+max(dp[i-1][0],dp[i-1][2])
    dp[i][2]=l[i-1][2]+max(dp[i-1][0],dp[i-1][1])
print(max(dp[-1]))


Measured memory_bytes: 76888
class in{struct my_iterator{int it;const bool rev;explicit constexpr my_iterator(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(my_iterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const my_iterator i,n;public:explicit constexpr in(int n):i(0),n(n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const my_iterator& begin(){return i;}const my_iterator& end(){return n;}};

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

void solve(int n) {
    int t; string s;
    cin >> t >> s;
    int ans = 0;
    int iocnt = -1;
    bool bi = false;
    for(char c : s) {
        if(c == 'I') {
            if(bi == false) {
                if(iocnt == n) {
                    ans++;
                    iocnt--;
                }
            }
            else
              iocnt = 0;
            bi = true;
        }
        else {
            if(bi == true) {
                ++iocnt;
            }
            else
              iocnt = 0;
            bi = false;
        }
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int n;
    while(cin >> n && n)
      solve(n);
    return 0;
}

Measured memory_bytes: 4652