akhauriyash/Code-Regression huggingface dataset:
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

class dijkstra{
  constructor(n){
    this.graph = Array(n).fill().map(a=>[]);
  }
  add(u,v,cost){
    this.graph[u].push(v,cost);
  }
  add2(u,v,cost){
    this.graph[u].push(v,cost);
    this.graph[v].push(u,cost);
  }
  solve(start){
    const INF = 1e18;
    const g = this.graph;
    var pq = new priorityQueue();
    pq.push(0,start);
    var dp = Array(g.length).fill(INF);
    dp[start] = 0;
    while(pq.size){
      var [t,v] = pq.pop();
      if(dp[v] < t)continue;
      for(var i = 0; i < g[v].length; i+=2){
        var V = g[v][i], c = g[v][i+1] + t;
        if(dp[V] <= c)continue;
        dp[V] = c;
        pq.push(c,V);
      }
    }
    return dp;
  }
}

class priorityQueue{
  constructor(){
    this.a=[];
  }
  push(num,inc){
    const a = this.a;
    for(var i = a.length, j; i; i = j){
      j = i - 1 >> 1;
      if(a[j][0] <= num)break;
      a[i] = a[j];
    }
    a[i] = [num,inc];
  }
  pop(){
    const a = this.a, r = a[0], x = a.pop(), k = a.length >> 1;
    for(var i = 0, j; i < k; i = j){
      j = (i << 1) + 1;
      if(a[j+1] && a[j+1][0] < a[j][0])j++;
      if(x[0] <= a[j][0])break;
      a[i] = a[j];
    }
    if(a.length)a[i] = x;
    return r;
  }
  get size(){
    return this.a.length;
  }
  get top(){
    return this.a[0];
  }
}

const mx = 2500;

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var [n,m,s] = nexts(3);
  var g = new dijkstra(mx * n);
  for(var i = 0; i < m; i++){
    var [u,v,a,b] = nexts(4);
    u--,v--;
    u *= mx, v *= mx;
    for(var j = mx; j-- > a;){
      g.add(u+j,v+j-a,b);
      g.add(v+j,u+j-a,b);
    }
  }
  for(var i = 0; i < n; i++){
    var [c,d] = nexts(2);
    var v = i * mx;
    for(var j = 0; j < mx-1; j++)g.add(v+j,v+Math.min(mx-1,j+c),d);
  }
  var dp = g.solve(Math.min(mx-1,s));
  var ans = xArray(1e18,n);
  for(var i = 1; i < n; i++){
    var v = i*mx;
    for(var j = 0; j < mx; j++){
      ans[i] = Math.min(ans[i],dp[v+j]);
    }
  }
  return ans.slice(1).join("\n");
}

Measured memory_bytes: 112212
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=nxt(),k=nxtl();
    vector <int> v(n+1);
    for(int i=1;i<=n;i++)
        cin>>v[i];
    vector <bool> visited(n+1,0);
    vector <int> path;
    vector <int> path2;
    int cur=1;
    while(1)
    {
        if(visited[cur]){
            int i=0;
            while(path[i]!=cur)
                i++;
            while(i<path.size()){
                path2.push_back(path[i]);
                i++;
            }
            break;
        }
        visited[cur]=1;
        path.push_back(cur);
        cur=v[cur];
    }
    ll x=path2.size();
    if(k<path.size())
    {
        cout<<path[k]<<endl;
        return 0;
    }
    k-=path.size();
    k%=x;
    //for(auto i:path)
      //  cout<<i<<" ";
    //cout<<endl;
    cout<<path2[k]<<endl;
    
    
    
    return 0;   
}




 
 


Measured memory_bytes: 6316
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main (){
	int N,X;cin>>N>>X;
	vector<int> m (N);for(int i=0;i<N;i++)cin>>m[i];
	int min=10000;
	for(int i=0;i<N;i++){
		if(min>m[i])min=m[i];
	}
	for(int i=0;i<N;i++){
		X=X-m[i];
	}
	cout<<X/min+N<<endl;

    return 0;
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> a(n + 1, 0);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  ll ans = 0;
  for(int i = 0; i < n; i++){
    if(a.at(i) >= 2){
      ans += a.at(i) / 2;
      a.at(i) -= a.at(i) / 2 * 2;
    }
    if(a.at(i) == 1 && a.at(i + 1) > 0){
      ans++;
      a.at(i)--;
      a.at(i + 1)--;
    }
  }
  
  cout << ans << '\n';
}

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

int main() {
	int n ; 
	double res  = 0 ;
	scanf("%d",&n);
	if(n&1)res+=(n>>1) + 1;
	else
	res += (n>>1);
	printf("%.9lf",res/(double)n);
	return 0;
}

Measured memory_bytes: 256
// Author -- Frame

#include<bits/stdc++.h>

#define lowbit(x) ((x)&(-(x)))
#define Finline __inline__ __attribute__ ((always_inline))
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
#define SZ(x) ((int)x.size())
#define mkpr std::make_pair
#define pb push_back

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef std::pair<int,int> pi;
typedef std::pair<ll,ll> pl;
using std::min;
using std::max;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x3f3f3f3f3f3f3f3f;

Finline uint rnd(){static uint seed=416;return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;}
template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>=0?a:-a;}
template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(b<a)&&(a=b);}
template <typename _Tp>Finline void read(_Tp &x)
{
	char ch(getchar());bool f(false);while(!isdigit(ch)) f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();while(isdigit(ch)) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
	f&&(x=-x);
}
template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args){read(t);read(args...);}
template <typename _Tp,typename... Args>Finline _Tp min(const _Tp &a,const _Tp &b,const Args &...args){return a<b?min(a,args...):min(b,args...);}
template <typename _Tp,typename... Args>Finline _Tp max(const _Tp &a,const _Tp &b,const Args &...args){return a<b?max(b,args...):max(a,args...);}
Finline int read_str(char *s)
{
	char ch(getchar());while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
	char *tar=s;*tar=ch,ch=getchar();while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
	return tar-s+1;
}

const int N=100005;
struct edge{
	int v,nxt,w;
}c[N<<1];
int front[N],edge_cnt;
Finline void addedge(int u,int v,int w)
{
	c[++edge_cnt]=(edge){v,front[u],w};
	front[u]=edge_cnt;
}
int minn,n,siz[N];
std::vector<int> root;
void getrt(int x,int fa)
{
	siz[x]=1;int tmp=0;
	for(int i=front[x];i;i=c[i].nxt)
	{
		int v=c[i].v;
		if(v==fa) continue;
		getrt(v,x);
		siz[x]+=siz[v];
		chmax(tmp,siz[v]);
	}
	chmax(tmp,n-siz[x]);
	if(tmp==minn) root.pb(x);
	else if(tmp<minn) minn=tmp,root.clear(),root.pb(x);
}
ll dis[N];
void dfs(int x,int fa)
{
	for(int i=front[x];i;i=c[i].nxt)
	{
		int v=c[i].v;
		if(v!=fa)
		{
			dis[v]=dis[x]+c[i].w;
			dfs(v,x);
		}
	}
}
int main()
{
	read(n);
	int x,y,z;
	for(int i=1;i<n;++i)
	{
		read(x,y,z);
		addedge(x,y,z),addedge(y,x,z);
	}
	minn=inf;getrt(1,0);
	dfs(root[0],0);
	ll ans=0;
	for(int i=1;i<=n;++i) ans+=dis[i]<<1;
	if(SZ(root)==1)
	{
		minn=inf;
		for(int i=front[root[0]];i;i=c[i].nxt) chmin(minn,c[i].w);
	}
	else for(int i=front[root[0]];i;i=c[i].nxt) if(c[i].v==root[1]) minn=c[i].w;
	ans-=minn;
	printf("%lld\n",ans);
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef long int lt;
typedef vector<ll> vi;
typedef vector<int> vin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
#define all(a) a.begin(),a.end()
#define rep(i,a,b) for(int i=a;i<b;++i)
#define f(i,b) for(int i=0;i<b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define test(t) int t; cin>>t; while(t--) solve()
#define endl "\n"
#define p1 cout<<"YES"<<endl
#define p0 cout<<"NO"<<endl
#define fst ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int mod=1e9+7;

ll mod_pow(ll a,ll n,ll mod)	//(a^n)%mod
{	ll res=1;
	while(n){	if(n&1)	res=(res*a)%mod; n/=2; a=(a*a)%mod;	}
	return res;
}

void solve();

int main()
{
    fst;
    //test(t);
     solve();
}

/**********************<="Actual code strats here"=>*****************************/


void solve()
{
    int n,k;
    cin>>n>>k;

    vi a(n);
    rep(i,0,n) cin>>a[i];

    nth_element(a.begin(),a.begin()+k,a.end());
    cout<<accumulate(a.begin(),a.begin()+k,0)<<endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
using ll = long long;
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=int(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
const ll mod = 1000000007;
using namespace std;

int main() {
    int N, M; cin >> N >> M;
    long long cnt=1;
    if(abs(N-M)==1||N==M){
        int s = N; int t = M;
        while(N){
            cnt=(cnt*N)%mod;
            N--;
        }
        while(M){
            cnt=(cnt*M)%mod;
            M--;
        }
        if(s==t){
            cout << (cnt*2)%mod << endl;
        }else{
            cout << cnt%mod << endl;
        }
    }
    else{
        cout << 0 << endl;
    }
	return 0;
}

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

using namespace std;
using ll  = long long;
using ii  = pair < int , int >;
using pll = pair < ll , ll >;
using i3  = pair < int , ii >;
using vi  = vector < int >;
using vl  = vector < ll >;
using vii = vector < ii >;
using vi3 = vector < i3 >;

const int N = 2e5 + 5;
const ll INF = 1e12;
const double eps = 1e-9 , PI = acos(-1);

int n , m;

void solve(){
    scanf("%d" , &n);
    
    printf("%d\n" , n*(n+1)/2);

}

main(){
    int t = 1;
    //scanf("%d" , &t);

    while( t -- ){
            solve();
    }

    return 0;
}





Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    int A,B;

int main(){
    cin>>A>>B;


    cout<<(A*A)-B;
    return 0;

}

Measured memory_bytes: 256
N, M = map(int, input().split())
cities = [float("{}.{:010}".format(*tuple(map(int, input().split())))) for _ in range(M)]
sorted_cities = sorted(cities)

ids = {}
cnt = 1
before = -1
for c in sorted_cities:
    id_ = int(c)
    if before != id_:
        before = id_
        cnt = 1
    else:
        cnt += 1
    ids[c] = cnt

[print("{:06}{:06}".format(int(c), ids[c])) for c in cities]


Measured memory_bytes: 19152
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

//return 10^n%2019
vector<int> vec(200030,1);

int main()
{
  for (auto i = 1; i < vec.size(); ++i)
  {
    vec[i]=(vec[i-1]*10)%2019;
  }

  string s;
  cin>>s;
  int n=s.size();
  vector<int> T(n,0);
  T[n-1]=(s[n-1]-'0')%2019;
  for (auto i = n-2; i >= 0; --i)
  {
    T[i]=((s[i]-'0')*vec[(n-i-1)]+T[i+1])%2019;
  }
  map<int,int> mp;
  for (auto i = 0; i < T.size(); ++i)
  {
    mp[T[i]]++;
  }
  mp[0]++;
  ll ans=0;
  for(const auto& e: mp) 
  {
    ans+=e.second*(e.second-1)/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 5224
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 05/03/20 20:34:41
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n,k; cin>>n>>k;
  set<int> sunukes;
  for (int i = 1; i <= n ;i++)
    sunukes.insert(i);
  for (int i = 0; i < k; i++) {
    int d; cin>>d;
    for (int j = 0; j < d; j++) {
      int a; cin>>a;
      sunukes.erase(a);
    }
  }
  cout << sunukes.size() << endl;

  return 0;
}


Measured memory_bytes: 3668
#include <stdio.h>
int main(void)
{
	int n, i, m, t=0;
	char s[100];
	
	scanf("%d", &n);
	scanf("%s", &s);
	
	m = n / 2;
	i = n % 2;
	
	if(i == 1){
		printf("No");
	}else{
		for(i = 0; i < m; i++){
			if(s[i] != s[i+m]){
				t++;
			}
		}
		if(t == 0){
			printf("Yes");
		}else{
			printf("No");
		}
	}
		return 0;
}

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

using namespace std;

int main () {

    int N;
    cin >> N;
    vector<int> heights(N);
    int ans = 0;
    for (int i = 0; i < N; i++) {
        cin >> heights[i];
    }

    // reverse(heights.begin(), heights.end());
    int m = 0;
    for (size_t i = 0; i < heights.size(); i++) {
    
        if (heights[i] >= m) {
            ans += 1;
        }
        m = max (m, heights[i]);
    }
    cout << ans << '\n';
    return 0;
}


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

using namespace std;

int main()
{
    long long int x;
    cin >> x;

    long long int ans = (x / (6+5))*2;

    if(x%(6+5) > 6) ans+=2;
    else if(x%(6+5) > 0) ans++;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
int main(void){
        char c[3][3];
        long long int ans;
        for(int i=0;i<3;i++){
                for(int j=0;j<3;j++){
                        std::cin >> c[i][j];
                }
        }
        printf("%c%c%c",c[0][0],c[1][1],c[2][2]);
        return 0;
}

Measured memory_bytes: 256
N,X=map(int,input().split())
x=list(map(int,input().split()))
l=[]
for i in range(N):
    l.append(abs(X-x[i]))
def gcd(a,b):
    if a == 0:
        return b
    if b == 0:
        return a
    r = 1
    while r > 0:
        r = a % b
        a = b
        b = r
    return a

ll=[0]*(N+1)
for i in range(N):
    ll[i+1]=gcd(ll[i],l[i])
print(ll[N])

Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define lli long long int
#define inf 2147483647
#define infll LLONG_MAX
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    map<int, int> m;    
    string s;
    cin >> s;
    lli sum = 0, now = 0, p = 1;

    if(s.size() <=3){
        cout << "0" << endl;
        return 0;
    }

    m[now]++;
    reverse(all(s));
    for(auto c: s){
        now = now + (c - '0') * p;
        p = p * 10 % 2019;
        now %= 2019;
        m[now]++;
    }

    for(auto p: m){
        sum += (p.second) * (p.second-1) /2;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
#define me(a,x) memset(a,x,sizeof(a))
#define sc scanf
#define pr printf
#define IN freopen("in.txt","r",stdin);
#define OUT freopen("out.txt","w",stdout);
typedef long long ll;
typedef unsigned long long ull;
const int N=1e6+6;
const int mod=1e9+7;
template<typename T>int O(T s){cout<<s<<endl;return 0;}
template<typename T>void db(T *bg,T *ed){while(bg!=ed)cout<<*bg++<<' ';pr("\n");}
template<typename T>void db(vector<T>it){for(auto i:it)cout<<i<<' ';pr("\n");}
inline ll mul_64(ll x,ll y,ll c){return (x*y-(ll)((long double)x/c*y)*c+c)%c;}
inline ll ksm(ll a,ll b,ll c){ll ans=1;for(;b;b>>=1,a=a*a%c)if(b&1)ans=ans*a%c;return ans;}
inline void exgcd(ll a,ll b,ll &x,ll &y){if(!b)x=1,y=0;else exgcd(b,a%b,y,x),y-=(a/b)*x;}
int main(){
    
    int n,m;
    cin>>n>>m;
    int s[300];
    int x=0,ans=0;
    for(int i=1;i<=n;i++)s[++x]=2*i;
    for(int i=1;i<=m;i++)s[++x]=2*i-1;
    for(int i=1;i<=x;i++){
        for(int j=i+1;j<=x;j++){
            if(s[i]+s[j]&1)continue;
            ans++;
        }
    }
    O(ans);
}

Measured memory_bytes: 256
S = input()
N = len(S)
 
ans = [0] * N
 
index = 0
lcount = 0
rcount = 0
for i in range(N):
    if S[i] == 'R' and S[i + 1] == 'R':
        rcount += 1
    if S[i] == 'L' and S[i - 1] == 'L':
        lcount += 1
    if S[i] == 'R' and S[i + 1] == 'L':
        if lcount != 0:
            ans[index] += lcount // 2 + lcount % 2
            ans[index + 1] += lcount // 2
            lcount = 0
        index = i
        ans[i] = 1
        ans[i + 1] = 1
        if rcount != 0:
            ans[i] += rcount // 2
            ans[i + 1] += rcount // 2 + rcount % 2
            rcount = 0
        i += 1
if lcount != 0:
    ans[index] += lcount // 2 + lcount % 2
    ans[index + 1] += lcount // 2
    lcount = 0
    
for i in range(N):
    print(ans[i], end=" ")

Measured memory_bytes: 4864
divisor :: Int -> Int -> [(Int, Int)]
divisor n i
    | n < i*i = []
    | n `mod` i == 0 =
        if i*i /= n then
            [(i, n `div` i)] ++ divisor n (i+1)
        else
            [(i,i)] ++ divisor n (i+1)
    | otherwise = divisor n (i+1)


main = do
    x <- readLn :: IO Int
    let ds = divisor x 1
    let res = minimum $ map (\(a,b) -> max (length $ show a) (length $ show b)) ds
    print res

Measured memory_bytes: 892
#include <stdio.h>
#include <stdlib.h>


int main (void){
        int N,Y,now,man=0,gosen=0,sen=0;
        scanf("%d %d",&N,&Y);
        if (N*10000<Y||N*1000>Y) {
                printf("-1 -1 -1");
                return 0;
        }
        now=(Y-N*1000)/1000;
        man=now/9;
        now=now%9;
        gosen=now/4;
        now=now%4;
        while (now!=0) {
                man--;
                now+=9;
                while (now>0) {
                        gosen++;
                        now-=4;
                }
        }
        sen=N-gosen-man;
        if (sen<0||man<0||gosen<0) {
                printf("-1 -1 -1");
                return 0;
        }
        printf("%d %d %d",man,gosen,sen);
        return 0;
}

Measured memory_bytes: 128
use v6;
my $a = get().chomp;
my $b = get().chomp;
my $c = get().chomp;
my $x = get().chomp;
my $ans = 0;

loop (my $i = 0; $i <= $a; $i++) {
    loop (my $j = 0; $j <= $b; $j++) {
        last if ($x < 500 * $i + 100 * $j);
        $ans++ if (($x - 500 * $i - 100 * $j) / 50 <= $c);
    }
}

say $ans;

exit;


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

int main()
{
    int N, M, X;
    cin >> N >> M >> X;

    int l = 0;
    int r = 0;
    int A;
    for (int i = 0; i < M; i++)
    {
        cin >> A;
        if (A < X)
        {
            l++;
        }
        if (A > X)
        {
            r++;
        }
    }
    cout << min(l, r) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;

int main() {
	string s, t; cin >> s >> t;
	int ans = 0;
	rep(i, 3) {
		if (s[i] == t[i]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;

int main(){
lint N,s;
cin >>N;
s=N/2;
if(N%2==0)cout<<0.5;
else if(N==1) cout<<1;
else printf("%6f",(double)(N-s)/N);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100000;
long long f[MAX_N + 1];

struct {
  auto &operator>>(int &x) {
    char c;
    do
      c = std::cin.rdbuf()->sbumpc();
    while (!isdigit(c));
    for (x = 0; isdigit(c); c = std::cin.rdbuf()->sbumpc())
      x = x * 10 + (c ^ 48);
    return *this;
  }
} io;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, W;
    memset(f, 0x3f, sizeof(f));
    io>> N >> W;
    f[0] = 0;
    for (int i = 0, w, v; i < N; ++i)
    {
        io >> w >> v;
        for (int j = MAX_N; j >= v; j--) 
        {
            f[j] = std::min(f[j], f[j - v] + w);
        }
    }
  
  for (int i = MAX_N; i >= 0; --i) 
  {
    if (f[i] <= W) 
    {
      std::cout << i;
      break;
    }
  }
}


Measured memory_bytes: 1024
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int arr[] = new int[n];
		int res = 0;
		for(int i=0;i<n;i++) {
			arr[i] = sc.nextInt();
			res = res^arr[i];
		}
		for(int i=0;i<n;i++) {
			System.out.print((res^arr[i])+" ");
		}
		sc.close();
	}
}


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

int main()
{
    char s[100];

    scanf("%s",s);

    int len = strlen(s);

    int i;
    int ans = 0;
    for(i=0;i<len/2;i++)
        if(s[i] != s[len -1 -i])
            ans++;

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

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int x; cin >> x;
	int ans = 0;
	if(x < 600) {
		ans = 8;
	} else if(x < 800) {
		ans = 7;
	} else if(x < 1000) {
		ans = 6;
	} else if(x < 1200) {
		ans = 5;
	} else if(x < 1400) {
		ans = 4;
	} else if(x < 1600) {
		ans = 3;
	} else if(x < 1800) {
		ans = 2;
	} else {
		ans = 1;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
const double inf=1e9;
typedef long long ll;
typedef pair<int,int>pr;
const ll mod=1e9+7;
ll _pow(ll  a,ll b) {
    ll ans=1;
    while(b) {
        if(b&1)
            ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}
ll a[maxn],b[maxn];
int main(){
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin>>n;
  for(int i=1;i<=n+1;i++){
    cin>>a[i];
  }
  for(int i=1;i<=n;i++){
    cin>>b[i];
  }
  ll ans=0;
  for(int i=1;i<=n;i++){
    if(b[i]>=a[i]+a[i+1]){
        ans+=a[i]+a[i+1];
        a[i]=0;
        a[i+1]=0;
    }
    else{
        if(a[i]>b[i]){
            ans+=b[i];
        }
        else if(a[i]<=b[i]){
            ans+=a[i];
            b[i]-=a[i];
            a[i]=0;
            if(a[i+1]>=b[i]){
                ans+=b[i];
                a[i+1]-=b[i];
            }
            else{
                ans+=a[i+1];
                a[i+1]=0;
            }
        }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    }
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
macro_rules! chmax {
    ($x:expr, $e:expr) => {
        $x = max($x, $e);
    };
}
macro_rules! chmin {
    ($x:expr, $e:expr) => {
        $x = min($x, $e);
    };
}

const INF: usize = 1 << 60;

fn main() {
    input!{
        N: chars,
    }
    let l = N.len();
    let mut dp = vec![vec![INF; 2]; l+10];
    dp[0][0] = 0;
    dp[0][1] = 1;
    for i in 0..l {
        let di = N[i] as usize - '0' as usize;
        for over in 0..2 {
            if over == 0 {
                chmin!(dp[i+1][over], dp[i][0] + di);
                chmin!(dp[i+1][over], dp[i][1] + (10 - di));
            } else {
                chmin!(dp[i+1][over], dp[i][0] + di + 1);
                chmin!(dp[i+1][over], dp[i][1] + (10 - di - 1));
            }
        }
    }
    println!("{}", dp[l][0]);
}


Measured memory_bytes: 49396
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    cin >> A >> B >> C >> D;
    X = C - A;
    Y = D - B;
    REP(i, X)
    S += 'R';
    REP(i, Y)
    S += 'U';
    REP(i, X)
    S += 'L';
    REP(i, Y)
    S += 'D';
    S += 'D';
    REP(i, X + 1)
    S += 'R';
    REP(i, Y + 1)
    S += 'U';
    S += 'L';
    S += 'U';
    REP(i, X + 1)
    S += 'L';
    REP(i, Y + 1)
    S += 'D';
    S += 'R';
    dump(S.size());
    cout << S << endl;
}

Measured memory_bytes: 3636
def num2alpha(num):
    if num <= 26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

N = int(input())

print(num2alpha(N).lower())

Measured memory_bytes: 9172
import heapq


N = int(input())

a = list(map(int,input().split()))

lq = []
lsum = 0
rq = []
rsum = 0

for i in range(N):

    heapq.heappush(lq,a[i])
    lsum += a[i]

    heapq.heappush(rq,-1 * a[3 * N - 1 - i])
    rsum += a[3*N-1-i]

llis = []
rlis = []

for i in range(N+1):

    llis.append(lsum)
    rlis.append(rsum)

    heapq.heappush(lq,a[N+i])
    heapq.heappush(rq,-1 * a[2*N-1-i])
    lsum += a[N+i]
    rsum += a[2*N-1-i]

    lpop = heapq.heappop(lq)
    rpop = -1 * heapq.heappop(rq)
    lsum -= lpop
    rsum -= rpop

rlis.reverse()

ans = -1 * float("inf")

for i in range(N+1):

    ans = max(ans,llis[i]-rlis[i])

print (ans)

    


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

using namespace std;

int main()
{
    while(true)
    {
        char raw1[300]={};
        char raw2[300]={};
        int h, w;    

        scanf("%d %d", &h, &w);
        if(h == 0 && w == 0) break;
        else if(h == 0 || w == 0) { cout << "\n"; continue; };
        for(int i=0; i<w; i++)
        {
            raw1[i] = '#';
            raw2[i] = (i==0 || i == w-1) ? '#' : '.';
        }
        for(int j=0; j<h; j++)
        {
            if(j == 0 || j == h-1) {printf("%s\n", raw1);}
            else                   {printf("%s\n", raw2);}
            
        }
        cout << "\n";
    }
}


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

long long int gcd(long long int a, long long int b) {
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    
    if (b == 0) return a;
    else return gcd(b, a % b);
}

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

    vector<long long int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    long long int ans = gcd(0, a[0]);
    for(int i=1; i<n; i++){
        ans = gcd(ans, a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
n=int(input())
l=list(map(int,input().split()))
count=0
for i in range(n-2):
    for j in range(i,n-1):
        for k in range(j,n):
            if len(set([l[i],l[j],l[k]]))<3:
                continue
            if l[i]<l[j]+l[k] and l[j]<l[i]+l[k] and l[k]<l[i]+l[j]:
                count+=1
print(count)

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

int main() {
  int w, h, x, y;
  cin >> w >> h >> x >> y;

  double ans = (double)w * h / 2;
  int num = (w == x * 2 && h == y * 2) ? 1 : 0;
  printf("%.10f\n%d\n", ans, num);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main()
{
    unsigned short *A, *B;

    int C[VMAX + 1];
    int n, i, j;
    scanf("%d", &n);

    A = malloc(sizeof(short) * n + 1);
    B = malloc(sizeof(short) * n + 1);

    for (i = 0; i <= VMAX; i++)
    {
        C[i] = 0;
    }
    for (i = 0; i < n; i++)
    {
        scanf("%hu", &A[i + 1]);
        C[A[i + 1]]++;
    }
    for (i = 1; i <= VMAX; i++)
    {
        C[i] = C[i] + C[i - 1];
    }
    for (j = 1; j <= n; j++)
    {
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
    for (i = 1; i <= n; i++)
    {
        if (i > 1)
        {
            printf(" ");
        }
        printf("%d", B[i]);
    }
    printf("\n");

    return 0;
}


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

#define INF 1e9
#define PI 3.141592653589793238
#define N 1000000010
#define mod 1000000007
typedef long long ll;

int main() {
    int k,x;cin>>k>>x;
    if(x<=500*k) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


    return 0;
}

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

int main() {
  string st = "";
  int acounter = 0;
  int aindex = 0;
  int zcounter = 0;
  int zindex = 0;
  int result = 0;
  cin >> st;
  //cout << st.size() << endl;
  for(int i = 0 ; i < st.size(); i++){
    if((st[i] == 'A') & (acounter == 0)){
      //cout << i << endl;
      acounter ++;
      aindex = i;
    }
    if((st[i] == 'Z') & (acounter != 0)){
      //cout << i << endl;
      zcounter ++;
      zindex = i;
    }
  }
  cout << zindex - aindex + 1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;
string dectobin(int n){
	string bin;
	while(n){
		bin+='0'+(n%2);
		n/=2;
	}
	reverse(bin.begin(),bin.end());
	return bin;
}

int main() {
	int d,n;
	char current;
	char digit[10] = {63,6,91,79,102,109,125,39,127,111};
	
	while(cin>>n,n+1){
		current = 0;
		for(int i=0;i<n;++i){
			cin>>d;
			cout<<setfill('0')<<setw(7)<<dectobin((int)(current^digit[d]))<<endl;
			current = digit[d];
		}
	}
	return 0;
}

Measured memory_bytes: 1196
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main(void)
{
	int n;
	int i, max_i, min_i;
	int a[50];
	int max = INT_MIN, min = INT_MAX;
	int cs;
	int cnt;
	scanf("%d", &n);
	for (i = 0; i < n; ++i){
		scanf("%d", a + i);
		if (a[i] > max){
			max = a[i];
			max_i = i;
		}
		if (a[i] < min){
			min = a[i];
			min_i = i;
		}
	}
	//	printf("%d\n", n * 2);
	if (max <= 0){
		//all negative
		printf("%d\n", n - 1);
		for (i = 0; i < n - 1; ++i){
			printf("%d %d\n", n - i, n - i - 1);
		}
	}
	else if (min >= 0){
		//all positive
		printf("%d\n", n - 1);
		for (i = 0; i < n - 1; ++i){
			printf("%d %d\n", i + 1, i + 2);
		}
	}
	else if (-max < min){
		printf("%d\n", n + n - 1);
		for (i = 0; i < n; ++i){
			printf("%d %d\n", max_i + 1, i + 1);
		}
		for (i = 0; i < n - 1; ++i){
			printf("%d %d\n", i + 1, i + 2);
		}
	}
	else{
		printf("%d\n", n + n - 1);
		for (i = 0; i < n; ++i){
			printf("%d %d\n", min_i + 1, i + 1);
		}
		for (i = 0; i < n - 1; ++i){
			printf("%d %d\n", n - i, n - i - 1);
		}
	}
	//	printf("%s\n", s);
	return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  string s,t; cin>>s>>t;
  ll ans=t.size();
  rep(i,s.size()-t.size()+1){
    string substr = s.substr(i,t.size());
    ll key=t.size();
    rep(i,t.size()){
      if(substr[i]==t[i])key--;
    }
    ans=min(ans,key);
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 3600
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	ll N;
	scan(N);
	ll kazu;
	for(ll i=sqrt(N)+1;i>=1;i--){
		if(N%i==0){
			kazu=max(i,N/i);
			break;
		}
	}
	int ans=0;
	while(kazu){
		kazu/=10;
		ans++;
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 256
a = [str(i) for i in input()]
op = ["+", "+", "+"]

for bit in range(2 ** len(op)):
	v = op.copy()
	for i in range(len(op)):
		if (bit >> i) & 1:
			v[i] = "-"
			
	if eval(a[0] + v[0] + a[1] + v[1] + a[2] + v[2] + a[3]) == 7:
		print(a[0] + v[0] + a[1] + v[1] + a[2] + v[2] + a[3] + "=7")
		exit()

	

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
int main()
{
    Hello
    int n;
    cin >> n;
    cout << n / 2 + n % 2;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=0
b=0

for i in range(n):
    A,B=map(str,input().split())
    
    A=list(A)
    B=list(B)
    
    if A>B:
        a+=3
    
    if A==B:
        a+=1
        b+=1
        
    if A<B:
        b+=3
        
    i+=1
    
print(a,b)


Measured memory_bytes: 5596
import java.util.*;
public class Main{
	static int StrToNum(String s){
		switch(s){
			case "a":
				return 1;
			case "b":
				return 2;
			case "c":
				return 3;
			case "d":
				return 4;
			case "e":
				return 5;
			case "f":
				return 6;
			case "g":
				return 7;
			case "h":
				return 8;
			case "i":
				return 9;
			case "j":
				return 10;
			case "k":
				return 11;
			case "l":
				return 12;
			case "m":
				return 13;
			case "n":
				return 14;
			case "o":
				return 15;
			case "p":
				return 16;
			case "q":
				return 17;
			case "r":
				return 18;
			case "s":
				return 19;
			case "t":
				return 20;
			case "u":
				return 21;
			case "v":
				return 22;
			case "w":
				return 23;
			case "x":
				return 24;
			case "y":
				return 25;
			case "z":
				return 26;
		}
		return 0;
	}
	
	static int ListCompare(int[] l1, int[] l2){
		for(int i=0; i<l1.length; i++){
			if(i >= l2.length){
				return 1;
			}
			if(l1[i] > l2[i]){
				return 1;
			}else if(l1[i] < l2[i]){
				return -1;
			}
		}
		if(l2.length > l1.length){
			return -1;
		}else{
			return 0;
		}
	}
	
	static void quick_sort(int[][] d, int left, int right) {
		if(left>=right){
				return;
		}
		int[] p = d[(left+right)/2];
		int l = left, r = right;
		int[] tmp = new int[p.length];
		while(l<=r){
			while(ListCompare(d[l], p) > 0){ l++; }
			while(ListCompare(d[r], p) < 0){ r--; }
			if (l<=r) {
				tmp = d[l]; d[l] = d[r]; d[r] = tmp;
				l++;
				r--;
			}
		}
		quick_sort(d, left, r);
		quick_sort(d, l, right);
	}
	
	public static void main(String[] args){
		long ans = 0;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] sp = new int[n][26];
		for(int i=0; i<n; i++){
			for(int l=0; l<26; l++){
				sp[i][l] = 0;
			}
			String s = sc.next();
			String[] ssp = s.split("");
			for(int j=0; j<ssp.length; j++){
				sp[i][StrToNum(ssp[j])-1]++;
			}
		}
		
		quick_sort(sp, 0, n-1);
		
		int j = 0;
		while(j < n-1){
			int rep = 1;
			int k = j+1;
			while(ListCompare(sp[k], sp[j]) == 0){
				ans += rep;
				rep++;
				k++;
				if(k >= sp.length){
					break;
				}
			}
			j = k;
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 104560
using System;

namespace abc043_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int output = 0;
            for (int i = 1; i <= N; i++)
            {
                output += i;
            }
            Console.WriteLine(output);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 2648
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n, w;
    cin >> n >> w;
    long long wt[n], v[n];
    for(long long i = 0;i < n;++i) cin >> wt[i] >> v[i];
    long long dp[n + 1][w + 1];
    memset(dp, 0, sizeof(dp));
    for(long long i = 1;i <= n;++i){
        for(long long j = 0;j <= w;++j){
            if(j >= wt[i - 1]) dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - wt[i - 1]] + v[i - 1]);
            else dp[i][j] = dp[i - 1][j];
        }
    }
    long long ans = 0;
    for(int i = 1; i <= w;++i) ans = max(ans, dp[n][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 79104
N = int(input())
A = [int(input()) for _ in range(N)]
max_a = max(A)
count = A.count(max_a)

if count > 1:
    for n in range(N):
        print(max_a)
else:
    for n in range(N):
        if A[n] == max_a:
            print(max(A[:n] + A[n+1:]))
            continue
        print(max_a)

Measured memory_bytes: 15604
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int d,t,s;
	cin >> d >> t >> s;
	if(d <= t * s)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int n,m,a[1005],b[1005],c,fg;
char s[1006];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d%d",&a[i],&b[i]);
        if((a[i]+b[i])&1)c++;
        else c--;
    }
    if(abs(c)!=n){
        puts("-1");
        return 0;
    }
    m=31+(c<0);
    printf("%d\n",m);
    for(int i=0;i<=30;i++)printf("%d ",(1<<i));
    if(c<0)printf("1");
    puts("");
    for(int i=1;i<=n;i++){
        int x=a[i],y=b[i];
        if(c<0)s[31]='R',x--;
        fg=0;
        for(int j=30;j>=0;j--){
            if(abs(x)<abs(y)){
                swap(x,y);
                fg^=1;
            }
            if(x>0){
                x-=(1<<j);
                s[j]=fg?'U':'R';
            }
            else{
                x+=(1<<j);
                s[j]=fg?'D':'L';
            }
        }
        printf("%s\n",s);
    }
}

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

int main() {
  const vector<int> dx = {0, -1, 0, 1};
  const vector<int> dy = {-1, 0, 1, 0};
  
  int h, w; cin >> h >> w;
  
  vector<string> grids(h);
  for (int i = 0; i < h; i++) cin >> grids[i];
  
  bool answer = true;
  
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (grids[i][j] == '#') {
        bool possible = false;
        for (int d = 0; d < 4; d++) {
          if (i + dy[d] < 0 || i + dy[d] >= h) continue;
          if (j + dx[d] < 0 || j + dx[d] >= w) continue;
          if (grids[i + dy[d]][j + dx[d]] == '#') possible = true;
        }
        if (!possible) {
          answer = false;
          break;
        }
      }
    }
    if (!answer) break;
  }
  
  if (answer) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

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

#define N 90

using namespace std;

int n, m;
int ice[N][N];

int xdir[4] = {0, 1, 0, -1};
int ydir[4] = {1, 0, -1, 0};

int dfs(int y, int x, int count){
  ice[y][x] = 0;

  int max_count = count;
  for(int i = 0; i < 4; ++i){
    int next_x = x + xdir[i];
    int next_y = y + ydir[i];

    if(0 <= next_y && next_y < n && 0 <= next_x && next_x < m
       && ice[next_y][next_x]){
      max_count = max(max_count, dfs(next_y, next_x, count+1));
    }
  }
  ice[y][x] = 1;

  return max_count;
}

int main()
{
  while(cin>>m>>n && n+m){
    for(int i = 0; i < n; ++i)
      for(int j = 0; j < m; ++j)
	cin >> ice[i][j];

    int mx = 0;
    for(int i = 0; i < n; ++i)
      for(int j = 0; j < m; ++j)
	if(ice[i][j])
	  mx = max(mx, dfs(i, j, 1));

    cout << mx << endl;
  }

  return 0;
}

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

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

    int n;
    cin >> n;

    string s[n];
    rep(i, 0, n) cin >> s[i];

    ll ct[5];
    rep(i, 0, 5) ct[i] = 0;
    rep(i, 0, n) {
        if (s[i][0] == 'M') {
            ct[0]++;
        } else if (s[i][0] == 'A') {
            ct[1]++;
        } else if (s[i][0] == 'R') {
            ct[2]++;
        } else if (s[i][0] == 'C') {
            ct[3]++;
        } else if (s[i][0] == 'H') {
            ct[4]++;
        }
    }

    ll ans;
    rep(i, 0, 5)
        rep(j, i + 1, 5)
            rep(h, j + 1, 5)
                ans += ct[i] * ct[j] * ct[h];

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

Measured memory_bytes: 5760
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int A = sc.nextInt();
        if (X < A) {
            System.out.println(0);
        } else {
            System.out.println(10);
        }
    }
}

Measured memory_bytes: 23764
#include<cstdio>
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
typedef long long LL;
LL Id,n;
map<string,LL>Map;
LL G[LL(1e5+5)];
int main()
{
    scanf("%lld",&n);
    for(LL i=1;i<=n;i++) {
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        if(!Map.count(s))
            Map[s]=++Id;
        G[Map[s]]++;
    }
    LL Ans=0;
    for(LL i=1;i<=Id;i++)
        Ans+=G[i]*(G[i]-1)/2;
    printf("%lld",Ans);
}


Measured memory_bytes: 11904
#include<queue>
#include<iostream>

using namespace std;

static const int MAX = 100;
int n, m[MAX][MAX], vst[MAX];
int d[MAX];

struct ddat
{
	int nm;
	int d;
};


int next(int u) {

	for (int v = 0;v < n;v++) {
		if (m[u][v]) {
			return v;
		}
	}

	return -1;
}


void bfs() {

	queue<ddat> que;
	ddat  d1; d1.nm = 0;;d1.d = 0;
	que.push(d1);



	while (!que.empty())
	{
		ddat d2 = que.front();
		que.pop();
		vst[d2.nm] = 1;
		d[d2.nm] = min(d2.d, d[d2.nm]);

		for (int i = 0; i < n; i++)
		{
			if (m[d2.nm][i] != 0 && vst[i] == 0) {
				ddat dch;
				dch.nm = i;dch.d = d2.d + 1;
				
				que.push(dch);
			}
		}

	}

	return;
}


int main() {


	int  u, k, v;


	cin >> n;
	for (int i = 0;i < n;i++) {
		for (int j = 0; j < n; j++) m[i][j] = 0;
	}

	for (int i = 0;i < n;i++) {
		cin >> u >> k;
		for (int j = 0;j < k;j++) {
			cin >> v;
			m[u - 1][v - 1] = 1;
		}
	}

	for (int i = 0; i < n; i++)
	{
		d[i] = 999'999;
	}

	bfs();

	for (int i = 0; i < n; i++) {
		if (d[i] == 999999) d[i] = -1;

		cout << i + 1 << " " << d[i] << endl;
	}


	return 0;
}




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

typedef struct {
  int parent, depth;
  vector<int> cs;
} node;

vector<node> vs;

void calc_parent(int id, int p)
{
  if (vs[id].parent != -1) return;
  vs[id].parent = p;
  for (int c : vs[id].cs)
    calc_parent(c, id);
}

void calc_depth(int id, int depth)
{
  vs[id].depth = max(vs[id].depth, depth);
  for (int c : vs[id].cs)
    calc_depth(c, depth+1);
}

void kind(int id)
{
  if (vs[id].parent == -1) {
    cout << "root";
  } else if (vs[id].cs.size()==0) {
    cout << "leaf";
  } else {
    cout << "internal node";
  }
}

int main()
{
  int n; cin >> n;
  vs = vector<node>(n);
  for (int i = 0; i < n; i++) {
    int id, k; cin >> id >> k;
    vs[id].cs = vector<int>(k);
    for (int j = 0; j < k; j++)
      cin >> vs[id].cs[j];
    vs[id].parent = -1;
  }

  for (int i = 0; i < n; i++)
    calc_parent(i, -1);

  for (int i = 0; i < n; i++)
    calc_depth(i, 0);

  for (int i = 0; i < n; i++) {
    printf("node %d: parent = %d, depth = %d, ",
        i,
        vs[i].parent,
        vs[i].depth);
    kind(i);
    cout << ", [";
    for (int j = 0; j < vs[i].cs.size(); j++) {
      cout << vs[i].cs[j];
      if (j != vs[i].cs.size()-1)
        cout << ", ";
    }
    cout << "]" << endl;
  }


  return EXIT_SUCCESS;
}



Measured memory_bytes: 6404