akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

#include <random>
std::random_device seed_gen;
std::mt19937_64 engine(seed_gen());
// ull a = engine();
ll D;
vll now, c(26);
vvl s;
vector<set<ll>> st(26);
ll now_score = 0;

void init(ll d){
  D = d;
  now.resize(d, 0);
  s = VV(d, 26, 0, ll);
}
void make_set(vll t){
  for(int i=0;i<D;i++) st[t[i]].insert(i);
  for(int i=0;i<26;i++) st[i].insert(-1);
  for(int i=0;i<26;i++) st[i].insert(D);
}
ll calc(vll t){
  ll score = 0;
  vll cnt(26, 0);
  for(int i=0;i<D;i++){
    ll idx = t[i];
    for(int j=0;j<26;j++){
      if(j==idx) cnt[j] = 0;
      else{
        cnt[j]++;
        score -= cnt[j]*c[j];
      }
    }
    score += s[i][idx];
  }
  return score;
}

ll ch_score(ll day, ll after){
  ll score = now_score;
  ll prev = now[day];//前に選択していたもの
  if(prev==after) return score;

  //prevを消したことで減るスコア
  score -= s[day][prev];

  auto itr = st[prev].find(day);
  auto p = itr, q = itr;
  ll x = day - (*--p) - 1;
  ll y = (*++q) - day - 1;

  ll z = x + y + 1;
  //x, y分増え、z分減る
  score += c[prev]*((x*(x+1))/2 + (y*(y+1))/2);
  score -= c[prev]*((z*(z+1))/2);
  //afterを挿入した事で増えるスコア
  score += s[day][after];
  itr = st[after].upper_bound(day);
  p = itr;
  p--;

  z = (*itr) - (*p) - 1;
  x = day - (*p) - 1;
  y = (*itr) - day - 1;

  score += c[after]*(z*(z+1)/2);
  score -= c[after]*((x*(x+1))/2 + (y*(y+1))/2);
  return score;
}

void change(ll day, ll after){
  ll prev = now[day];
  st[prev].erase(day);
  st[after].insert(day);
  now[day] = after;
  now_score = ch_score(day, after);
}


int main(int argc, char const *argv[]) {
  ll d;std::cin >> d;
  init(d);
  re(i, 26) std::cin >> c[i];
  re(i, D) re(j, 26) std::cin >> s[i][j];


  //初期値
  re(i, D) now[i] = i%26;

  //初期化
  make_set(now);
  now_score = calc(now);


  //関数:
  // change(day, after) dayをafterに変更
  // ch_score(day, after) dayをafterに変更した場合の試算
  // 共に計算量10~20くらい
  // シミュレート回数10^7

  ll sim = 10000000;
  while(--sim){
    unsigned long long a = engine();
    unsigned long long b = engine();
    a %= D, b %= 26;
    if(now_score < ch_score(a, b)){
      change(a, b);
    }
  }
  for(int i=0;i<D;i++) std::cout << now[i]+1 << '\n';
  return 0;
}


Measured memory_bytes: 3320
#include <iostream>
using namespace std;
int main() {

    int he,wh = 0;
    int h,w = 0;
    cin >> he >> wh >> h >> w;

    int ans = he*wh;

    ans -= h * wh;
    he -= h;
    ans -= w * he;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n);
  map<ll,ll>cnt;
  for(int i=0;i<n;i++){
    cin>>A[i];
    A[i] -= i;
    cnt[A[i]]++;
  }
  ll ans=  0;
  for(int i=0;i<n;i++){
    ll now = A[i];
    ans += cnt[-now-2*i];
  }
  cout<<ans<<endl;
  return 0;
}


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

int N;
LL P[200000][2];
int X[200000];

bool cmp_a(int l,int r){ return (P[l][0]-P[l][1]) < (P[r][0]-P[r][1]); }
bool cmp_b(int l,int r){ return (P[l][0]+P[l][1]) < (P[r][0]+P[r][1]); }

int main(){
 scanf("%d",&N);
 rep(i,N) rep(j,2) scanf("%lld",&P[i][j]);
 rep(i,N) X[i]=i;

 LL ans=0;

 sort(X,X+N,cmp_a);
 ans = max(ans,
    abs(P[X[N-1]][0]-P[X[0]][0])+abs(P[X[N-1]][1]-P[X[0]][1]));
 sort(X,X+N,cmp_b);
 ans = max(ans,
    abs(P[X[N-1]][0]-P[X[0]][0])+abs(P[X[N-1]][1]-P[X[0]][1]));

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

 return 0;
}




Measured memory_bytes: 7668
#include <bits/stdc++.h>
using namespace std;
int n, n1;
const int N = 2e+5 + 100;
vector<int> adj[N];
int st[4 * N + 1], a[N], atree[N], ans[N];
map<int, int> valtoidx;
multiset<int> preval[N];
void build(int v = 1, int l = 1, int r = n)
{
    if (l == r)
    {
        st[v] = 0;
    }
    else
    {
        build(2 * v, l, (l + r) / 2);
        build(2 * v + 1, (l + r) / 2 + 1, r);
        st[v] = max(st[2 * v], st[2 * v + 1]);
    }
    return;
}

int querry(int l, int r, int tl = 1, int tr = n, int v = 1)
{
    if (l > r)
        return 0; //change for sum and other stuff
    else
    {
        if (tr == r && tl == l)
            return st[v];
        else
        {
            int tm = (tr + tl) / 2;
            return max(querry(l, min(tm, r), tl, tm, 2 * v), querry(max(l, tm + 1), r, tm + 1, tr, 2 * v + 1));
        }
    }
}

void update(int val, int pos, int v = 1, int tl = 1, int tr = n)
{
    if (tr == tl)
        st[v] = val;
    else
    {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(val, pos, 2 * v, tl, tm);
        else
            update(val, pos, 2 * v + 1, tm + 1, tr);
        st[v] = max(st[2 * v], st[2 * v + 1]);
    }
}

void dfs(int v, int p,int cans)
{
    int idx = valtoidx[atree[v]];
    int ansv= 1+querry(1, idx - 1);
    preval[idx].insert(-ansv);
    int uval = -*preval[idx].begin();
    update(uval, idx);
    cans=max(cans,ansv);
    ans[v]=cans;
    // cout<<idx<<" "<<uval<<" "<<querry(1,idx)<<"\n";
    for (auto it : adj[v])
    {
        if (it != p)
        {
            dfs(it, v,cans);
        }
    }
    preval[idx].erase(preval[idx].find(-ansv));
    uval = -*preval[idx].begin();
    update(uval, idx);
}
int main()
{
    //examples
    // build();
    // querry(1, 4);
    // update(3, 4);
    cin >> n1;
    for (int i = 1; i <= n1; i++)
    {
        cin >> atree[i];
        valtoidx[atree[i]] = 1;
    }
    n = 1;
    for (auto it : valtoidx)
    {
        valtoidx[it.first] = n;
        preval[n].insert(0);
        n++;
    }
    n--;
    build();
    for (int i = 1; i < n1; i++)
    {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(1, 0,0);
    for(int i=1;i<=n1;i++)
        cout<<ans[i]<<"\n";
    return 0;
}

Measured memory_bytes: 69320
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(6);
	cout << fixed;

	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < (int)s.size() / 2; ++i) {
		if (s[i] != s[(int)s.size() - i - 1])
			++ans;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
//#include "{algoritm.hpp}"

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
constexpr int inf=1e9;

int main(){
    int n,m;
    cin>>n>>m;
    vector<ll>cost(1<<n,inf),dp(1<<n,inf);
    for(int i=0;i<m;++i){
        int a,b;
        cin>>a>>b;
        int bit=0;
        for(int i=0;i<b;++i){
            int c;
            cin>>c;
            bit+=(1<<(c-1));
        }
        cost[bit]=min(cost[bit],(ll)a);
    }
    dp[0]=0;
    for(int i=0;i<(1<<n);++i){
        for(int j=0;j<(1<<n);++j){
            if(dp[i]!=inf && cost[j]!=inf){
                int p=i|j;
                dp[p]=min(dp[p],dp[i]+cost[j]);
            }
        }
    }
    if(dp[(1<<n)-1]==inf){
        cout<<-1<<endl;
    }
    else cout<<dp[(1<<n)-1]<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 998244353; //1000000007;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}
template <class _T> static _T tp_pow(int base, int exp)
{
	_T ans = 1;

	for (int i = 0; i < exp; i++) {
		ans *= (_T)base;
	}
	return ans;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

typedef std::pair<LLONG, LLONG> LPair;
static void exec()
{
	int T;
	get(T);

	while (T--) {
		LLONG N, A, B, C, D;
		get(N, A, B);
		get(C, D);

		LLONG cost[6] = { 0 };
		cost[2] = A;
		cost[3] = B;
		cost[5] = C;

		LLONG ans = 1e18;
		std::priority_queue<LPair, std::vector<LPair>, std::greater<LPair>> que;
		std::map<LLONG, LLONG> memo;

		auto insert = [&](LLONG v, LLONG n) {
			if (v < ans && (!memo.count(n) || v < memo[n])) {
				que.emplace(v, n);
				memo[n] = v;
			}
		};

		que.emplace(0, N);
		while (!que.empty()) {
			auto lp = que.top(); que.pop();
			LLONG val = lp.first, num = lp.second;

			if (val >= ans) break;
			if (num <= 2e18 / D) ans = std::min(ans, val + num * D);

			for (int d : {2, 3, 5}) {
				int r = num % d;
				LLONG val2 = val + r * D + cost[d];
				insert(val2, num / d);
				val2 = val + (d - r) * D + cost[d];
				insert(val2, num / d + 1);
			}
		}
		printf("%lld\n", ans);
	}
}


Measured memory_bytes: 4644
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int A , B;

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

	if (A == B)
	{
		cout << A << endl;
		return 0;
	}

	int ans = 0;

	int a1 = (A & 1) != 0 ? 1 : 0;
	int a2 = (A & 2) != 0 ? 1 : 0;
	int b1 = (B & 1) != 0 ? 1 : 0;
	int b2 = (B & 2) != 0 ? 1 : 0;
	if (a2 == 0)
	{
		ans += (b1 ^ b2);
	}
	else
	{
		ans += ((b1 ^ b2) ^ 1);
	}

	
	int keta = 1;
	while (true)
	{
		if ((1LL << keta) > B)
		{
			break;
		}

		bool is_flip = false;

		if ((A & (1LL << keta)) != 0)
		{
			if (A % 2 == 1)
			{
				is_flip = true;
			}
		}

		if (is_flip)
		{
			if ((B & (1LL << keta)) == 0)
			{
				ans += (1LL << keta);
			}
			else
			{
				if (B % 2 == 1)
				{
					ans += (1LL << keta);
				}
			}
		}
		else
		{
			if ((B & (1LL << keta)) != 0)
			{
				if (B % 2 == 0)
				{
					ans += (1LL << keta);
				}
			}
		}

		keta++;
	}
	cout << ans << endl;
}









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

using namespace std;

int main()
{
	long long int d;
	scanf("%lld", &d);
	long long int q=d;
	int nd=0;
	while(q!=0){
		q=q/10;
		nd++;
	}
	long long int p10[19];
	p10[0]=1;
	for(int i=1; i<=18; i++){
		p10[i]=p10[i-1]*10;
	}
	long long int ans=0;
	for(int k=1; k<=9; k++){
		long long int ans1=1, d1=d;
		if(k>1){
		for(int i=1; i<=k; i++){
			if(i==1){
				if(d1%10==0){
					ans1=ans1*9;
					d1=d1/10;
				}else{
					ans1=ans1*(d1%10-1);
					d1=(d1-(10-d1%10)*(p10[2*k-1]-1))/10;
				}
			}else if(i!=k){
				if(d1>=0){
					if(d1%10==0){
						ans1=ans1*10;
						d1=d1/10;
					}else{
						ans1=ans1*(d1%10);
						d1=(d1-(10-d1%10)*(p10[2*k-2*i+1]-1))/10;
					}
				}else{
					if((-d1)%10==0){
						ans1=ans1*10;
						d1=d1/10;
					}else{
						ans1=ans1*((-d1)%10);
						d1=(d1+(10-(-d1)%10)*(p10[2*k-2*i+1]-1))/10;
					}
				}
			}else{
				if(d1<0) d1=-d1;
				if(d1%9!=0 || d1/9>9){
					ans1=0;
				}else{
					ans1=ans1*(10-d1/9);
				}
			}
		}
		ans=ans+ans1;
		}else{
		if(d1%9!=0 || d1/9>9){
			ans1=0;
		}else{
			ans1=ans1*(9-d1/9);
		}
		ans=ans+ans1;
		}
	}
	for(int k=1; k<=8; k++){
		long long int ans1=1, d1=d;
		if(k>1){
		for(int i=1; i<=k; i++){
			if(i==1){
				if(d1%10==0){
					ans1=ans1*9;
					d1=d1/10;
				}else{
					ans1=ans1*(d1%10-1);
					d1=(d1-(10-d1%10)*(p10[2*k]-1))/10;
				}
			}else if(i!=k){
				if(d1>=0){
					if(d1%10==0){
						ans1=ans1*10;
						d1=d1/10;
					}else{
						ans1=ans1*(d1%10);
						d1=(d1-(10-d1%10)*(p10[2*k-2*i+2]-1))/10;
					}
				}else{
					if((-d1)%10==0){
						ans1=ans1*10;
						d1=d1/10;
					}else{
						ans1=ans1*((-d1)%10);
						d1=(d1+(10-(-d1)%10)*(p10[2*k-2*i+2]-1))/10;
					}
				}
			}else{
				if(d1<0) d1=-d1;
				if(d1%99!=0 || d1/99>9){
					ans1=0;
				}else{
					ans1=ans1*(10-d1/99);
				}
			}
		}
		ans1=ans1*10;
		ans=ans+ans1;
		}else{
		if(d1%99!=0 || d1/99>9){
			ans1=0;
		}else{
			ans1=ans1*(9-d1/99);
		}
		ans1=ans1*10;
		ans=ans+ans1;
		}
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

//Main
public class Main {
	static int mod=(int)1e9+7; 

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n=sc.nextInt();
		long ans = power(10, n) - 2 * power(9, n) + power(8, n);
		ans = ((ans % mod) + mod) % mod;
		System.out.println(ans);

	}
	static long power(long a, long b) {
		long x = 1, y = a;
		while (b > 0) {
			if (b % 2 != 0) {
				x = (x * y) % mod;
			}
			y = (y * y) % mod;
			b /= 2;
		}
		return x % mod;
	}
	

	static final Random random = new Random();

	static void ruffleSort(int[] a) {
		int n = a.length;//shuffle, then sort 
		for (int i = 0; i < n; i++) {
			int oi = random.nextInt(n), temp = a[oi];
			a[oi] = a[i];
			a[i] = temp;
		}
		Arrays.sort(a);
	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 32932
#include<stdio.h>

int main()
{
    int n,a,b,ans;

    scanf("%d%d%d",&n,&a,&b);

    ans=n*a;

    if(b>ans)
    {
        printf("%d\n",ans);
    }

    else
    {
        printf("%d\n",b);
    }


    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;

int cnt[101010];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K, Q;
    cin >> N >> K >> Q;
    int A;
    rep(i, 0, Q) {
        cin >> A;
        cnt[0]--;
        cnt[A]++;
        cnt[A + 1]--;
    }
    rep(i, 1, N + 1) {
        cnt[i] += cnt[i - 1];
        if (K + cnt[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  int maxi = -inf;
  int mini = inf;
  vector<int> a;
  rep(i, n){
    int x;
    cin >> x;
    a.pb(x);
    maxi = max(maxi, x);
    mini = min(mini, x);
  }
  vector<int> x, y;
  int add = 0;
  if(mini < 0 && maxi > 0){
    if(-mini > maxi)add = mini;
    else add = maxi;
    int base = 0;
    rep(i, n){
      if(add == a[i]){
        base = i;
        break;
      }
    }
    rep(i, n){
      if((ll)a[i] * (ll)add < 0){
        a[i] += add;
        x.pb(base);
        y.pb(i);
      }
    }
  }else{
    if(mini >= 0)add = maxi;
    else add = mini;
  }
  int sign = (add < 0) ? - 1: 1;
  if(sign < 0){
    for(int i = n - 1; i > 0; i--){
      if(a[i-1] > a[i]){
        x.pb(i);
        y.pb(i-1);
        a[i - 1] += a[i];
      }
    }
  }else{
    FOR(i, 1, n){
      if(a[i-1] > a[i]){
        x.pb(i-1);
        y.pb(i);
        a[i] += a[i - 1];
      }
    }
  }
  cout << x.size() << endl;
  rep(i, x.size()){
    cout << x[i] + 1 << " " << y[i] + 1 << endl;
  }
	return 0;
}


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

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

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end(), greater<int>());
  int Alice = 0;
  int Bob = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      Alice += a.at(i);
    }
    else {
      Bob += a.at(i);
    }
  }
  int ret = Alice - Bob;
  cout << ret << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a[1000],b[1000],c[1000];
  cin >> a >> b >> c;
  cout << "A" << b[0] << "C";
  return 0;
  if(a==b==c){
    cout << 1;
  }
  else if(a==b||b==c||c==a){
    cout << 2;
  }
  else{
    
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b,c,i,j,ufs_road[200009],ufs_rail[200009],n,k,l,p,q,ret[200009];
struct type{
	int road,rail,ind;
}data[200009];
bool cmp(type a,type b){
	if(a.road!=b.road){
		return a.road<b.road;
	}else{
		return a.rail<b.rail;
	}
}
int find_road(int x){
	if(ufs_road[x]==x){
		return x;
	}else{
		return ufs_road[x]=find_road(ufs_road[x]);
	}
}
int find_rail(int x){
	if(ufs_rail[x]==x){
		return x;
	}else{
		return ufs_rail[x]=find_rail(ufs_rail[x]);
	}
}
int main(){
	cin>>n>>k>>l;
	for(i=1;i<=n;i++){
		ufs_road[i]=ufs_rail[i]=i;
	}
	for(i=1;i<=k;i++){
		cin>>p>>q;
		if(p>q){//big:q
			swap(p,q);
		}
		if(find_rail(p)!=find_road(q)){
			ufs_road[find_road(p)]=find_road(q);
		}
	}
	for(i=1;i<=l;i++){
		cin>>p>>q;
		if(p>q){
			swap(p,q);
		}
		if(find_rail(p)!=find_rail(q)){
			ufs_rail[find_rail(p)]=find_rail(q);
		}
	}
	for(i=1;i<=n;i++){
		data[i].ind=i;
		data[i].road=find_road(i);
		data[i].rail=find_rail(i);
	}
	sort(data+1,data+n+1,cmp);
	int count=1,start=1;
	for(i=2;i<=n;i++){
		if(data[i].road==data[i-1].road&&data[i].rail==data[i-1].rail){
			count++;
		}else{
			for(j=start;j<i;j++){
				ret[data[j].ind]=count;
			}
			count=1;
			start=i;
		}
	}
	for(j=start;j<=n;j++){
		ret[data[j].ind]=count;
	}
	for(i=1;i<=n;i++){
		cout<<ret[i]<<' ';
	}
	cout<<endl;
	return 0;
} 
/*
10 5 5
1 4
2 4
3 5
6 8
7 8

4 2
3 5
6 4
7 4
5 3
*/



Measured memory_bytes: 5376
#include <iostream>

int main(){
   int N;
   std::cin >> N;

   int ans = 0;
   int tmp = 0;
   int H_prev, H_now;
   std::cin >> H_prev;
   for(int i=1; i<N; ++i){
      std::cin >> H_now;
      if(H_now<=H_prev) tmp++;
      else{
	 ans = std::max(tmp,ans);
	 tmp = 0;
      }
      H_prev = H_now;
   }
   ans = std::max(tmp,ans);
   std::cout << ans << std::endl;
   return 0;

}


Measured memory_bytes: 256
n=int(input())
a=list(str(input()))
b=list(str(input()))
c=list(str(input()))
t=0
for i in range(n):
  if a[i]==b[i] and b[i]==c[i]:
    continue
  elif a[i]==b[i] or b[i]==c[i] or c[i]==a[i]:
    t+=1
  else:
    t+=2
print(t)
    

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> counter(N);
  
  for (int i = 0; i < 2*M; i++) {
    int x;
    cin >> x;
    for (int j = 0; j < N; j++) {
      if (j + 1 == x) counter.at(j)++;
    }
  }
  
  for (int j = 0; j < N; j++) {
    cout << counter.at(j) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main()
{
   int i, h, m, s;
   cin >> i;
   h = i / 3600;    
   m = (i % 3600)/60;
   s = i % 60;
  cout << h << ":" << m << ":" << s << endl;
   
   return 0;
}


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

int main(){
  int N;
  cin >> N;
  map<string,bool> exist;
  int count = 0;
  for(int i = 0; i < N; i++){
    string S;
    cin >> S;
    if(!exist[S]){
      exist[S] = true;
      count += 1;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 19256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long ll;

ll mod = 1e9 + 7;
ll go(ll x, ll y) {
	if (y == 1)return x;
	if (y & 1) {
		return ((x * go(x, y - 1)) % mod);
	}
	else {
		ll tmp = go(x, y / 2);
		return ((tmp * tmp) % mod);
	}
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n, a, b; cin >> n >> a >> b;
	ll sum = (go(2, n)) - 1;
	// sum - nCa - nCb - 1;
	ll t = 1;
	for (ll i = n - a + 1; i <= n; i++) {
		t *= i; t %= mod;
	}
	ll s = 1;
	for (int i = 1; i <= a; i++) {
		s *= i; s %= mod;
	}
	ll e = (go(s, mod - 2) * t) % mod;

	sum -= e;
	if (sum < 0)sum += mod;

	t = 1;
	for (ll i = n - b + 1; i <= n; i++) {
		t *= i; t %= mod;
	}
	s = 1;
	for (int i = 1; i <= b; i++) {
		s *= i; s %= mod;
	}
	e = (go(s, mod - 2) * t) % mod;

	sum -= e;
	if (sum < 0)sum += mod;

	cout << sum << '\n';






}




Measured memory_bytes: 256
program ken
  implicit none
  integer :: n,a,b,c,d
  character(len=200000) :: S
  integer :: dmp
  character(len=2) :: jam
  character(len=3) :: tohan
  tohan='...'
  jam='##'
  dmp=0
  read(*,*) N,A,B,C,D
  read(*,*) S
  if((index(S(A:C),jam).ne.0).or.(index(S(B:D),jam).ne.0)) then
     dmp=1
  else
     if(C.gt.D) then
        if(index(S(B-1:D+1),tohan).eq.0) then
           dmp=1
        else
           dmp=0
        endif
     else
        dmp=0
     endif
  endif

  if(dmp.eq.1)then
     write(*,'(a)') 'No'
  else
     write(*,'(a)') 'Yes'
  endif

end program ken



Measured memory_bytes: 1084
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

ll dp[3005][3005][4];
int item[3005][3005];

int main(){
  int R,C,K;
  cin >> R >> C >> K;
  rep(i,K){
    int r,c,v;
    cin >> r >> c >> v;
    item[r-1][c-1]=v;
  }

  rep(i,R)rep(j,C){
    for(int k=2;k>=0;k--){
      chmax(dp[i][j][k+1],dp[i][j][k]+item[i][j]);
    }
    rep(k,4)chmax(dp[i+1][j][0],dp[i][j][k]);
    rep(k,4)chmax(dp[i][j+1][k],dp[i][j][k]);
  }

  ll ans=0;
  rep(k,4)chmax(ans,dp[R-1][C-1][k]);
  cout << ans << endl;
}

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] s = new Integer[n];
        long sum = 0;
        for(int i = 0;i < n;i++) {
            s[i] = sc.nextInt();
            sum += s[i];
        }
        Arrays.sort(s);
        
        /*
         * 10の倍数を引いても意味がないので、
         * 10の倍数以外の数値を引く。
         */
        long ans = 0;
        for(int i = 0;i < n;i++) {
            if(sum % 10 != 0) {
                ans = sum;
                break;
            }
            else if(s[i] % 10 != 0){
                sum -= s[i];
            }
        }
        
        System.out.println(ans);
    }

}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int change(string k){
	int res=0;
	rep(i,0,k.size()){
		res+=(k[i]-'0')*pow(10,k.size()-i-1);
	}
	return res;
}

int main(){
	string c;
	int ans=0,f=0,g=1;
	for(int i=0;;i++){
		cin>>c;
		if(c=="=") break;
		else if(c=="+") f=1;
		else if(c=="-") f=2;
		else if(c=="*") f=3;
		else if(c=="/") f=4;
		else{
			int nw=change(c);
			//o(nw);
			if(g){
				ans=nw; g=0; continue;
			}
			if(f==1) ans+=nw;
			if(f==2) ans-=nw;
			if(f==3) ans*=nw;
			if(f==4) ans/=nw;
		}
	}
	o(ans);
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long x,y,ans,sum=0;
    cin>>x>>y;
    ans=(y/x*1ll);
    while(ans>=1)
    {
        ans/=2;
        sum++;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
template <typename T>
class RingBuffer {
	int size;
	int idx;
	T* arr;
	T& at(int i) {
		return arr[i % size];
	}
public:
	RingBuffer(int s) {
		size = s;
		idx = 0;
		arr = new T[s];
	}
	void push(T t) {
		at(idx++) = t;
	}
	const T& peek() {
		return at(idx);
	}
};
int solve(int n, int k) {
	RingBuffer<int> buffer(k);
	int sum = 0;
	int a;
	for (auto i = 0; i < k; ++i) {
		std::cin >> a;
		buffer.push(a);
		sum += a;
	}
	int max = sum;
	for (auto i = k; i < n; ++i) {
		std::cin >> a;
		sum += a - buffer.peek();
		buffer.push(a);
		if (sum > max) max = sum;
	}
	return max;
}
int main() {
	int n, k;
	while (std::cin >> n >> k && n != 0) {
		std::cout << solve(n, k) << '\n';
	}
	return 0;
}

Measured memory_bytes: 3208
s = gets.chomp
ok = true
while !s.empty? do
  if s.end_with?("dream")
    s.slice!(s.length - 5, 5)
  elsif s.end_with?("dreamer")
    s.slice!(s.length - 7, 7)
  elsif s.end_with?("erase")
    s.slice!(s.length - 5, 5)
  elsif s.end_with?("eraser")
    s.slice!(s.length - 6, 6)
  else
    ok = false
    break
  end
end
puts ok ? "YES" : "NO"


Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define elif else if
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

const int N = 3e5, M = N;
//=======================

ll int gcd(ll int a, ll int b) { 
    if (b == 0) return a; 
    return gcd(b, a % b);   
} 

void solve() {
  int n;
  cin >> n;
  if(n%1000 == 0)  cout << 0;
  else cout << (n/1000 + 1)*1000 - n;
  
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

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

    return 0;
}




Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=2e5+5;
int main()
{
    int a[N],n;
    ll ans=0;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    if(a[1])
    {
        cout<<-1;
        return 0;
    }
    for(int i=2;i<=n;i++)
    {
        if(a[i]>a[i-1]+1)
        {
            cout<<-1;
            return 0;
        }
        else if(a[i]-a[i-1]==1)ans++;
        else ans+=a[i];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb push_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed;
// cout << setprecision(10) << val;

int a, b, c;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> a >> b >> c;
  cout << a * b / 2 << endl;
  return 0;
}



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

using namespace std;

int main() {
  int n, r;

  cin >> n >> r;

  if (n >= 10) {
    cout << r;
  } else {
    cout << (r + 100 * (10 - n));
  }

  cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  int r, g; cin >> r >> g;
  cout << 2 * g - r << endl;
  return;
}

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


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, t;
  cin >> a >> b >> t;
  int x = t / a;
  cout << x * b << endl;
  return 0;
}

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


int main()
{
  int n, m;
  cin >> n >> m;
  priority_queue<int> q;
  rep(i, n)
  {
    int a;
    cin >> a;
    q.push(a);
  }
  rep(i, m)
  {
    int a = q.top();
    q.pop();
    q.push(a / 2);
  }
  ll ans = 0;
  rep(i, n)
  {
    ans += q.top();
    q.pop();
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 892
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  n <- unsafeSignedDecimal <$> T.getLine :: IO Int
  ps <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  let l = length . filter not $ zipWith (==) [1..n] ps
  putStrLn $ if l <= 2 then "YES" else "NO"

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


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

int main(){
  int n;
  cin >> n;
  bool answer = false;
  for(int i = 1; i < 10; i++){
    if(n % i == 0 && n / i < 10){
      answer = true;
      break;
    }
  }
  if(answer){
    cout << "Yes" << endl;
  }
  else{  
    cout << "No" << endl;
  }
}


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

int main()
{
  ll N,ans = 0,Q;
  cin >> N;
  vector<ll> vec(N);
  map<int,int> mp;
  rep(i,N){
    cin >> vec[i];
    mp[vec[i]]++;
    ans += vec[i];
  }
  cin >> Q;
  int cn, num;
  rep(i, Q){
    cin >> cn >> num;
    ans += mp[cn] * num - mp[cn] * cn;
    mp[num] += mp[cn];
    mp[cn] = 0;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 8376
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1e15
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1e2 + 2;
ll i,n,c;
string a;
stack<char> s;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>a;
    n = a.length();
    rep(i,0,n){
        if(s.empty()) s.push(a[i]);
        else{
            if(s.top() != a[i]){
                s.pop();
                c += 2;
            }
            else
                s.push(a[i]);
        }
    }
    cout<<c;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>; // dist pairs d[i][j]
using LP = pair<ll, int>; // vertex number pairs

const ll INF = 1e18;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};


int main(){
    int h, w, k;
    cin >> h >> w >> k;
    int si, sj, ti, tj;
    cin >> si >> sj >> ti >> tj;
    --si; --sj; --ti; --tj;
    vector<string> g(h);
    rep(i, h) cin >> g[i];

    auto toId = [&](int i, int j, int v){
        return (i*w + j) * 4 + v;
    };

    auto modCeilK = [&](ll x){ // Ceil(x) and return x multiplied by k.
       return (x+k-1)/k*k;
    };

    vector<ll> dist(h*w*4, INF);
    priority_queue<LP, vector<LP>, greater<LP>> q; // Heap in ascending order.
    
   auto push = [&](int i, int j, int v, ll x){ // Judge whether we can reach to x.
        int id = toId(i, j, v);
        if (dist[id] <= x) return;
        dist[id] = x;
        q.emplace(x, id);
    };

    rep(v, 4) push(si, sj, v, 0); // Initialize by assigning 0 to all (si, sj, v).
    while (!q.empty()){
        ll d = q.top().first;
        int id = q.top().second;
        q.pop();
        if (dist[id] != d) continue;
        int i = id/w/4;
        int j = id/4%w;
        int v = id%4;
        // Chnage directions.
        rep(nv, 4) push(i, j, nv, modCeilK(d));
        // Go until change directions.
        {
            int ni = i+di[v], nj = j+dj[v];
            if (0 <= ni && ni < h && 0 <= nj && nj < w){
                if (g[ni][nj] == '.'){
                    push(ni, nj, v, d+1);
                }
            }
        }
    }

    ll ans = INF;
    rep(v, 4) ans = min(ans, dist[toId(ti, tj, v)]);
    if (ans == INF){
        cout << -1 << endl;
    } else {
        ans = modCeilK(ans)/k;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 44168
N = int(input())
s = [sorted(input()) for i in range(N)]
s.sort()
ans = 0
for i in range(N-1):
    if s[i] == s[i+1]:
        start = i
        end = N-1
        while start != end:
            center = (start + end) // 2
            if s[center] == s[i]:
                if s[center+1] == s[i]:
                    start = center+1
                else:
                    start = end = center
            else:
                end = center
        ans += start - i
print(ans)

Measured memory_bytes: 30692
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  int n; cin >> n;
  vi l(n); rep(i,n) cin >> l[i];
  int ans = 0;
  rep(i,n){
    for(int j = i+1; j < n; j++){
      for(int k = j+1; k < n; k++){
        if(l[i] != l[j] && l[j] != l[k] && l[k] != l[i]){
          if(l[k]<l[i]+l[j] && l[i]<l[j]+l[k] && l[j]<l[k]+l[i]) ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(void) {
  string S; cin >> S;

  char flag = 1;
  while (flag) {
    if (S.front() == 'B') {
      S.erase(S.begin());
      continue;
    }

    flag = 0;
    for (int i = 0; i < S.length()-1; i++) {
      if (S.at(i) != 'B' && S.at(i+1) == 'B') {
        S.erase(S.begin() + i, S.begin() + i+2);
        flag = 1;
        i--;
      }
    }
  }

  cout << S << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
    #include<numeric>
    #include<array>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define Vl vector<ll>
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<ll>>;
    using P = pair<ll, ll>;
     
const ll MOD = 1e9 + 7;
const ll ZER = 0;

int main(){
    string s;
    cin >> s;
    rep(i, 3)cout << s[i];cout << endl; 
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

int main() {
	ll a,b,k;
	cin >> a >> b >> k;
	ll x = max(0LL,a-k);
	ll y = max(0LL,b+a-k);
	y = min(y,b);
	cout << x << ' ' << y << endl;
	return 0;
}



Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <climits>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    ll n,k;
    cin >> n >> k;
    ll a = n%k;
    cout << min(a, abs(k-a)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
using namespace std;
#define MAX 10000
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INFTY (1<<30)
int n;
vector<pair<int,int> > adj[MAX];

void dijkstra()
{
  priority_queue<pair<int,int> > PQ;
  int d[MAX],color[MAX];
  for(int i=0;i<n;i++)
    {
      d[i]=INFTY;
      color[i]=WHITE;
    }
  d[0] = 0;
  PQ.push(make_pair(0,0));
  color[0]=GRAY;
  while(!PQ.empty())
    {
      pair<int,int> f= PQ.top(); PQ.pop();
      int u=f.second;
      color[u]=BLACK;
      if(d[u] < f.first * (-1) ) continue;
      for(int j=0;j<adj[u].size();j++)
	{
	  int v=adj[u][j].first;
	  if(color[v] == BLACK) continue;
	  if(d[v] > d[u] + adj[u][j].second)
	    {
	      d[v]=d[u]+adj[u][j].second;
	      PQ.push(make_pair(d[v] *(-1), v));
	      color[v]=GRAY;
	    }
	}
    }
  for( int i=0;i<n;i++)
    {
      cout << i << " " << (d[i]==INFTY ? -1: d[i] ) << endl;
    }
}

int main(){
  cin >> n;

  int k,c,u,v;
  for(int i=0; i<n; i++)
    {
      cin >> u >> k;
      for(int j=0;j<k;j++)
	{
	  cin >> v >> c;
	  adj[u].push_back(make_pair(v,c));
	}
    }
  dijkstra();
  return 0;
}

Measured memory_bytes: 7988
#include <bits/stdc++.h>
#define N 301
using namespace std;
int w[N],mem[N][N],used[N][N];
 
int dfs(int l,int r){
  if(l==r) return 0;
  if(r-l==1) return 2*(abs(w[l]-w[r])<=1);
  if(used[l][r]++) return mem[l][r];
   
  int res=0;
  if(abs(w[l]-w[r])<=1&&dfs(l+1,r-1)==r-l-1)res=2+dfs(l+1,r-1);
   
  for(int i=l;i<r;i++) res=max(res,dfs(l,i)+dfs(i+1,r));
  return mem[l][r]=res;
}
 
int main(){
  int n;
  while(cin>>n,n){
    for(int i=0;i<n;i++)cin>>w[i];
    memset(used,0,sizeof(used));
    cout<<dfs(0,n-1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3744
import java.util.Scanner;

public class Main {
  public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
    int b = sc.nextInt();
    int t = sc.nextInt();
    
    int ans = t/a * b;
      System.out.println(ans);
  }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int N;
vector<i64> A;

vector<i64> ans;
vector<i64> MAX[2];
vector<i64> mi[2];
vector<i64> res;
int main(){
  cin >> N;
  A.resize(1 << N);
  ans.resize(1 << N,0);
  MAX[0].resize(1 << N,0);
  MAX[1].resize(1 << N,0);
  mi[0].resize(1 << N,0);
  mi[1].resize(1 << N,0);
  res.resize(1 << N,0);
  rep(i,0,(1 << N) - 1) cin >> A[i];
  MAX[0][0] = A[0];
  mi[0][0] = 0;
  ans[0] = A[0];
  res[0] = A[0];
  int cnt = 0;
  rep(s,1,(1 << N) - 1){
    vector<pair<i64,i64>> vec;
    vec.push_back({A[s],s});
    rep(i,0,N){
      if(s & (1 << i)){
        vec.push_back({MAX[0][s & ~(1 << i)],mi[0][s & ~(1 << i)]});
        vec.push_back({MAX[1][s & ~(1 << i)],mi[1][s & ~(1 << i)]});
      }
    }
    sort(all(vec));
    vec.erase(unique(all(vec)),vec.end());
    reverse(all(vec));
    if(vec.size() >= 2){
      MAX[0][s] = vec[0].first;
      mi[0][s] = vec[0].second;
      MAX[1][s] = vec[1].first;
      mi[1][s] = vec[1].second;
      ans[s] = MAX[0][s] + MAX[1][s];
    }
    else{
      MAX[0][s] = vec[0].first;
      mi[0][s] = vec[0].second;
      ans[s] = MAX[0][s];
    }
    res[s] = max(ans[s],res[s - 1]);
    cout << res[s] << endl;
  }
}


Measured memory_bytes: 17408
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.NoSuchElementException;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		int n = sc.nextInt();
		ArrayDeque<Integer> list = new ArrayDeque<>();
		
		for(int i=1; i<=n; i++) {
			String cmd = sc.next();
			
			switch (cmd) {
			case "insert":
				int num1 = sc.nextInt();
				list.push(num1);
				break;
				
			case "delete":
				int num2 = sc.nextInt();
				list.removeFirstOccurrence(num2);
				break;
				
			case "deleteFirst":
				list.removeFirst();
				break;
				
			case "deleteLast":
				list.removeLast();
				break;

			}
		}
		
		int size = list.size();
		for(int i=0; i<size; i++) {
			System.out.print(list.pop());
			if(i != size-1) {
				System.out.print(" ");
			}
		}
		System.out.println();
	}

	static class FastScanner {
	    private final InputStream in = System.in;
	    private final byte[] buffer = new byte[1024];
	    private int ptr = 0;
	    private int buflen = 0;
	    private boolean hasNextByte() {
	        if (ptr < buflen) {
	            return true;
	        }else{
	            ptr = 0;
	            try {
	                buflen = in.read(buffer);
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            if (buflen <= 0) {
	                return false;
	            }
	        }
	        return true;
	    }
	    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
	    public String next() {
	        if (!hasNext()) throw new NoSuchElementException();
	        StringBuilder sb = new StringBuilder();
	        int b = readByte();
	        while(isPrintableChar(b)) {
	            sb.appendCodePoint(b);
	            b = readByte();
	        }
	        return sb.toString();
	    }
	    public long nextLong() {
	        return Long.parseLong(next());
	    }
	    public int nextInt(){
	    	return Integer.parseInt(next());
	    }
	}
}

Measured memory_bytes: 180176