akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int m,tr[3][1100005],tg[1100005],pw3[13],a[1100005],cnt=0,n,ans[1100005];
char s[200005];
void build(int p,int f,int num)
{
	//printf("@%d %d %d %d\n",p,f,num,n);
	if(f==n)
	{
		//printf("#%d %d\n",p,num);
		a[p]=num;
		return;
	}
	tr[0][p]=++cnt;
	tr[1][p]=++cnt;
	tr[2][p]=++cnt;
	build(tr[0][p],f+1,num);
	build(tr[1][p],f+1,num+pw3[f]);
	build(tr[2][p],f+1,num+2*pw3[f]);
}
void push(int p)
{
	swap(tr[1][p],tr[2][p]);
	tg[p]=0;
	tg[tr[1][p]]^=1;tg[tr[2][p]]^=1;tg[tr[0][p]]^=1;
}
void opt(int p,int f)
{
	if(f==n)return;
	if(tg[p])push(p);
	swap(tr[1][p],tr[2][p]);
	swap(tr[0][p],tr[1][p]);
	opt(tr[0][p],f+1);
}
void dfs(int p,int f,int num)
{
	if(f==n)
	{
		ans[a[p]]=num;
		return;
	}
	if(tg[p])push(p);
	dfs(tr[0][p],f+1,num);
	dfs(tr[1][p],f+1,num+pw3[f]);
	dfs(tr[2][p],f+1,num+2*pw3[f]);
}
int main()
{
	pw3[0]=1;
	for(int i=1;i<=12;i++)pw3[i]=pw3[i-1]*3;
	scanf("%d",&n);
	scanf("%s",s+1);
	m=strlen(s+1);cnt=1;
	build(1,0,0);
	for(int i=1;i<=m;i++)
	{
		if(s[i]=='S')tg[1]^=1;
		else opt(1,0);
	}
	dfs(1,0,0);
	for(int i=0;i<pw3[n];i++)printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 21772
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

ll dp[100][100001];
ll n,m,k;
int main(){
    while(1) {
        cin >> n >> m >> k;

        if(n == 0) 
            break;

        REP(i,n + 1) {
            REP(j,n * m + 1) {
                dp[i][j] = 0;
            }
        }
        dp[0][0] = 1;

        FOR(i,1,n + 1) {
            REP(j,n * m + 1) {
                if(j > 0) {
                    dp[i][j] = dp[i][j - 1];
                }
                if(j - m - 1 >= 0) {
                    dp[i][j] -= dp[i - 1][j - m - 1];
                }
                if(j - 1 >= 0) {
                    dp[i][j] += dp[i - 1][j - 1];
                }
            }
        }

        double ans = 0;
        double d = 1;

        REP(i,n) {
            d *= (1.0 / m);
        }

        REP(i,n * m + 1) {
            ans += ((max(1ll,i - k) * dp[n][i] * 1.0) * d);
        }

        printf("%0.10f\n",ans);
    }
}




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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  cout << s.substr(0, 3) << endl;
}


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


using ll = long long;
ll modinv(ll a, ll m) {
	assert(m > 0);
	if (m == 1) return 0;
	a %= m;
	if (a < 0) a += m;
	assert(a != 0);
	if (a == 1) return 1;
	return m - modinv(m, a) * m / a;
}

template <int MOD_> struct modnum {
private:
	int v;
public:
	static const int MOD = MOD_;

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int () const { return v; }
	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum operator ~ () const {
		modnum res;
		res.v = modinv(v, MOD);
		return res;
	}

	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= (~o);
	}

	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};

using num = modnum<int(1e9) + 7>;

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
		a[i]--;
	}
	vector<pair<int,int> > sums;
	int cur = -1;
	int cmax = 0;
	for(int i = 0; i < n; i++){
		cmax = max(a[i], cmax);
		if(cmax == i){
			int y = -1;
			int z = -1;
			int cy = 0;
			int cz = 0;
			for(int v = cur + 1; v <= i; v++){
				if(a[v] >= z){
					z = a[v];
					cz++;
				} else if(a[v] >= y){
					y = a[v];
					cy++;
				} else {
					cout << 0 << '\n';
					return 0;
				}
			}
			sums.push_back({cy, cz});
			cur = i;
		}
	}
	vector<num> dp(n+1, 0);
	dp[0] = 1;
	for(pair<int,int> v : sums){
		vector<num> newdp(n+1, 0);
		for(int i = 0; i + v.first <= n; i++) newdp[i+v.first] += dp[i];
		for(int i = 0; i + v.second <= n; i++) newdp[i+v.second] += dp[i];
		dp = newdp;
	}
	num ans = 0;
	for(int i = 0; i <= n; i++){
		if(i <= m && n-i <= m) ans += dp[i];
	}
	cout << (int)ans << '\n';
}


Measured memory_bytes: 3272
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = (int)1e9 + 7;

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

    map<int, bool> mp;
    REP(i, 4){
        int x;
        cin >> x;
        mp[x] = true;
    }
    if(mp[1] && mp[9] && mp[7] && mp[4]) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int r;
    cin >> r;
    cout << (r < 1200 ? "ABC" : (r < 2800 ? "ARC" : "AGC")) << endl;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if((a+b)/2.0 - (a+b)/2 >= 0.5) {
        cout << (a+b)/2 + 1<< endl;    
    } else {
        cout << (a+b)/2 << endl;
    }
    
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int a[210];
int main(){
	int x,y;
	cin>>x>>y;
	a[1]=300000;a[2]=200000;a[3]=100000;
	if(x==1&&y==1){
		cout<<a[x]+a[y]+400000<<endl;
	}
	else  cout<<a[x]+a[y]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL <<60;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始
ll dp[100100][3];
ll a [100100][3];

int main(){
  int n;
  cin>>n;
  
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 3; j++){
      cin>>a[i][j];
    }
  }
  // 初期化不要（最大値問題のため、すでに初期化できている現状で問題なし）
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < 3; k++){
        if(j==k) continue;
        chmax(dp[i+1][k], dp[i][j]+a[i][k]);
      }
    }
  }
  ll ans = 0;
  for(int i = 0; i < 3; i++){
    ans=max(ans,dp[n][i]);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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 (a>b) { a=b; return 1; } return 0; }

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

    int K,X; cin >>  K >> X;
    for(int i = X-K+1; i < X + K -1; i++) {
        cout << i << " ";
    }
    cout << X + K -1 << endl;
    return 0;



}



Measured memory_bytes: 256
N, A, B = [int(a) for a in input().split()]
S = input()
ans = []
npas = 0
npas_b = 0

for i in range(N):
    if S[i] == 'c':
        ans.append('No')
    else:
        if S[i] == 'a':
            if npas < A+B:
                ans.append('Yes')
                npas += 1
            else:
                ans.append('No')
        elif S[i] == 'b':
            if npas < A+B and npas_b < B:
                ans.append('Yes')
                npas += 1
                npas_b += 1
            else:
                ans.append('No')
                npas_b += 1

for a in ans:
    print(a)


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

namespace aoj_ALDS1_4_A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
			int couny_S = int.Parse(Console.ReadLine());
			int[] S = Console.ReadLine().Split(' ').Select(item => int.Parse(item)).ToArray();

			int couny_T = int.Parse(Console.ReadLine());
            int[] T = Console.ReadLine().Split(' ').Select(item => int.Parse(item)).ToArray();

			int matchCount = 0;
            foreach (var item in T)
			{
                foreach (var item2 in S)
				{
					if (item == item2) 
					{
						matchCount++;
						break;
					}
				}
			}

			Console.WriteLine(matchCount);
        }
    }
}



Measured memory_bytes: 18316
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    vector<int> B(N);
    for (int i = 0; i < N-1; ++i) {
        cin >> B[i];
    }

    vector<int> A(N, 0);
    A[0] = B[0];
    for (int i = 1; i < N-1; ++i) {
        A[i] = min(B[i-1], B[i]);
    }
    A[N-1] = B[N-2];

    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        ans += A[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
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;
}

int main() {
	int a, b;
	cin >> a >> b;
	cout << a * b;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

int main(){
    ios::sync_with_stdio(false);
    int x,y,z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    return 0;
}

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

int main() {
  int n, m;
  while (cin >> n >> m, n) {
    bool used[1010] = {};
    int cnt = 0;
    vector<int> ans;
    for (int i = 0; ans.size() < n; ++i) {
      i %= n;
      if (used[i]) continue;
      cnt++;

      if (cnt == m) {
        used[i] = true;
        cnt = 0;
        ans.push_back(i + 1);
      }
    }

    cout << ans.back() << endl;
  }
}

Measured memory_bytes: 3024
#include "bits/stdc++.h"

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
int main() {
  int N,a,b;
  string s;
  cin >> N >> a >> b;
  cin >> s;
  a+=b;
  rep(i, N) {
    if (s[i] == 'a') {
      if (a > 0) {
        a--;
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    } else if (s[i] == 'b') {
      if (a > 0 and b > 0) {
        a--;
        b--;
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);


*/



Measured memory_bytes: 896
package main

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

func main() {
	v := ReadInts(5)
	k := ReadInt()

	ok := true
	for i := 0; i < 5; i++ {
		for j := 0; j < 5; j++ {
			if Abs(v[i]-v[j]) > k {
				ok = false
				break
			}
		}
	}
	if ok {
		fmt.Println("Yay!")
	} else {
		fmt.Println(":(")
	}
}

func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		long ans = 0;
		
		int[] a = new int[N];
		
		for(int i = 0; i < N; i++){
			a[i] = sc.nextInt();
		}
		
		Arrays.sort(a);
		
		if(N >= K){
			for(int i = 0; i < N - K; i++){
				ans = ans + a[i];
			}
		} else {
			ans = 0;
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 50500
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
using namespace std;
 
 
int main() {
    long n;
    cin >> n;
    map<long,long> mp;
    bool ans=1;
    for(long i=0;i<n;i++){
        long s;
        cin >>s;
        auto itr =mp.find(s);
        if(itr!=mp.end()) ans=0;
        else mp[s]=1;
    }
    if(ans) cout <<"YES" << endl;
    else cout <<"NO" << endl;
}
 



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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

class UnionFind{
private:
	vector<int> par; //�e
	vector<int> sizes; //�f�[�^�̐�

public:
	UnionFind(int n){ 
		par.resize(n);
		sizes.resize(n);
		for(int i = 0; i < n; i++){
			par[i] = i;
			sizes[i] = 1;
		}
	}
	//�؂̍������߂�
	int find(int x){
		if(par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	//x��y�̑�����W���𕹍�
	void unite(int x,int y){
		x = find(x); //x,y�͊e�f�[�^�̍��m�[�h�𓾂�
		y = find(y);
		if(x == y) return;
		//if (sizes[x] < sizes[y]) swap(x,y);
		par[y] = x; //x��y�̐e�ƂȂ�悤�ɘA������
		sizes[x] += sizes[y];
	}
	//x��y�������W���ɑ����邩�ۂ�
	bool same(int x, int y){
		return find(x) == find(y);
	}
	//x��������W���̃f�[�^��
	int size(int x){
		return sizes[find(x)];
	}
};

int main()
{
	IOS;
	int n,m;
	cin >> n >> m;
	vi a(m),b(m);
	rep(i,m){
		cin >> a[i] >> b[i];
		a[i]--,b[i]--;
	}
	UnionFind uni(n);
	vector<ll> ans(m);
	ans[m-1] = (ll)n*(n-1)/2;
	for(int i = m-1; i >= 1; i--){
		ans[i-1] = ans[i];
		if(!uni.same(a[i],b[i])){
			ans[i-1] -= (ll)uni.size(a[i])*uni.size(b[i]);
			uni.unite(a[i],b[i]);
		}
	}
	rep(i,m) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;
const bool debug = 0;
//---------------------------------//

int A, B, C, D;
int imos[300];

int main() {
	cin >> A >> B >> C >> D;
	
	imos[A]++;
	imos[B]--;
	
	imos[C]++;
	imos[D]--;
	
	FOR(i, 1, 300) imos[i] += imos[i - 1];
	
	int ans = 0;
	REP(i, 300) if (imos[i] == 2) ans++;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    V<> a(3);
    rep(i, 3) cin >> a[i];
    int k;
    cin >> k;
    sort(all(a));
    rep(i, k) a[2] *= 2;
    ll ans = a[0] + a[1] + a[2];
    cout << ans << endl;
}

Measured memory_bytes: 3576
import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def Main():
    a, b = read_ints()
    print(100, 100)
    grid = [['#']*100 for _ in range(50)] + [['.']*100 for _ in range(50)]
    for i in range(~-a):
        x, y = divmod(i, 49)
        grid[x * 2 + 1][y * 2 + 1] = '.'
    for i in range(~-b):
        x, y = divmod(i, 49)
        grid[x * 2 + 51][y * 2 + 1] = '#'
    print(*[''.join(g) for g in grid], sep='\n')

if __name__ == '__main__':
    Main()

Measured memory_bytes: 9272
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=0;i<=(n);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int INF = 10000000;

int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			int n = int.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int ans = saiki(n, 0, false, false, false);
			Console.WriteLine(ans);


			Console.Out.Flush();
		}

		static int saiki(int n, int x, bool f3, bool f5, bool f7)
		{
			int result = 0;
			if (f3 && f5 && f7) {
				result++;
			}
			//System.Diagnostics.Debug.WriteLine($"{x} {f3 && f5 && f7}");

			long i = (long)x * 10 + 3;
			if (i <= n) { result += saiki(n, (int)i, true, f5, f7); }
			i = (long)x * 10 + 5;
			if (i <= n) { result += saiki(n, (int)i, f3, true, f7); }
			i = (long)x * 10 + 7;
			if (i <= n) { result += saiki(n, (int)i, f3, f5, true); }

			return result;
		}
	}
}


Measured memory_bytes: 13140
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

N, M, C = map(int, raw_input().split())
B = map(int, raw_input().split())

ans = 0
for _ in range(N):
    A = map(int, raw_input().split())
    S = C
    for i in range(M):
        S += A[i] * B[i]
    if S > 0:
        ans += 1

print ans

Measured memory_bytes: 2812
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a_s: [usize; n],
    }
    let mut a_s = a_s.iter().enumerate().collect::<Vec<_>>();
    a_s.sort_by(|x, y| y.1.cmp(x.1));
    let max = a_s[0];
    let next = a_s[1];
    for i in 0..n {
        if max.0 == i {
            println!("{}", next.1);
        } else {
            println!("{}", max.1);
        }
    }
}


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

namespace _20200502
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] inputLongArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();


            int x = inputLongArray[0] / n;//商
            int y = inputLongArray[0] % n;//あまり

            int a = inputLongArray[0] - n * x;
            int b = inputLongArray[1] - n * x;

            if (n<= inputLongArray[1]+1 - inputLongArray[0] ) { Console.WriteLine("OK"); }
            else if (a == n) { Console.WriteLine("OK"); }
            else if (b == n) { Console.WriteLine("OK"); }
            else if (a == 0) { Console.WriteLine("OK"); }
            else if (b == 0) { Console.WriteLine("OK"); }
            else if (a< n && b < n) { Console.WriteLine("NG"); }
            else
            { 
                Console.WriteLine("OK"); 
            
            
            }

        }
    }
}


Measured memory_bytes: 28304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (ll i = (a); i < (n); i += (s))
#define rep(...) _overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> inline void chmax(T& a, const T& b) {if (a < b) a = b;}
template<typename T> inline void chmin(T& a, const T& b) {if (a > b) a = b;}
template<typename T> inline void print(const T& x) {cout << x << "\n";}
struct Init {Init() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} init;

int main() {
    string s;
    cin >> s;
    reverse(all(s));
    ll idx = 0;
    bool isOk = true;
    while (idx < sz(s)) {
        string sub5 = s.substr(idx, 5);
        string sub6 = s.substr(idx, 6);
        string sub7 = s.substr(idx, 7);
        if (idx + 5 <= sz(s) and sub5 == "maerd") {
            idx += 5;
        }
        else if (idx + 7 <= sz(s) and sub7 == "remaerd") {
            idx += 7;
        }
        else if (idx + 5 <= sz(s) and sub5 == "esare") {
            idx += 5;
        }
        else if (idx + 6 <= sz(s) and sub6 == "resare") {
            idx += 6;
        }
        else {
            isOk = false;
            break;
        }
    }
    if (isOk) print("YES");
    else print("NO");
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#define maxn 105
#define int long long

using namespace std;

int a[maxn], n, x;

signed main(){
	scanf("%lld%lld", &n, &x);
	
	for (int i = 1; i <= n; i++) scanf("%lld", a + i);
	sort(a + 1, a + n + 1);
	
	int i = 1, sum = 0;
	while (i < n){
		sum += a[i];
		if (sum > x) break;
		i++;
	} --i;
	if (i == n - 1){
		if (a[n] == x - sum) i++;
	}
	printf("%lld\n", i);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

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

    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    cout << a[N-1] - a[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mx = 300000;
bool sieve[mx];
int ps[mx];
int main() {
  fill(sieve + 2, sieve + mx, 1);
  for (int i = 2; i < mx; i++) if (sieve[i]) for (int j = 2 * i; j < mx; j += i) sieve[j] = false;
  for (int i = 1; i < mx; i++) ps[i] = ps[i - 1] + sieve[i];
  while (true) {
    int n; cin >> n; if (n == 0) return 0;
    cout << ps[2 * n] - ps[n] << endl;
  }
}


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

int main() {
    int a, b;
    cin >> a >>b;
    int count = 0;
    while (a!=0 || b!=0) {
        for (int i=1; i<=a-2; i++) {
            for (int j=i+1; j <= a-1; j++) {
                for (int k=j+1; k<=a; k++) {
                    if (i+j+k==b) count++;
                }
            }
        }
        cout << count << endl;
        count = 0;
        cin >> a >>b;
    }
    return 0;
}


Measured memory_bytes: 3100
/**
 *    author:  accesss_denied
**/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;			
ll inf=1e18;

int main() {
			fast
			// #ifndef ONLINE_JUDGE
			// freopen("input.txt","r",stdin);
			// freopen("output.txt","w",stdout);
			// #endif

			
				ll n;
				cin>>n;
				ll arr[n];
				for(ll i=0;i<n;i++)
				{
					cin>>arr[i];
				}
				ll ans=0;
				ll mx=arr[0];

				for(ll i=1;i<n;i++)
				{
					if(arr[i]<mx)
					{
						ans+=(mx-arr[i]);
					}
					mx=max(mx,arr[i]);
				}
				cout<<ans;

				
                
			
			return 0;
		 }	




Measured memory_bytes: 5216
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

const int V = 100010;
P a[100010], b[100010];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    rep(i, 0, V){
        a[i].second = i;
        b[i].second = i;
    }
    rep(i, 0, n){
        int c;
        cin >> c;
        c--;
        if(i % 2 == 0) a[c].first++;
        else b[c].first++; 
    }
    sort(a, a + V);
    sort(b, b + V);
    reverse(a, a + V);
    reverse(b, b + V);
    int ans = n;
    if(a[0].second == b[0].second){
        ans = min(n - a[0].first - b[1].first, n - a[1].first - b[0].first);
    }else{
        ans = n - a[0].first - b[0].first;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
def solve(string):
    n, *a = map(int, string.split())
    m1, m2 = sorted(a)[::-1][:2]
    return "\n".join(map(str, [m2 if _a == m1 else m1 for _a in a]))


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))


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

using namespace std;

typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin>>n;
  ll h[n+1];
  for(ll i=1;i<=n;i++)
  {
  cin>>h[i];
  }
  ll dp[n+1];
  dp[1]=0;
  dp[2]=abs(h[2]-h[1]);
  for(ll i=3;i<=n;i++)
  {
  dp[i]=min((dp[i-1]+abs(h[i]-h[i-1])),(dp[i-2]+abs(h[i]-h[i-2])));
  }
  cout<<dp[n];
}


Measured memory_bytes: 5176
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;

using namespace std;
ll MOD = 1000000000 + 7;
ll c[100050][13];
int initCount(){
    for(ll yi = 0; yi < 100050; yi++){
        for(ll xi = 0; xi < 13; xi++){
            c[yi][xi] = -1;
        }
    }
}

ll solve(ll y, ll x,string& s){
    if(c[y][x] != -1){
        return c[y][x];
    }
    if(s[y] != '?'){
        //全部の値を更新
        int tmp = s[y] - '0';
        for(ll xi = 0; xi < 13; xi++){
            c[y][(xi * 10 + tmp) % 13] = solve(y-1,xi,s) % MOD;
        }
        return c[y][x];
    }
    //はてなの時の処理
    for(int tmp = 0; tmp < 10; tmp++){
        for(ll xi = 0; xi < 13; xi++){
            if(tmp == 0){
                c[y][(xi * 10 + tmp) % 13] = solve(y - 1,xi,s) % MOD;
            }else{
                c[y][(xi * 10 + tmp) % 13] += solve(y - 1,xi,s) % MOD;
            }
        }
    }
    return c[y][x];
}

int main() {
    string s;
    cin >> s;
    initCount();
    for(ll xi = 0; xi < 13; xi++){
        c[0][xi] = 0;
    }
    if(s[0] != '?'){
        c[0][s[0] - '0'] = 1;
    }else{
        for(int i = 0; i < 10; i++){
            c[0][i] = 1;
        }
    }
    ll ans = solve(s.size() - 1,5,s) % MOD;
    cout << ans << endl;


}


Measured memory_bytes: 18432
#include<stdio.h>
#include<stdlib.h>
int cmp(const void*a,const void*b){
  return *(int*)a-*(int*)b;}
int main(){
  int a[3];
  int i;
  for(i=0;i<3;i++)
    scanf("%d",&a[i]);
  qsort(a,3,sizeof(int),cmp);
  printf("%d\n",a[0]+a[1]);
  return 0;}


Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	vector<int> a,b;
	for (int i=0;i<n;i++){
		for (int j=0;j<m;j++){
			int temp;
			cin>>temp;
			a.push_back(temp);
		}
	}
	for (int i=0;i<m;i++){
		int temp;
		cin>>temp;
		b.push_back(temp);
	}
	for (int i=0;i<n;i++){
		int c=0;
		for (int j=0;j<m;j++){
			c+=a[m*i+j]*b[j];
		}
		cout<<c<<endl;
	}
	return 0;
}

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

int main(){
    int n=0,ans=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int j=0;j<n;j++){
        for(int l=j+1;l<n;l++){
            ans = ans + (a[j]*a[l]);
        }
    }
   cout <<ans;
}

Measured memory_bytes: 256
n = int(input())
md = {'M':0, 'A':0 , 'R':0, 'C':0, 'H':0}
for _ in range(n):
    s = input()
    if s[0] in md:
        md[s[0]] += 1

vs = []
for v in md.values():
    vs.append(v)

ans = 0
for i in range(5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            ans += vs[i]*vs[j]*vs[k]

print(ans)

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];

    long long sum1 = 0, res1 = 0;
    for (int i = 0; i < N; i++) {
        sum1 += A[i];
        if (i % 2 == 0 && sum1 <= 0) {
            res1 += 1 - sum1;
            sum1 = 1;
        }
        if (i % 2 == 1 && sum1 >= 0) {
            res1 += sum1 + 1;
            sum1 = -1;
        }
    }

    long long sum2 = 0, res2 = 0;
    for (int i = 0; i < N; i++) {
        sum2 += A[i];
        if (i % 2 == 0 && sum2 >= 0) {
            res2 += 1 + sum2;
            sum2 = -1;
        }
        if (i % 2 == 1 && sum2 <= 0) {
            res2 += 1 - sum2;
            sum2 = 1;
        }
    }

    cout << min(res1, res2) << endl;
    return 0;
}

Measured memory_bytes: 640
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

string s;
vi alpha(3);
int t;
int formula(int a){
	int out=-1;
	if(s[t]=='(')++t,out=formula(0);
	else if(s[t]=='-')++t,out=2-formula(1);
	else if(isdigit(s[t]))out=s[t]-'0';
	else if(isalpha(s[t]))out=alpha[s[t]-'P'];
	
	if(a)return out;
	t++;
	
	if(s[t]=='*')		++t,out=min(out,formula(0));
	else if(s[t]=='+')	++t,out=max(out,formula(0));
	return out;
}
void f(){
	int co=0;
	rep(P,3)rep(Q,3)rep(R,3){
		alpha[0]=P;
		alpha[1]=Q;
		alpha[2]=R;
		if(formula(t=0)==2)co++;
	}
	cout<<co<<endl;
}
int main(){while(cin>>s,s!=".")f();}





Measured memory_bytes: 3028
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  // 全探索、x,y,zは10**2以下
  int N;
  cin >> N;
  vector<int> ans(N+1);  // 1-indexed
  for (int i = 1; i < 1001; i++) {
    for (int j = 1; j < 1001; j++) {
      for (int k = 1; k < 1001; k++) {
        int target = i*i + j*j + k*k + i*j + j*k + k*i;
        if (target>N) break;
        ans[target]++;
      }
    }
  }
  for (int i = 1; i < N+1; i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll n,a,b[100010]={},c=0;
  cin>>n;
  fr(i,n){cin>>a;b[a]++;b[a+1]++;b[a+2]++;}
  fr(i,1e5) c=max(c,b[i]);
  cout<<c<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){

  char w[101];
  scanf("%s", w);
  int count_alp[26];
  for (int i = 0; i < 26; i++) {
    count_alp[i] = 0;
  }
  for (int i = 0; i < 101; i++) {
    if (w[i] < 'a' || w[i] > 'z') {
      break;
    }
    count_alp[w[i]-'a']++;
  }
  int flag = 1;
  for (int i = 0; i < 26; i++) {
    if (count_alp[i]%2 != 0) {
      flag = 0;
      break;
    }
  }
  if (flag == 1) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <math.h>
const long long mod = 1000000007;
//const long long mod = 998244353;
class Combination {
	int MAX;
	int mod;
	long long *kai;
	long long modpow(long long a, long long n) {
		long long res = 1;
		while (n > 0) {
			if (n & 1) res = res * a % mod;
			a = a * a % mod;
			n >>= 1;
		}
		return res;
	}
	long long modinv(long long a) {
		return modpow(a, mod - 2);
	}
	void Init() {
		for (int i = 1; i < MAX; i++) {
			kai[i] = kai[i - 1] * i;
			kai[i] %= mod;
		}
	}
public:
	Combination(int max, int mod) :mod(mod), MAX(max + 5) {
		kai = new long long[max + 5]{ 1 };
		Init();
	}
	~Combination() {
		delete[] kai;
	}
	long long operator()(int n, int k) {
		if (n < 0 || k < 0 || n < k)return 0;
		long long res = kai[n];
		res *= modinv(kai[k]);
		res %= mod;
		res *= modinv(kai[n - k]);
		res %= mod;
		//printf("%d C %d = %d\n", n, k, res);
		return res;
	}
};
int main() {
	int N, K;
	scanf("%d %d", &N, &K);
	Combination nck(N, mod);
	int *A = new int[N];
	for (int i = 0; i < N; i++)scanf("%d", A + i);
	std::sort(A, A + N);
	long long res = 0;
	for (int i = 0; i < N - 1; i++) {
		res += (A[N - 1 - i] * nck(N - i - 1, K - 1));
		res %= mod;
		res += mod - (A[i] * nck(N - i - 1, K - 1)) % mod;
		res %= mod;
	}
	printf("%lld", res);
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>

using namespace std;

const int MAX_N = 12 + 1;
const double INF = 1e12;
int n, W;
double dp[1 << MAX_N][MAX_N];  // DPテーブル
double d[MAX_N][MAX_N];

vector<int> ToRadius(const string &s)
{
    vector<int> res;

    for (int i = 0; i < s.size(); i++) {
        if (isdigit(s[i])) {
            int r = s[i] - '0';

            while (isdigit(s[i + 1])) {
                r *= 10;
                r += s[++i] - '0';
            }
            res.push_back(r);
        }
    }
    return res;
}

void solve()
{
    for (int S = 0; S < 1 << n; ++S)
        fill(dp[S], dp[S] + n, INF);
    dp[(1 << n) - 1][0] = 0;

    for (int S = (1 << n) - 2; S >= 0; --S) 
        for (int v = 0; v < n; ++v) 
            for (int u = 0; u < n; ++u)
                if (!(S >> u & 1))
                    dp[S][v] = min(dp[S][v], dp[S | 1 << u][u] + d[v][u]);

    if (W - dp[0][0] >= 0.0)
        cout << "OK\n";
    else
        cout << "NA\n";
}

int main()
{
    string s;

    while (getline(cin, s)) {
        vector<int> c = ToRadius(s + " ");

        W = c[0];
        n = c.size();
        c[0] = 0;

        for (int i = 0; i < n; i++)
            d[0][i] = d[i][0] = (double)c[i];

        for (int i = 1; i < n; i++) 
            for (int j = 1; j < n; j++) 
                d[i][j] = d[j][i] = 2 * sqrt((double)c[i] * c[j]);

        solve();
    }

    return 0;
}

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

int main() {
  string s; cin >> s;
  int n = s.size();
  vector<int> ans(n);
  int pnt1;
  int pnt2 = 0;
  rep(i, n) {
    if(s[i] == 'R' && s[i+1] == 'L') {
      pnt1 = i;
    } else if((s[i] == 'L' && s[i+1] == 'R') || i == n-1) {
      if ((pnt1 - pnt2 + 1) % 2 == 0) {
        ans[pnt1] += (pnt1 - pnt2 + 1) / 2; 
        ans[pnt1+1] += (pnt1 - pnt2 + 1) / 2;
      } else if ((pnt1 - pnt2 + 1) % 2 == 1) {
        ans[pnt1] += (pnt1 - pnt2) / 2 + 1;
        ans[pnt1+1] += (pnt1-pnt2) / 2;
      }
      pnt2 = i + 1;
      int lpnt = pnt2 - 1;
      if ((lpnt - pnt1 + 1) % 2 == 0) {
        ans[pnt1] += (lpnt - pnt1 + 1) / 2 - 1; 
        ans[pnt1+1] += (lpnt - pnt1 + 1) / 2;
      } else if ((lpnt - pnt1 + 1) % 2 == 1) {
        ans[pnt1] += (lpnt - pnt1) / 2;
        ans[pnt1+1] += (lpnt - pnt1) / 2;
      }
    }
  }
  rep(i, n-1) {
    cout << ans[i] << ' ';
  }
  cout<<ans[n-1] <<  endl;
}

Measured memory_bytes: 1024
while 1:
	n,r = map(int,raw_input().split())
	if n == 0: break
	card = range(n,0,-1)
	for i in range(r):
		p,c = map(int,raw_input().split())
		card = card[p-1:p-1+c] + card[:p-1] + card[p-1+c:]
	print card[0]

Measured memory_bytes: 4204