akhauriyash/Code-Regression huggingface dataset:
//
//  abc169_f.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 998244353;
ll INF = 1000000007;
#define PI 3.14159265

ll modpow (int x, int n) {
  if (n==0) return 1%mod;
  ll u = modpow(x, n/2);
  u = (u*u)%mod;
  if (n%2==1) u = (u*x)%mod;
  return u;
}

int main() {
  int n, s;
  std::cin >> n >> s;
  int a[n];
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
  }

  ll dp[n][s+1];

  for (int i = 0; i < s+1; i++) {
    dp[0][i] = 0;
  }
  dp[0][a[0]] = 1;
  dp[0][0] = 1;

  for (int i = 1; i < n; i++) {
    for (int j = 0; j < s+1; j++) {
      dp[i][j] = (dp[i-1][j]*2) % mod;
      if (j-a[i] > 0) dp[i][j] = (dp[i][j] + dp[i-1][j-a[i]]) % mod;
      else if (j-a[i] == 0) dp[i][j] = (dp[i][j] + modpow(2, i)) % mod;
    }
  }

  // ll ans = 0;
  // for (int i = 0; i < n; i++) {
  //   ans = (ans + COM(i+1, dp[i][s])) %mod;
  // }

  // std::cout << ans << std::endl;
  std::cout << dp[n-1][s] << std::endl;

  return 0;
}

Measured memory_bytes: 73916
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int a[3];
 cin>>a[0]>>a[1]>>a[2];
 sort(a,a+3);
 if(a[0]==5 && a[1]==5 && a[2]==7)
 cout<<"YES"<<endl;
 else
 cout<<"NO"<<endl;
 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 2 * 105000;

class Fenwick {
private:
  vector <long long> f;
public:
  void init(int n) {
    f.assign(n, 0);
  }
  void update(int pos, int delta) {
    for (; pos < sz(f); pos = (pos | (pos + 1))) {
      f[pos] += delta;
    }
  }
  long long sum(int pos) {
    long long res = 0;
    for (; pos >= 0; pos = (pos & (pos + 1)) - 1) {
      res += f[pos];
    }
    return res;
  }
  long long sum(int l, int r) {
    return sum(r) - sum(l - 1);
  }
};

int n, k;
int a[MAXN];
vector< pair<long long, int> > v;

int main() {

  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    a[i] -= k;
  }

  long long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    v.push_back({sum, i});
  }
  sort(all(v));

  Fenwick f;
  f.init(n);

  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (v[i].first >= 0) {
      ans++;
    }
    ans += f.sum(0, v[i].second);
    f.update(v[i].second, 1);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 7152
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define INF 2000000000
#define PI 3.1415926535897932384626
const ll MOD=1e9+7;
char a[105],b[105];
int main(){
        int n;
        while(~getI(n)){
                scanf("%s%s",a,b);
                F(i,0,n) printf("%c%c",a[i],b[i]);
                puts("");
        }
}

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

#define ll long long
#define f(i, x, n) for (int i = x; i < n; i++)

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x-a) < abs(x-b))
        cout << "A" << endl;
    else cout << "B" << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
X = list(map(int, input().split()))
R = [1]*N
for _ in range(M):
    x, y = map(int, input().split())
    x, y = x-1, y-1
    if X[x] > X[y]:
        R[y] = 0
    elif X[y] > X[x]:
        R[x] = 0
    else:
        R[x] = 0
        R[y] = 0
c = 0
for i in R:
    if i==1:
        c += 1
print(c)


Measured memory_bytes: 84844
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;
#define int long long

#define fr(s,n,i) for(int i=s;i<n;i++)
#define fr_(s,n,i) for(int i=s;i>=n;i--)
#define srt(v) sort(v.begin(), v.end())
#define upr(v, aim, ind) int ind; ind=(int)distance(v.begin(), upper_bound(v.begin(),v.end(), aim));
#define sz(v) (int)v.size()
#define ers(v, i) v.erase(v.begin() + i)
#define swp(v, i, j) int buf = v[j]; v[j] = v[i]; v[i] = buf;
#define shout(a) cout << a << endl;
#define dshout(a) printf("%.16f\n", a);
#define vi vector<int>
#define iinp(a) int a; cin >> a;
#define sinp(a) string a; cin >> a;
#define dinp(a) double a; cin >> a;
#define ios() ios_base::sync_with_stdio(0);cin.tie(0);

int MOD = 1000000007;

void solve();

signed main() {
    ios()
    solve();
    return 0;
}
vi arms(32);
void solve(){
    int arm = 1LL << 31;
    fr(0,32,i){
        arms[i] = arm;
        arm>>=1;
    }
    iinp(N);
    vi xs(N);vi ys(N);
    bool even = true;
    bool odd = true;
    fr(0,N,i){
        cin >> xs[i];
        cin >> ys[i];
        if((xs[i]+ys[i])%2){
            even = false;
        } else {
            odd = false;
        }
    }
    if(!even && !odd){
        shout(-1)
        return;
    }
    if(even){
        arms.push_back(1);
    }
    shout(sz(arms))
    fr(0,sz(arms),i){
        cout << arms[i];
        if(i != sz(arms)-1){
            cout << " ";
        }
    }
    cout << endl;
    fr(0,N,i){
        int bx = xs[i], by = ys[i];
        fr(0,sz(arms),j){
            int a = arms[j];
            if(abs(bx) >= abs(by)){
                if(bx < 0){
                    bx += a;
                    cout << 'L';
                } else {
                    bx -=a;
                    cout << 'R';
                }
            } else {
                if(by < 0){
                    by +=a;
                    cout << 'D';
                } else {
                    by -=a;
                    cout << 'U';
                }
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    char c; cin >> c;
    if (isupper(c)){
        cout << "A" << endl;
    } else {
        cout << "a" << endl;
    }
}


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

void vread(int n, int a[100001])
{
    for (int i = 0; i < n; ++i)
        cin >> a[i];
}

int main()
{
    int n, a[100001], b[100001], c[100001];
    cin >> n;
    vread(n, a);
    vread(n, b);
    vread(n, c);

    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);

    long long nr[100001], cnt = 0;
    int lf, rt;
    for (int j = 0; j < n; ++j) {
        lf = 0; rt = n - 1;
        while (lf <= rt) {
            if (c[(lf + rt) / 2] > b[j])
                rt = (lf + rt) / 2 - 1;
            else
                lf = (lf + rt) / 2 + 1;
        }
        nr[j] = n - lf;
    }

    for (int j = n - 2; j >= 0; --j)
        nr[j] += nr[j + 1];

    for (int i = 0; i < n; ++i) {
        lf = 0, rt = n - 1;
        while (lf <= rt) {
            if (b[(lf + rt) / 2] > a[i])
                rt = (lf + rt) / 2 - 1;
            else
                lf = (lf + rt) / 2 + 1;
        }
        if (lf < n)
            cnt += nr[lf];
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define mkp make_pair
typedef long long LL;
const int INF = 0x3f3f3f3f;
const int maxn = 2e6 + 5;
const int maxm = 2e6 + 5;
struct Edge{
	int v, w, next;
}E[maxm];
int head[maxn], tol;
int dis[maxn], vis[maxn];
map < int, int > G[maxn];
map < int, int > :: iterator it;

void init(){
	memset(head, -1, sizeof head);
	tol = 0;
}

void add_edge(int u, int v, int w){
	E[tol].v = v;
	E[tol].w = w;
	E[tol].next = head[u];
	head[u] = tol++;
}

struct Node{
	int v, dis;
	Node(){}
	Node(int __dis, int __v){
		dis = __dis;
		v = __v;
	}
	bool operator<(const Node& tmp) const{
		return tmp.dis < dis;
	}
};

int dij(int s, int t, int n){
	fill(dis, dis + n + 1, INF);
	fill(vis, vis + n + 1, 0);
	priority_queue < Node > q;
	q.push(Node(0, s));
	dis[s] = 0;
	while(!q.empty()){
		int u = q.top().v; q.pop();
		if(vis[u]) continue;
		vis[u] = 1;
		for(int i = head[u]; ~i; i = E[i].next){
			int v = E[i].v;
			if(!vis[v] && dis[v] > dis[u] + E[i].w){
				dis[v] = dis[u] + E[i].w;
				q.push(Node(dis[v], v));
			}
		}
	}
	return dis[t] == INF ? -1 : dis[t] / 2;
}

int main(){
	int n, m, u, v, c, node = 0;
	scanf("%d%d", &n, &m);
	init();
	for(int i = 1; i <= m; i++){
		scanf("%d%d%d", &u, &v, &c);
		if(!G[u].count(c))
			G[u][c] = ++node;
		if(!G[v].count(c))
			G[v][c] = ++node;
		add_edge(G[u][c], G[v][c], 0);
		add_edge(G[v][c], G[u][c], 0);
	}
	int s = ++node, t = ++node;
	for(int i = 1; i <= n; i++){
		++node;
		for(it = G[i].begin(); it != G[i].end(); it++){
			add_edge(it->second, node, 1);
			add_edge(node, it->second, 1);
			if(i == 1) add_edge(s, it->second, 2);
			if(i == n) add_edge(it->second, t, 0);
		}
	}
	printf("%d\n", dij(s, t, node));
	return 0;
}

Measured memory_bytes: 139644
N = gets.chomp.to_i
a = 0
if N < 10
    puts N
elsif N < 100
    puts 9
elsif N < 1000
    a = 9 + (N-99)
    puts a
elsif N < 10000
    puts 909
elsif N < 100000
    a = 909 + (N-9999)
    puts a
else
    puts 90909
end

Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int x, y;
	cin >> x >> y;
	rep(i, x+1) {
		if (i * 2 + (x - i) * 4 == y) {
			cout << "Yes" << "\n";
			return 0;
		}
	}
	cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 3692
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,k,b;
	while(cin>>n>>k,n && k){
		int s[k];
		rep(i,k)cin>>s[i];
		bool check=true;
		rep(i,n){
			rep(j,k){
				cin>>b;
				s[j]-=b;
				if(s[j]<0)check=false;
			}
		}
		if(check)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
const int t=1000000007;
int main()
{
	long long s;
	int i,n;
	while(scanf("%d",&n)!=EOF)
	{
		s=1;
		for(i=2;i<=n;i++)
		s=(s*i)%t;
		printf("%lld\n",s);
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	vector<Int> a(1);
	cin >> a[0];

	vector<Int> cnt(1000000 + 1);
	cnt[a[0]]++;

	Int temp;
	for (Int i = 0; i < 1000000; i++) {
		if (a[i]%2) {
			temp = 3 * a[i] + 1;
			if (cnt[temp]) {
				cout << i+2 << "\n";
				return 0;
			}
			else {
				a.push_back(temp);
				cnt[temp]++;
			}
		}
		else {
			temp = a[i] / 2;
			if (cnt[temp]) {
				cout << i + 2 << "\n";
				return 0;
			}
			else {
				a.push_back(temp);
				cnt[temp]++;
			}
		}
	}


}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll  n,x,i,s=1;
    cin>>n;
    vector < ll >ara;
    for(i=0;i<n;i++){
        cin>>x;
        ara.push_back(x);
    }
   sort(ara.begin(),ara.end());
   if(ara[0]==0)
        s=0;
   else{
    for(i=n-1;i>=0;i--){
            if(ara[i]<=1000000000000000000/s)
               s=s*ara[i];
             else{s=-1;break;}
    }

   }
   cout<<s<<endl;
}


Measured memory_bytes: 4316
/*input
eel
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
vector<int> idx[26];
int mid=-1;
vector<pii> v;
vector<int> a;

int low(int i){return i&-i;}

int bit[maxn];

void mdf(int n,int d){
	for(int i=n;i<maxn;i+=low(i+1)) bit[i]+=d;
}
ll query(int n){
	ll ret=0;
	for(int i=n;i>=0;i-=low(i+1)) ret+=bit[i];
	return ret;
}

bool cmp(pii A,pii B){
	if(A.F<B.F&&B.S<A.S) return true;
	if(B.F<A.F&&A.S<B.S) return false;
	return true;
}
int main(){
	IOS;
	string s;
	cin>>s;
	REP(i,SZ(s)){
		idx[s[i]-'a'].pb(i);
	}
	{
		REP(i,26) if(SZ(idx[i])%2){
			if(mid!=-1){
				cout<<"-1\n";
				return 0;
			}
			mid=idx[i][SZ(idx[i])/2];
		}
	}
	REP(i,26){
		REP(j,SZ(idx[i])/2) v.pb(MP(idx[i][j],idx[i][SZ(idx[i])-1-j]));
	}
	sort(ALL(v));
	a.resize(SZ(s));
	REP(i,SZ(v)){
		a[i]=SZ(s)-1-v[i].F;
		a[SZ(s)-1-i]=SZ(s)-1-v[i].S;
	}
	if(mid!=-1){
		a[SZ(s)/2]=SZ(s)-1-mid;
	}
	// REP(i,SZ(s)) cout<<a[i]<<" \n"[i==SZ(s)-1];
	ll ans=0;
	REP(i,SZ(s)){
		ans+=query(a[i]);
		mdf(a[i],1);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 4108
#include<bits/stdc++.h>
using namespace std;
int main(){
  string N;
  cin >> N ;
    if (N[0] == '7'){
      cout << "Yes" << endl ;
    }
    else if (N[1] == '7'){
      cout << "Yes" << endl ;
    }
    else if (N[2] == '7'){
      cout << "Yes" << endl ;
    }
    else{
      cout << "No" <<endl;
    }
  }


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <complex>

using namespace std;

typedef complex<double> P;
typedef pair<P,double> circle;
struct L { P p, q; L(P p, P q) : p(p), q(q) {} };

template <class T>
inline const T& abs(const T& a)
{
	return a > 0 ? a : -a;
}

const double EPS = 1e-8;

double dot(P a, P b) { return real(conj(a)*b); }
double cross(P a, P b) { return imag(conj(a)*b); }

P footPerp(L l, P p) {
	return l.p + (l.q-l.p) * dot(l.q-l.p, p-l.p) / norm(l.q-l.p);
}

double lenPerp(L l, P p){
	return abs(footPerp(l, p)-p);
}

P ssCrosspoint(L a, L b){
	double A = cross(a.q-a.p, b.q-b.p);
	double B = cross(a.q-a.p, a.q-b.p);
	return b.p + B/A * (b.q-b.p);
}

bool crossCircle(circle c1, circle c2){
	double r1 = c1.second;
	double r2 = c2.second;
	double d = abs(c1.first-c2.first);
	if(d<r1||d<r2)
		return d-abs(r1-r2)>EPS;
	return r1+r2-d>-EPS;
}

vector<P> crossPoint(circle c1, circle c2){
	vector<P> res;
	double r1 = c1.second;
	double r2 = c2.second;
	double r3 = abs(c1.first-c2.first);
	double rc = (r3*r3+r1*r1-r2*r2)/(2*r3);
	double rs = sqrt(r1*r1-rc*rc);
	P dif = (c2.first-c1.first)/r3;
	res.push_back(c1.first+dif*P(rc,rs));
	if(abs(rs) > EPS) res.push_back(c1.first+dif*P(rc,-rs));
	return res;
}

int main(){
	int x1, y1, x2, y2, x3, y3;
	while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3, x1|y1|x2|y2|x3|y3){
		x1 += 100, y1 += 100;
		x2 += 100, y2 += 100;
		x3 += 100, y3 += 100;
		while(x1-x2>0){
			int tmp = x1; x1 = x2; x2 = x3; x3 = tmp;
			    tmp = y1; y1 = y2; y2 = y3; y3 = tmp;
		}
		P p1 = P(x1, y1), p2 = P(x2, y2), p3 = P(x3, y3);
		double res = 1e12;
		int cnt = 0;
		for(int xa=0;xa<=200;xa++){
			for(int ya=0;ya<=200;ya++){
				if(cross(p2-p1, P(xa,ya)-p1) > -EPS) break;
				double len = abs(P(xa,ya)-p2);
				int r1 = int(len+EPS);
				for(int xb=max(0,x2-r1);xb<=min(200,x2+r1);xb++){
					if(len < abs(x2-xb)) continue;
					double dsq = sqrt(len*len-(x2-xb)*(x2-xb));
					int sqt = int(dsq+EPS);
					if(abs(dsq-sqt) > EPS) continue;
					for(int sgn=-1;sgn<=1;sgn+=2){
						int yb = sgn*sqt + y2;
						if(yb < 0 || 200 < yb) continue;
						if(abs(abs(p2-P(xb,yb)) - len) > EPS || abs(P(xb,yb)-P(xa,ya)) < EPS) continue;
						if(cross(p3-p2, P(xb,yb)-p2) > -EPS) continue;
						circle ca = make_pair(p1, abs(p1-P(xa,ya)));
						circle cb = make_pair(p3, abs(p3-P(xb,yb)));

						P pt = ssCrosspoint(L(P(xa,ya), P(xa,ya)+P(0,1)*(p2-p1)), L(P(xb,yb), P(xb,yb)+P(0,1)*(p3-p2)));
						double la = lenPerp(L(p1,p2), P(xa,ya));
						double lb = lenPerp(L(p1,p2), pt);
						if(la*la-lb*lb < EPS) continue;
						if(sqrt(la*la-lb*lb) > res) continue;

						if(!crossCircle(ca, cb)) continue;
						vector<P> cp = crossPoint(ca, cb);
						for(int i=0;i<cp.size();i++){
							int xc = cp[i].real()+0.5;
							int yc = cp[i].imag()+0.5;
							if(xc < 0 || 200 < xc || yc < 0 || 200 < yc) continue;
							if(cross(p1-p3, P(xc,yc)-p3) > -EPS) continue;
							if(abs(P(xc,yc)-cp[i]) > EPS) continue;
							res = min(res, sqrt(la*la-lb*lb));
						}
					}
				}
			}
		}
		if(res < 1e10) printf("%.7lf\n", res);
		else           puts("-1");
	}
}

Measured memory_bytes: 988
//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber
// 19 04 2020

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define    pi    acos(-1.0)

void task()
{
    int n, m, x, ans=0;

    cin >> n >> m;

    vector<int> ara(m);

    for(int K=0; K<m; K++){
        cin >> x;
        ans+=x;
    }

    if(ans>n) cout << "-1" << "\n";
    else cout << n-ans << "\n";
}

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

    //clock_t tStart = clock();

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    task();

    //printf("Time taken: %.3fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);

    return 0;
}


Measured memory_bytes: 3684
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int main(){
	n=read();m=read();
	printf("%d\n",max(0,n-m*2));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i,N)cin >> A[i];
    ll two = 0;
    REP(i,N){
        while(!(A[i]%2)){
            two++;
            A[i]/=2;
        }
    }
    cout << two << "\n";
}

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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

int n, a[600000];
string s;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> s;
  n = sz(s);
  for (int i = 0; i < n; i++)
    if (s[i] == '<')
    a[i + 1] = a[i] + 1;
  for (int i = n - 1; i >= 0; i--)
    if (s[i] == '>')
      a[i] = max(a[i], a[i + 1] + 1);
  ll r = 0;
  for (int i = 0; i <= n; i++)
    r += a[i];
  cout << r << "\n";
}


Measured memory_bytes: 2844
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;

struct Node {
  vector<int> edge_to;
  vector<int> edge_from;
  vector<ll> edge_cost;
  vector<ll> edge_from_cost;

  bool done;
  bool contain;
  ll cost;
};

int main() {
  int n, m, R;
  cin >> n >> m >> R;
  vector<int> r(R);
  for(int i = 0; i < R; i++) {
    cin >> r[i];
    r[i]--;
  }
  sort(r.begin(), r.end());
  vector<Node> node(n);
  for(int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    node[a].edge_to.push_back(b);
    node[a].edge_cost.push_back(c);
    node[b].edge_to.push_back(a);
    node[b].edge_cost.push_back(c);
  }

  vector<vector<ll>> dis(n + 1, vector<ll>(n + 1, -1));
  for(int i = 0; i < R; i++) {
    for(int j = 0; j < n; j++) {
      node[j].done = false;
      node[j].cost = -1;
    }
    auto compare = [](Node a, Node b) { return a.cost < b.cost; };
    priority_queue<Node, vector<Node>, decltype(compare)> q{compare};
    node[r[i]].cost = 0;
    q.push(node[r[i]]);
    while(!q.empty()) {
      Node doneNode = q.top();
      q.pop();
      doneNode.done = true;
      for(int j = 0; j < doneNode.edge_to.size(); j++) {
        ll to = doneNode.edge_to[j];
        ll cost = doneNode.cost + doneNode.edge_cost[j];
        if(node[to].cost < 0 || cost < node[to].cost) {
          node[to].cost = cost;
          if(node[to].done == false){
            q.push(node[to]);
          }
        }
      }
    }
    for(int j = 0; j < R; j++) {
      dis[r[i]][r[j]] = node[r[j]].cost;
    }
  }

  ll ans = 100101001001001;
  do {
    ll sum = 0;
    for(int i = 0; i < R - 1; i++) {
      sum += dis[r[i]][r[i + 1]];
    }
    ans = min(ans, sum);
  } while(next_permutation(r.begin(), r.end()));

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

Measured memory_bytes: 1760
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;
int n , m , x;
char a[10][10];
int main() {
    abdelrahman010
    cin >> n >> m >> x;
    for(int i = 0;i < n;i++)
        for(int j = 0;j < m;j++)
            cin >> a[i][j];
    int ans = 0;
    for(int i = 0;i < (1 << n);i++) {
        char b[10][10];
        for(int j = 0;j < (1 << m);j++) {
            for(int p1 = 0;p1 < n;p1++)
                for(int p2 = 0;p2 < m;p2++)
                    b[p1][p2] = a[p1][p2];
            for(int j = 0;j < n;j++)
                if((1 << j) & i)
                    for(int k = 0;k < m;k++)
                        b[j][k] = '.';
            for(int k = 0;k < m;k++)
                if((1 << k) & j)
                    for(int p = 0;p < n;p++)
                        b[p][k] = '.';
            int cnt = 0;
            for(int j = 0;j < n;j++)
                for(int k = 0;k < m;k++)
                    cnt += (b[j][k] == '#');
            if(cnt == x)
                ans++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int main() {
  string s;
  while(cin >> s) {
    int c[3] = {};
    REP(i,s.size()) {
      if (s[i] == 'a') c[0]++;
      else if (s[i] == 'b') c[1]++;
      else c[2]++;
    }
    int n = s.size();
    bool ok = 0;
    REP(i,3) {
      REP(j,3) {
        REP(k,3) {
          if (i == j || i == k || j == k)continue;
          if (c[i] == (n + 2) / 3 &&
              c[j] == (n + 1) / 3 &&
              c[k] == n / 3)
            ok = 1;
        }
      }
    }
    cout << (ok ? "YES" : "NO") << endl;
  }
}


Measured memory_bytes: 512
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    v = list(map(int, readline().split()))
    ve = collections.Counter(v[0::2]).most_common()
    vo = collections.Counter(v[1::2]).most_common()
    if ve[0][0] != vo[0][0]:
        print((n // 2 - ve[0][1]) + (n // 2 - vo[0][1]))
    else:
        if len(ve) == len(vo) == 1:
            print(n // 2)
        elif len(ve) == 1:
            print((n // 2 - ve[0][1]) + (n // 2 - vo[1][1]))
        elif len(vo) == 1:
            print((n // 2 - ve[1][1]) + (n // 2 - vo[0][1]))
        else:
            print(min((n // 2 - ve[0][1]) + (n // 2 - vo[1][1]), (n // 2 - ve[1][1]) + (n // 2 - vo[0][1])))



if __name__ == '__main__':
    solve()


Measured memory_bytes: 58724
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt();
        char[] c=fsc.next().toCharArray();
        fsc.close();
        int max=0;
        for(int i=1;i<c.length-1;i++){
            HashSet<Character> fir=new HashSet<>();
            HashSet<Character> sec=new HashSet<>();
            for(int j=0;j<i;j++) fir.add(c[j]);
            for(int j=i;j<c.length;j++) sec.add(c[j]);
            int num=0;
            for(char ch:fir) if(sec.contains(ch)) num++;
            max=Math.max(max, num);
        }
        System.out.println(max);
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 21844
import math
A,B=[int(item) for item in input().split()]

def gdc(A,B):
    if A < B:
        A,B = B,A
    if B==0:
        return A
    else:
        A,B=B,A%B
        return gdc(A,B)

def chk_pn(num):
    flag=True
    if num <= 3:
        pass
    else:
        for i in range(2,int(math.sqrt(num))+1):
            if num % i ==0:
                flag = False
                break
    return flag
def mk_factor(num):
    max_divisor = int(math.sqrt(num))+1
    divisor =2
    factor_list=[1]

    while divisor <= max_divisor:
        if num % divisor ==0:
            factor_list.append(divisor)
            num /= divisor
        else:
            divisor += 1
    factor_list.append(num)
    return factor_list

GDC=gdc(A,B)
pn_factor = [i for i in mk_factor(GDC) if chk_pn(i) is True]
print(len(set(pn_factor)))


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define fori(i,a,b) for(int i=a;i<=b;i++)
#define ford(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define fs first
#define sc second


int main()
{
    ll m,n;
    cin >>m>>n;
    int l = max(n,m);
    for(ll i =0;i<l;i++)
    {
        if(abs(n-i)==abs(m-i))
        {
            cout<<i;
            exit(0);
        }
    }
    cout<<"IMPOSSIBLE";
    return 0;
}

Measured memory_bytes: 256
import sys

import numpy as np
from collections import deque
from collections import Counter
from itertools import accumulate
from itertools import permutations, combinations
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt
### ceil切り上げ，floor切り下げ

def main():
	n, x = map(int, input().split())
	lst = list(map(int, input().split()))
	d = 0
	ans = 1
	for l in lst:
		d += l
		if d <= x:
			ans += 1
		else:
			break
	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 12428
n, x, y = gets.chomp.split.map(&:to_i)


# 各点からの最短距離を求める
# graph = Hash.new{ |h,k| h[k] = []}
graph = Array.new(n+1){Array.new}

1.upto(n) do |i|
  graph[i] << i+1 unless i == n
  graph[i] << i-1 unless i == 1
end

graph[x] << y
graph[y] << x



# ans = Hash.new(0)
# arrayなら0を気にしなくて良い
ans = Array.new(n,0)

1.upto(n) do |i|
  # visited = Hash.new(false)

  # queueに距離を持たず、それ用の配列を用意する
  # これにvisitedの役割も持たせている
  dist = Array.new(n+1, -1)

  dist[i] = 0
  queue = [i]

  while queue.size > 0
    v = queue.shift

    graph[v].each do |nv|
      next unless dist[nv] == -1
      dist[nv] = dist[v] + 1
      queue << nv
      ans[dist[nv]] += 1
    end
  end
end


1.upto(n-1) do |i|
  puts ans[i] / 2
end


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

int main(){
	int a, b, c, x;
	cin >> a >> b >> c;
	if (a > b){
		x = a;
		a = b;
		b = x;
	}
	if (b > c){
		x = b;
		b = c;
		c = x;
	}
	if (a > b){
		x = a;
		a = b;
		b = x;
	}
	cout << a << " " << b << " " <<c << endl;
	return 0;
}

Measured memory_bytes: 1164
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
import math
import sys
input = sys.stdin.readline
#文字列のときはうまく行かないのでコメントアウトすること
sys.setrecursionlimit(2147483647)

def main():
  k, s = map(int, input().split())
  ans = 0
  for x in range(0, k+1):
    for y in range(0, k+1):
      z = s-x-y
      if 0<=z and z<=k:
        ans += 1
  print(ans)
  

if __name__ == '__main__':
  main()

Measured memory_bytes: 40940
#include <iostream>
using namespace std;
int main(){
	int w,d;
	cin >> w >> d;
	int k=0;
	int ans[100000]={};
	while(w!=0 && d!=0){
		int hw[10]={},hd[15]={};
		for(int i=0;i<w;i++){
			cin >> hw[i];
		}
		for(int i=0;i<d;i++){
			cin >> hd[i];
		}
		int sum=0;
		for(int i=0;i<w;i++){
			sum+=hw[i];
		}
		int fw[10]={};
		for(int i=0;i<d;i++){
			for(int j=0;j<w;j++){
				if(hd[i]==hw[j]){
					if(fw[j]!=1){
						fw[j]=1;
						break;
					}
				}
				if(j==w-1){
					sum+=hd[i];
				}
			}
		}
		ans[k]=sum;
		k++;
		cin >> w >> d;
	}
	for(int i=0;i<k;i++){
		cout << ans[i] << endl;
	}
}




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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
#define MAX 999999999

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};

typedef long long ll;

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

    int a, b;
    cin >> a >> b;

    if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) cout << "Possible\n";
    else cout << "Impossible\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int
main ()
{
  int w, n;
  cin >> w >> n;
  vector < int >list (w);
  vector < int >::iterator it;
  int i = 1;
  for (it = list.begin (); it != list.end (); ++it)
    *it = i++;
  for (w = 0; w < n; w++)
    {
      int b, a;
      scanf ("%d%*c%d", &b, &a);
      swap (list[b - 1], list[a - 1]);
    }
  for_each (list.begin (), list.end (),[](int n)
	    {
	    cout << n << endl;});

}

Measured memory_bytes: 1236
#include <iostream>
#include<map>
#include<string>

using namespace std;

int main() {
	int n, num;
	char ch;
	map <string, bool> map;

	char name[] = { 'S','H','C','D' };
	int j = 0;
	string str;
	while (j < 4) {
		str = name[j];
		for (int i = 1; i < 14; i++) {
			map[str + to_string(i)] = false;
		}
		j++;
	}

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> ch >> num;
		str = ch;
		map[str + to_string(num)] = true;
	}

	j = 0;
	while (j < 4) {
		str = name[j];
		for (int i = 1; i < 14; i++) {
			if (!map[str + to_string(i)])
				cout << name[j] << " " << i << endl;
		}
		j++;
	}

	return 0;
}


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;

int main(){
    
    int N,x;cin>>N>>x;
    if(x==1||x==2*N-1) cout<<"No"<<endl;
    else{
        cout<<"Yes"<<endl;
        if(x>=N){
            for(int i=0;i<2*N-1;i++){
                cout<<(x+i-(N-1)-1)%(2*N-1)+1<<endl;
            }
        }else{
            for(int i=0;i<2*N-1;i++){
                cout<<(x+i+N-1)%(2*N-1)+1<<endl;
            }
        }
    }
}


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

long long cost(long long P, std::vector<long long>& X){
    long long c = 0;
    for(auto iter: X){
        c += (iter - P)*(iter - P);
    }
    return c;
}

void solve(long long N, std::vector<long long> X){
    long long s = 0;
    for(auto iter: X){
        s += iter;
    }
    if(s % N == 0){
        cout << cost(s/N, X) << endl;;
    }else{
        long long left = cost(s/N, X);
        long long right = cost(s/N + 1, X);
        cout << min(left, right) << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> X(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
    }
    solve(N, std::move(X));
    return 0;
}


Measured memory_bytes: 256
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val ll = readLine()!!.split(" ").map { it.toInt() }.sorted()

    var cnt = 0

    for (i in 0 until n-2) {
        inner1@for (j in i+1 until n-1) {
            if (ll[i] == ll[j]) continue@inner1

            inner2@for (k in j+1 until n) {
                if (ll[j] == ll[k]) continue@inner2
                if (ll[k] >= ll[i] + ll[j]) continue@inner2

                cnt++
            }
        }
    }

    println(cnt)
}

Measured memory_bytes: 40988
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

struct mint{
    static const long long MOD = 1000000007;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a) const{
        return mint(v) *= a;
    }

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint operator/(mint a) const {
        return mint(v) /= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};

mint operator*(long long l, mint r){ return r * l; }

std::ostream& operator<<(std::ostream& stream, const mint& m){
    stream << m.v;
    return stream;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n){ cin >> a.at(i); }

    mint ans = 0;
    mint cs = 0;
    REP(i, n){
        ans += cs * a.at(i);
        cs += a.at(i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4844
def dfs(V,E):
    s[V-1]=1
    for i in Ren[V-1]:
        if E!={V,i} and s[i-1]==0:dfs(i,E)
N,M=map(int,input().split())
Edge=[list(map(int,input().split())) for i in range(M)]
Ren=[[] for i in range(N)]
for a,b in Edge:
    Ren[a-1].append(b)
    Ren[b-1].append(a)
ans=0
for i in Edge:
    s=[0]*N
    dfs(1,set(i))
    if 0 in s:ans+=1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
int n, w;
//vector<vector<int>> c(50,vector<int>(50));
//vector<vector<bool>> visit(50,vector<bool>(50));
int c[50][50] = {};
bool visit[50][50] = {};
void dfs(int x, int y){
    
    if(x < 0 || y < 0 || x >= w || y >= n) return;
    if(visit[x][y] == true) return;

    visit[x][y] = true;
    
    dfs(x+1, y);
    dfs(x-1, y);
    dfs(x, y+1);
    dfs(x, y-1);
    dfs(x+1, y+1);
    dfs(x+1, y-1);
    dfs(x-1, y+1);
    dfs(x-1, y-1);
}


int main(void){

    cin >> n >> w;
    
    while(n != 0 && w != 0){
    
    
        for(int i = 0; i < w; i++){
            for(int j = 0; j < n; j++){
                cin >> c[i][j];
                if(c[i][j] == 0) visit[i][j] = true;
            }
        }
        
        int ans = 0;
        
        for(int i = 0; i < w; i++){
            for(int j = 0; j < n; j++){
                if(!visit[i][j]){
                dfs(i, j);
                ans++;
                }
            }
        }
        
        cout << ans << endl;
        
        for(int i = 0; i < 50; i++){
            for(int j = 0; j < 50; j++){
                visit[i][j] = false;
            }
        }
        
        cin >> n >> w;
    }
}



Measured memory_bytes: 3120
n = int(input())
s = input()

ans = s.count('R') * s.count('G') * s.count('B')

for i in range(n):
    for j in range(i + 1, n):
        k = 2 * j - i
        # 三個目が範囲内 かつ 三文字違う かつ 距離が同じはダメ
        if k < n and (s[i] != s[j] and s[j] != s[k]
                      and s[i] != s[k]) and j - i == k - j:
            ans -= 1

print(ans)


Measured memory_bytes: 68172
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
	if (ch == 'A') return 1;
	else if (ch == 'C') return 2;
	else if (ch == 'G') return 3;
	else if (ch == 'T') return 4;
	else return 0;
}

long long getKey(char str[]){
	long long sum = 0, p = 1, i;
	for (i = 0; i < strlen(str); i++){
		sum += p*(getChar(str[i]));
		p *= 5;
	}

	return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M - 1)); }

int find(char str[]){
	long long key, i, h;
	key = getKey(str);
	for (i = 0;; i++){
		h = (h1(key) + i*h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0) return 0;
	}
	return 0;
}

int insert(char str[]){
	long long key, i, h;
	key = getKey(str);
	for (i = 0;; i++){
		h = (h1(key) + i*h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0){
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}

int main(){
	int i, n, h;
	char str[L], com[9];
	for (i = 0; i < M; i++)H[i][0] = '\0';
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%s %s", com, str);

		if (com[0] == 'i'){
			insert(str);
		}
		else{
			if (find(str)){
				printf("yes\n");
			}
			else{
				printf("no\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 14916
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  int n,a,b,ans = 0;
  cin >> n >> a >> b;
  ans = min(n*a,b);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pb push_back

void test_case() {
    int n,k;
    cin >> n>>k;
    vector<int> v(n);
    for (auto &it : v) cin >> it;

    vector<int> dp(n, 1e9 + 5);
    dp[0] = 0;
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n && j<=i+k; j++)
            dp[j] = min(dp[j], dp[i] + abs(v[i] - v[j]));
    cout << dp[n - 1] << endl;
}

int main() {
    int t = 1;
    // cin >> t;
    while (t--) test_case();
    return 0;
}

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

int main(){
  int n;cin >> n;
  int a[n],ans = 0;
  rep(i,n)cin >> a[i];
  int i=0;
  while(i <= n-1){
    if(a[i]%2 == 0){ans += 1;a[i]/=2;}
    else i+= 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		int v = Integer.parseInt(line);
		int v2 = v;
		v2 *= v * v;
		System.out.println(v2);
	}
}

Measured memory_bytes: 26028
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	char buf[1001],table[11];

	for(int i = 0; i < 11; i++)table[i] = 0;

    scanf("%s",buf);


    int loc = 0,next_loc;

    for(int i = 0; buf[i] != '\0'; i++){
    	next_loc = (buf[i]-33)/9;

    	if(next_loc > loc){
    		for(int k = 0; k < next_loc-loc; k++)printf(">");
    	}else{
    		for(int k = 0; k < loc-next_loc; k++)printf("<");
    	}

    	if(table[next_loc] > buf[i]){
    		while(table[next_loc] > buf[i]){
    			printf("-");
    			table[next_loc]--;
    		}
    	}else{
    		while(table[next_loc] < buf[i]){
    			printf("+");
    			table[next_loc]++;
    		}
    	}
    	printf(".");
    	loc = next_loc;
    }
    return 0;
}

Measured memory_bytes: 3164