akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    fast;
    long long n;
    cin>>n;
    long long i,a[n],k=0;
    map<long long,long long> m;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        m[a[i]]+=1;
    }
    for(auto x:m)
    {
        k+=((x.second-1)*(x.second))/2;
    }
    for(i=0;i<n;i++)
    {
        cout<<k-(m[a[i]]-1)<<endl;
    }
}


Measured memory_bytes: 13184
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INFTY (1<<21)
#define N 100
int n,M[N][N];
int color[N],d[N],p[N];
 
int prim(){
 
  int u, mincost, i, v,sum = 0;
 
  for(i = 0; i < n; i++ ){
    color[i] = WHITE;
    d[i] = INFTY;
    p[i] = -1;
  }
 
  d[0] = 0;
 
  while(1){
    mincost = INFTY;
    u = -1;
    for(i = 0; i < n; i++){
      if(mincost > d[i] && color[i] != BLACK){
    u = i;
    mincost = d[i];
      }
    }
    if(u == -1)break;
    color[u] = BLACK;
    for( v = 0; v < n; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
    if(M[u][v] < d[v]){
      d[v] = M[u][v]; 
      p[v] = u;
      color[v] = GRAY;
    }
      }
    }
  }
  for(i = 0; i < n; i++){
    if(p[i] != -1){
      sum += M[i][p[i]];
    }
  }
  return sum;
}
int main(){
  int i, j, sum=0;
  scanf("%d",&n);
  for(i = 0; i < n; i++ ){
    for(j = 0; j < n; j++){
      scanf("%d",&M[i][j]);
      if(M[i][j] == -1)M[i][j]=INFTY;
    }
  } 
  sum = prim(n);
  printf("%d\n",sum);
 
  return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll K, X;
  cin >> K >> X;

  ll bottom = X - K + 1;
  ll top = X + K - 1;

  for (ll i = bottom; i <= top; i++) {
    cout << i << " ";
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdlib>
#include<cmath>
using namespace std;
int main(){
  int N; cin>>N;
  int Happy=0;
 int K=N/500;
  Happy+=K*1000;
  N=N%500;
  Happy+=(N/5)*5;
  cout<<Happy<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

int H;

void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> H;
    int ans = 0;
    int tmp = 1;
    while (H > 0) {
        H /= 2;
        ans += tmp;
        tmp *= 2;
    }
    cout << ans << endl;
    solve();
    return 0;
}


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

#define ll long long

using namespace std;

int main()
{
    string s;
    cin >> s;
    if(s == "Sunny")
    {
        cout << "Cloudy" << endl;
    } else
        {
            if(s == "Cloudy") cout << "Rainy" << endl;
                else cout << "Sunny";
        }
}


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

int main(){
    std::string n;
    std::cin >> n;
    int keta,sum=0;
    keta = n.size();

    for(int i=0;i<keta;i++){
        int k=n[i]-'0';
        sum = sum + k;
    }
    if(sum % 9==0){
        std::cout << "Yes" << std::endl;
    }
    else{
        std::cout << "No" << std::endl;
    }
    
    return 0;


}


Measured memory_bytes: 3700
import java.util.*;

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

		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());

		System.out.println(a + b + c - Math.max(a, Math.max(b, c)));
	}
}

Measured memory_bytes: 23252
n = int(input())
a = list(map(int,input().split()))
ans =[0]
sum_rain = sum(a)
a_double = [i*2 for i in a]*2
minus = sum(a_double[1:n-1:2])
ans[0] = sum_rain-minus

for i in range(1,n): 
  ans.append(2*a[i-1]-ans[i-1])

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

Measured memory_bytes: 87268
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
  	cin>>s;
  	if(s=="ABC")
      cout<<"ARC"<<endl;	
  	else
      cout<<"ABC"<<endl;
}


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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for(int i=0;i<n;i++)
    {
        cin >> v[i];
    }
    sort(all(v));
    reverse(all(v));
    int ans = 0;
    for(int i=k;i<n;i++) ans += v[i];
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
typedef long long ll;
int h,w,k;
ll solve(int w,int h)
{
    ll ans=0;
    for(int a=1;a<w;a++)
        for(int c_b=0;c_b<h;c_b++)
    {
        int R=2*k-a*c_b+__gcd(c_b,w)-2;
        if(R<0) break;
        int low=min(h-1-c_b,R/w);
        ans+=c_b==0?low:low*2;
        low++;
        if(low+c_b<h&&w*low-__gcd(w-a,low+c_b)-__gcd(a,low)<=R)
            ans+=c_b==0?1:2;
    }
    return ans*2;
}
int main()
{
    scanf("%d%d%d",&w,&h,&k);
    printf("%lld\n",solve(w,h)+solve(h,w));
}

Measured memory_bytes: 3836
D=int(input())
c=list(map(int,input().split()))
s=[]
t=[]
last=[0]*26
v=0

for _ in range(D):
    ss=list(map(int,input().split()))
    s.append(ss)
for _ in range(D):
    tt=int(input())
    t.append(tt)

for d in range(D):
    last[t[d]-1]=d+1
    decrease=0
    for j in range(26):
        decrease+=c[j]*(d+1-last[j])
        
    v+=s[d][t[d]-1]-decrease
    print(v)

Measured memory_bytes: 9260
h, w, a, b = [int(item) for item in input().split()]

MOD = 10**9 + 7
n = h + w 
def mod_pow(x, n):
    ans = 1
    while(n != 0):
        if n & 1:
            ans = ans * x % MOD
        x = x * x % MOD
        n = n >> 1
    return ans

fac = [1] + [0] * n
fac_inv = [1] + [0] * n
for i in range(1, n+1):
    fac[i] = fac[i-1] * (i) % MOD
    # Fermat's little theorem says
    # a**(p-1) mod p == 1
    # then, a * a**(p-2) mod p == 1
    # it means a**(p-2) is inverse element
    fac_inv[i] = fac_inv[i-1] * mod_pow(i, MOD-2) % MOD

def mod_nCr(n, r):
    if n == 0 and r == 0:
        return 1
    if n < r or n < 0:
        return 0
    tmp = fac_inv[n-r] * fac_inv[r] % MOD
    return tmp * fac[n] % MOD

if a+b > (h+w)//2:
    ans = 0
    for i in range(h-a):
        ans += mod_nCr(b-1+i, i) * mod_nCr(w-b-1 + h-1-i, h-1-i)
        ans %= MOD
else:
    ans = mod_nCr(h-1+w-1, h-1)
    for i in range(b):
        ans -= mod_nCr(h-a-1+i, i) * mod_nCr(a-1 + w-1-i, a-1)
        ans %= MOD
print(ans)

Measured memory_bytes: 20420
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int ans = 0;

		Scanner scan = new Scanner(System.in);

		int H = Integer.parseInt(scan.next());
		int W = Integer.parseInt(scan.next());
		int h = Integer.parseInt(scan.next());
		int w = Integer.parseInt(scan.next());

		ans = H * W;

		ans = ans - (h * W);

		ans = ans - (H * w);

		ans = ans + (h * w);

		System.out.println(ans);
	}
}

Measured memory_bytes: 22612
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  long long a, b, x;
  cin >> a >> b >> x;
  long long k = max(0LL, (x - b) / (a - b));
  x %= mod;
  k %= mod;
  b %= mod;
  cout << (x + k * b % mod) % mod << endl;
  return 0;	
}


Measured memory_bytes: 3184
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int N;
  cin>>N;
  while(N--){
    int x, y;
    cin>>x>>y;
    int ng[8] = {1, 0, -1, 0, x, -y, -x, y};
    int ng2[8] = {0, 1, 0, -1, y, x, -y, -x};
    int cnt = 0;
    for(int m = -200; m < 200; m++){
      for(int n = -200; n < 200; n++){
        if(m*m + n*n == 0) continue;
        bool ok = true;
        REP(i, 8) if(ng[i] == m && ng2[i] == n) ok = false;
        if(!ok) continue;
        int p = m * m + n * n;
        if((m * x + n * y) % p == 0 && (m * y - n * x) % p == 0){
          cnt = 1;
          break;
        }
      }
    }
    if(cnt){
      cout<<"C"<<endl;
    }else{
      cout<<"P"<<endl;
    }
  }
  return 0;
}

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

using namespace std;
const long long MAXN = 2e5+5;
long long dp[MAXN][5];

int main()
{
    long long n;
    cin>>n;
    long long num;
    cin>>num;
    dp[0][0] = num;
    dp[0][1] = -1e18;
    dp[0][2] = -1e18;
    
    for(long long i=1;i<n;i++){
        long long x;
        char y;
        
        cin>>y;
        cin>>x;
        if(y == '+'){
            dp[i][0] = dp[i-1][0]+x;
            dp[i][0] = max(dp[i][0],dp[i-1][1]-x);
            dp[i][1] = dp[i-1][1]-x;
            dp[i][1] = max(dp[i][1],dp[i-1][2]+x);
            dp[i][2] = dp[i-1][2]+x;
        }else{
           
            dp[i][0] = dp[i-1][0]-x;
            dp[i][0] = max(dp[i][0],dp[i-1][1]+x);
            dp[i][1] = dp[i-1][1]+x;
            dp[i][1] = max(dp[i][1],dp[i-1][0]-x);
            dp[i][1] = max(dp[i][1],dp[i-1][2]-x);
            dp[i][2] = dp[i-1][2]-x;
            dp[i][2] = max(dp[i][2],dp[i-1][1]+x);
        }
     //   cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}

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

#define  optimize   ios::sync_with_stdio(0); cin.tie(0);
#define PI  acos(-1.0)
#define RESET(a, b) memset(a, b, sizeof(a))
#define pb push_back
int n;
vector<int> g[100001];
map<int,map<int,int> > cost;
int vis[100001];
map<int,int>clr;
void bfs(int s){
   queue<int>q;
   q.push(s);
   vis[s]=1;
   clr[s]=0;
   while(q.size()>0){
     int top=q.front();
     q.pop();
     for(int i=0;i<g[top].size();i++){
        int x=g[top][i];
        if(vis[x]==0){
          if(clr[top]==0){
            if(cost[top][x]%2==0) clr[x]=0;
            else clr[x]=1;
          }
          else{
            if(cost[top][x]%2==0) clr[x]=1;
            else clr[x]=0;
          }
          q.push(x);
          vis[x]=1;
        }
     }
   }
}
int main()
{
     optimize
     cin>>n;
     for(int i=1;i<n;i++){
        int x,y,w;
        cin>>x>>y>>w;
        g[x].pb(y);
        g[y].pb(x);
        cost[x][y]=cost[y][x]=w;
     }
     RESET(vis,0);
     bfs(1);
     //cout<<clr[7]<<endl;
     for(int i=1;i<=n;i++) cout<<clr[i]<<" ";
}


Measured memory_bytes: 32916
#include <stdio.h>

int main(void)
{
	int a[5];
	if(scanf("%d%*c%d%*c%d%*c%d%*c%d%*c", &a[0], &a[1], &a[2], &a[3], &a[4]) < 0) {
		return 0;
	}
	int i, min_i = 0, min = 10;
	for(i=0;i<5;i++) {
		if(min > a[i]%10 && a[i]%10 != 0) {
			min_i = i;
			min = a[i]%10;
		}
	}

	int sum = 0;
	for(i=0;i<5;i++) {
		if(i == min_i)
			continue;
		sum += a[i]/10*10;
		if(a[i]%10 != 0) sum += 10;
	}
	sum += a[min_i];
	printf("%d", sum);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define sz(c)       int(c.size())
#define rep(i,a,b)  for (int i=a; i<(b); ++i)
#define per(i,a,b)  for (int i=(b)-1; i>=(a); --i)
#define fore(c,...) for (auto __VA_ARGS__:(c))
using namespace std;
typedef long long ll;



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

	ll A,B,N;
	cin>>A>>B>>N;
	ll res=0;
	auto check=[&](ll x) {
		// cerr<<x<<endl;
		if (x>N) return;
		res=max(res,(A*x/B)-A*(x/B));
	};
	check(N-1);
	check(N);
	check(B);
	check(B-1);
	check(B/gcd(A,B));
	cout<<res<<'\n';
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100000;
ll N;
ll P[MAX_N];

vector<Pll> vpll;
set<int> st;

vector<ll> uppper_indices(ll idx) {
  vector<ll> res;
  auto ite = st.lower_bound(idx);
  if (ite == st.end()) return res;
  res.push_back(*ite);
  if (++ite == st.end()) return res;
  res.push_back(*ite);
  return res;
}

vector<ll> lower_indices(ll idx) {
  vector<ll> res;
  auto ite = st.lower_bound(idx);
  if (ite == st.begin()) return res;
  res.push_back(*(--ite));
  if (ite == st.begin()) return res;
  res.push_back(*(--ite));
  return res;
}

ll calcNumOfInterval(vector<ll>& up, vector<ll>& low, ll idx) {
  ll res = 0;
  if (len(low) == 0 && len(up) == 0) res = 0;
  if (len(low) == 0 && len(up) == 1) res = (idx+1) * (N-up[0]);
  if (len(low) == 0 && len(up) == 2) res = (idx+1) * (up[1]-up[0]);
  if (len(low) == 1 && len(up) == 0) res = (low[0]+1) * (N-idx);
  if (len(low) == 1 && len(up) == 1) {
    res = (low[0]+1) * (up[0]-idx) + (idx-low[0]) * (N-up[0]);
  }
  if (len(low) == 1 && len(up) == 2) {
    res = (low[0]+1) * (up[0]-idx) + (idx-low[0]) * (up[1]-up[0]);
  }
  if (len(low) == 2 && len(up) == 0) res = (low[0]-low[1]) * (N-idx);
  if (len(low) == 2 && len(up) == 1) {
    res = (low[0]-low[1]) * (up[0]-idx) + (idx-low[0]) * (N-up[0]);
  }
  if (len(low) == 2 && len(up) == 2) {
    res = (low[0]-low[1]) * (up[0]-idx) + (idx-low[0]) * (up[1]-up[0]);
  }
  return res;
}


int main() {
  cin >> N;
  rep(i, N) cin >> P[i];

  rep(i, N) {
    vpll.push_back(Pll(P[i], i));
  }
  sort(all(vpll));
  reverse(all(vpll));

  ll ans = 0;
  for (int i = 0; i < N; ++i) {
    ll idx = vpll[i].sc;
    vector<ll> upper = uppper_indices(idx);
    vector<ll> lower = lower_indices(idx);
    ll numOfInterval = calcNumOfInterval(upper, lower, idx);
    ans += numOfInterval * P[idx];
    st.insert(idx);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 7280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(0); 
    cin.tie(0);   
	ll n,a[200009],m,k,ans=0,fl=0;
	string s;
	cin>>n>>m;
	float tem=ceil((float)n/0.08);
	ll temp=ll(tem);
	while((ll)floor(temp*0.08)==n)
	{
		if((ll)floor(temp*0.1)==m)
		{
			break;
		}
		temp++;
	}
	if((ll)floor(temp*0.08)==n)
		cout<<temp<<endl;
	else
		cout<<"-1\n";
	return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h> 
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	for (int i=0;i<100;i++)
		for (int n=0;n<100;n++)
			if (i+n==a&&i*2+n*4==b)
			{
				cout<<"Yes";
				return 0;
			}
	cout<<"No";
	return 0;
}

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

S = []
C = []
for m in range(M):
    s, c = map(int, input().split())
    S.append(s)
    C.append(c)

tmp_ans = []
for n in range(10**N):
    n = str(n)

    if len(n)<N:
        continue

    flag = True
    for s, c in zip(S,C):
        if int(n[s-1]) != c:
            flag = False
            break

    if flag:
        tmp_ans.append(n)

if len(tmp_ans)>0:
    print(min(tmp_ans))
else:
    print(-1)


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

#define za ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod %1000000007
#define moz 1000000007
#define nl "\n"
#define S second
#define F first
#define PB push_back
#define MP make_pair
#define V vector
#define P pair
#define LEN length()
#define SZ size()
#define loop(i,a,b) for(int i=(a);i<=(b);i++)
typedef long long ll;
typedef complex<ll> C;
#define X real()
#define Y imag()

int n,a,b,c;

int main()
{
    za;
    ll arr[30]={0};
    string s;
    cin >> s;
    loop(i,0,s.LEN-1)
    {
        arr[s[i]-'a']++;
    }
    ll ans=s.LEN;
    ans=(ans*(ans+1))/2;
    loop(i,0,29)
    {
//        cout << i << ' ' << arr[i] << nl;
        if(arr[i]>0)
        {
            ans-=((arr[i]*(arr[i]+1))/2);
            //ans++;
        }
    }
    cout << ans+1 << nl;
}


Measured memory_bytes: 720
#include<cstdio>
#include<iostream>
#define INF 200001 
using namespace std;
int main(){
 int u,k,C,V,A[1000][1000],D[1000][1000],n;
  scanf("%d",&n);
   for(int i=0;i<n;i++)for(int j=0;j<n;j++)D[i][j] = INF;
  for(int i=0;i<n;i++){
      scanf("%d %d",&u,&k);    
      for(int j=0;j<k;j++){
    scanf("%d %d",&V,&C);
    D[u][V] = C;
      }    
  }
  for(int i=0;i<n;i++)D[i][i] = 0;
  for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)D[i][j]= min(D[i][j],D[i][k] + D[k][j]);
  for(int i=0;i<n;i++)printf("%d %d\n",i,D[0][i]);
  return 0;
}

Measured memory_bytes: 0
extern crate proconio;
use proconio::input;

fn main() {
    input! {
      mut s: String,
    }
    let s = s.chars().collect::<Vec<_>>();
    let mut ans = 0;
    if s[0] == 'R' || s[1] == 'R' || s[2] == 'R' {
        ans = 1;
    }
    if s[0..2] == ['R', 'R'] || s[1..3] == ['R', 'R'] {
        ans = 2;
    }
    if s == ['R', 'R', 'R'] {
        ans = 3;
    }
    println!("{}", ans);
}

Measured memory_bytes: 2148
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main()
{
    int a,b,c;
    while(~scanf("%d %d %d",&a,&b,&c))
    {
        if(c>=a&&c<=b)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define dup(x, y) (((x) + (y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template <class T> inline void chmax(T &a, T b) {
    if(a < b) {
        a = b;
    }
}
template <class T> inline void chmin(T &a, T b) {
    if(a > b) {
        a = b;
    }
}
template <class T> inline T gcd(T x, T y) {
    if(y == 0) {
        return x;
    } else if(x == 0) {
        return y;
    }
    return gcd(y, x % y);
}
template <class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template <class T> inline void print_vector(vector<T> vec) {
    for(int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    cout << endl;
}
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;



int main(void) {
    LL x;
    cin >> x;

    LL ans = x/11*2;
    if((x-x/11*11) <= 6 and x%11 != 0){
        ans += 1;
    }else if((x-x/11*11) > 6){
        ans += 2;
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include<algorithm>
#include <functional>
#include <queue>
#include <unordered_map>
using namespace std;

void func_C() {
	int N;
	unsigned long long res = 0;

	unordered_map<string, int> dict;
	string s;

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> s;
		sort(s.begin(), s.end());
		if (dict.find(s) != dict.end())
			res += ++dict[s];
		else
			dict[s] = 0;

	}
	cout << res << endl;
}

int main()
{
	func_C();
	return 0;
}

Measured memory_bytes: 10660
import java.util.Scanner;

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



Measured memory_bytes: 26232
n = int(input())
S = [int(i) for i in input().split()]
q = int(input())
T = [int(i) for i in input().split()]
c = 0
for t in T:#L<t,U>=t
    L = -1
    U = n
    while U - L > 1:
        x = (L+U)//2
        if S[x] >= t:
            U = x
        else:
            L = x
    if S[U]==t:
        c+=1
print(c)


Measured memory_bytes: 16896
N = int(input())

points = [list(map(int, input().split())) for _ in range(N)]
vec_dic = {}

max_same = 0
for i in range(N):
    x1,y1 = points[i]
    for j in range(N):
        if i == j:
            continue
        x2,y2 = points[j]
        d_x = x2 - x1
        d_y = y2 - y1
        if d_x in vec_dic.keys():
            if d_y in vec_dic[d_x].keys():
                vec_dic[d_x][d_y] += 1
                max_same = max(max_same, vec_dic[d_x][d_y])
            else:
                vec_dic[d_x][d_y] = 1
                max_same = max(max_same,1)
        else:
            vec_dic[d_x] = {d_y: 1}
            max_same = max(max_same, 1)
print(N-max_same)

Measured memory_bytes: 3956
//#include <bits/stdc++.h>
//
//using namespace std;
//
//#define int long long
//#define endl '\n'
//#define maxn 100010
//const int MOD = 1000000007;
//
//void solve() {
//    int n;
//    cin >> n;
//
//    vector<int> v(n), b(n);
//    for (int i = 0; i < n; ++i)cin >> v[i];
//    for (int i = 0; i < n; ++i)cin >> b[i];
//    sort(v.begin(), v.end());
//    sort(b.begin(), b.end());
//
//    int va = accumulate(v.begin(), v.end(), 0ll);
//    int vb = accumulate(b.begin(), b.end(), 0ll);
//    if (va > vb) {
//        cout << "No" << endl;
//        return;
//    } else {
//
//    }
//    for (int i = 0; i < n; i++) {
//        if (v[i] == b[i])continue;
//        else if (v[i] > b[i]) {
//            cout << "No" << endl;
//            return;
//        }
//    }
//    cout << "Yes" << endl;
//}
//
//int32_t main() {
//    ios_base::sync_with_stdio(false);
//    cin.tie(nullptr);
//
//    int t = 1;
////    cin >> t;
//
//    while (t--)
//        solve();
//    return 0;
//}

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;


void solve() {

    int n;
    cin >> n;

    vector<int> dp(n + 1);
    iota(dp.begin(), dp.end(), 0ll);
    for (int i = 0; i <= n; i++) {
        for (int j = 6; j + i <= n; j *= 6)
            dp[j + i] = min(dp[j + i], 1 + dp[i]);
        for (int j = 9; j + i <= n; j *= 9)
            dp[j + i] = min(dp[j + i], 1 + dp[i]);
    }
    cout << dp[n] << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int P = Integer.parseInt(sc.next());
		
		int ans = (A*3+P)/2;

		System.out.println(ans);

	}
}

Measured memory_bytes: 22228
N, M = [eval(v) for v in input().strip().split(" ")]
H = [eval(v) for v in input().strip().split(" ")]

Adj_matrix = []
for i in range(N):
    Adj_matrix.append([])

for i in range(M):
    A, B = [eval(v) for v in input().strip().split(" ")]
    A -= 1
    B -= 1
    Adj_matrix[A].append(B)
    Adj_matrix[B].append(A)
    # Adj_matrix[A][B] = 1
    # Adj_matrix[B][A] = 1

# print(Adj_matrix)

count = 0
for i in range(N):
    success = True
    for j in range(len(Adj_matrix[i])):
        A, B = i, Adj_matrix[i][j]
        if H[A] <= H[B]:
            success = False
            break
    if success:
        count += 1

print(count)


Measured memory_bytes: 29364
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve() {
  ll h;
  cin>>h;
  ll p=1,ans=0;
  while(h>0){
    h/=2;
    ans+=p;
    p*=2;
  }
  out(ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

int main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
	if(A+B>C+D)cout<<"Left"<<endl;
    else if(A+B<C+D)cout<<"Right"<<endl;
    else cout<<"Balanced"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    while(x != 0 || y != 0){
      if(x > y) {
        System.out.println(y + " " + x);
      }else {
        System.out.println(x + " " + y);
      }
      x = sc.nextInt();
      y = sc.nextInt();
    }
  }
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int count7 = count(s.begin(), s.end(), '7');
    if(count7 >= 1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <algorithm>
#include <queue>
#include <utility>

using namespace std;

typedef pair<int, int> P;

int main() {
    int h, w;
    scanf("%d %d", &h, &w);
    bool black[1000][1000];
    char s[1001];
    int x[] = {1, -1, 0,  0},
        y[] = {0,  0, 1, -1};
    queue<P> q;
    for (int i=0; i<h; i++) {
        scanf("\n%s", s);
        for (int j=0; j<w; j++) {
            black[i][j] = (s[j] == '#');
            if (black[i][j]) q.push(P(i, j));
        }
    }
    int count=0;
    q.push(P(-1,-1)); //しきり
    while (q.size() > 0) {
        P p = q.front(); q.pop();
        int i = p.first, j = p.second;
        if (q.size() > 0 && i == -1 && j == -1) {
            q.push(P(-1,-1));
            count++;
            continue;
        }
        for (int k=0; k<4; k++) {
            int i1 = i+x[k], j1 = j+y[k];
            if (0 <= i1 && i1 < h && 0 <= j1 && j1 < w && !black[i1][j1]) {
                black[i1][j1] = true;
                q.push(P(i1, j1));
            }
        }
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 9360
import java.util.*;
import java.math.*;
class Main{
public static void main(String[] args) {
  Scanner stdIn = new Scanner(System.in);
  String s = stdIn.next();
  char[] a = new char[s.length()];
  int counta = 0;
  int countb = 0;
  char b = ' ';
  char c = ' ';
  int k = 0;
  for(int i = 0;i<a.length;i++) {
    a[i] = s.charAt(i);
  }
  b = a[0];
  for(int i = 0;i<a.length;i++) {
    if(b==a[i]) counta += 1;
    else if(k==0){
      k += 1;
      c = a[i];
      countb += 1;
    } else if(k!=0&&c==a[i]) {
      countb += 1;
    }
  }
  if(counta==countb&&counta==2&&countb==2) {
    System.out.println("Yes");
  } else {
    System.out.println("No");
  }

}
}


Measured memory_bytes: 24148
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

void displayVector(vector<lli> v);

int main(){
    lli n;
    cin >> n;
    vector<lli> len;
    for(lli i = 0; i < n; i++){
        lli q;
        cin >> q;
        len.push_back(q);
    }

    sort(len.begin(), len.end(), greater<lli>());
    //displayVector(len);

    lli lenPair1 = 0, lenPair2 = 0;
    for(lli i = 0; i < n - 1; i++){
        //lli nextIndex = i;
        if(len[i] == len[i + 1]){
            if(lenPair1 == 0) lenPair1 = len[i];
            else{
                lenPair2 = len[i];
                break;
            }

            i++;
        }
    }

    cout << lenPair1 * lenPair2 << endl;
    return 0;
}

void displayVector(vector<lli> v){
    lli n = (lli)v.size();
    for(lli i = 0; i < n; i++){
        char c = (i == n - 1)? '\n' : ' ';
        cout << v[i] << c;
    }
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007


int main() {
	long double n;
	cin>>n;
	long double a=n/3;
	a=a*a*a;
	printf("%.10Lf",a);
	// your code goes here
	return 0;
}

Measured memory_bytes: 3740
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    int x;
    cin >> x;
    vector<bool> pr(100100, true);
    pr[0] = pr[1] = false;
    for(int i = 2; i < 100100; i++){
        if(pr[i]){
            for(int j = 2*i; j < 100100; j += i){
                
                pr[j] = false;
            }
        }
    }
    for(int i = x; i < 100100; i++){
        if(pr[i] == true){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3656
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int y = sc.nextInt();

        int sum = 0;

        if (x < 4) {
            switch (x) {
                case 1: sum += 100000;
                case 2: sum += 100000;
                case 3: sum += 100000;
                    break;
            }
        }

        if (y < 4) {
            switch (y) {
                case 1: sum += 100000;
                case 2: sum += 100000;
                case 3: sum += 100000;
                    break;
            }
        }

        if (x + y == 2) {
            sum += 400000;
        }

        System.out.println(sum);
    }
}

Measured memory_bytes: 22100
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)


#define MAX_V 100000
vector<int> G[MAX_V];
bool usedV[MAX_V];
int ord[MAX_V],lowlink[MAX_V];
int k=0;


void dfs(int v,int p){	//make ord and lowlink
	usedV[v] = true;
	ord[v]=lowlink[v]=k;
	k++;
	
	rep(i,G[v].size()){
		int to = G[v][i];
		if(!usedV[to]){
			dfs(to,v);
			lowlink[v] = min(lowlink[v],lowlink[to]);
		}
		else if(usedV[to]&&to!=p){	//use back edge
			lowlink[v] = min(lowlink[v],ord[to]);
		}
	}
}


int main(){
	int v,e;
	cin>>v>>e;
	vector<pii> edges;
	rep(i,e){
		int s,t;
		cin>>s>>t;
		if(s>t)swap(s,t);
		edges.pb(pii(s,t));
		G[s].pb(t);
		G[t].pb(s);
	}
	
	dfs(0,-1);
	
	vector<pii> ans;
	
	rep(i,e){
		int a = edges[i].first, b = edges[i].second;
		if(ord[a]>ord[b])swap(a,b);
		if(ord[a]<lowlink[b])ans.pb(pii(edges[i].first,edges[i].second));
	}
	
	sort(all(ans));
	rep(i,ans.size())cout<<ans[i].first<<" "<<ans[i].second<<endl;
}

Measured memory_bytes: 7116
import sys
import itertools
import collections
# X = int(input())
N, M, Q = map(int, input().split())
As =[0]
Bs =[0]
Cs =[0]
Ds =[0]
 
for i in range(Q):
	a, b, c, d = map(int, input().split())
	As.append(a)
	Bs.append(b)
	Cs.append(c)
	Ds.append(d)
 
lst = range(1, M+1)
AAss = list(itertools.combinations_with_replacement(lst, N))

rCs = collections.Counter()
# for i, c in enumerate(Cs):
	# print(i)
	# rCs[c] = Ds[i]
max_score = 0
# print("rCs")
# print(rCs)
for AAs in AAss:
	score = 0
	# print("AAs")
	# print(AAs)
	AAs = [0] + list(AAs)
	for i in range(1,Q+1):
		# print("AAs[Bs[i]] - AAs[As[i]]")
		# print(AAs[Bs[i]] - AAs[As[i]])
		if Cs[i] == AAs[Bs[i]] - AAs[As[i]]:
			score+=Ds[i]
		# print("dif_score")
 
	if score > max_score:
		max_score = score
	# print("score")
	# print(score)
print(max_score)

Measured memory_bytes: 21812
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <numeric>
#include <limits>
using namespace std;

int main(void) {
	long long a, b, c, i, j, n, tt, count = 0, ans = 0;
	cin >> n >> tt;
	vector<long long> t(n);
	for (i = 0; i < n; i++) {
		cin >> t[i];
	}

	for (i = 1; i < n; i++) {
		if (t[i] - t[i - 1] < tt) {
			ans += t[i] - t[i - 1];
		}
		else {
			ans += tt;
		}
	}
	ans += tt;
	ans -= t[0];
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_130
{
    class E
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int[] nm = ReadInts();
            int n = nm[0];
            int m = nm[1];
            int[] ss = ReadInts();
            int[] ts = ReadInts();

            long mask = 1000000000 + 7;
            long[,] dp = new long[n + 1, m + 1];
            long[,] sums = new long[n + 1, m + 1];
            dp[0, 0] = 1;
            sums[0, 0] = 1;
            for (int i = 1; i <= n; i++) sums[i, 0] = 1;
            for (int i = 1; i <= m; i++) sums[0, i] = 1;

            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= m; j++)
                {
                    if (ss[i - 1] == ts[j - 1]) dp[i, j] = sums[i - 1, j - 1];
                    sums[i, j] = dp[i, j];
                    sums[i, j] += sums[i - 1, j] + sums[i, j - 1]
                        - sums[i - 1, j - 1];
                    while (sums[i, j] < 0) sums[i, j] += mask;
                    sums[i, j] %= mask;
                }
            }

            WriteLine(sums[n, m]);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 73304
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i = 1; i <= 10000; i++) {
			int en = i * 1000;
			if(en >= n) {
				System.out.println(en-n);
				return;
			}
		}
	}
}

Measured memory_bytes: 35756
#include <stdio.h>
int ch[15];
int main(){
	int n,i,k,j;
	char a[100];
	scanf("%d",&n);
long long int b,sum=0;
	for(i=0;i<n;i++){
		scanf("%s",a);
		if(a[0]=='M') ch[1]++;
		else if(a[0]=='A') ch[2]++;
		else if(a[0]=='R') ch[3]++;
		else if(a[0]=='C') ch[4]++;
		else if(a[0]=='H') ch[5]++;
	}
	for(i=1;i<=5;i++){
		for(j=i+1;j<=5;j++){
			for(k=j+1;k<=5;k++){
				b=ch[i];
				b*=ch[k]; b*=ch[j];
				sum+=b;
			}
		}
	}
	printf("%lld",sum);
	
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
    int M1, D1, M2, D2;
    char c;
    
    
    scanf("%d%c%d%c", &M1, &c, &D1, &c);
    scanf("%d%c%d%c", &M2, &c, &D2, &c);
    
    
    if(M1 < M2)
    {
        switch(M1)
        {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
                if(D1 == 31)
                    printf("1\n");
                else
                    printf("0\n");
                
                break;
            case 2:
                if(D1 == 28)
                    printf("1\n");
                else
                    printf("0\n");
                    
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                if(D1 == 30)
                    printf("1\n");
                else
                    printf("0\n");
        }
    }
    else
        printf("0\n");
    
    
    //system("pause");
    
    return 0;
}


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

int as[16][16];
long long dp[1<<16];

int main(){
  int N;
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      scanf("%d",&as[i][j]);
    }
  }
  for(int mask=0;mask<(1<<N);mask++){
    for(int i=0;i<N;i++){
      if(mask&(1<<i)){
	for(int j=i+1;j<N;j++){
	  if(mask&(1<<j)){
	    dp[mask]+=as[i][j];
	  }
	}
      }
    }
  }
  for(int mask=0;mask<(1<<N);mask++){
    for(int sub=mask;sub;sub=(sub-1)&mask){
      dp[mask]=std::max(dp[mask],dp[sub]+dp[sub^mask]);
    }
  }
  printf("%lld\n",dp[(1<<N)-1]);
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

const ll MOD = 1000000007;
const int dx[8] = { 1, 2, 2, 1, -1, -2, -2, -1 };
const int dy[8] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int w, h;
int field[100][100];
int knight[100][100];

ll calc(int y, int x, int depth, int sum) {
  if (y == h) { return 1; }
  if (x >= w) {
    int nx = x % w;
    if (w % 2 == 0) { nx ^= 1; }
    return calc(y + 1, nx, 0, 0);
  }
  if (depth == 8) {
    sum += field[y][x];
    if (sum % 3 != 0) { return 0; }
    return calc(y, x + 2, 0, 0);
  }
  ll ret = 0;
  int nx = x + dx[depth];
  int ny = y + dy[depth];
  int ndepth = depth + 1;
  if (nx < 0 || nx >= w || ny < 0 || ny >= h) { return calc(y, x, ndepth, sum); }
  if (knight[ny][nx] != -1) { return calc(y, x, ndepth, sum + knight[ny][nx]); }
  knight[ny][nx] = 0;
  ret += calc(y, x, ndepth, sum);
  knight[ny][nx] = 1;
  ret += calc(y, x, ndepth, sum + 1);
  knight[ny][nx] = -1;
  return ret;
}

ll EdgeCase() {
  ll ret = 1;
  REP(y, 2) {
    REP(x, 2) {
      if (w <= x + 2 && h <= y + 2) {
        if (field[y][x] != 0) { ret = 0; }
        else { ret *= 2; }
      }
    }
  }
  return ret;
}

int main() {
  while (scanf("%d %d", &h, &w), w|h) {
    REP(y, h) REP(x, w) {
      scanf("%d", &field[y][x]);
    }
    ll ans = 0;
    if (w == 1 || h == 1) {
      REP(y, h) REP(x, w) {
        if (field[y][x] != 0) { puts("0"); goto next; }
      }
      ans = (1LL << (w * h)) % MOD;
      printf("%lld\n", ans);
    } else {
      MEMSET(knight, -1);
      ll left = calc(0, 0, 0, 0);
      ll right = calc(0, 1, 0, 0);
      ans = left * right;
      ans *= EdgeCase();
      printf("%lld\n", ans);
    }
next:;
     break;
  }
}

Measured memory_bytes: 0
N = gets.to_i
A = N.times.map { gets.to_i }

count = 0
prev = 0

A.each do |current|
  if prev > 0 && current > 0
    count += 1
    current -= 1
  end
  prev = current.even? ? 0 : 1
  count += current / 2
end

p count


Measured memory_bytes: 2996
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: i64 = input();
    let b: i64 = input();
    let c: i64 = input();
    let x: i64 = input();

    let mut ans = 0;
    for i in 0..a + 1 {
        if 500 * i > x {
            break;
        }

        for j in 0..b + 1 {
            let r = x - 500 * i - 100 * j;
            if 0 <= r && r <= 50 * c {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


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

#define double long double
#define int long long
#define vec vector
#define pb push_back
#define unset unordered_set
#define ii pair<int, int>
#define X first
#define Y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define bitcount(n) __builtin_popcountll(n)
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first,l.second+r.second};
} 
typedef void (*callback_function)(void); // type for conciseness
const long long ZERO = 0LL;
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0L);
const double EPS = static_cast<double>(1e-9);
typedef long long ll;

inline int Pow(int a, int k) {
  int s = 1; 
  for(; k; k >>= 1) {
    k & 1 ? s = 1LL * s * a % MOD : 0;
    a = 1LL * a * a % MOD;
  }
  return s;
}

const int N = 1e6 + 7;

// 29gg


void input() {
  //freopen("??.in", "r", stdin);
  //freopen("??.out", "w", stdout);
  // 34gg

}

void preprocess() {

}

void debug() {
  //  44gg
  if (true) {
  
  }
}

void solve() {
  preprocess();
  // 50gg
  string s; cin >> s;
  int cnt[2] = {0, 0};
  for (char &ch : s) {cnt[ch - '0']++;}
  cout << min(cnt[0], cnt[1]) * 2 << endl;
  //debug();
  // read the question correctly (is y a vowel?)
  // look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
}

void output() {

}

#undef int
int main() {
#define int long long
	ios_base::sync_with_stdio(false);
	cin.tie();
  //auto beginProgram = chrono::steady_clock::now();

  {
    input();
    solve();
    output();
  }

  //auto endProgram = chrono::steady_clock::now();

  return 0;
}



Measured memory_bytes: 512