akhauriyash/Code-Regression huggingface dataset:
N, M = list(map(int, input().split()))

p = {}
flag=True
for _ in range(M):
    s,c = list(map(int, input().split()))
    if s in p and p[s]!=c:
        flag=False
    p[s] = c

if 1 in p:
    if N!=1 and p[1]==0:
        flag=False
        
if flag:
    ans = ''
    for i in range(1, N+1):
        if i in p:
            ans+=str(p[i])
        elif N!=1 and i==1:
            ans+='1'
        else:
            ans+='0'
    print(int(ans))
else:
    print(-1)

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

int main(){
    int a, b, c, d;
    bool flag = false;
    cin >> a >> b >> c >> d;
    if (abs(a - c) <= d) flag = true;
    else if (abs(a - b) <= d && abs(b - c) <= d) flag = true;
    
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    int c = 1;
    for(int i=0;i<n;i++){
        if(a[i] == c){
            c++;
        }
    }
    if(c == 1){
        cout << -1 << endl;
    }else{
        cout << n - (c - 1) << endl;
    }
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

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

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll i,ans,res;
  string s;cin>>s;
  res=(s[0]-'0')*100+(s[1]-'0')*10+s[2]-'0';
  ans=abs(res-753);
  For(i,3,s.size()){
    res=res*10%1000+s[i]-'0';
    chmin(ans,(ll)abs(res-753));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    char b;
    cin >> b;
    switch (b)
    {
        case 'A':
            cout << 'T' << endl;
            break;
        case 'T':
            cout << 'A' << endl;
            break;
        case 'C':
            cout << 'G' << endl;
            break;
        case 'G':
            cout << 'C' << endl;
            break;

    }
}

Measured memory_bytes: 256
X,Y,Z,K=map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
C=list(map(int, input().split()))
D=[]
for i in A:
  for j in B:
    D.append(i+j)
D=sorted(D)[::-1]
if X*Y>K:
  D=D[:K]
E=[]
for i in D:
  for j in C:
    E.append(i+j)
E=sorted(E)[::-1]
E=E[:K]
for i in E:
  print(i)

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

int main(){
	int n;
	int a[1000000];
	int b;
	int i, j, p;
	int c[10000][2];
	p = 1;
	while (1==1){
		scanf("%d", &c[p][0]);
		if(c[p][0]!=0)p++;
		else break;
	}
	//p--;
		b = (int)pow(1000000.0, 0.5);
		a[0] = -1;
		for (i = 2; i <= b; i++){
			for (j = 2; j <= 1000000/ i; j++){
				a[i*j - 1] = -1;
			}
		}
	//	printf("%d-%d\n",c[0][0],c[1][0]);
	for (i = 1; i < p; i++){	
		c[i][1] = 0;
		for (j = 1;c[i][0]>0; j++){
			if (a[j - 1] != -1){ 
				c[i][1]+=j; 
				c[i][0]--;
			}
		}
		printf("%d\n", c[i][1]);
	}

	return 0;
}

Measured memory_bytes: 4508
n = int(input())
w = [int(i) for i in input().split()]
total = sum(w)
accu_w = [0] * n
accu_w[0] = w[0]
for i in range(n - 1):
    accu_w[i + 1] = accu_w[i] + w[i + 1]
accu_w = [abs(total - ww - ww) for ww in accu_w]
print(min(accu_w))

Measured memory_bytes: 3060
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
LL n;
db ans = 0;
char s[10];
int main() {
	cin >> n;
	for (LL i = 1; i <= n; ++i) {
		db g; cin >> g >> s;
		if (s[0] == 'J') ans += g; else ans += g * 380000.0;
	}
	printf("%.9f\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//


ll n, k;
vector<vector<ll> > vv(MAX);
ll ans = 1;

//----------//

ll solve(ll children, ll col, ll v, ll bef){
    bool ok = false;
    for(ll u : vv[v]){
        if(u != bef) ok = true;
    }
    if(!ok){
        ans = ans * col % MOD;
        return col;
    }

    ll res = col;
    if(children < 2) children++;
    int num = 0;
    for(ll u : vv[v]){
        if(u == bef) continue;
        //cout << u << endl;
        res = res * solve(children, (k-children-num), u, v) % MOD;
        num++;
    }

    return res;
}

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    cin >> n >> k;
    rep(i, n-1){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        vv[a].push_back(b);
        vv[b].push_back(a);
    }

    cout << solve(0, k, 0, -1) << endl;
    //cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 11520
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end(), greater<>());

    ll ans = 0;
    rep(i, n - 1){
        if(i == 0) ans += a[i];
        else ans += a[(i + 1) / 2];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4784
n = gets.to_i
b = gets.split.map(&:to_i)

a = []
a[0] = b[0]

b.each_index do |i|
  if n - i == 2
    a[i+1] = b[i]
  elsif b[i].to_i < b[i+1].to_i
    a[i+1] = b[i]
  elsif b[i].to_i >= b[i+1].to_i
    a[i+1] = b[i+1]
  end
end

sum = 0
a.each { |i| sum += i.to_i}
p sum


Measured memory_bytes: 1788
#include<cstdio>
#include<iostream>
using namespace std;
string s1,s2;
int main()
{
	cin>>s1;
	cin>>s2;
	int sum=0;
	for(int i=0;i<s1.size();++i)
	{
		if(s1[i]!=s2[i]) sum++;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3892
function Main(input) {
	var tmp = input.split(" ");
	var k = parseInt(tmp[0], 10);
	var r = parseInt(tmp[1], 10);
	if(k > 10){
    	k = 10;
    }
	console.log(r+(10-k)*100);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
//============================================================================
// Name        : ABC145.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int r;
	cin >> r;
	int ans;
	ans = r*r;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
 
#define pb push_back
#define mp make_pair

typedef long long ll; 

#define fi first
#define se second
 
#define all(x) (x).begin(), (x).end()
 
using namespace std;             
//using namespace __gnu_pbds;
 
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int INF = (int)1e10;

ll n;

void solve() {        
    cin >> n;
    cout << n * n;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int tt = 1;
 
    while (tt--) {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
using Vi = vector<int>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n,a,b;
    cin>>n>>a>>b;
    int ans=(n-a+1)*(n-b+1);
    if(ans<0){
        cout<<0<<endl;
    }
    else{
        cout<<ans<<endl;
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n=5;
    int arr[n],p;
    for(int i=1;i<=5;i++){
        cin>>arr[i];
        if(arr[i]==0){
        p=i;}
        
    }
    cout<<p<<endl;
    return 0;
    
}

Measured memory_bytes: 3684
/*
   Username : moondancer
   Name : Moon Dancer
*/


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

#define int long long

signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t;
    cin>>t;
    while(t--)
        cout<<"ACL";
    return 0;
}

Measured memory_bytes: 3640
#!/usr/bin/env python3

def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    B = [int(x) for x in input().split()]
    C = [int(x) for x in input().split()]
    
    Bs = []
    for i in range(1, N):
        if A[i] - A[i-1] == 1:
            Bs.append(C[A[i -1] - 1])

    print(sum(B) + sum(Bs))

main()

Measured memory_bytes: 3060
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007


#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 

 
int main() {
    int Q=0;
    cin >>Q;
    ll x[Q];
    ll y[Q];
    FOR(i,0,Q-1){
        cin>>x[i]>>y[i];
    }
    ll ru[100001];
    ru[0]=0;
    FOR(i,1,100000){
        if(isPrimeNum(i)&&isPrimeNum((i+1)/2)){
            ru[i]=ru[i-1]+1;
        }else{
            ru[i]=ru[i-1];
        }

    }

    FOR(i,0,Q-1){
        cout<<ru[y[i]]-ru[x[i]-1]<<endl;
    }


  return 0;
}



Measured memory_bytes: 2944
"""
author : halo2halo
date : 25,Oct,2019
"""

import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

a = readline().rstrip()
b = readline().rstrip()

print("Yes" if ''.join(sorted(a)) < ''.join(sorted(b)[::-1]) else "No")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
using namespace std;
typedef long long ll;

int main(void){
	string s, t;
	cin >> s >> t;

	map<char, int> mp_s, mp_t, check_s, check_t;
	rep(i, s.size()) mp_s[s[i]]++;
	rep(i, t.size()) mp_t[t[i]]++;
	for(char c = 'a'; c <= 'z'; c++){
		check_s[mp_s[c]]++;
		check_t[mp_t[c]]++;
	}
	bool jud = true;
	for(int i = 0; i <= 200005; i++)
		if(check_s[i] != check_t[i]) jud = false;
	cout << (jud ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 776
S = str(input())
K = int(input())

one = 0

for i in range(len(S)):
  if S[i] == "1":
    one += 1
  else:
    notone = S[i]
    break
#print(one,K,notone)
if one >= K:
  print("1")
else:
  print(notone)

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

const int MAX_N = (int)(10000 + 5);

int n;
int a[MAX_N];

int ans;

int main(void){
  // Here your code !
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &(a[i]));

  a[n] = 114514;

  int cur = a[0];
  int length = 1;
  for (int i = 1; i <= n; ++i) {
    if (a[i] == cur) {
      length += 1;
    }
    else {
      ans += length / 2;
      length = 1;
    }
    cur = a[i];
  }

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

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<bitset>
#include<functional>
#include<iterator>
#include<complex>
#include<fstream>
#include<random>
#include<ctype.h>
#include<stdio.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using PII = pair<ll, ll>;
using piii = pair<pii, pii>;
using Pi = pair<int, pii>;
using Graph = vector<vector<int>>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
bool check(int x, int y) {
	if (0 <= x && x<55 && 0 <= y && y<55)return true;
	else return false;
}
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;

//iの逆元mod inf
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const double PI = 3.14159265358979323846;
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
double Euclidean_distance(double x1, double y1, double x2, double y2) {
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

int prime[1001000];//i番目の素数
bool is_prime[1001010];//is_prime[i]がtrueならiは素数
					   //n以下の素数の数を返す
int sieve(int n) {
	int p = 0;
	for (int i = 0; i <= n; ++i) {
		is_prime[i] = true;
	}
	is_prime[0] = false;
	is_prime[1] = false;
	for (int i = 2; i <= n; ++i) {
		if (is_prime[i]) {
			prime[p] = i;
			p++;
			for (int j = 2 * i; j <= n; j += i) {
				is_prime[j] = false;
			}
		}
	}
	return p;
}

//素因数分解
map<int, int>prime_factor(int n) {
	map<int, int>res;
	for (int i = 2; i*i <= n; ++i) {
		while (n%i == 0) {
			++res[i];
			n /= i;
		}
	}
	if (n != 1)res[n] = 1;
	return res;
}


ll powmod(ll a, ll k, ll mod) {
	ll ap = a, ans = 1;
	while (k) {
		if (k & 1) {
			ans *= ap;
			ans %= mod;
		}
		ap = ap * ap;
		ap %= mod;
		k >>= 1;
	}
	return ans;
}
ll invi(ll a, ll mod) {
	return powmod(a, mod - 2, mod);
}
//逆元Aを足したときのmodで割った余りは
//+=invi(A)
//Yで割ることはY^(10^9+7)-2を掛けることは同値
///////////////////////////////////////


int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	if (a+b >= k)cout << min(a,k) << endl;
	else {
		cout << a - (k - a - b) << endl;
	}
	return 0;
}


Measured memory_bytes: 3556
#include<stdio.h>
int main(void)
{
	int a,a1,a2,a3,b,b1,b2,b3;
	scanf("%d %d %d %d",&a,&a1,&a2,&a3);
	scanf("%d %d %d %d",&b,&b1,&b2,&b3);
	if(a+a1+a2+a3>=b+b1+b2+b3)	printf("%d\n",a+a1+a2+a3);
	else	printf("%d\n",b+b1+b2+b3);
	return 0;
}



Measured memory_bytes: 2748
#include <iostream>

#define int long long

using namespace std;

const int N = 2e5 + 10;

int32_t main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);    
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < s.length(); ++i) 
    {
        ans += s[i] != t[i];
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3820
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  int a[100000],b[100000],c[100000];  
  cin >> n;
  for(int i=0;i<n;i++)cin >> a[i];
  for(int i=0;i<n;i++)cin >> b[i];
  for(int i=0;i<n;i++)cin >> c[i];
  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);
  int ans=0;
  for(int i=0;i<n;i++){
    int aa,bb;
    int lb=-1,m,ub=n;
    while(ub-lb>1){
      m=(lb+ub)/2;
      if(a[m]<b[i])lb=m;
      else ub=m;
    }
    aa=ub;
    lb=-1,ub=n;
    while(ub-lb>1){
      m=(lb+ub)/2;
      if(c[m]<b[i]+1)lb=m;
      else ub=m;
    }
    bb=n-ub;
    ans+=aa*bb;
  }
  cout << ans << endl; 
  return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);	
    cin.tie(0);
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) ans++;
	}
	cout << ans << "\n";
	return 0;
}


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

int main(){
  int n,t[100],m,p,x,sum=0;
  cin >> n;
  for(int i=0;i<n;++i){
  	cin>>t[i];
  	sum+=t[i];
  }
  cin >> m;
  while(m--){
  	cin >> p >> x;
  	cout << sum-t[p-1]+x << endl;
  }
  return 0;
}

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

int main() {
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<ll> A(X), B(Y), C(Z);
  rep(i, 0, X) cin >> A[i];
  rep(i, 0, Y) cin >> B[i];
  rep(i, 0, Z) cin >> C[i];
  sort(A.begin(), A.end(), greater<ll>());
  sort(B.begin(), B.end(), greater<ll>());
  sort(C.begin(), C.end(), greater<ll>());
  priority_queue<ll,vector<ll>> Q;
  rep(i, 0, X) rep(j, 0, Y) {
    if(i * j > K) continue;
    Q.push(A[i] + B[j]);
  }
  priority_queue<ll,vector<ll>> ans;
  rep(i, 0, K) {
    if(Q.empty()) break;
    ll v = Q.top(); Q.pop();
    rep(j, 0, Z) ans.push(v + C[j]);
  }
  rep(i, 0, K) {
    ll v = ans.top(); ans.pop();
    cout << v << "\n";
  }
  return 0;
}


Measured memory_bytes: 35300
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
  int N,M,ans=0;
  cin>>N;
  string s;
  map<string,int> B,R;

  for(int i=0;i<N;i++){
    cin>>s;
    if(B.find(s)==B.end()){
      B[s]=1;
    }else{
      B[s]++;
    }
    
  }

  cin>>M;

  for(int i=0;i<M;i++){
    cin>>s;
    if(R.find(s)==R.end()){
      R[s]=1;
    }else{
      R[s]++;
    }
    
  }

  map<string,int>::iterator it;

  for(it=B.begin();it!=B.end();it++){
    if(R.find(it->first)!=R.end()) ans=max(ans,it->second-R[it->first]);
    else ans=max(ans,it->second);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main (){
	int N;
	scanf("%d",&N);
	int d[N];
	for (int i = 0;i<N;i++){
		scanf("%d",&d[i]);
	}
	int sum = 0;
	for (int j = 0;j<N;j++){
		for (int k=j+1;k<N;k++){
			sum = sum + d[j]*d[k];
		}
	}
	printf("%d\n",sum);
	return 0;
}



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

int main() {
    int N;
    set <int> s;
    cin >> N;
    for (int i=0; i<N;i++) {
        int t;
        cin >> t;
        s.insert(t);
    }
    printf("%d\n", s.size());
}


Measured memory_bytes: 764
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}

int main() {
	//file();
	fast();
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<ll> v1(a), v2(b), v3(c + 1);
	for (auto& it : v1) cin >> it;
	for (auto& it : v2) cin >> it;
	for (int i = 1; i <= c; i++) cin >> v3[i];

	sort(v3.begin() + 1, v3.end());
	reverse(v3.begin() + 1, v3.end());
	for (int i = 1; i <= c; i++)
		v3[i] += v3[i - 1];

	vector<ll> All(1);
	sort(allr(v1)), sort(allr(v2));
	for (int i = 0; i < x; i++) All.push_back(v1[i]);
	for (int i = 0; i < y; i++) All.push_back(v2[i]);
	sort(All.begin() + 1, All.end());
	for (int i = 1; i < sz(All); i++)
		All[i] += All[i - 1];

	ll ans = All.back();
	for (int i = 1; i < min(sz(v3), sz(All)); i++) {
		if (v3[i] + All.back() - All[i] > ans)
			ans = v3[i] + All.back() - All[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4852
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef pair<ll , ll> lli;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
typedef vector<lli> vlli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define in insert
#define f0(b) for(int i=0;i<(b);i++)
#define f00(b) for(int j=0;j<(b);j++)
#define f1(b) for(int i=1;i<=(b);i++)
#define f11(b) for(int j=1;j<=(b);j++)
#define f2(a,b) for(int i=(a);i<=(b);i++)
#define f22(a,b) for(int j=(a);j<=(b);j++)
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld", &a , &b)
#define pf(a) printf("%lld\n",a)
#define pff(a,b) printf("%lld %lld\n", a , b)
#define PI 3.14159265359
#define bug printf("**!\n")
#define mem(a , b) memset(a, b ,sizeof(a))
#define front_zero(n) __builtin_clzll(n)
#define back_zero(n) __builtin_ctzll(n)
#define total_one(n) __builtin_popcountll(n)

const ll mod = 1000000007;
const ll maxn = (ll)2e5+5;
const int nnn = 1048590;
const int inf = numeric_limits<int>::max()-1;
//const ll INF = numeric_limits<ll>::max()-1;
const ll INF = 1e18;

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

void solve(){
	
	set < string > s;
	ll n;
	cin >> n;
	while(n--){
		string str;
		cin >> str;
		s.in(str);
	}
	cout << s.size();
	return;
}


int main() {
   
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    ll T;
    T=1;
    //cin >> T;
    //scanf("%lld",&T);
    ll CT = 0;
    //work();
    while(T--){
    	//cout << "Case " << ++CT <<": " ;
    	//printf("Case %lld: ",++CT);
		solve();
	}
    
    return 0;
}


Measured memory_bytes: 19260
N,M = map(int,input().split())
ab = [[0,0]] * N
cd = [[0,0]] * M

distance = [[0 for i in range(M)] for j in range(N)]

for i in range(N):
    ab[i] = list(map(int, input().split()))

for i in range(M):
    cd[i] = list(map(int, input().split()))

for i in range(N):
    for j in range(M):
        distance[i][j] = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])

for i in range(N):
    print(distance[i].index(min(distance[i])) + 1)

Measured memory_bytes: 3064
l,r=map(int,input().split())
L=l//2019
R=r//2019
k=[]
if L==R:
    for i in range(l,r):
        for j in range(i+1,r+1):
            k.append((i*j)%2019)
    print(min(k))
else:
    print(0)


Measured memory_bytes: 75408
def readinput():
    #a,b=list(map(float,input().split()))
    a,b=input().split()
    a=int(a)
    b=float(b)
    return a,b

def main(a,b):
    #ans=int(a*b*10)//10
    b=int(b*100+0.5)
    ans=a*b//100
    return ans

if __name__=='__main__':
    a,b=readinput()
    ans=main(a,b)
    print(ans)


Measured memory_bytes: 9188
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

struct mint {
    static constexpr long MOD = 1000000007;
    long value;

    constexpr mint(long value = 0) noexcept : value((value % MOD + MOD) % MOD) {}
    constexpr mint operator-() const noexcept {
        return mint(-value);
    }
    constexpr mint& operator+=(const mint& rhs) noexcept {
        if ((value += rhs.value) >= MOD) value -= MOD;
        return *this;
    }
    constexpr mint& operator-=(const mint& rhs) noexcept {
        if ((value += MOD - rhs.value) >= MOD) value -= MOD;
        return *this;
    }
    constexpr mint& operator*=(const mint& rhs) noexcept {
        (value *= rhs.value) %= MOD;
        return *this;
    }
    constexpr mint operator+(const mint& rhs) const noexcept {
        mint res(*this);
        return res += rhs;
    }
    constexpr mint operator-(const mint& rhs) const noexcept {
        mint res(*this);
        return res -= rhs;
    }
    constexpr mint operator*(const mint& rhs) const noexcept {
        mint res(*this);
        return res *= rhs;
    }
    constexpr mint pow(long e) const noexcept {
        if (e == 0) return 1;
        mint a = pow(e >> 1);
        a *= a;
        if (e % 2 == 1) a *= *this;
        return a;
    }
    constexpr mint inv() const noexcept {
        return pow(MOD - 2);
    }
    constexpr mint& operator/=(const mint& rhs) noexcept {
        return *this *= rhs.inv();
    }
    constexpr mint operator/(const mint& rhs) const noexcept {
        mint res(*this);
        return res /= rhs;
    }
    friend constexpr mint pow(const mint& a, const long& b) noexcept {
        return a.pow(b);
    }
    friend ostream& operator<<(ostream& os, const mint& n) noexcept {
        os << n.value;
        return os;
    }
};

void prime_factorize(vector<int>& a, long n) {
    for (long i = 2; i * i <= n; i++) {
        if (n % i != 0) continue;

        int cnt = 0;
        while (n % i == 0) {
            cnt++;
            n /= i;
        }

        a[i] += cnt;
    }

    if (n != 1) a[n] += 1;
}

int main() {
    int n;
    cin >> n;
    mint ans = 1;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) prime_factorize(a, i);

    for (int i : a) {
        if (i == 0) continue;
        ans *= i + 1;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

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

    int n,k; cin >> n >> k;
    vint a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    int cnt=1,res=0;
    rep(i,n-1){
        if(a[i]!=a[i+1]) cnt++;
    }
    vint map(2e5+1,0);
    rep(i,n){
        map[a[i]]++;
    }
    sort(all(map));
    for(auto m:map){
        if(m==0) continue;
        if(cnt<=k) break;
        res+=m;
        cnt--;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 6312
#include<stdio.h>
#define MAX 1000
#define NIL -1

struct Node{
  int parent;
  int left;
  int right;
};
struct Node Tree[MAX];
int n;

void pre(int u)
{
  if( u == NIL )return;
  printf(" %d",u);
  pre(Tree[u].left);
  pre(Tree[u].right);
}

void in(int u)
{
  if( u == NIL )return;
  in(Tree[u].left);
  printf(" %d",u);
  in(Tree[u].right);
}

void post(int u)
{
  if( u == NIL )return;
  post(Tree[u].left);
  post(Tree[u].right);
  printf(" %d",u);
}

int main()
{
  int i;
  int right;
  int left;
  int root;
  int k;

  scanf("%d",&n);
  for( i = 0 ; i < n ; i++ ){
    Tree[i].parent = NIL;
  }
  for( i = 0 ; i < n ; i++ ){
    scanf("%d%d%d",&k,&left,&right);
    Tree[k].left = left;
    Tree[k].right = right;
    if( left != NIL )Tree[left].parent = k;
    if( right != NIL )Tree[right].parent = k;
  }
  for( i = 0 ; i < n ; i++ ){
    if( Tree[i].parent == NIL ){
      root = i;
    }
  }
  printf("Preorder\n");
  pre(root);
  printf("\n");
  printf("Inorder\n");
  in(root);
  printf("\n");
  printf("Postorder\n");
  post(root);
  printf("\n");

  return 0;
  
}
  

  
  



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

#define ff                  first
#define sf                  scanf
#define pf                  printf
#define ss                  second
#define ppb                 pop_back
#define pb                  push_back
#define MP                  make_pair
#define MAXN                10000
#define MOD                 100000007
#define inf                 0x3f3f3f3f
#define PI                  (2.0*acos(0.0))
#define INF                 0x3f3f3f3f3f3f3f3f
#define rev(v)              reverse(all(v))
#define all(v)              v.begin(), v.end()
#define __lcm(x, y)         (x * y) / __gcd(x, y)
#define FOR(i, x, y)        for(int i = x; i < y; i++)
#define RFOR(i, x, y)       for(int i = x; i >= y; i--)
#define MEM(arr, val)       memset(arr, val, sizeof(arr));
#define unq(v)              (v).resize(unique(all(v)) - v.begin())
#define READ()              freopen("input.txt", "r", stdin)
#define WRITE()             freopen("output.txt", "w", stdout)
#define si(n)               scanf("%d", &n)
#define sl(n)               scanf("%lld", &n)
#define sii(a, b)           scanf("%d %d", &a, &b)
#define sll(a, b)           scanf("%lld %lld", &a, &b)
#define siii(a, b, c)       scanf("%d %d %d", &a, &b, &c)
#define slll(a, b, c)       scanf("%lld %lld %lld", &a, &b, &c)
#define siiii(a, b, c, d)   scanf("%d %d %d %d", &a, &b, &c, &d)
#define sllll(a, b, c, d)   scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define vout(v)             for(int i = 0; i < v.size(); i++) {cout << v[i]; if(i < v.size() - 1) cout << ' '; else cout << endl;}

int main(){
        int n; si(n);
        string s; cin >> s;
        if(s.size() <= n) cout << s << endl;
        else {
            FOR(i, 0, n) cout << s[i];
            cout << "..." << endl;
        }
 

    return 0;
}

Measured memory_bytes: 3652
import java.util.*;
import java.io.*;
import java.awt.Point;
import java.math.BigInteger;

public class Main {

	public static void main(String[] args) throws Exception {
		FastIO sc = new FastIO(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		int N = sc.nextInt();
		long[][] gain = new long[N][N];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
				gain[i][j] = sc.nextInt();
			}
		}
		
		long[] cost = new long[1<<N];
		
		for(int mask = 0; mask < 1 << N; mask++) {
			ArrayList<Integer> bits = new ArrayList<Integer>();
			for(int j = 0; j < N; j++) {
				if(((1 << j) & mask) > 0) bits.add(j);
			}
			long tot = 0;
			for(int i = 0; i < bits.size(); i++) {
				for(int j = i+1; j < bits.size(); j++) {
					cost[mask] += gain[bits.get(i)][bits.get(j)];
				}
			}
		}
		
		long[] dp = new long[1 << N];
		for(int big = 0; big < 1 << N; big++) {
			long add = 0;
			for(int i = big; i > 0; i = (i-1) & big){
				add = Math.max(add, cost[i]+dp[big-i]);
			}
			dp[big] = add;
		}
		
		pw.println(dp[(1<<N)-1]);
		pw.close();
		
	}

	static class FastIO {

		//Is your Fast I/O being bad?

		InputStream dis;
		byte[] buffer = new byte[1 << 17];
		int pointer = 0;

		public FastIO(String fileName) throws Exception {
			dis = new FileInputStream(fileName);
		}

		public FastIO(InputStream is) throws Exception {
			dis = is;
		}

		int nextInt() throws Exception {
			int ret = 0;

			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}

			return (negative) ? -ret : ret;
		}

		long nextLong() throws Exception {
			long ret = 0;

			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}

			return (negative) ? -ret : ret;
		}

		byte nextByte() throws Exception {
			if (pointer == buffer.length) {
				dis.read(buffer, 0, buffer.length);
				pointer = 0;
			}
			return buffer[pointer++];
		}

		String next() throws Exception {
			StringBuffer ret = new StringBuffer();

			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			while (b > ' ') {
				ret.appendCodePoint(b);
				b = nextByte();
			}

			return ret.toString();
		}

	}
}


Measured memory_bytes: 30336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll W,H;
  cin >> W >> H;
  ll x,y;
  cin >> x >> y;
  int mode = 0;
  long double ans = (W * H) / 2.0;
  if (W % 2 == 0 && H % 2 == 0 && x == W/2 && y == H/2) {
    mode = 1;
  }
  cout << setprecision(120) << ans;
  cout << " " << mode << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
using namespace std;
stack<char>q;
int main(){
	string s;
	cin>>s;
	int len=s.size() ;
	for(int i=0;i<len;i++){
		if(s[i]=='S')q.push('S');
		else{
			if(q.size()==0)q.push('T');
			else{
				char c=q.top();
				if(c=='S')q.pop();
				else q.push('T');
			}
			
		}
	}
	cout<<q.size()<<endl;
} 

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

using namespace std;

int powi(int x, int y) {
    int ret = 1;
    for (int i = 0; i < y; ++i) {
        ret *= x;
    }
    return ret;
}

void Main() {
    int X;
    cin >> X;

    int ans = 1;
    for (int i = 1; i <= X; ++i) {
        for (int j = 2; j <= 10; ++j) {
            int p = powi(i, j);
            if (p <= X) {
                ans = max(ans, p);
            }
            else {
                break;
            }
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<cstdlib>

using namespace std;

int dp[100001];

int main()
{
    
    int n,i;
    
    cin>>n;
    
    int h[n];
    
    for(i=0;i<n;i++)
        cin>>h[i];
    dp[0];
    for(i=1;i<n;i++)
    {
        dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        if(i>=2)
        {
            dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
            
        }
    }
    
    cout<<dp[n-1]<<endl;
    
    
    
    
    return 0;
    
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pll pair<ll,ll>
#define sll set<ll>
#define msll multiset<ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define vpl vector<pll>
#define gll greater<ll>
#define gpl greater<pll>
#define spl set<pll>
#define mspl multiset<pll>
#define lb lower_bound
#define bp __builtin_popcount
#define ub upper_bound
#define prq priority_queue
#define mp make_pair
#define pb push_back
#define mem(x,y) memset(x, y, sizeof x)
#define endl "\n"
#define sz(x) (ll)x.size()
#define sqr(x) x*x
#define rapido ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long int ll;
typedef long double ld;
ll mx=INT_MAX;
ll mn=INT_MIN;
ll MOD=1e9+7;
const ll maxs=1e5+10;
ll max2d=1e3+3;
ll INF = 1e18;
const ll lg=22; 

void code_idhr_h(){
    string S; cin>>S;
    cout<<S[0]<<S[1]<<S[2];
}

int main(){
    rapido;
    ll T=1; //cin>>T;
    while(T--){
        code_idhr_h();
    }
    return 0;
}

Measured memory_bytes: 3640
import std.stdio, std.range, std.conv, std.string;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting;

void main()
{
    readln();
    const auto targets = readln().strip.split.to!(long[]);
    long[] list;
    list.length = targets.length;

    int count;
    foreach(i; 0..targets.length) {
        while(true)
        {
            auto range = list[i..$].commonPrefix!"a!=b"(targets[i..$]);
            if(range == [])
                break;

            range[] += 1;
            count++;
        }
    }
    writeln(count);
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
    int sum = 0;
    int i=0;
    int fh=0,oh=0,ft=0, ot=0, f=0, o =0;
    
 
    scanf("%d", &sum);
 
    while(sum > 4){
        if(sum >=500){
            i = sum / 500;
            fh += i;
            sum -= 500 * i;
        } 
        else if(sum>=5){
            i=sum/5;
            f+=i;
            sum-=5*i;
        } 
    }
 
    printf("%d", fh*1000+f*5);
 
    return 0;
 
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/01/29  Problem: ABC 087 B / Link: http://abc087.contest.atcoder.jp/tasks/abc087_b  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	int A, B, C, X;
	cin >> A >> B >> C >> X;
	FOR(a, 0, A + 1) {
		FOR(b, 0, B + 1) {
			FOR(c, 0, C + 1) {
				int sum = 500 * a + 100 * b + 50 * c;
				if (sum == X)ans++;
			}
		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
class Main{
  public static void main(String[] args){
    Scanner sin = new Scanner(System.in);
    int N = sin.nextInt();
    int K = sin.nextInt();
    int X = sin.nextInt();
    int Y = sin.nextInt();
    
    if(N<=K){
      int rent = X*N;
      System.out.println(rent);
    }else{
      int lent = N-K;
      int lent2 = X*K + lent*Y;
      System.out.println(lent2);
    }
  }  
}

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














ll N;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	auto ep = enumpr(N);

	int ans = 0;
	fore(p, ep) {
		int cnt = p.second;
		rep(i, 1, 1010) {
			if (i <= cnt) {
				ans++;
				cnt -= i;
			}
			else break;
		}
	}
	cout << ans << endl;
}







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

int main(){
  int N, M;
  cin >> N >> M;
  int64_t num;
  priority_queue<int64_t> A;
  for(int i=0; i<N; i++){
    cin >> num;
    A.push(num);
  }
  
  int64_t half;
  for(int i=0; i<M; i++){
    half = A.top() / 2;
    A.push(half);
    A.pop();
  }  

  int64_t sum = 0;
  while(!A.empty()){
    sum += A.top();
    A.pop();
  }
   
  cout << sum << endl;
}



Measured memory_bytes: 1400
N = int(input())
a = [[0] * 9 for i in range(9)]
b = [[0] * 9 for i in range(9)]
ans = 0
for A in range(1,N+1):
    list_a = str(A)
    if list_a[-1] == '0':
        continue
    a[int(list_a[0])-1][int(list_a[-1])-1] += 1
    b[int(list_a[-1])-1][int(list_a[0])-1] += 1
for i in range(9):
    for j in range(9):
        ans += a[i][j]*b[i][j]
print(ans)    


Measured memory_bytes: 3064