akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int n;
vector<pii> G[MAX];  // (id, to)
int col[MAX];

void dfs(int v, int pv, int pc) {
    int cur = 1;
    for (auto &e : G[v])
        if (e.se != pv) {
            if (cur == pc) ++cur;
            col[e.fi] = cur;
            dfs(e.se, v, cur);
            ++cur;
        }
}

int main() {
    scanf("%d", &n);
    rep(i, n - 1) {
        int a, b;
        scanf("%d%d", &a, &b);
        --a;
        --b;
        G[a].emplace_back(i, b);
        G[b].emplace_back(i, a);
    }
    dfs(0, -1, -1);
    printf("%d\n", *max_element(col, col + n - 1));
    rep(i, n - 1) printf("%d\n", col[i]);
}

Measured memory_bytes: 14864
#include<iostream>
#include<cstring>
#include<cstdlib>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;
 
string id;
ll sum[22], ans;
bool head[22], use[22];
 
void rec(int depth, ll val){
  if(depth+1 == (int)id.size()){
    ll rem = sum[depth];
    if(rem == 0LL){
      if(val == 0LL){
        ans += 10-depth;
        if(!use[0] && head[depth])ans--;
      }
    }else{
      if(val == 0LL){
    if(!use[0] && !head[depth])ans++;
      }else if(val*rem<0){
    val = abs(val); rem = abs(rem);
    if(val%rem==0LL && val/rem<10LL && !use[val/rem]){
      ans++;
    }
      }
    }
    return;
  }
 
  for(ll i=0;i<10;i++){
    if(i==0LL && head[depth])continue;
    if(use[i])continue;
    use[i] = true;
    rec(depth+1, val + sum[depth]*i);
    use[i] = false;
  }
}   
 
int main(){
  int n;
  string s;
 
  while(cin >> n, n){
    memset(sum,0,sizeof(sum));
    memset(head,0,sizeof(head));
    id = "";
 
    rep(i,n){
      cin >> s;
      ll tmp = 1;
      for(int j=(int)s.size()-1;j>=0;j--){
    int k=0;
    for(;k<(int)id.size();k++){
      if(s[j] == id[k])break;
    }
    sum[k] += (i+1==n)?-tmp:tmp;
    if(k==id.size())id += s[j];
    if(j==0 && s.size()!=1)head[k] = true;
    tmp *= 10LL;
      }
    }
 
    ans = 0;
    memset(use,0,sizeof(use));
    rec(0,0);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353,maxn=1000;
int n,a[444],b[444],dp[444][444][444],sa,sb,jc[1111],injc[1111],p,ans,t[444];
int binpow(int a,int t)
{
	int res=1,p=a;
	for (int i=t;i;i>>=1)
	{
		if (i&1) res=1ll*res*p%mod;
		p=1ll*p*p%mod;
	}
	return res;
}
void Init()
{
	jc[0]=injc[0]=1;
	for (int i=1;i<=maxn;i++)
	{
		jc[i]=1ll*jc[i-1]*i%mod;
		injc[i]=1ll*injc[i-1]*binpow(i,mod-2)%mod;
	}
}
int main()
{
	Init();
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		sa+=a[i];
		sb+=b[i];
	}
	for (int i=1;i<=n;i++) t[i]=1ll*a[i]*binpow(sa,mod-2)%mod;
	dp[0][0][0]=1;
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<=sa;j++)
		{
			for (int k=0;k<=sb;k++)
			{
				dp[i+1][j][k]=(dp[i+1][j][k]+dp[i][j][k])%mod;
			}
			for (int k=0;k<=sb;k++)
			{
				if (!dp[i][j][k]) continue;
				int cc=1;
				for (int h=0;h<b[i+1];h++)
				{
					dp[i+1][j+a[i+1]][k+h]=(-1ll*injc[h]*dp[i][j][k]%mod*cc+dp[i+1][j+a[i+1]][k+h])%mod;
					cc=1ll*cc*t[i+1]%mod;
				}
			}
		}
	}
	for (int i=1;i<=sa;i++)
	{
		p=1ll*(sa-i)*binpow(sa,mod-2)%mod;
		for (int j=0;j<=sb;j++)
		{
			if (!dp[n][i][j]) continue;
			ans=(-1ll*dp[n][i][j]*binpow(1-p,mod-2-j)%mod*jc[j]+ans)%mod;
		}
	}
	printf("%d\n",(ans+mod)%mod);
	return 0;
}

Measured memory_bytes: 308608
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	vector<vi> cur,nxt;
	cur.push_back(vi(1,1));
	int n,m,q;
	cin >> n >> m >> q;
	rep(i,1,n){
		nxt.clear();
		for(auto &v:cur){
			rep(j,v.back(),m+1){
				vi cp = v;
				cp.push_back(j);
				nxt.push_back(cp);
			}
		}
		cur.swap(nxt);
	}
	vector<array<int,4>> v(q);
	rep(i,0,q)rep(j,0,4)cin >> v[i][j];
	int ans = 0;
	for(auto &s:cur){
		int tmp = 0;
		for(auto &a: v){
			if(s[a[1]-1] - s[a[0]-1] == a[2])tmp+=a[3];
		}
		gmax(ans,tmp);
	}
	cout << ans << '\n';
}



Measured memory_bytes: 8420
//naveen mall
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb               push_back
#define sz(c)            (int)c.size()
#define len(c)           (int)c.length()
#define vec              vector
#define int              long long int
#define all(c)           c.begin(), c.end()
#define rall(c)          c.rbegin(), c.rend()
#define trav(a,i)        for(auto i: a)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define invect(v,n)       for(int i=0;i<n;i++ ){int arb;cin>>arb;v.pb(arb);}
#define inset(s,n)        fl(i,0,n){int aset;cin>>aset;s.insert(aset);}
#define display(c)        trav(c,i) cout<<i<<" ";cout<<"\n";
#define F                 first
#define S                 second
#define pii               pair<int,int>
#define PB                pop_back
#define endl              "\n"
#define what(x) cerr <<  #x << " is " << x << endl;
int sum() { return 0; }template<typename T,typename... Args>T sum(T a, Args... args) { return a + sum(args...); }



void solve()
{   
	 int n,k;
	 cin>>n>>k;
	 int a[n+1];
	 rep(i,1,n+1)
	   {cin>>a[i];
	   	//  v[i+1].pb(a[i]);
	   	}
	   	vec<int> vv;
	   	vv.pb(1);
	     int c=1;
	   	int i=1;
        set<int> s;
        s.insert(1);

	   	while(s.find(a[i])==s.end())
	   		  { 
                 c++;
                 vv.pb(a[i]);
                 s.insert(a[i]);
                 i=a[i];

	   		  }
	   		  int end=a[i];
	   		  int prel=0;
	   		// display(vv)

	   		  for(int i=0;i<sz(vv);i++)
	   		  	   { if(vv[i]==end)
	   		  	   	     {prel=i;
	   		  	   	     	break;}


	   		  	   }
	   		  	   int cy=sz(vv)-prel;


	   		  	   // cout<<prel<<" ";
	   		  	   // cout<<cy;

	   		  	   if(k<=prel)
	   		  	   	   cout<<vv[k];
	   		  	   	else
	   		  	   		 {
	   		  	   		 	k=(k-prel)%cy;
	   		  	   		 	cout<<vv[prel+k];
	   		  	   		 }


    


}
signed main()
{fast
    int t;
 t=1;
 
 //  cin>>t;
  while(t--)
     {
      solve();
     }
 
 
 
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int l = a + b, r = c + d;
  if (l == r) {
    cout << "Balanced\n";
  } else if (l < r) {
    cout << "Right\n";
  } else {
    cout << "Left\n";
  }
  
  return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N;
void solve()
{
    cin>>N;
    vector<ll>v(N);
    for(ll i=0;i<N;++i)
    {
        cin>>v[i];
    }
    ll sum=0;
    ll maxu=v[0];
    for(ll i=1;i<N;i++)
    {
        if(v[i]<maxu)
        sum+=(maxu-v[i]);
        if(v[i]>maxu)
        maxu=v[i];
    //cout<<sum<<"\n";

    }
    cout<<sum<<"\n";
}
signed main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif 
    solve();
}

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

using namespace std;

int main() {
	long long n, a; cin >> n;
	long long mini = 10e15;
	for (int i = 0; i < 5; ++i) {
		cin >> a;
		mini = min(mini, a);
	}
	cout << (n - 1) / mini + 5 << endl;
	

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
  char s[5];
  scanf("%s", s);
  
  if(s[0] == s[1] && s[1] == s[2] && s[2] == s[3])
    puts("No");
  else if(s[0] == s[1] && s[2] == s[3] || s[0] == s[2] && s[1] == s[3] || s[0] == s[3] && s[1] == s[2])
    puts("Yes");
  else
    puts("No");
  
  return 0;
}

Measured memory_bytes: 128
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


int main() {
	
	ll a, b, c;
	cin >> a >> b >> c;
	cout << (a + b < c ? "No" : "Yes") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef long long ll;
int l[100010],r[100010];
bool cmp(int a,int b){return a>b;}
int main(){
	int n,i;
	ll ans;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d%d",l+i,r+i);
	sort(l,l+n+1,cmp);
	sort(r,r+n+1);
	ans=0;
	for(i=0;i<=n;i++){
		if(l[i]<=r[i])break;
		ans+=l[i]-r[i];
	}
	printf("%lld",ans<<1);
}

Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String array[] = br.readLine().split(" ");
	int x = Integer.parseInt(array[0]);
	int y = Integer.parseInt(array[1]);
	int z = y % 4;
	if ((z == 0 || z % 2 == 0) && 4 * x >= y && 2 * x <= y) {
	    System.out.println("Yes");
	} else {
	    System.out.println("No");
	}

    }
}


Measured memory_bytes: 32716
import java.util.Arrays;
import java.util.Scanner;

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

			int n = sc.nextInt();
			int k = sc.nextInt();
			
			int[] sunukes = new int[n+1]; 
			
			for(int i = 0 ; i < k ; i++ ) {
				int di = sc.nextInt();
				for(int j = 0 ; j < di ; j++ ) {
					int a = sc.nextInt();
					sunukes[a] = 1;
				}
			}
			
			int haves = Arrays.stream(sunukes).sum();
			System.out.println(n - haves);
		}
	}

}

Measured memory_bytes: 46324
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}

string strin(){string s;cin>>s;return s;}
char chin(){char c;cin>>c;return c;}
ll lin() {ll x;scanf("%lld",&x);return x;}

int main(){
    int a=in(),b=in(),c=in(),d=in(),e=in(),f=in();
    if(e-a<=f) cout<<"Yay!"<<endl;
    else cout<<":("<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=3e5+7;
const int mod=1e9+7;
typedef pair<int,int> pii;
int w[maxn],v[maxn],f[maxn];
string vis[maxn];
int main()
{
	int n,t;
	cin>>n>>t;string s="0";
	for(int i=1;i<=n+1;i++) s+="0";
	for(int i=1;i<=n;i++)
	{
		cin>>w[i]>>v[i];
	}
	for(int i=0;i<=t+1;i++) vis[i]=s;
	for(int i=1;i<=n;i++)
	{
   	 	for(int c=t-1;c>=0;c--)
   	 	{
     	   if(c>=w[i])
      	  {
      	  	if(f[c]<f[c-w[i]]+v[i])
      	  	{
      	  		f[c]=max(f[c],f[c-w[i]]+v[i]);
      	  		//cout<<f[c]<<endl;
      	  		vis[c]=vis[c-w[i]];
      	  		//cout<<vis[c]<<endl;
      	  		vis[c][i]='1';
			}
		}
   		 }
	}
	//cout<<vis[t-1]<<endl;
	//cout<<f[t-1]<<endl;
	int mx=0;
	for(int i=1;i<=n;i++) if((vis[t-1][i]=='0')) mx=max(mx,v[i]);
	cout<<f[t-1]+mx<<endl;
 } 

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a);i>(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1000000000;
const LL MOD = 1000000007;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int d = A-B;
  int ans = C-d;
  if (ans < 0) ans = 0;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>

using namespace std;

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

  vector<pair<long long, int>> sack = {{0, 0}};

  for (int i = 0; i < n; i++) {
    int w;
    long long v;
    cin >> w >> v;

    vector<pair<long long, int>> new_sack;
    for (int j = 0; j < sack.size(); j++) {
      long long sack_v = sack[j].first;
      int sack_w = sack[j].second;

      new_sack.push_back({sack_v, sack_w});
      if (sack_w + w <= W) {
        new_sack.push_back({sack_v + v, sack_w + w});
      }
    }

    sort(new_sack.begin(), new_sack.end());

    vector<pair<long long, int>> filtered_sack;

    for (int j = 0; j < new_sack.size(); j++) {
      bool filtered = false;
      for (int t = j + 1; t < new_sack.size(); t++) {
        if (new_sack[j].first <= new_sack[t].first &&
            new_sack[j].second >= new_sack[t].second) {
          filtered = true;
        }
      }

      if (!filtered) {
        filtered_sack.push_back(new_sack[j]);
      }
    }

    sack = filtered_sack;

    // for (int j = 0; j < new_sack.size(); j++) {
      // cout << new_sack[j].first << " " << new_sack[j].second << " ; ";
    // }
    // cout << endl;
  }

  long long result = 0;
  for (int i = 0; i < sack.size(); i++) {
    result = max(result, sack[i].first);
  }

  cout << result << endl;

  return 0;
}


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

typedef long long lint;
typedef pair<int, int> pii;

const int INF = 2e9;
const int MOD = 998244353;
const int MAX = 1e5+10;
const lint LNF = 2e18;

int n, A[310], sum;
int D[90001], half;
int E[2][90001];
int inv2;

inline int f(int x, int y){ return 1LL*x*y%MOD; }
inline int g(int x, int y){ return (0LL+x+y)%MOD; }

int pw(int a, int e){
	if(e==0) return 1;
	int t = pw(a,e/2); t = f(t,t);
	return (e%2 ? f(t,a) : t);
}

int inv(int a){
	return pw(a, MOD-2);
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n;
	for(int i=1; i<=n; i++) cin>>A[i], sum+=A[i];

	D[0] = 1;
	for(int i=1; i<=n; i++){
		for(int j=90000; j>=A[i]; j--){
			D[j] = g(D[j], D[j-A[i]]);
		}
	}
	half = (sum%2 ? 0 : D[sum/2]);

	inv2 = inv(2);

	E[0][0] = 1;
	for(int i=1; i<=n; i++){
		int b = i&1, c = 1-b;
		for(int j=0; j<A[i]; j++) E[b][j] = E[c][j];
		for(int j=A[i]; j<=90000; j++){
			E[b][j] = g(E[c][j], f(inv2, E[c][j-A[i]]));
		}
	}
	lint over = 0;
	for(int i = (sum+1)/2; i<=sum; i++){
		over = g(over, E[n&1][i]);
	}
	over = f(pw(2, n), over);

	// cout<<3*over<<' '<<3*half<<'\n';

	lint ans = pw(3,n);
	ans = g(ans, f(half, 3));
	ans = g(ans, MOD-f(over, 3));
	cout<<ans<<'\n';



	return 0;
}


Measured memory_bytes: 1280
//karna padega 
#include<bits/stdc++.h>
using namespace std;	
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;	i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		string s,t;
		cin>>s>>t;
		int ans =0;
		int n = s.size();
		fn{
			if(s[i]!=t[i])ans++;
		}
		cout<<ans;
	
	
	}
	return 0;
}

Measured memory_bytes: 3824
import itertools
import math
N = int(input())

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



l = list(range(N))
total = 0
dist = 0
for i, v in enumerate(itertools.permutations(l, N)):
    total += 1
    old_j = v[0]
    for j in v[1:]:
        dist += math.sqrt((D[j][0] - D[old_j][0]) ** 2 + (D[j][1] - D[old_j][1]) ** 2)

print(dist / total)
 

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


int main(){
    long long N;
    cin >> N;
    vector<long long> C;
    for (int i = 0; i < N;i++){
        long long a;
        cin >> a;
        C.emplace_back(a);
    }
    sort(C.begin(), C.end());
    for (int i = 0; i < N - 1;i++){
        if(C[i] == C[i+1]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;

}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';        
#define debug(x) cerr << __LINE__ << ' ' << #x << " = " << x << '\n';
#define dln cerr << '\n';
#define dsp cerr << ' ';
#define pln cout << '\n';
#define psp cout << ' ';

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;


clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

int main(){
  fastio
  ll n;
  string s;
  cin >> s;
  set<char> t;
  map<char,int> m;
  for(auto p : s){
    t.insert(p);
    m[p]++;
  }
  if(sz(t) != 2){
    cout << "No\n";
  }else{
    auto c = *t.begin();
    auto d = *t.rbegin();
    if(m[c] == 2 and m[d] == 2){
      cout << "Yes\n";
    }else{
      cout << "No\n";
    }
  }
  ktj();

}


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

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

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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#define showvv(v)
#endif

using namespace std;

#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

int main(){
  ll h, w; cin >> h >> w;
  vvi c(10, vi(10));
  rep(i, 10) rep(j, 10) cin >> c[i][j];
  rep(k, 10) rep(i, 10) rep(j, 10) c[i][j] = min(c[i][j], c[i][k] + c[k][j]);

  ll a;
  ll ans = 0;
  rep(i, h) rep(j, w){
    cin >> a;
    if(abs(a) != 1) ans += c[a][1];
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL gcd(LL a,LL b) { return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b) { return a/gcd(a,b)*b;}

LL N;
LL A[200000],B[200000];

LL ans = 1;

void solve(){
	vector<LL> pow2(200001,1);
	for(int i=1;i<=200000;i++) pow2[i] = (pow2[i-1]*2LL)%mod;

	map<pair<LL,LL>,LL> pair_num;
	map<pair<LL,LL>,bool> used;
	for(int i=0;i<N;i++){
		if(A[i]==0 && B[i]!=0) B[i] = INF;
		if(A[i]!=0 && B[i]==0) A[i] = INF;
		if(A[i]!=0 && B[i]!=0){
			LL gcd_AB = gcd(A[i],B[i]);
			A[i] /= gcd_AB;
			B[i] /= gcd_AB;
			if((A[i]<0 && B[i]<0) || (A[i]>0 && B[i]<0)){
				A[i] *= -1LL;
				B[i] *= -1LL;
			}
		}
		pair_num[pair<LL,LL>(A[i],B[i])]++;
	}

	for(auto iter=pair_num.begin();iter!=pair_num.end();iter++){
		pair<LL,LL> one = iter->first;
		if(used[one]) continue;
		//cout << one.first << " " << one.second << endl;
		if(one.first==0 && one.second==0){
			used[one] = true;
		}
		else if(one.first==0){
			pair<LL,LL> another(INF,0);
			used[one] = true;
			used[another] = true;
			ans *= (pow2[pair_num[one]] + pow2[pair_num[another]] - 1LL)%mod;
			ans %= mod;
		}
		else if(one.second==0){
			pair<LL,LL> another(0,INF);
			used[one] = true;
			used[another] = true;
			ans *= (pow2[pair_num[one]] + pow2[pair_num[another]] - 1LL)%mod;
			ans %= mod;
		}
		else{
			pair<LL,LL> another((one.second),-(one.first));
			used[one] = true;
			used[another] = true;
			ans *= (pow2[pair_num[one]] + pow2[pair_num[another]] - 1LL)%mod;
			ans %= mod;
		}
	}
	if(used[pair<LL,LL>(0,0)]){
		ans += (pair_num[pair<LL,LL>(0,0)]);
		ans %= mod;
	}
	ans--;
	ans = (ans+mod)%mod;
}

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

    solve();

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

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

int main() {
  int n, i, ans = 0;
  cin >> n;
  
  vector<int> l(2 * n);
  for(i = 0; i < 2 * n; i++){
    cin >> l.at(i);
  }
  
  sort(l.begin(), l.end());
  
  for(i = 0; i < n; i++){
    ans += l.at(2 * i);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_map>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define RevRange(container) container.rbegin(), container.rend()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;


constexpr int MOD = 1000000007;

constexpr int COMB_MAX = 110000;
ll fac[COMB_MAX], finv[COMB_MAX], inv[COMB_MAX];
void initComb(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COMB_MAX; i ++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    Cin(int, n);
    Cin(int, m);
    initComb();
    
    unordered_map<int, int> d;
    for(int i = 2; i*i <= m; i ++){
        while(m % i == 0){
            d[i] ++;
            m /= i;
        }
    }
    if(m > 1) d[m] ++;
    ll ans = 1;
    for(auto &nd : d){
        ans = ans * comb(n-1 + nd.second, nd.second) % MOD;
    }
    Cout(ans);
}



Measured memory_bytes: 2816
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int cnt = 0;
	for (int i = 0; i <= A; i++) {
		for (int j = 0; j <= B; j++) {
			for (int k = 0; k <= C; k++) {
				if (i * 500 + j * 100 + k * 50 == X) {
					cnt++;
				}
			}
		}
	}
	cout << cnt << endl;
}

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

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

struct UnionFind
{
    vector<int> d;
    UnionFind(int n = 0) : d(n, -1) {}
    int find(int x)
    {
        if (d[x] < 0)
            return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y)
            return false;
        if (d[x] > d[y])
            swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);

    int n, m;
    cin >> n >> m;
    struct UnionFind uf(n);

    rep(i, m)
    {
        int x, y, z;
        cin >> x >> y >> z;
        x--;y--;
        uf.unite(x, y);
    }
    int ans = 0;
    rep(i, n)
    {
        if (uf.find(i) == i) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
int main(){

  int n, k;
  char s[50];

  scanf("%d %d",&n,&k);

  scanf("%s",s);

  if(n >= k){
    if(s[k-1] < 'a'){
      s[k-1] = s[k-1]+32;
    }else{
      s[k-1] = s[k-1]-32;
    }
  }
  printf("%s\n",s);

  return 0;


}


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

int main() {
  int A, B, C, D;
  int time[301] = {0};
  cin >> A >> B >> C >> D;
  for(int i = A; i < B; i++) time[i]++;
  for(int i = C; i < D; i++) time[i]++;
  int ans = 0;
  for(int i = 0; i < 301; i++) if(time[i] == 2) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;

void main()
{
        char[] input = chomp(readln).dup;
        int i = 0;
        foreach(e; input) {
                if(e == '+') {
                        i += 1;
                } else {
                        i -= 1;
                }
        }
        writeln(i);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    map<int,string >m1;
    map<int,int>m2;
    int t,cnt=0,sum=0,k;
    string s,p;
    cin>>t;
    for(int i=0; i<t; i++)
    {
        cin>>m1[i];
        cin>>m2[i];
        cnt+=m2[i];
    }
    cin>>p;
    auto itr1=m2.begin();
    auto itr=m1.begin();
    while(itr->second!=p)
    {
        sum+=itr1->second;
        itr++;
        itr1++;
    }
    k=abs(cnt-sum)-(itr1->second);
    cout<<k<<endl;
    m1.clear();
    m2.clear();
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static int count[][];
	static String s;
	static int x, y;
	static boolean dp[][] = new boolean[4001][16001];

	public static boolean solve(int t, int n) {
		int tx = y + 8000;
		dp[0][8000] = true;
		dp[0][count[t][0] + 8000] = true;
		if (t == 0)
			tx = x + 8000;
		for (int i = 1; i <= n; ++i) {
			for (int j = 0; j <= 16000; ++j) {
				if (dp[i - 1][j]) {
					dp[i][j + count[t][i]] = true;
					dp[i][j - count[t][i]] = true;
				}
			}
		}
		if (dp[n][tx])
			return true;
		return false;
	}

	public static void ini() {
		for (int i = 0; i <= 4000; ++i) {
			for (int j = 0; j <= 16000; ++j) {
				dp[i][j] = false;
			}
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		s = sc.next();
		x = sc.nextInt();
		y = sc.nextInt();
		String ans[] = { "Yes", "No" };
		sc.close();
		int a = 1;
		int n = s.length();
		count = new int[2][(n / 2) + 1];
		int j = 0;
		for (int i = 0; i < n; ++i) {
			int tmp = j % 2;
			if (s.charAt(i) == 'F')
				++count[tmp][(j / 2) + tmp];
			else {
				++j;
			}
		}
		if (solve(0, (j / 2))) {
			ini();
			if (solve(1, (j / 2) + j % 2))
				a = 0;
		}
		System.out.println(ans[a]);
	}

}


Measured memory_bytes: 135892
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 1000000007, INF = 1111111111;
const double EPS = 1e-9;

int main() {

	cin.tie(0);

	vector<string> s(3);
	FOR(i, 0, 3) cin >> s[i];
	int offset = 'A' - 'a';

	FOR(i,0,3) cout << ((char)(s[i][0] + offset));

	return 0;
}

Measured memory_bytes: 256
<?php
$N = trim(fgets(STDIN));
$S = trim(fgets(STDIN));
$max = 0;
$x = 0;
for($i = 0; $i < $N; $i++){
	if($S[$i] == 'I'){
		$x++;
		if($max < $x) $max = $x;
	}
	else $x--;
}
echo $max;
?>

Measured memory_bytes: 3452
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

map<string, set<int>> memo;

int toNum(string str){
	int num = 0;
	rep(i,str.size()){
		num *= 10;
		num += str[i] - '0';
	}
	return num;
}

bool numCheck(string s){
	for(auto i : s){
		if(not isdigit(i)) return false;
	}
	return true;
}

auto close(string::iterator it){
	int c = 0;
	while(true){
		if(*it == '(') c++;
		else if(*it == ')') c--;

		if(c == 0) return it;
		it++;
	}
	assert(false);
	return it;
}

set<int> expr(string s){
	if(memo.count(s)) return memo[s];
	if(numCheck(s)) return memo[s] = {toNum(s)};
	if(s.front() == '(' && close(s.begin()) == --s.end()){
		return memo[s] = expr(string(++s.begin(), --s.end()));
	}

	set<int> res;
	for(auto it = s.begin(); it != s.end(); it++){
		if(*it == '(') it = close(it);

		if(not isdigit(*it) && *it != ')'){
			//cout << string(s.begin(), it) << ' ' << string(it + 1, s.end()) << endl;
			set<int> a = expr(string(s.begin(), it));
			set<int> b = expr(string(it + 1, s.end()));

			for(auto i : a){
				for(auto j : b){
					if(j == 0 && *it == '/') continue;
					switch (*it) {
						case '+':
							res.emplace(i + j);
							break;
						case '-':
							res.emplace(i - j);
							break;
						case '*':
							res.emplace(i * j);
							break;
						case '/':
							res.emplace(i / j);
							break;
					}
				}
			}
		}
	}
	return res;
}

int main(){
	string s;
	while(cin >> s, s[0] != '#'){
		cout << expr(s).size() << endl;
	}
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;
 
using namespace std;
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;
    double density_max = 0;
    double water_max = 0;
    double sugar_max = 0;
    rep(i,0,101){
        rep(j,0,101){
            rep(k,0,101){
                rep(l,0,101){
                    double water = 100 * A * i + 100 * B * j;
                    double sugar = C * k + D * l;
                    if(water + sugar <= F && water + sugar != 0 && water != 0){
                        double density = 100 * sugar /(water + sugar);
                        double d_E = 100 * E / (100 + E);
                        if(density <= d_E){
                            if(density >= density_max){
                                density_max = density;
                                water_max = water;
                                sugar_max = sugar;
                            }
 
                        }
                    }
                }
            }
 
        }
    }
    cout << water_max + sugar_max << " " << sugar_max << endl;
 
}

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

using ll = long long int;

const ll MAX_N = (ll)(2e5 + 5);

int n;
ll a[MAX_N];

deque<ll> v;
ll ap[MAX_N];

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%lld", &(a[i]));
  }

  for (int i = 0; i < n; ++i) {
    if (i % 2 == 0) {
      v.push_front(a[i]);
    }
    else {
      v.push_back(a[i]);
    }
  }

  int i = 0;
  for (auto itr = v.begin(); itr != v.end(); ++itr) {
    ap[i] = *itr;
    i += 1;
  }

  if (n % 2 == 1) {
    for (int i = 0; i < n; ++i) {
      printf("%lld ", ap[i]);
    }
  }
  else {
    for (int i = n - 1; i >= 0; --i) {
      printf("%lld ", ap[i]);
    }
  }

  printf("\n");

  return 0;
}

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

using namespace std;
int n;
struct stu
{
	int no;
	int sum;
}st[100010];

bool cmp(stu x, stu y)
{
	return x.sum < y.sum;
}
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		st[i].no = i + 1;
		st[i].sum = a;
	}
	sort(st, st + n, cmp);
	for (int i = 0; i < n; i++)
		cout << st[i].no << " ";
	return 0;
}

Measured memory_bytes: 1664
using System;

namespace TenkaPBC2019B
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数Nの入力
            int N = int.Parse(Console.ReadLine());
            // 文字列Sの入力
            string S = Console.ReadLine();
            // 整数Kの入力
            int K = int.Parse(Console.ReadLine())-1;

            string note = S.Substring(K, 1);
            string[] pieces = new string[N];
            string ans = "";
            for (int i = 0; i < N; i++)
            {
                pieces[i] = S.Substring(i, 1);
                if (pieces[i]!=note)
                {
                    pieces[i] = "*";
                }
                ans += pieces[i];
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	V<int> a(3);
	cin>>a[0]>>a[1]>>a[2];
	Sort(a);
	cout<<a[2]-a[0]<<endl;
}

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

#define int long long
const int maxn = 1e5 + 5;

int n, m, ps[maxn];
vector <int> a;

int check(int x) {
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += a.end() - lower_bound(a.begin(), a.end(), x - a[i]);
	}
	return ans;
}

int bs() {
	int l = 0, r = 2e5 + 5;
	while (r > l + 1) {
		int mid = (l + r) / 2;
		if (check(mid) < m)
			r = mid;
		else
			l = mid;
	}
	return l;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	a.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int x = bs();
	int y = m - check(x + 1);
	int ans = 0;
	ps[n - 1] = a[n - 1];
	for (int i = n - 2; i >= 0; i--)
		ps[i] = ps[i + 1] + a[i];
	for (int i = 0; i < n; i++) {
		ans += ps[lower_bound(a.begin(), a.end(), x + 1 - a[i]) - a.begin()] + a[i] * (a.end() - lower_bound(a.begin(), a.end(), x + 1 - a[i]));
	}
	ans += y * x;
	cout << ans;
}


Measured memory_bytes: 1792
n = input()

if n[0] == n[1] and n[1] == n[2] and n[0] == n[2]:
    print(n)
elif n[0] == '9':
    print('999')
elif n[0] == n[1] and n[0] > n[2]:
    print(n[0]*3)
elif n[0] == n[1] and n[0] < n[2]:
    print(str(int(n[0])+1) * 3)
elif n[0] < n[1]:
    print(str(int(n[0])+1) * 3)
elif n[0] > n[1]:
    print(n[0]*3)


Measured memory_bytes: 3064
import java.util.Scanner;


public class Main {
	static int N,M,K;
	static int[] foods;
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		 N = sc.nextInt();
		 M = sc.nextInt();
		 foods = new int[M];

		 for(int i = 0 ; i < N ; i++){
			 K = sc.nextInt();

			 for(int j = 0 ; j < K ; j++){
				 foods[sc.nextInt()-1] += 1;
			 }
		 }

		sc.close();

		int ans = 0 ;
		for(int k = 0 ; k < M ; k++){
			if(foods[k] == N){
				ans += 1;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 24276
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double pi = acos(-1);
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}


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

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

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

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

//↑template↑





bool dang[100005];
ll dp[100005];
int main() {
	int a, b, k[100005];
	cin >> a >> b;
	for (int i = 0; i < b; ++i) {
		cin >> k[i];
		dang[k[i]] = 1;
	}
	dp[0] = 1;
	for (int i = 0; i < a; ++i) {
		dp[i] %= MOD;
		if (!dang[i]) {
			dp[i + 1] += dp[i], dp[i + 2] += dp[i];
		}
	}


	cout << dp[a] % MOD << endl;
}

Measured memory_bytes: 1536
/*maksuda*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x,b,t,n,c;
    cin>>x>>b>>t;
    if(t>=x){
        n=(t+0.5)/x;
        c=n*b;
    }
    else
   { c=0;}
    cout<<c<<endl;
}


Measured memory_bytes: 3672
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#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 REP(i, n) for (int i = 0; i < n; ++i)
#define int long long

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

const int kMaxH = 50;

int H, W;
string s[kMaxH];
string ans;

int d[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

signed main() {
  cin >> H >> W;
  REP(i, H) { cin >> s[i]; }

  ans = "Yes";
  REP(i, H) {
    REP(j, W) {
      if (s[i][j] == '#') {
        bool imp = true;
        REP(k, 4) {
          int ni = i+d[k][0]; int nj = j+d[k][1];
          if (0 <= ni && ni < H && 0 <= nj && nj < W) {
            if (s[ni][nj] == '#') {
              imp = false;
              break;
            }
          }
        }
        if (imp) {
          ans = "No";
          goto r;
        }
      }
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <tr1/unordered_map>
#define debug(x) (cout << "#x = " << (x) << endl)
#define lowbit(x) (x & -x)
#define Set(x, i) memset(x, i, sizeof x)
#define R register
#define For( i, j, k ) for(R int i = (j); i <= (k); ++i)
#define Rep( i, j, k ) for(R int i = (j); i >= (k); --i)
#define Cross( i, j, k ) for(R int i = (j); i; i = (k))
typedef long long ll;
using namespace std;
const ll N = 100011;
const ll INF = 5e16;

namespace IO {

	#define dd ch = getchar()
	inline ll read() {
		ll x = 0; bool f = 0; char dd;
		for (; !isdigit (ch); dd) f ^= (ch == '-');
		for (; isdigit (ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write ( ll x ) {
		if (x < 0) putchar ('-'), x = -x;
		if (x > 9) write (x / 10); putchar (x % 10 | 48);
	}

	inline void wrn ( ll x ) { write(x); putchar (' '); }

	inline void wln ( ll x ) { write(x); putchar ('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn(x); wln (y); }

}

using namespace IO;

namespace Cesare {

	/*
		根据 b 排序，使 a 也有序的最少交换次数。 
		n - 2 次交换是否能使序列有序。
		
		3 1 6 4 3 2
		2 2 3 3 4 8
		
		1 2 3 3 4 6 
	*/
	
	ll n;
	
	struct Node {
		ll a, b, id;
	} K[N];
	
	struct xzy {
		ll x, id;
	} A[N];
	
	inline bool cmp (Node a, Node b) {
		return a.b == b.b? a.a < b.a: a.b < b.b;
	}
	
	inline bool Cmp (xzy a, xzy b) {
		return a.x < b.x; 
	}
	
	#define int long long
	
	vector <int> v;
	
	inline int Cycle(ll res = 0) {
		map <ll, ll> mp;
		For ( i, 1, n ) mp[A[i].id] = K[i].id;
		for (ll x = mp[1]; x != 1; x = mp[x]) ++res;
		return res + 1 == n;
	}
	
	signed main() {
		n = read();
		For ( i, 1, n ) K[i].a = read();
		For ( i, 1, n ) K[i].b = read();
		For ( i, 1, n ) A[i].x = K[i].a, K[i].id = A[i].id = i;
		sort(A + 1, A + n + 1, Cmp);
		sort(K + 1, K + n + 1, cmp);
		
		For ( i, 1, n ) if (A[i].x > K[i].b) return puts("No"), 0;
		For ( i, 2, n ) if (A[i].x <= K[i - 1].b) return puts("Yes"), 0;
		return puts(!Cycle()? "Yes": "No"), 0;
	} // 至少有一个位置的交换一次就换对两个地方。 
	
}

signed main()
{
	return Cesare :: main();
}

/*

*/



Measured memory_bytes: 10368