akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (int NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF =1000000000000000;

int main(){
  int n,q,num;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> a(n);
  vector<int> b(n);
  num = 0;
  
  REP(i,n-1){
    if(s.at(i) == 'A' && s.at(i+1) == 'C'){
      num++;
    }
    a.at(i+1) = num;
    b.at(i) = num;
  }
  
  int l,r;
  REP(i,q){
    cin >> l >> r;
    if(l == 1) cout << a.at(r-1) << endl;
    else cout << a.at(r-1)-b.at(l-2) << endl;
  }
}

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

int main () {
  int n;
  int *a_heap;
  cin >> n;
  a_heap = new int[n];
  for (int i = 0; i < n;i++) {
    cin >> a_heap[i];
  }
  for (int i = n-1; i >= 0; i--) {
    cout << a_heap[i];
    if (i != 0) {
      cout << " ";
    }
  }
  cout << endl;
  return 0;
}

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

int main(){
	int N;
	cin >> N;
	vector<long long> a(3*N);
	for(auto &i:a)cin >> i;
	
	priority_queue<long long,vector<long long>,greater<long long>> qx;
	vector<long long> X(N+1);
	X[0]=accumulate(a.begin(),a.begin()+N,0LL);
	for(int i=0;i<N;i++)qx.push(a[i]);
	
	for(int i=0;i<N;i++){
		int k=i+N;
		X[i+1]=X[i]+a[k];
		qx.push(a[k]);
		X[i+1]-=qx.top();
		qx.pop();
	}
	
	reverse(a.begin(),a.end());
	
	priority_queue<long long,vector<long long>,less<long long>> qy;
	vector<long long> Y(N+1);
	Y[0]=accumulate(a.begin(),a.begin()+N,0LL);
	for(int i=0;i<N;i++)qy.push(a[i]);
	
	for(int i=0;i<N;i++){
		int k=i+N;
		Y[i+1]=Y[i]+a[k];
		qy.push(a[k]);
		Y[i+1]-=qy.top();
		qy.pop();
	}
	
	reverse(Y.begin(),Y.end());
	
	long long ans=-999999999999999999;
	for(int i=0;i<N+1;i++)ans=max(ans,X[i]-Y[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6516
def reverse_polish_calculator(s):
    """Calculate a reverse polish notation s.
    + - * operators can be used in s. Only positive integer is
    supported for operand.

    >>> reverse_polish_calculator("1 2 +")
    3
    >>> reverse_polish_calculator("1 2 + 3 4 - *")
    -3
    """
    def calc(val1, op, val2):
        if op == '+':
            return val1 + val2
        elif op == '-':
            return val1 - val2
        elif op == '*':
            return val1 * val2
        else:
            raise ValueError()

    stack = []
    for c in s.split():
        if c.isnumeric():
            stack.append(int(c))
        else:
            v2 = stack.pop()
            v1 = stack.pop()
            stack.append(calc(v1, c, v2))

    return stack.pop()


def run():
    s = input()
    print(reverse_polish_calculator(s))


if __name__ == '__main__':
    run()


Measured memory_bytes: 5608
s = list(input())
S = [[] for _ in range(len(s))]
for i in range(len(s)):
    S[i] = int(s[i])

gap = 1000
X = 0
for i in range(len(S)-2):
    X = S[i]*100 + S[i+1]*10 + S[i+2]
    if gap>abs(X-753):
        gap = abs(X-753)
        
print(gap)

Measured memory_bytes: 3064
N, = (int(x) for x in input().split())
S, = ((x) for x in input().split())


import collections

cc = collections.Counter(S)
if len(cc) != 3:
    sol = 0
else:
    sol = 1
    for x in cc.values():
        sol *= x

for i in range(N):
    for j in range(i + 2, N, 2):
        if S[i] == S[j]:
            continue
        k = (i + j) // 2
        if S[k] not in (S[i], S[j]):
            sol -= 1

print(sol)


Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
 #define fast() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll  long long
#define int long long
#define f(i,a,b) for(int i=a; i<b; i++)
#define pb push_back
#define MP make_pair
#define vi vector<int>
#define F     first
#define S    second
#define all(x) x.begin(), x.end()

const int N = 1e6+7;
unordered_set<int> v;
int h[N];
void init()
{
    for(int i = 2; i <= sqrt(N); i++)
    {
        if(h[i] != 0)
            continue;
        for(int j = i*2; j < N; j += i)
            h[j]++;
    }
}
bool check(int x)
{
    for(int i = 2; i <= sqrt(x); i++)
    {
        if(x % i == 0)
            return false;
    }
    return true;
}
signed main()
{
    fast();
    int a, b;
    init();
    cin >> a >> b;

    if(a > b)
        swap(a, b);

    int flag = 0;
    for(int i = 1; i <= sqrtl(a); i++)
    {
        if(a % i == 0)
        {
            if(b % i == 0)
                v.insert(i);
            int p = a / i;
            if(b % p == 0)
                v.insert(p);
        }
    }

    int c = 0;

    for(auto it: v)
    {
        if(it >= N )
        {
            if(check(it))
                c++;
        }
        else if(h[it] == 0)
            c++;
    }
    cout << c;
}

Measured memory_bytes: 8320
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll l, n;
    cin >> l >> n;
    vl x(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
    }
    vl clock(n, 0);
    clock[0] = x[0];
    for (int i = 1; i < n; ++i) {
        clock[i] += clock[i - 1] + x[i];
    }
    vl anti(n, 0);
    anti[0] = l - x[n - 1];
    for (int i = 1; i < n; ++i) {
        anti[i] += anti[i - 1] + (l - x[n - 1 - i]);
    }
    ll ret = 0;
    for (int i = 0; i < n; ++i) {
        if (i == n - 1) {
            chmax(ret, x[i]);
            continue;
        }
        ll temp = x[i] * 2;
        ll odd  = (n - 1 - i) % 2;
        if (n - 1 - i >= 2) {
            temp += 2 * clock[i + (n - 1 - i) / 2];
            temp -= 2 * clock[i];
        }
        if (n - 1 - i >= 1) {
            temp += 2 * anti[(n - 1 - i) / 2 - 1 + odd];
            if (odd == 1)
                temp -= l - x[n - (n - 1 - i) / 2 - odd];
            else
                temp -= x[i + (n - 1 - i) / 2];
        }
        chmax(ret, temp);
    }
    reverse(x.begin(), x.end());
    for (auto &xx : x) {
        xx = l - xx;
    }
    swap(clock, anti);
    for (int i = 0; i < n; ++i) {
        if (i == n - 1) {
            chmax(ret, x[i]);
            continue;
        }
        ll temp = x[i] * 2;
        ll odd  = (n - 1 - i) % 2;
        if (n - 1 - i >= 2) {
            temp += 2 * clock[i + (n - 1 - i) / 2];
            temp -= 2 * clock[i];
        }
        if (n - 1 - i >= 1) {
            temp += 2 * anti[(n - 1 - i) / 2 - 1 + odd];
            if (odd == 1)
                temp -= l - x[n - (n - 1 - i) / 2 - odd];
            else
                temp -= x[i + (n - 1 - i) / 2];
        }
        chmax(ret, temp);
    }

    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 4992
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1)(r(2).readFileSync("/dev/stdin","UTF-8"))},function(e,t){e.exports=function(e){var t=e.split(" "),r=Number(t[0]),n=Number(t[1]),o=Math.max(r+n,r-n,r*n)+0;console.log(o)}},function(e,t){e.exports=require("fs")}]);

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a), t(b);
    rep(i, a) cin >> s[i];
    rep(i, b) cin >> t[i];
    rep(i, q) {
        ll x;
        cin >> x;
        ll ans = LONG_LONG_MAX;
        auto its = lower_bound(all(s), x);
        auto itt = lower_bound(all(t), x);
        {
            if ((its != s.begin()) && (itt != t.begin())) {
                auto itst = its; itst--;
                auto ittt = itt; ittt--;
                ll tmp = x - min(*itst, *ittt);
                ans = min(ans, tmp);
            }
        }
        {
            if ((its != s.end()) && (itt != t.begin())) {
                auto ittt = itt; ittt--;
                ll tmp = (*its - x) + (x - *ittt) + min(*its - x, x - *ittt);
                ans = min(ans, tmp);
            }
        }
        {
            if ((its != s.begin()) && (itt != t.end())) {
                auto itst = its; itst--;
                ll tmp = (x - *itst) + (*itt - x) + min(x - *itst, *itt - x);
                ans = min(ans, tmp);
            }
        }
        {
            if ((its != s.end()) && (itt != t.end())) {
                ll tmp = max(*its, *itt) - x;
                ans = min(ans, tmp);
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	string s;
	cin>>s;
	rep(i,3){
		if(s[i]=='1')s[i]='9';
		else s[i]='1';
	}
	cout<<s<<endl;

	

	return 0;
}


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

int main() {
    long double A, B, H, M;
    cin >> A >> B >> H >> M;
    long double m = H * 60 + M;
    long double ang = M_PI * m / 360.0 - M_PI * m / 30;
    cout << fixed << setprecision(9) << sqrt(A * A + B * B - 2.0 * A * B * cos(ang)) << endl;   
}

Measured memory_bytes: 4084
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define int long long
#define all(arr) arr.begin(),arr.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vstr vector<string>
#define vbool vector<bool>
#define vvi vector<vector<int> >
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define vpair vector<pii > 
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) {cout<<a[i]<<' ';}cout<<'\n'
#define mem(a,v) memset(a,v,sizeof(a))
#define loop(i,a,b) for (int i = a; i < b; i++)
#define loope(i,a,b) for (int i = a; i <= b; i++)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(9)
#define PI 3.14159265
#define S second
#define F first
#define CHECK cout<<"CHEDEDWB"<<endl
#define br '\n'
int mod = 1e9+7;
/*int inf = 1e18;
int m_inf = INT_MIN;
int MOD = 100001;*/

void solve()
{
	int n;
	cin>>n;
	int ac=0, wa=0, tle=0, re=0;
	while(n--)
	{
		string s;
		cin>>s;
		if(s=="AC")
			ac++;
		if(s=="WA")
			wa++;
		if(s=="TLE")
			tle++;
		if(s=="RE")
			re++;
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
}

int32_t main()
{
	FastIO; PRECISION;
	int t = 1;
	//cin>>t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 3232
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vv = vector<vector<ll>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()

typedef pair<ll, ll> Pair;
bool pairCompare(const Pair &firstElof, const Pair &secondElof) {
  return firstElof.second > secondElof.second;
}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

ll factorial(int n) {
  ll ans = 1;
  for (int i = 2; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll P(int n, int m) {
  ll ans = 1;
  for (int i = m + 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll power(int n, int m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = power(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * power(n, m - 1)) % MOD;
  }
}
ll C(int n, int m) {
  return (P(n, n - m) * power(factorial(m), MOD - 2)) % MOD;
}
ll GCD(ll a, ll b) {
  if (b == 0)
    return a;
  return GCD(b, a % b);
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ll A, B, C;
  string S;
  cin >> A >> B >> C;
  cout << min(B / A, C) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <cstring>
#include <ctime>
#include <map>
#include <algorithm>
#include <cmath>
#define MAXN 100005
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ba 823
#define ha 99994711
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
int N;
struct node {
	int to,next;
}E[MAXN * 2];
int sumE,head[MAXN],ind[MAXN],fa[MAXN],st,ed,D[MAXN];
int line[MAXN],tot;
void add(int u,int v) {
	E[++sumE].to = v;
	E[sumE].next = head[u];
	head[u] = sumE;
}
void dfs(int u) {
	ed = u;
	for(int i = head[u] ; i ; i = E[i].next) {
		int v = E[i].to;
		if(v != fa[u] && ind[v] != -1) {
			fa[v] = u;
			dfs(v);
		}
	}
}
void Solve() {
	scanf("%d",&N);
	int u,v;
	for(int i = 1 ; i < N ; ++i) {
		scanf("%d%d",&u,&v);
		add(u,v);add(v,u);
		ind[u]++;ind[v]++;
	}
	if(N == 2) {
		puts("1 2");return;
	}
	memcpy(D,ind,sizeof(ind));
	for(int i = 1 ; i <= N ; ++i) {
		if(ind[i] == 1) {
			for(int j = head[i] ; j ; j = E[j].next) {
				int v = E[j].to;
				D[v]--;
			}
			D[i] = -1;
		}
	}
	memcpy(ind,D,sizeof(ind));
	for(int i = 1 ; i <= N ; ++i) {
		if(ind[i] > 2) {puts("-1");return;}
	}
	for(int i = 1 ; i <= N ; ++i) {
		if(ind[i] == 1) {st = i;dfs(st);break;}
	}
	if(!st) {
		for(int i = 1 ; i <= N ; ++i) {
			if(ind[i] == 0) {st = i;dfs(st);break;}
		}
	}
	for(int i = head[ed] ; i ; i = E[i].next) {
		int v = E[i].to;
		if(v != fa[ed]) {
			fa[v] = ed;
			ed = v;
			break;
		}
	}

	for(int i = head[st] ; i ; i = E[i].next) {
		int v = E[i].to;
		if(!fa[v]) {
			fa[st] = v;
			st = v;
			break;
		}
	}
	ind[ed] = ind[st] = 1;
	int p = ed;
	while(p) {
		++tot;
		for(int i = head[p] ; i ; i = E[i].next) {
			int v = E[i].to;
			if(ind[v] == -1) {
				line[tot]++;
			}
		}
		p = fa[p];
	}
	int L = 1,R = tot;
	while(L <= tot && R >= 1) {
		if(line[L] < line[R]) break;
		else if(line[L] > line[R]) {reverse(line + 1,line + tot + 1);break;}
		++L;--R;
	}
	p = 2;
	printf("%d",1);
	for(int i = 2 ; i <= tot ; ++i) {
		for(int j = p + 1 ; j <= p + line[i] ; ++j) {
			printf(" %d",j);
		}
		printf(" %d",p);
		p = p + line[i] + 1;
	}
	putchar('\n');
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}

Measured memory_bytes: 7040
n = int(input())
list = []
max = 0
ans = 0

for i in range(n):
    line = int(input())
    list.append(line)
    if list[i] > max:
        max = list[i]
        c = i

for i in range(n):
    if c == i:
        ans = ans + (list[i] / 2)
    else:
        ans = ans + list[i]

print(int(ans))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN (300006)
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define emp emplace
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
string A;
string to_string(char const c) { string s(1,c);return s; } 
string last3(string const stk) { ll s=stk.size(); return to_string(stk[s-3])+to_string(stk[s-2])+to_string(stk[s-1]);}
bool c(string A){return A=="ABC";}
deque<char>correct;
ll ans;
struct lmao {
	ll l,r,a,b,c;
}; vector<lmao>v;
int main()
{
	FAST
	cin>>A;
	while(A.size()>=3) {
		if(!c(last3(A))){correct.push_front(A.back());A.pop_back();continue;}
		correct.push_front('#');
		A.pop_back();A.pop_back();A.pop_back();
	}
	while(A.size())correct.push_front(A.back()),A.pop_back();
	A="";
	for(auto i:correct)A+=i;
	cerr<<A<<endl;
	FOR(i,0,A.size()){
		if(A[i]!='#')continue;
		ll endd=i-1;
		while(endd>=0&&A[endd]=='A')--endd;
		++endd;
		// inclusive
		ll hmm=i+1;
		while(hmm<A.size()&&A[hmm]=='#')hmm++;
		hmm--;
		ll BC=hmm+1;
		while(BC+1<A.size()&&A[BC]=='B'&&A[BC+1]=='C')BC+=2;
		BC--;
		// endd to BC
		// cerr<<i-endd<<' '<<hmm-i+1<<' '<<BC-hmm<<'\n';
		// ans+=solve(i-endd,hmm-i+1,(BC-hmm));
		v.pb({endd,BC,i-endd,hmm-i+1,(BC-hmm)/2});
		i=BC+1;--i;
	}
	string con=""; ll ans=0,sum=0;
	FOR(i,0,v.size()){
		if(i+1<v.size()&&v[i+1].l==v[i].r+1){
			while(v[i].a--)con+='A';
			while(v[i].b--)con+='A',con+='#';
			while(v[i].c--)con+='#';
			continue;
		}
		while(v[i].a--)con+='A';
		while(v[i].b--)con+='A',con+='#';
		while(v[i].c--)con+='#';
		sum=0;
		for(auto i:con){
			if(i=='A')sum++;
			else ans+=sum;
		}
		con="";
	}
	cout<<ans;
}


Measured memory_bytes: 2064
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
int main(){
    vector <long long> v;
    long long a,b,c=0,d=0,e=1,f=0,g=0,i,j,k=1,l=0,r=1,n,m[300001],z[400001],h[600001],p[600001],sum[10001];
    string s,t,x,y[200001];
    double q,u,w;
    cin>>a>>b>>c;
    for(i=b;i<=c;i++){
        if(i%a==0){
            cout<<"OK";
            stop;
        }
    }
    cout<<"NG";
}

Measured memory_bytes: 9876
# 8
# a枚のお札の合計金額がb円となるか調べる
# ならない場合は'-1 -1 -1'出力
a, b = map(int, input().split())
sum = 0
uso = True
for i in range(a+1):
    for j in range(a+1-i):
        sum = 10000 * i + 5000 * j + 1000 * (a - i - j)
        if sum == b:
            print(i, j, a - i - j)
            uso = False
            break
    else:
        continue
    break

if uso:
    print('-1 -1 -1')


Measured memory_bytes: 3060
// Justice will be served
// شهید حاج قاسم سلیمانی

#include<bits/stdc++.h>
using namespace std ;

int main() {
  int a[3] ;
  cin >> a[0] >> a[1] >> a[2] ;
  sort(a , a + 3) ;
  cout << a[0] + a[1] ;
}

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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc =new Scanner(System.in);
		int n=sc.nextInt();
		int x[]=new int[n];
		for(int i=0;i<n;i++) {
			x[i]=sc.nextInt();
		}
		int y[]=x.clone();
		Arrays.sort(y);
		int l=y[n/2-1];
		int r=y[n/2];
		for(int i=0;i<n;i++) {
			if(x[i]<=l)System.out.println(r);
			else System.out.println(l);
		}
		
	}

}


Measured memory_bytes: 91424
#include <bits/stdc++.h>
using namespace std;
int main(){
 string S;
 string  T;
 bool a=true;
cin>>S>>T;
int h=S.size();
for(int i=0; i<h; i++){
if(S.at(i)==T.at(i)){
}
else
{
a=false;
}

}
if(a==true){
 cout<<"Yes"<<endl;
}
else
{
cout<<"No"<<endl;
}

}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
  REP(i, a.size()) {
    cin >> a[i];
    a[i]--;
  }
}

ll mod = 1000000007;

int main() {
  ll N,M;
  cin>>N>>M;
  vec A(M,-1);
  ll ans=N;
  REP(i,M){
    cin>>A[i];
    ans-=A[i];
  }

  if(ans<0) ans=-1;

  cout<<ans<<endl;

  return 0;


}

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

vector<Int> factorize(Int M){
    vector<Int> res;
    for(int i = 1; i*i <= M; i++) {
        if(M % i == 0){
            res.push_back(i);
            if(i*i != M) res.push_back(M/i);
        }
    }
    sort(res.begin(), res.end(), greater<Int>());
    return res;
}

int main(){
    Int N, M; cin >> N >> M;
    vector<Int> A = factorize(M);

    rep(i, A.size()){
        Int sum = M/A[i];
        if(N > sum) continue;
        cout << A[i] << endl; return 0; 
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int N, M;
int a[1050], b[1050], c[1050][20];

inline bool chmin(int &a,int b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

void input() {
	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		cin >> a[i] >> b[i];
		for (int j = 1; j <= b[i]; j++) cin >> c[i][j];
	}
}

int main() {
	input();
	int INF = 1e9;
	vector<int> dp(5000,INF);
	dp[0] = 0;
	for (int i = 1; i <= M; i++) {
		int now = 0;
		for (int j = 1; j <= b[i]; j++) {
			now |= (1 << (c[i][j] - 1));
		}
		for (int bits = 0; bits < (1 << N); bits++) {
			chmin(dp[bits | now], dp[bits] + a[i]);
		}
	}
	if (dp[(1 << N) - 1] == INF)dp[(1 << N) - 1] = -1;
	cout << dp[(1 << N) - 1] << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;
int main(){
	int i, j, k;
	int t, n;

	cin >> t;

	for(i = 0; i < t; i++){
		int maxup = 0, maxdown = 0;
		cin >> n;
		int* h = new int[n];
		for(j = 0; j < n; j++){
			cin >> h[j];
		}
		for(k = 0; k < n - 1; k++){
			if(h[k] < h[k + 1]){
				if(maxup < h[k + 1] - h[k]){
					maxup = h[k + 1] - h[k];
				}
			}
			else{
				if(maxdown < h[k] - h[k + 1]){
					maxdown =  h[k] - h[k + 1];
				}
			}
		}
		cout << maxup << " " << maxdown << endl;
	}
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 18 10:01:05 2017

@author: syaga
"""

if __name__ == "__main__":
    N = int(input())
    C = list(input().split())
    D = C[:]

    # Bunbble Sort
    for i in range(0, N):
        for j in range(N-1, i, -1):
            if int(C[j][1]) < int(C[j-1][1]):
                temp = C[j]
                C[j] = C[j-1]
                C[j-1] = temp
    print(" ".join(C))
    print("Stable")

    # Selection Sort
    for i in range(0, N):
        minj = i
        for j in range(i, N):
            if int(D[j][1]) < int(D[minj][1]):
                minj = j
        temp = D[i]
        D[i] = D[minj]
        D[minj] = temp
    print(" ".join(D))
    flag = 0
    for (i, j) in zip(C, D):
        if i != j:
            flag = 1
            break
    if flag == 1:
        print("Not stable")
    else:
        print("Stable")

Measured memory_bytes: 7736
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

int main(){

  int n, idx = 0;
  ll a[100010] = {};
  ll x[2] = {};
  cin >> n;
  for(int j = 0; j < n; j++) cin >> a[j];
  sort(a, a+n, greater<ll>());
  for(int i = 0; i < n-1; i++){
    if(a[i] == a[i+1]){
      x[idx++] = a[i];
      i++;
    }
  }
  cout << x[0] * x[1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#
# abc145 c
#

import sys
from io import StringIO
import unittest
import math
import itertools


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
0 0
1 0
0 1"""
        output = """2.2761423749"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2
-879 981
-866 890"""
        output = """91.9238815543"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """8
-406 10
512 859
494 362
-955 -475
128 553
-986 -885
763 77
449 310"""
        output = """7641.9817824387"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    P = [list(map(int, input().split())) for _ in range(N)]

    L = [i for i in range(N)]
    R = itertools.permutations(L)

    all = 0
    for r in R:
        for pi in range(1, len(r)):
            all += math.sqrt((P[r[pi]][0]-P[r[pi-1]][0])**2 +
                             (P[r[pi]][1]-P[r[pi-1]][1])**2)

    n = 1
    for i in range(1, N+1):
        n *= i

    print(f"{all/n:.10f}")


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16292
#include <iostream>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
using namespace std;


int main(void) {
  int n, x;
  cin >> n >> x;
  int cost = 1000000000;
  for(int i = 0; i < n; i++){
    int m;
    cin >> m;
    cost = min(cost, m);
    x -= m;
  }
  cout << n + (x/cost) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;


int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==5 && b==5 && c==7){
    cout<<"YES"<<endl;
  }
  else if(a==5 && b==7 && c==5){
    cout<<"YES"<<endl;
  }
  else if(a==7 && b==5 && c==5){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
int main()
{
    int N;
    std::cin >> N;
    std::vector<int> x(N), y(N), h(N);
    for (int i = 0; i < N; i++) {
        std::cin >> x[i] >> y[i] >> h[i];
    }
    auto ok = [&](const int X, const int Y) {
        int l = 0, r = 1001001001;
        for (int i = 0; i < N; i++) {
            const int H = std::abs(X - x[i]) + std::abs(Y - y[i]) + h[i];
            if (h[i] == 0) {
                r = std::min(r, H);
            } else {
                l = std::max(l, H), r = std::min(r, H);
            }
        }
        return l == r ? l : -1;
    };
    for (int X = 0; X <= 100; X++) {
        for (int Y = 0; Y <= 100; Y++) {
            if (ok(X, Y) != -1) {
                return std::cout << X << " " << Y << " " << ok(X, Y) << std::endl, 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	ll I,O,T,J,L,S,Z;
	cin>>I>>O>>T>>J>>L>>S>>Z;
	ll ans = 0;
	ll t = min({I,J,L});
	if(t>=1) t=1;
	ans = t*3;
	ans += (I-t)/2*2+(J-t)/2*2+(L-t)/2*2;
	ll tmp = I/2*2+J/2*2+L/2*2;
	maxs(ans, tmp);
	cout<<ans+O<<endl;
}	


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long int a, b, ans;
	cin >> a;
	cin >> b;
	if( a > b ){
		long long int temp = a;
		a = b;
		b = temp;
	}
	if( a == 1 ){
		if( b == 1 ){
			ans = 1;
		} else {
			ans = b - 2;
		}
	} else if( a == 2 ){
		ans = 0;
	} else {
		ans = (a-2)*(b-2);
	}
	cout << ans << 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;
using ll=long long;
using P=pair<int,int>;

int main(){
   ll n; cin>>n;
   //対称性
   ll ans=1e18;
   for(ll i=1;i*i<=n;i++){
      if(n%i==0) ans=min(ans,i+(n/i)-2);
   }
   cout<<ans<<endl;
   return 0;
}

   


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

  
// {{{ ModInt
template<int _MOD>
struct ModInt {
    static const auto MOD = _MOD;
    template<class T> using integral_only = typename enable_if<is_integral<T>::value>::type;

    int x;   
    constexpr ModInt() : x() {}

    template<class T, integral_only<T>* = nullptr>
    ModInt(T _x=0) {
        x = _x % MOD;
        if(x<0) x+=MOD;
    }
    ModInt operator-() const { return {x == 0? 0 : MOD-x}; }
    ModInt& operator+=(const ModInt a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt a) {
        x = (long long)x * a.x % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt a) {
        return (*this) *= a.inv();
    }

    ModInt operator+(const ModInt a) const { return ModInt(*this) += a; }
    ModInt operator-(const ModInt a) const { return ModInt(*this) -= a; }
    ModInt operator*(const ModInt a) const { return ModInt(*this) *= a; }
    ModInt operator/(const ModInt a) const { return ModInt(*this) /= a; }
    ModInt inv() const {
        // for prime MOD
        return pow(MOD-2);
    }
    ModInt inv2() const {
        // work for non-prime MOD if gcd(x,MOD) = 1
        int a = x, b = MOD, u = 1, v = 0;
        while(b != 0) {
            int t = a / b;
            a -= t * b;
            u -= t * v;
            swap(a, b);
            swap(u, v);
        }
        return u;
    }
    template<class T, integral_only<T>* = nullptr>
    ModInt pow(T t) const {
        ModInt r = 1, p = *this;
        while(t) {
            if(t & 1) r *= p;
            p *= p;
            t >>= 1;
        }
        return r;
    }

    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    bool operator<(ModInt rhs) const { return x < rhs.x; }
    bool operator<=(ModInt rhs) const { return x <= rhs.x; }
    bool operator>(ModInt rhs) const { return x > rhs.x; }
    bool operator>=(ModInt rhs) const { return x >= rhs.x; }

    friend string to_string(ModInt i) { return to_string(i.x); }
    friend istream& operator>>(istream&i,ModInt&a) { return i>>a.x; }
    friend ostream& operator<<(ostream&o,const ModInt&a) { return o<<a.x; }
};

const int MOD=1000000007;
using mint=ModInt<MOD>;
// }}}
const int N=1e5+5;
mint dp[N][2]; // 0: same with s, 1: smaller

int main() {
    string s;
    cin >> s;
    int n=s.size();
    dp[0][0]=1;
    // ai+bi<=si and ai&bi==ai+bi
    for ( int i=0; i<n; i++ ) {
        if ( s[i]=='0' ) {
            // a+b=0
            dp[i+1][0]+=dp[i][0];
            dp[i+1][1]+=dp[i][1];
            // a+b=1
            dp[i+1][1]+=dp[i][1]*2;
        } else {
            // a+b=0
            dp[i+1][1]+=dp[i][0]+dp[i][1];
            // a+b=1
            dp[i+1][0]+=dp[i][0]*2;
            dp[i+1][1]+=dp[i][1]*2;
        }
    }
    cout << dp[n][0]+dp[n][1] << '\n';
    return 0;
}








Measured memory_bytes: 4480
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAX = 1e5;
char is_exist[MAX + 10];
char is_repeat[MAX + 10];
int d[MAX + 10];
typedef long long ll;
#define debug

void run() {
	
	ll n;
	while(cin >> n) {
		ll num_len = 0, repeat_len = 0;
		memset(is_exist, 0, sizeof(0));
		memset(is_repeat, 0, sizeof(0));
		int t;
		for(int i = 0; i < n; i++) {
			cin >> t;
			if(!is_exist[t]) {
				is_exist[t] = 1;
				num_len++;
			}else {
				if(!is_repeat[t]) {
					repeat_len++;
					is_repeat[t] = 1;
				}else {
					repeat_len--;
					is_repeat[t] = 0;
				}
			}
		}
		ll ans;
		if(repeat_len % 2) {
			ans = num_len - 1;
		}
		else {
			ans = num_len;
		}
		
		cout << ans << endl;
		
	}
}
int main(int argc, char *argv[]) {
	
	run();
		
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    int x, n; cin >> x >> n;
    set<int> s;
    rep(i,n){
        int tmp;
        cin >> tmp;
        s.insert(tmp);
    }

    if (n == 0) {
        cout << x << endl;
        return 0;
    }
    
    if (n == 1) {
        cout << x-1 << endl;
        return 0;
    }

    int left = 0, right = 101;
    for (int i = 1; i <= 100; i++) {
        auto it = s.find(i);
        if (i <= x && it == s.end())
            left = i;
        if (i > x && it == s.end()) {
            right = i;
            break;
        }
    }
    if (abs(left - x) <= abs(right - x)) {
        cout << left << endl;
    } else {
        cout << right << endl;
    }
    return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const 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;
    }
}

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

    ll N;
    cin >> N;
    set<string> s;
    while (N--) {
        string S;
        cin >> S;
        s.insert(S);
    }

    cout << s.size() << "\n";
}

Measured memory_bytes: 19164
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;

void main(){

    int N;
    int[] arr = new int[100];
    string[] s;
    int count = 0;
    readf("%d\n",&N);
    s = split(readln());
    for(int i=0;i<N;i++){
	arr[i] = to!int(s[i]);
    }

    for(int i=0;i<N;i++){
	for(int j=N-1;j>0;j--){
	    if(arr[j] < arr[j-1]) {
		count++;
		swap(arr[j],arr[j-1]);
	    }
	}
    }

    write(arr[0]);
    for(int i=1;i<N;i++){
	writef(" %d",arr[i]);
    } 
    writeln();
    writeln(count);
}

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

int main() {
  int N, R,temp;
  
  cin >> N >> R;
  
  if(N>10){
   cout << R << endl;
  }
  else{
    temp = 100 * (10-N);
    cout << R + temp << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define f first
#define s second
#define mp make_pair
#define sz size()
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	string s;
	cin >> n >> s;
	if(n & 1) cout << "No";
	else {
		for(int i = 0; i < n / 2; ++i) if(s[i] != s[i + n / 2]) cout << "No", exit(0);
		cout << "Yes";
	}
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace A___Biscuit_Generator
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABT = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = ABT[0], B = ABT[1], T = ABT[2];
            int sum = 0;

            Console.WriteLine(T / A * B);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp(26) ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  string s,t;cin>>s>>t;
  if(s[0]==t[2]&&s[2]==t[0]&&s[1]==t[1])cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
    int a[5];
    int sum=0;
    for(int i=0;i<5;i++){
        cin>>a[i];
        sum+=a[i];
    }    
    int r=0;
    vector<int>rem;
    for(int i=0;i<5;i++){
        int r=a[i]%10;
        if(r>0)r=10-r;
        rem.push_back(r);
    }
    sort(rem.begin(),rem.end());
    for(int i=0;i<4;i++)sum+=rem[i];
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<utility>
#include<algorithm>
#include<set>
using namespace std;

int w,h;
pair<int,int> g[50][50];
int s[50][51];

void dfs(int x,int y,int xx,int yy){
    g[x][y]=make_pair(xx,yy);
    for(int i=max(0,x-1);i<min(x+2,h);i++){
        for(int j=max(0,y-1);j<min(y+2,w);j++){
            if(s[i][j]&&(g[i][j].first!=xx||g[i][j].second!=yy)){
                dfs(i,j,xx,yy);
            }
        }
    }
}

int main(){
    scanf("%d%d",&w,&h);
    while(w&&h){
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                scanf("%d",&s[i][j]);
            }
        }
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                g[i][j]=make_pair(i,j);
            }
        }
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(s[i][j]==1&&g[i][j].first==i&&g[i][j].second==j){
                    dfs(i,j,i,j);
                }
            }
        }
        set<pair<int,int> > se;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(s[i][j]==1){
                    se.insert(g[i][j]);
                }
            }
        }
        printf("%ld\n",se.size());
        scanf("%d %d",&w,&h);
    }
}


Measured memory_bytes: 2984