akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstdlib>
#include <cmath>

typedef long long ll;

#define reps(i, s, e) for (ll i = s; i < e; ++i)
#define rep(i, n) reps(i, 0, n)
#define rreps(i, s, e) for (ll i = e-1; i >= s; --i)
#define rrep(i, n) rreps(i, 0, n)

const ll LL_INF = 1LL<<60;

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

using namespace std;

template<class T> inline void swap_T(T& a, T& b) {
    T tmp = b;
    b = a;
    a = tmp;
}

template<class T> inline T bubble_sort(vector<T>& a) {
    T n = a.size();
    T cnt = 0;
    rep(i, n-1) {
        rreps(j, i+1, n) {
            if (a[j] < a[j-1]) {
                swap<T>(a[j], a[j-1]);
                cnt++;
            }
        }
    }
    return cnt;
}

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll cnt = bubble_sort(a);
    rep(i, n) {
        cout << a[i];
        if (i != n-1) cout << " ";
        else cout << "\n";
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())

using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;

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

int main(void){
	short N;
	cin >> N;
	LL T = 1;
	REP(i,N){
		LL t;
		cin >> t;
		T = lcm(max(T,t),min(T,t));
	}

	cout << T << endl;
	return 0;

}



Measured memory_bytes: 256
#include <iostream>

int main() {
	int r, g, b;
	scanf("%d%d%d", &r, &g, &b);
	int number = r * 100 + g * 10 + b;
	if (number % 4 == 0)
		printf("YES");
	else
		printf("NO");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int h,w,i,j;
	char a[100][100];
	while(scanf("%d %d",&h,&w)!=EOF){
	for(i=0;i<h;i++)
		scanf("%s",a[i]);
		
	for(i=0;i<w+1;i++)
	printf("#");
	printf("#\n");
	
	for(i=0;i<h;i++)
	{
		printf("#");
		for(j=0;j<w;j++)
		printf("%c",a[i][j]);
		printf("#\n");
	}
	for(i=0;i<w+1;i++)
	printf("#");
	printf("#\n");
	}
	return 0;
 } 

Measured memory_bytes: 128
#include <iostream>
#include<map>
#include<vector>
#include<algorithm>
#include <stdio.h>
#include<set>
#include<string>
#include<math.h>
#include<cmath>
#include<iomanip>
#include<queue>
#include<stack>
#define ll long long
using namespace std;
long double pi = 3.14159265358979323846;
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);


int main()
{
	fast
		ll n; cin >> n;
	ll sum = 0;
	sum += (n / 500) * 1000;
	n %= 500;
	sum += (n / 5) * 5;
	cout << sum;

	return 0;

}

Measured memory_bytes: 888
from fractions import gcd
import math
a,b = map(int,input().split())
n = gcd(a,b)
if n == 1:
    print(1)
    exit()
count = 1
for i in range(2,math.ceil(math.sqrt(n))+1):
    if n % i == 0:
        count += 1
        while n % i == 0:
            n //= i
if n > 1:
    count += 1
print(count)

Measured memory_bytes: 5048
import java.util.*;

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

        int red = 0;

        for (int i = 0; i < s.length(); i++) {
            if ('0' == s.charAt(i))
                red++;
        }

        System.out.println(2 * Math.min(s.length() - red, red));

    }
}


Measured memory_bytes: 24852
#include<iostream>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a;
  cin>>b;
  if(a>b)
    swap(a,b);
  if(a==1 && b==2)
    cout<<"3"<<endl;
  else if(a==2 && b==3)
    cout<<"1"<<endl;
  else
    cout<<"2"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define index_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIndex find_by_order
#define indexOf order_of_key
#define MOD 1000000007
#define MAX 200005

int dp[MAX];

void solve() {
    int n;
    cin>>n;
    list<int> data;
    for(int i = 1 ; i<= n ; i++){
        int value; cin>>value;
        if(i % 2 == 1){
            data.push_back(value);
        }else data.push_front(value);
    }
    if(n % 2 == 0){
        for(auto i : data){
            cout<<i<<" ";
        }
    }else {
        reverse(data.begin() , data.end());
        for(auto i : data){
            cout<<i<<" ";
        }
    }

}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 8448
import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split()] , dtype=np.int64)
m = 10**9+7
ans = 0
for k in range(60):
    b = (a>>k) & 1
    res = np.count_nonzero(b)
    ans += res*(n-res)*2**k
print(ans%m)

Measured memory_bytes: 48852
#include <bits/stdc++.h>
using namespace std;
int mod = 1e9+7;
int main()
{
	int h,w;
	string str[1001];
	int dp[1001][1001];
	cin >> h >> w;
	for(int i=0;i<h;i++)
		cin >> str[i];
	memset(dp,0,sizeof(dp));
	for(int i=0;i<h;i++)
	{
		if(str[0][i]=='.')
			dp[0][i] = 1;
		else
			break;
	}
	for(int i=0;i<w;i++)
	{
		if(str[i][0] == '.')
			dp[i][0] = 1;
		else
			break;
	}
	for(int i=1;i<h;i++)
	{
		for(int j=1;j<w;j++)
		{
			if(str[i][j]=='.')
				dp[i][j] = (dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
			else
				dp[i][j] = 0;
		}
	}
	cout << dp[h-1][w-1] << "\n";
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

typedef pair<ll, int> P;

struct BIT{
    int N;
    vector<int> data;

    BIT(int n){
        N = n;
        data.resize(N+1, 0);
    }

    void add(int a, int x){
        for(int i = a; i <= N; i += i & -i)
            data[i] += x;
    }

    int sum(int a){
        int ret = 0;
        for(int x = a; x > 0; x -= x & -x)
            ret += data[x];
        return ret;
    }

};

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i,N){
        ll a;
        cin >> a;
        A[i] = a - K;
    }

    vector<ll> S(N);
    S[0] = A[0];
    priority_queue<P, vector<P>, greater<P> > que;

    que.push(P(0, 0));
    que.push(P(S[0], 1));
    for(int i = 1; i < N; i++){
        S[i] = S[i-1] + A[i];
        que.push(P(S[i], i+1));
    }


    vector<int> X(N+1);
    REP(i,N+1){
        auto p = que.top(); que.pop();
        X[p.second] = i;
    }

    BIT bit(N+1);
    ll ans = 0;
    for(int i = 0; i < N+1; i++){
        int x = X[i];
        ans += bit.sum(x+1);
        bit.add(x+1, 1);
    }

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


Measured memory_bytes: 9584
from collections import deque

N,u,v=map(int,input().split()) # u,vから1を引く必要がある
a=[[] for _ in range(N)] # 0-initial
for _ in range(N-1):
    Ai,Bi=map(int,input().split())
    a[Ai-1].append(Bi-1)
    a[Bi-1].append(Ai-1)
T=u-1;A=v-1

# 方針
# Tは，Tからの距離dTがAからの距離dA以下であるような点のうち，最もdAが大きい点を目指す。
dT=[-1]*N
q=deque()
q.append(T);dT[T]=0
while q:
    u=q.popleft()
    for v in a[u]:
        if dT[v]==-1:
            dT[v]=dT[u]+1
            q.append(v)

dA=[-1]*N
q=deque()
q.append(A);dA[A]=0
while q:
    u=q.popleft()
    for v in a[u]:
        if dA[v]==-1:
            dA[v]=dA[u]+1
            q.append(v)   

'''
print(a)
print(dT)
print(dA)
'''
ans=0
if a[T]!=[A] and T!=A:
    for i in range(N):
        if dT[i]<dA[i] and ans<dA[i]-1:
            ans=dA[i]-1

print(ans)

Measured memory_bytes: 64800
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
int main(){
  int n,cnt,num,tmp,gr74,gr24,gr14,gr4,gr2,sum=0;
  gr74=gr24=gr14=gr4=gr2=0;
  bool cp_list[101];
  vector<int> prime_list;
  fill(cp_list,cp_list+101,true);
  cin >> n;
  for(int i=2;i<=100;i++){
    if(cp_list[i]){
      for(int j=i;j<=100;j+=i){
        cp_list[j]=false;
      }
      prime_list.push_back(i);
    }
  }
  for(int i=0;i<prime_list.size();i++){
    num = tmp = prime_list[i];
    cnt = 0;
    while(num<=n){
      cnt += (n/num);
      num *= tmp;
    }
    if(cnt>=2){
      gr2++;
      if(cnt>=4){
        gr4++;
        if(cnt>=14){
          gr14++;
          if(cnt>=24){
            gr24++;
            if(cnt>=74){
              gr74++;
            }
          }
        }
      }
    }
  }
  sum += gr74;
  num = gr24*(gr2-1);
  if(num>0) sum+=num;
  num = (gr14)*(gr4-1);
  if(num>0) sum+=num;
  num = (gr4*(gr4-1)*(gr2-2))/2;
  if(num>0) sum+=num;
  cout << sum << endl;
}


Measured memory_bytes: 256
/*input
async layered coding
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	int n;
	cin>>n;
	cout<<48-n;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
void LCSL(char* X,char* Y){
  int m,n,i,j,c[1050][1050];
  m=strlen(X+1);
  n=strlen(Y+1);
  for(i=0;i<=m+1;i++){
    c[i][0]=0;
  }
  for(i=0;i<=n+1;i++){
    c[0][i]=0;
  }
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      
      
      if( X[i]==Y[j]){
	c[i][j]=c[i-1][j-1]+1;
      }
      else if(c[i-1][j]>=c[i][j-1]){
	c[i][j]=c[i-1][j];
      }      
      else c[i][j]=c[i][j-1];
    }
    
  }
 /*  for(i=0;i<=m;i++){ */
/*     for(j=0;j<=n;j++){printf(" %d",c[i][j]);} */
/*     printf("\n"); */
/* } */


  printf("%d\n",c[i-1][j-1]);
}

main(){
  int n,i,j;
  char x[1050],y[1050];
  scanf("%d",&n);
  while(n){
    scanf("%s",x+1);
    scanf("%s",y+1);
    LCSL(x,y);
    n--;
  }
  return 0;

}

Measured memory_bytes: 4720
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  double n;
  scanf("%lf", &n);
  printf("%lf\n", ceil(n / 2) / n);
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int N, F; cin >> N >> F;
	map<pair<string, string>, int>mp;
	for (int i = 0; i < N; ++i) {
		int M; cin >> M;
		vector<string>sts;
		for (int j = 0; j < M; ++j) {
			string st; cin >> st;
			sts.emplace_back(st);
		}
		sort(sts.begin(), sts.end());
		for (int j = 0; j < M; ++j) {
			for (int k = j + 1; k < M; ++k) {
				mp[make_pair(sts[j], sts[k])]++;
			}
		}
	}
	vector<pair<string, string>>anss;
	for (auto m : mp) {
		if (m.second >= F) {
			anss.emplace_back(m.first);
		}
	}
	cout << anss.size() << endl;
	for (int i = 0; i < anss.size(); ++i) {
		cout << anss[i].first << " " << anss[i].second << endl;
	}
	return 0;
}

Measured memory_bytes: 3688
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>

typedef std::vector<int> vec;

bool power_of_2(int n) {
    return (n & (n - 1)) == 0;
}

int max_divisor(int n) {
    return n & -n;
}

int g(const vec& sequence) {
    int sum = 0;
    for (int i = 0; i < sequence.size(); i++) {
        sum += sequence[i];
    }

    vec table(sum + 1);
    std::fill(table.begin() + 1, table.end(), -1);
    table[0] = 0;

    sum = 0;
    for (int i = 0; i < sequence.size(); i++) {
        int x = sequence[i];
        for (int a = sum & -x; a >= 0; a -= x) {
            if (table[a] >= 0) {
                int b = a + x;
                if (table[b] >= 0) {
                    table[b] = std::max(table[a] + 1, table[b]);
                } else {
                    table[b] = table[a] + 1;
                }
            }
        }
        sum += sequence[i];
    }

    int max = 0;
    for (int i = 1; i <= sum; i <<= 1) {
        max = std::max(max, table[i]);
    }
    return max;
}

vec extract(const vec& sequence, int k) {
    vec subsequence;
    int min = INT_MAX;
    for (int i = 0; i < sequence.size(); i++) {
        int x = sequence[i];
        if (x % k == 0 && power_of_2(x / k)) {
            subsequence.push_back(x);
            min = std::min(min, x);
        }
    }
    for (int i = 0; i < subsequence.size(); i++) {
        subsequence[i] /= min;
    }
    return subsequence;
}

int f(const vec& sequence) {
    vec numbers;
    for (int i = 0; i < sequence.size(); i++) {
        int x = sequence[i];
        numbers.push_back(x / max_divisor(x));
    }
    std::sort(numbers.begin(), numbers.end());
    numbers.erase(std::unique(numbers.begin(), numbers.end()), numbers.end());

    int max = 0;
    for (int i = 0; i < numbers.size(); i++) {
        int k = numbers[i];
        const vec& subsequence = extract(sequence, k);
        max = std::max(max, g(subsequence));
    }
    return max;
}

int main() {
    while (true) {
        int n;
        std::cin >> n;
        if (n == 0) {
            break;
        }
        vec sequence(n);
        for (int i = 0; i < n; i++) {
            std::cin >> sequence[i];
        }
        std::cout << f(sequence) << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(string, _, S);
  ll ans = 0;
  ll X = 0;
  each(x, S) {
    X += x == 'I' ? 1 : -1;
    ans = max(ans, X);
  }
  print(ans);
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

int dp[505][505];
void solve()
{
  int n, m, q, l, r, ql, qr;
  cin >> n >> m >> q;
  for(int i = 0; i < m; ++i)
  {
    cin >> l >> r;
    dp[l][r]++;
  }


  for(int y = 1; y <= n; ++y)
  {
    for(int x = 1; x <= n; ++x)
    {
      dp[y][x] += dp[y][x - 1];
    }    
  }

  for(int x = 1; x <= n; ++x)
  {
    for(int y = 1; y <= n; ++y)
    {
      dp[y][x] += dp[y - 1][x];
    }    
  }

  for(int i = 0; i < q; ++i)
  {
    cin >> ql >> qr;
    ql--;
    cout << dp[qr][qr] - dp[ql][qr] - dp[qr][ql] + dp[ql][ql] << endl;
  }
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 4536
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	ll H, W;
	cin >> H >> W;
	if (H == 1 || W == 1) {
		cout << 1 << endl;
		return 0;
	}
	else {
		if (H * W % 2 == 0) {
			cout << H * W / 2 << endl;
		}
		else {
			cout << H * W / 2 + 1 << endl;
		}
	}
}

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

int main(){
    int n;
    int ans=999999;
    cin >> n;
    vector<int> vec(n,0);
    for(int i=0;i<n;i++){
        cin >> vec.at(i);
    }
    for(int i=0;i<n;i++){
        int fir=0;
        int sec=0;
        for(int j=0;j<n;j++){
            if(j<i) fir=fir+vec.at(j);
            else sec=sec+vec.at(j);
        }
        int a;
        if(fir>sec) a=fir-sec;
        else a=sec-fir;
        ans=min(ans,a);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split())) * 2
mod = 10**9 + 7
ans = 0
b = 0
c = 0

for i in range(N):
    for j in range(i + 1, 2 * N):
        if j == N:
            c = b
        if A[i] > A[j] and j < N:
            b += 1
        elif A[i] > A[j] and j >= N:
            c += 1
    if b == c - b:
        ans += b * K * (K + 1) // 2
    else:
        ans += b * K + (c - b) * K * (K - 1) // 2
    b = 0
    c = 0

print(ans % mod)

Measured memory_bytes: 42348
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
  int w,a,b;
  cin >> w >> a >> b;
  cout << max(0, max(b - (a + w), a - (b + w))) << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	n := nextInt()
	a := nextInt()
	b := nextInt()

	ans := 0
	for i := 1; i <= n; i++ {
		sum := 0
		for nn := i; nn > 0; {
			// println(nn)
			sum += nn % 10
			nn /= 10
		}
		// println(sum)
		if sum >= a && sum <= b {
			ans += i
		}
	}

	println(ans)
	return
}

func main() {
	defer out.Flush()
	in.Split(bufio.ScanWords)

	solve()
}

// --- template ---

var (
	in  = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func println(a ...interface{}) {
	fmt.Fprintln(out, a...)
}

func printf(format string, a ...interface{}) {
	fmt.Fprintf(out, format, a...)
}

func next() string {
	in.Scan()
	return in.Text()
}

func nextInt() int {
	s := next()
	i, e := strconv.Atoi(s)
	if e != nil {
		fmt.Println(e)
	}
	return i
}

func nextInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = nextInt()
	}
	return res
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <queue>
#include <stack>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

class Graph{
public:

Graph(long long int o_size){
    graph_size=o_size;
    node.resize(graph_size,0);
    edge.resize(graph_size);
}

long long int add_edge(long long int a,long long int b){
    edge[a].push_back(b);
    edge[b].push_back(a);
        
    return a+b;
}

long long int node_add(long long int i,long long int a){
    node[i]+=a;
    return node[i];
}

void dfs(long long int start){
    stack<pair<long long int,long long int>> st;
    st.push(make_pair(-1,start));
    while(st.size()){
        long long int where = st.top().second,pre_where=st.top().first;
        //cout << "Unko" << endl;
        st.pop();
        for(auto x:edge[where]){
            if(x!=pre_where){
                st.push(make_pair(where, x));
                node[x] += node[where];
            }
        }
        
    }

}

void print(){
    REP(i,graph_size-1){
        cout << node[i] << " ";
    }
    cout << node[graph_size - 1] << endl;
}


private:
vector<vector<long long int>> edge;
vector<long long int> node;
long long int graph_size;

};

int main(){

    long long int n,q,tmpa,tmpb;
    cin>>n>>q;
    Graph graph(n);
    REP(i,n-1){
        scanf("%lld %lld",&tmpa,&tmpb);
        graph.add_edge(tmpa-1,tmpb-1);
    }
    REP(i,q){
        scanf("%lld %lld",&tmpa,&tmpb);
        graph.node_add(tmpa - 1, tmpb) ;
    
    }
    graph.dfs(0);
    graph.print();

    return 0;
}


Measured memory_bytes: 17520
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    long double ans = 0;
    while (n--) {
        long double a;
        string b;
        cin >> a >> b;
        if (b == "JPY") {
            ans += a;
        } else {
            ans += a*380000.0;
        }
    }
    cout << fixed << setprecision(6) << ans << endl;
}


Measured memory_bytes: 3800
import std.stdio;
import std.string;
import std.conv;
void main(){
	int[string] diction;
	int max;
	string longest="";
	foreach( c ; readln().chomp().split() ){
		diction[c]++;
		if( max < diction[c] ){
			max = diction[c];
		}
		if( longest.length < c.length ){
			longest = c;
		}
	}
	foreach( c,i ; diction ){
		if( max == diction[c] ){
			write( c," " );
		}
	}
	writeln( longest );
}

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

#define vint vector<int>
#define vvint vector<vint>
#define rep(i, n) for(int i=0;i<(int)(n);i++) // 繰り返し処理
#define all(x) (x).begin(),(x).end() // 全体 こんな感じで使う→sort(all(a));
#define ct(a) cout << a << endl
#define iceil(a,b) (a+(b-1))/b //int ceil : 繰り上げの割り算 通常のceilではceil((7.0/2.0))のようにしなければならなかった。
vint CinLine(int N){vint v(N);for(int i=0;i<N;i++){cin >> v.at(i);}return v;}//cin line 連続でvectorに格納
void CoutLine(vint v){for(int i=0;i<v.size()-1;i++){cout<<v.at(i)<<" ";}cout << v.at(v.size()-1)<<endl;}

template<class T>
inline void container_sort(std::vector<T>& v) {
    std::sort(v.begin(), v.end());
}
template<class T>
inline void container_sort(std::list<T>& v) {
    v.sort();
}

//////////////////////////////
// 重複削除関数
template<class T>
void vec_unique(T& v) {

    container_sort(v);
    v.erase(
            std::unique(
                    v.begin(),
                    v.end()),
            v.end()
    );

}

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

    vector<string> S(N);
    rep(i,N){
        cin >> S.at(i);
    }
    vec_unique(S);
    ct(S.size());


#if 0
    vector<string> ans;

    rep(i,N){
        string s;
        cin >> s;
        if(i == 0){
            ans.push_back(s);
        }else{
            bool b = true;
            rep(j,ans.size()){
                if(ans.at(j) == s){
                    b = false;
                    break;
                }
                if(b){
                    ans.push_back(s);
                    break;
                }
            }
        }
    }
    ct(ans.size());
#endif
}

int main() {
    Main();
}


Measured memory_bytes: 9580
#include<bits/stdc++.h>
using namespace std;
int sl[27];
int main(){
	int i;
	string a;
	cin>>a;
	for(i=0;i<a.size();i++){
		sl[int(a[i]-96)]++;
	}
	for(i=1;i<=26;i++){
		if(sl[i]%2!=0){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
} 

Measured memory_bytes: 256
# util functions
def dfs(x)
  return 0 if x > $num
  sum = 0
  if x.to_s.split("").uniq.size == 3
    sum += 1
  end

  [3,5,7].each do |i|
    sum += dfs(10*x + i)
  end
  return sum
end

# debug
debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if debugFlag

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end
$num = inputs[0][0]

# body
if debugFlag
end

puts dfs(0)


Measured memory_bytes: 1916
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>

#define ipair pair<int,int>
#define rep(n) for(int i=0;i<n;i++)

using namespace std;

typedef long long int lli;
typedef vector<int> vi;

bool check(int n) {
	bool three, five, seven;

	three = five = seven = false;

	while (n > 0) {
		if (n % 10 == 3)
			three = true;
		if (n % 10 == 5)
			five = true;
		if (n % 10 == 7)
			seven = true;
		n /= 10;
	}

	return (three && five && seven);
}

int main() {
	int n;
	int j, k, count = 0;
	bool carry;
	lli x;
	vi keta;

	cin >> n;

	keta.resize(10);

	rep(10) {
		keta[i] = 3;
	}

	k = 2;

	while (1) {
		x = 0;
		rep(k+1) {
			x = x * 10 + keta[k - i];
		}
		if (n >= x) {
			if (check(x)) {
				count++;
			}
		}
		else if (n < x) {
			break;
		}

		carry = true;
		j = 0;
		while (carry) {
			carry = false;
			keta[j] += 2;
			if (keta[j] == 9) {
				keta[j] = 3;
				carry = true;
				j++;
			}
			if (carry && j == k+1) {
				k++;
				break;
			}
		}

	}

	cout << count;

	return 0;
}

Measured memory_bytes: 256
MOD = 10**9+7

N, M=map(int,input().split())
S=list(map(int,input().split()))
T=list(map(int,input().split()))

dp=[[1]*(M+1) for i in range(N+1)]
S_index=[[] for i in range(10**5+1)]

for i in range(N):
  S_index[S[i]].append(i)
  if len(S_index[S[i]])>=2:
    ikkomae=S_index[S[i]][-2]
    for j in range(M+1):
    	dp[i-1][j]=(dp[i-1][j]+dp[ikkomae-1][j])%MOD
  for j in range(M):
    dp[i][j]=dp[i][j-1]
    if len(S_index[T[j]])>=1:
    	dp[i][j]=(dp[i][j]+dp[S_index[T[j]][-1]-1][j-1])%MOD
      
print(dp[N-1][M-1])


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

//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("Ofast")

#define F first
#define S second
#define MT make_tuple
#define SZ(a) ((int)(a).size())
#define PB push_back
#define LBS 20
#define MOD ((long long)1e9+7) //1e9+9
#define LEFT(i) (2*(i))
#define RIGHT(i) (2*(i)+1)
#define PAR(i) ((i)/2)

using namespace std;

typedef long long ll;
typedef double rat;
typedef long long bi;
typedef pair<int, int> ii;
typedef std::vector<ii> vii;
typedef std::map<int, int> mii;
typedef bitset<LBS> bis;
typedef std::vector<bis> vbs;

template<class T>
void vin(std::vector<T> &a){
  for(auto &x: a)
    cin >> x;
}

template<class T>
void vout(std::vector<T> &a){
  for(auto x: a)
    cout << x << " ";
  cout << endl;
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll n; cin >> n;
  std::vector<ll> b(n-1), a(n);
  vin(b);
  a[0]=b[0];
  for(int i=1; i<n-1; i++)
    a[i]=min(b[i-1], b[i]);
  a[n-1]=b[n-2];
  ll s=0;
  for(ll &i: a)
    s+=i;
  cout << s << "\n";
}


Measured memory_bytes: 256
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define PI acos(-1.0)
#define random(x) rand() % x
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
const int MAX = 1e5 + 5;
const int Mod = 1e9 + 7;

LL dp1[MAX], dp2[MAX];

int main()
{
    LL a, b;
    cin >> a >> b;
    cout << (a * 3 + b) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin, (X).rend()
#define DRI(X) int (X); cin >> X
#define DRII(X, Y) int X, Y; cin >> X >> Y
#define DRIII(X, Y, Z) int X, Y, Z; cin >> X >> Y >> Z
// #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define readV(X) for(int &ele : (X)) cin >> ele
#define readVI(X) for(int idx = 1; idx < SZ((X)); ++idx) cin >> (X)[idx]
#define REP(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MP make_pair
#define PB push_back
#define F first
#define S second
 
using namespace std;
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
// void err(istream_iterator<string> it) {}
// template<typename T, typename... Args>
// void err(istream_iterator<string> it, T a, Args... args) {
//     cerr << *it << " = " << a << endl;
//     err(++it, args...);
// }
// template<typename... Args>
// void read(Args&... args)
// {
//     ((cin >> args), ...);
// }
 
// template<typename... Args>
// void write(Args... args)
// {
//     ((cout << args), ...);
// }
typedef long long LL;
const int INF = 1<<29;
 
 
int main(){
    FAST_IO
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    int a, b;
    char op;
    cin >> a >> op >> b;
    if(op == '+') cout << a + b << "\n";
    else cout << a - b << "\n";
}    

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
static const int INF = 12e5;
int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> key;
    for (int i = 0; i < M; i++) {
        int a, b, c, s = 0;
        cin >> a >> b;
        for (int j = 0; j < b; j++) {
            cin >> c;
            s |= (1 << (c - 1));
        }
        key.emplace_back(s, a);
    }
    vector<int> dp(1 << N, INF);
    dp[0] = 0;
    for (int s = 0; s < (1 << N); s++) {
        for (int i = 0; i < M; i++) {
            int t = s | key[i].first;
            int cost = dp[s] + key[i].second;
            dp[t] = min(dp[t], cost);
        }
    }
    auto ans = dp.back();
    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

/*
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)
*/

func dvector(x1, y1, x2, y2 int) (int, int) {
	return -(y2 - y1), x2 - x1
}

func main() {
	var wtr = bufio.NewWriter(os.Stdout)
	var N int
	var S string
	fmt.Scan(&N)
	fmt.Scan(&S)
	mA := map[byte]int{}
	mB := map[byte]int{}

	for i := 0; i < N; i++ {
		if _, ok := mB[S[i]]; ok {
			mB[S[i]]++
		} else {
			mB[S[i]] = 1
		}
	}
	smax := 0
	for i := 0; i < N; i++ {
		if _, ok := mA[S[i]]; ok {
			mA[S[i]]++
		} else {
			mA[S[i]] = 1
		}
		if v, _ := mB[S[i]]; v == 1 {
			delete(mB, S[i])
		} else {
			mB[S[i]]--
		}
		s := 0
		for k, _ := range mB {
			if _, ok := mA[k]; ok {
				s++
			}
		}
		if s > smax {
			smax = s
		}
	}
	fmt.Fprintln(wtr, smax)
	/*
		for i := 0; i < N; i++ {
			if v, ok := mA[S[i]]; ok {
				v++
				sA
			} else {
				v = 1
			}
			if v, ok := mB[S[i]]; v == 1 && ok {
				v--
			} else {
				delete(mB, S[i])
			}
		}
	*/

	_ = wtr.Flush()
}


Measured memory_bytes: 1856
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int x, y; cin >> x >> y;
	int ans = 1e9 + 20;
	if(x <= y) ans = min(ans, y - x);
	if(-x <= y) ans = min(ans, y + x + 1);
	if(-x >= y) ans = min(ans, -x - y + 1);
	if(x >= y) ans = min(ans, x - y + 2);
	
	cout << ans << endl;
	
	return 0;
}

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

int N,W;
vector<int>v,w;

int dp[10001];

int main(){
    cin>>N>>W;
    v.resize(N);w.resize(N);

    for(int i=0;i<N;i++)cin>>v[i]>>w[i];

    for(int i=0;i<N;i++){
        for(int j=W;j>0;j--){
            if(j-w[i]<0)continue;
            dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
        }
    }

    cout<<dp[W]<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

void solve(int test_case) {
	string s;
	cin>>s;
	stack<char> d;
	for(char c:s) {
		if(c!='B')d.PU(c);
		else if(!d.empty())d.PO();
	}
	string sol = "";
	while(!d.empty()) {
		sol+=d.top();
		d.PO();
	}
	reverse(sol.begin(),sol.end());
	cout<<sol;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3620
#include<cstdio>
using namespace std;
int d2b(int n,int b,char c[])
{
    int i=0,k;                                                                                                                                                   
    while(n!=0)
    {
        k=n%b;
        n/=b;
        if(k<0){k-=b;n+=1;}//这里是负进制的重点
        if(k>9)c[i]=char(k-10+'A');
        else c[i]=char(k+'0');
        i++;
    }
    return i-1;
}
int main()
{
    int a,n,i;
    char b[40];
    scanf("%d%d",&a);n=-2;
    if(a==0)printf("0");
    for(i=d2b(a,n,b);i>=0;i--)printf("%c",b[i]);
}

Measured memory_bytes: 128
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto x = readln.chomp.to!long;
    long r = x / 11L * 2;
    if (x%11L >= 7) {
        r += 2;
    } else if (x%11L >= 1) {
        r += 1;
    }
    writeln(r);
}

Measured memory_bytes: 256
#coding: utf-8
import numpy as np
N, M = map(int, input().split())
AB = np.array([list(map(int, input().split())) for _ in range(N)])
money = 0
col_num = 0
AB = AB[np.argsort(AB[:, col_num])]
if M <= AB[np.argmin(AB[:, 0]), 1]:
    money += AB[0, 0] * M
else:
    i = 0
    while M > 0:
        money += AB[i, 0] * AB[i, 1]
        M -= AB[i, 1]
        if M <= 0:
          money += AB[i, 0] * M
        i += 1
print(money)

Measured memory_bytes: 37872
#include <iostream>
#include <vector>
#include <complex.h>
#include <math.h>
#include <algorithm>

typedef long long ll;
using namespace std;
#define FL(i,j,k) for(int i=j;i<k;++i)
int A[100],B[100];
int main(){
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    string s;
    getline(cin, s);
    FL(i, 0, s.size()){
        if(i==5||i==13){printf(" ");continue;}
        printf("%c",s[i]);
    }
}

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

int mcm(int n,int p[]){
	int m[n+1][n+1]={0};
	for(int s=0;s<n;s++){
		for(int i=1,j=s+2;j<=n;i++,j++){
			m[i][j]=1<<30;
			for(int k=i;k<j;k++){
				int tmp=m[i][k];
				tmp+=m[k+1][j];
				tmp+=p[i-1]*p[k]*p[j];
				m[i][j]=min(m[i][j],tmp);
			}
		}
	}
	return m[1][n];
}

int main(){
	int n;
	cin >> n;
	int p[n+1];
	for(int i=0;i<n;i++){
		int n1,n2;
		cin >> n1 >> n2;
		p[i]=n1;
		if(i==n-1) p[i+1]=n2;
	}
	
	cout << mcm(n,p) << endl;
	return 0;
}



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

int main(){
    int d;
    cin >> d;
    if(d==25) cout << "Christmas" << endl;
    if(d==24) cout << "Christmas Eve" << endl;
    if(d==23) cout << "Christmas Eve Eve" << endl;
    if(d==22) cout << "Christmas Eve Eve Eve" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
using namespace std;
vector<vector<char>> card(10);
vector<vector<char>> card2(10);
vector<pair<int,char>> card_b;
vector<pair<int,char>> card_i;
  
int main(void){
  int n;
  cin>>n;
  string s;
  for(int i=0;i<n;i++){
    cin>>s;
    int num=s[1]-'0';
    card[num].push_back(s[0]);
    card2[num].push_back(s[0]);
    card_b.push_back(make_pair(num,s[0]));
    card_i.push_back(make_pair(num,s[0]));
  }
  for(int i=0;i<n;i++){
    for(int j=n-1;j>=i+1;j--){
      if(card_b[j].first<card_b[j-1].first)
	swap(card_b[j],card_b[j-1]);
    }
  }
  for(int i=0;i<n;i++){
    int minj=i;
    for(int j=i;j<n;j++){
      if (card_i[j].first<card_i[minj].first)
	minj=j;
    }
    swap(card_i[i],card_i[minj]);
  }
  bool stable=true;
  for(vector<pair<int,char>>::iterator it=card_b.begin();it!=card_b.end();it++){
    if (it!=card_b.begin()) cout<<" ";
    cout<<it->second;
    cout<<it->first;
    if (stable && card[it->first][0]==it->second)
      card[it->first].erase(card[it->first].begin());
    else
      stable =false;
  }
  cout<<endl;
  if (stable)
    cout<<"Stable"<<endl;
  else
    cout<<"Not stable"<<endl;
  stable=true;
  for(vector<pair<int,char>>::iterator it=card_i.begin();it!=card_i.end();it++){
    if (it!=card_i.begin()) cout<<" ";
    cout<<it->second<<it->first;
    if (stable && card2[it->first].at(0)==it->second)
      card2[it->first].erase(card2[it->first].begin());
    else
      stable=false;
  }
  cout<<endl;
  if(stable)
    cout<<"Stable"<<endl;
  else
    cout<<"Not stable"<<endl;
  return 0;
  }
  



Measured memory_bytes: 3188
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

    vector<int> bunny(n+1);
    for(int i=0; i<k; ++i){
        int m;
        cin >> m;
        for(int j=0; j<m; ++j){
            int x;
            cin >> x;
            bunny[x] = i;
        }
    }

    int r;
    cin >> r;
    vector<bool> bad(n+1, false);
    for(int i=0; i<r; ++i){
        int p, q;
        cin >> p >> q;
        if(bunny[p] == bunny[q])
            bad[p] = bad[q] = true;
    }

    int ret = 0;
    for(int i=1; i<=n; ++i){
        if(bad[i])
            ++ ret;
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 0
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))

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

if (sum(a) <= 21):
    print("win")
else:
    print("bust")



Measured memory_bytes: 9148
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.container;
import std.bigint;

void main()
{
	BigInt ret = 1;
	foreach(i; 1..readln.chomp.to!int + 1) {
		ret *= i;
	}
	ret.writeln;
}

Measured memory_bytes: 1112
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef pair<int, int> pii;
vector<vector<pii>> unit;

int getint(int &p, string s){
    int res=0;
    while(p<(int)s.length() && '0'<=s[p] && s[p]<='9'){
        res *= 10;
        res += s[p]-'0';
        p++;
    }
    return res;
}
vector<vector<pii>> compose(vector<vector<pii>> &a, vector<vector<pii>> &b){
    int n = a.size();
    vector<vector<pii>> res(n, vector<pii>(n));
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            res[i][j] = b[a[i][j].first][a[i][j].second];
        }
    }
    return res;
}
vector<vector<pii>> shiftmap(int &p, string s){
    auto res = unit;
    int n = unit.size();
    while(p<(int)s.length() && s[p]!=')'){
        vector<vector<pii>> ch = unit;
        if(s[p] == '('){
            ch = shiftmap(++p, s);
            int rep = getint(++p, s);
            auto curr = unit;
            for(int i=31; i>=0; i--){
                curr = compose(curr, curr);
                if(rep>>i&1){
                    curr = compose(curr, ch);
                }
            }
            ch = curr;
        }else if(s[p] == 'L'){
            int i = getint(++p, s) - 1;
            for(int j=0; j<n; j++){
                ch[i][j] = pii(i, (j+n-1)%n);
            }
        }else if(s[p] == 'R'){
            int i = getint(++p, s) - 1;
            for(int j=0; j<n; j++){
                ch[i][j] = pii(i, (j+1)%n);
            }
        }else if(s[p] == 'U'){
            int j = getint(++p, s) - 1;
            for(int i=0; i<n; i++){
                ch[i][j] = pii((i+n-1)%n, j);
            }
        }else if(s[p] == 'D'){
            int j = getint(++p, s) - 1;
            for(int i=0; i<n; i++){
                ch[i][j] = pii((i+1)%n, j);
            }
        }
        res = compose(res, ch);
    }
    return res;
}

int main(){
    int n,l;
    string s;
    cin >> n >> l >> s;
    unit = vector<vector<pii>>(n);
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            unit[i].emplace_back(i, j);
        }
    }
    int p=0;
    auto shift = shiftmap(p, s);
    vector<vector<int>> ans(n,vector<int>(n));
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            ans[shift[i][j].first][shift[i][j].second] = i*n +j +1;
        }
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<n-1; j++){
            cout << ans[i][j] << " ";
        }
        cout << ans[i][n-1] << endl;
    }
    return 0;
}



Measured memory_bytes: 58132
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

const int M = 80 * (80 + 80);
int A[100][100], B[100][100];

signed main(){

  int H, W; cin >> H >> W;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> A[i][j];
    }
  }
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> B[i][j];
    }
  }

  static bool dp[100][100][M * 2];
  dp[0][0][M + abs(A[0][0] - B[0][0])] = dp[0][0][M - abs(A[0][0] - B[0][0])] = 1;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      for(int k = 0; k < M * 2; k++){
        if(dp[i][j][k]){
          if(i+1 < H){
            dp[i+1][j][k + abs(A[i+1][j] - B[i+1][j])] |= dp[i][j][k];
            dp[i+1][j][k - abs(A[i+1][j] - B[i+1][j])] |= dp[i][j][k];
          }
          if(j+1 < W){
            dp[i][j+1][k + abs(A[i][j+1] - B[i][j+1])] |= dp[i][j][k];
            dp[i][j+1][k - abs(A[i][j+1] - B[i][j+1])] |= dp[i][j][k];
          }
        }
      }
    }
  }

  int ans = INF;
  for(int i = 0; i < M * 2; i++){
    if(dp[H-1][W-1][i]){
      ans = min(ans, abs(M - i));
    }
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1LL << 60;

//Write From this Line

int main()
{
	ll a,b,c;
	cin >>  a>>b>>c;
	//どれかしらが偶数なら必ず戸数の差は0にできる
	vector<ll> tp = {a,b,c};
	SORT(tp);
	if(a%2==0 || b%2==0 ||0==c%2){
		cout << 0 << endl;
	}else{
		ll blue , red;
		//blueが一番小さいのを取るようにとりあえず固定
		//一番大きい奴をKとすれば、多い部分と少ない部分の比を
		// K / 2 : K / 2 + 1にできる
		//つまり、小さい二つの分だけが差になる
		cout << tp[0] * tp[1] << endl;

	} 
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;

typedef long long ll;

int main() {
  int N; cin >> N;
  string ans = "";

  while( N != 0 ) {
    if ( N % 2 != 0 ) {
      N--;
      ans = "1" + ans;
    } else  ans = "0"+ ans;
    
      N /= -2;
  }
  
  if ( ans == "" ) ans = "0";  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import itertools
h,w,k = map(int,input().split())
s = ["" for _ in range(h)]
for i in range(h):
  si = str(input())
  s[i] = si
lh = [i for i in range(h)]
lw = [j for j in range(w)]
sh = [0 for _ in range(h)]
sw = [0 for _ in range(w)]
for i in range(h):
  for j in range(w):
    if s[i][j] == "#":
      sh[i] += 1
      sw[j] += 1  
g = sum(sh) - k
c = 0
for i in range(h+1):
  for vh in itertools.combinations(lh,i):
    for j in range(w+1):
      for vw in itertools.combinations(lw,j):
        t = 0
        for hx in vh:
          t += sh[hx] 
        for hy in vw:
          t += sw[hy]
        for hx in vh:
          for hy in vw:
            if s[hx][hy] == "#":
              t -= 1
        if t == g:
          c += 1
print(c)
            
            
        

Measured memory_bytes: 9284