akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>

int N;
std::string S;


int main() {
  std::cin >> S;
  N = S.length();
  std::string S_r, S_1_r, S_2_r;
  S_r = S;
  std::reverse(S_r.begin(), S_r.end());
  std::string S_1 = S.substr(0, (N-1)/2);
  S_1_r = S_1;
  std::reverse(S_1_r.begin(), S_1_r.end());
  std::string S_2 = S.substr((N+3)/2-1);
  S_2_r = S_2;
  std::reverse(S_2_r.begin(), S_2_r.end());
  if ( S_r == S) {
    if (S_1_r == S_1) {
      if (S_2_r == S_2) {
        std::cout << "Yes" << std::endl;
        return 0;
      }
    }
  }
  std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int ans=0;
  string s;
  cin>>s;
  for(int i=0;i<s.size()/2;i++){
    if(s[i]!=s[s.size()-1-i])
      ans++;
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int a[2000];

int main()
{
	int N, Z, W;

	cin >> N >> Z >> W;
	rep(i, N) cin >> a[i];

	if (N == 1) cout << abs(a[0] - W) << endl;
	else cout << max(abs(a[N - 1] - a[N - 2]), abs(a[N - 1] - W)) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <sstream>
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;

int q, l, r;
const int N = 100005;
int is_prime[N];
int is_similar[N];

void sieve(){
    for(int i = 0; i < N; i++) {
      is_prime[i] = 1;
    }

    is_prime[0] = 0;
    is_prime[1] = 0;

    for(int i = 2; i * i < N; ++i)
        if(is_prime[i])
            for(int j = 2; i * j < N; ++j)
                is_prime[i * j] = 0;
}

void fill_similar() {
  for(int i = 0; i < N; i++) {
    if(is_prime[i] && is_prime[(i + 1) / 2]) {
      is_similar[i] = 1;
    }
  }
}

void inc() {
    int cur = 0;
    for(int i = 0; i < N; i++) {
      if (is_similar[i] == 1) {
        cur = cur + 1;
      }
      is_similar[i] = cur;
    }
}

int main() {
    sieve();
    fill_similar();

    //for(int i = 0; i < 20; i++) {
    //  cout << i << " "<< is_similar[i] << endl;
    //}

    inc();

    //for(int i = 0; i < 20; i++) {
    //  cout << i << " "<< is_similar[i] << endl;
    //}


    cin >> q;
    for(int i = 0; i < q; i++) {
      cin >> l >> r;
      // cout << is_similar[r] << " " << is_similar[l - 1] << " " << is_similar[r] - is_similar[l - 1] << endl;
      cout << is_similar[r] - is_similar[l - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long long ll;

template <typename T> void max_self(T& a, T b){
  a = max(a,b);
}

template <typename T> void min_self(T& a, T b){
  a = min(a,b);
}

void solve(){
  pi l, r;
  cin>>l.F>>l.S;
  cin>>r.F>>r.S;
  bool t = false;
  while(l.F && r.F){
    if(!t){
      r.F -= l.S;
      if(r.F < 0) r.F = 0;
    }else{
      l.F -= r.S;
      if(l.F < 0) l.F = 0;
    }
    t = !t;
  }
  if(l.F == 0)
    cout<<"No\n";
  else
    cout<<"Yes\n";

}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //int t; cin >> t;
  //while(t--) solve();
  //
  solve();
  return 0;
}


Measured memory_bytes: 3644
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

const int INF = (int)1e9;

void calc(int n){
  int k[10000],sum=0;
  bool flag = false;
  
  for(int i=0;i<n;i++){
    scanf("%d",&k[i]);
    if(k[i] > 0) sum++;
    if(k[i] >= 2) flag = true;
  }

  if(!flag){
    puts("NA");
    return;
  }

  cout << sum + 1 << endl; 

  return;
}
  

int main(){
  int n;

  while(1){
    scanf("%d",&n);

    if(n==0) break;
    calc(n);
  }

  return 0;
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define y1 DCXISSOHANDSOME
#define inf 2333333333333333333LL
#define inf1 2123333333

struct node { int t,v,op,next;ll c; }a[100010];

queue<int> q;

ll dis[2010],ans=0;
int x1[1010],y1[1010],c1[1010],x2[1010],y2[1010],c2[1010];
int head[2010],n,vs,vt,tot;
bool vis[2010],inq[2010];

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline void add(int x,int y,int z,ll c)
{
	a[++tot].t=y;a[tot].v=z;a[tot].c=c;a[tot].op=tot+1;a[tot].next=head[x];head[x]=tot;
	a[++tot].t=x;a[tot].v=0;a[tot].c=-c;a[tot].op=tot-1;a[tot].next=head[y];head[y]=tot;
}

inline bool spfa()
{
	while (!q.empty()) q.pop();
	for (int i=vs;i<=vt;i++) dis[i]=-inf;
	memset(inq,false,sizeof(inq));
	dis[vt]=0;q.push(vt);inq[vt]=true;
	while (!q.empty())
	{
		int x=q.front();q.pop();
		for (int i=head[x];i;i=a[i].next) if (a[a[i].op].v)
		{
			int t=a[i].t;
			if (dis[t]<dis[x]-a[i].c)
			{
				dis[t]=dis[x]-a[i].c;
				if (!inq[t]) q.push(t),inq[t]=true;
			}
		}
		inq[x]=false;
	}
	return dis[vs]>-inf;
}

inline int dfs(int x,int y)
{
	if (x==vt||!y) return y;
	int res=0;vis[x]=true;
	for (int i=head[x];i;i=a[i].next)
	{
		int t=a[i].t;
		if (dis[t]!=dis[x]-a[i].c||vis[t]||!a[i].v) continue;
		int hh=dfs(t,min(y,a[i].v));
		if (!hh) continue;
		res+=hh;y-=hh;ans+=a[i].c*hh;
		a[i].v-=hh;a[a[i].op].v+=hh;
	}
	return res;
}

int main()
{
	n=rd();
	for (int i=1;i<=n;i++) x1[i]=rd(),y1[i]=rd(),c1[i]=rd();
	for (int i=1;i<=n;i++) x2[i]=rd(),y2[i]=rd(),c2[i]=rd();
	vs=0;vt=n*2+5;
	for (int i=1;i<=n;i++) add(vs,i,c1[i],0),add(n+i,vt,c2[i],0);
	for (int i=1;i<=n;i++)
	{
		add(i,n*2+1,inf1,x1[i]+y1[i]);
		add(i,n*2+2,inf1,x1[i]-y1[i]);
		add(i,n*2+3,inf1,-x1[i]+y1[i]);
		add(i,n*2+4,inf1,-x1[i]-y1[i]);
	}
	for (int i=1;i<=n;i++)
	{
		add(n*2+1,n+i,inf1,-x2[i]-y2[i]);
		add(n*2+2,n+i,inf1,-x2[i]+y2[i]);
		add(n*2+3,n+i,inf1,x2[i]-y2[i]);
		add(n*2+4,n+i,inf1,x2[i]+y2[i]);
	}
	while (spfa())
	{
		do
		{
			memset(vis,false,sizeof(vis));
			dfs(vs,inf1);
		}while (vis[vt]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
int main(void){
    int n,i,temp,ren=0,prev,ans=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&temp);
        if(i==0){
            prev=temp;
            ren=1;
            continue;
        }
        if(temp==prev){
            ren++;
        }else{
            ans+=ren/2;
            prev=temp;
            ren=1;
        }
    }
    ans+=ren/2;
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 128
n=int(input())
a,b=[int(x) for x in input().split()]
p=[int(x) for x in input().split()]
q1,q2,q3=0,0,0
for i in p:
    if i<=a:
        q1+=1
    elif i>=b+1:
        q3+=1
    else:
        q2+=1
print(min(q1,q2,q3))

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



int main() {
	string s;
	cin >> s;


	int i = 0;

	for( int j = 0; j < 4; ++j ) {
		if( s[ j ] == '+' ) {
			++i;
		}
		else if ( s[ j ] == '-' ) {
			--i;
		}
	}

	printf( "%d\n", i );
}

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

void solve()
{
    string s;
    int n,m,k,i,j,x,d,l,r,count=0,sum=0,maxi=0,mini=1e18,flag=0;
    cin>>l>>r>>d;
    
    for(i=l;i<=r;i++)
    {
        if(i%d==0) count++;
    }
    
    cout<<count;
    
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
  //  cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 3648
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>
    #include<cstdint>

    #define INF 1e7
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;

    int main(){
        string s;cin>>s;
        vector<int>a(s.size(),0);
        if(s[0] == 'A' || s[0] == 'T' || s[0] == 'C' || s[0] == 'G')a[0] = 1;
        REP(i,1,s.size()-1){
            if(s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G'){
                a[i] = a[i-1]+1;
            }
            else {
                a[i] = 0;
            }
        }
        int res = 0;
        rep(i,s.size()){
            res = max(res,a[i]);
        }
        cout<<res;
    }
    


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<math.h>

using namespace std;

map<int, int> MR;
map<int, int> MG;
map<int, int> MB;

void make(){
  MR[0] = 0;
  MG[0] = 0;
  MB[0] = 0;
  MR[1] = 0;
  MG[1] = 0;
  MB[1] = 255;
  MR[2] = 0;
  MG[2] = 255;
  MB[2] = 0;
  MR[3] = 0;
  MG[3] = 255;
  MB[3] = 255;
  MR[4] = 255;
  MG[4] = 0;
  MB[4] = 0;
  MR[5] = 255;
  MG[5] = 0;
  MB[5] = 255;
  MR[6] = 255;
  MG[6] = 255;
  MB[6] = 0;
  MR[7] = 255;
  MG[7] = 255;
  MB[7] = 255;
}

int main(){

  make();

  char in[2];
  int status = 0;

  while(cin >> in[0]){
    if(in[0] == '0') break;

    int r, g, b;

    for(int i = 0; i < 3; i++){
      
      cin >> in[0] >> in[1];

      for(int j = 0; j <= 1; j++){
	if(in[j] == 'a') in[j] -= 39;
	if(in[j] == 'b') in[j] -= 39;
	if(in[j] == 'c') in[j] -= 39;
	if(in[j] == 'd') in[j] -= 39;
	if(in[j] == 'e') in[j] -= 39;
	if(in[j] == 'f') in[j] -= 39;
      }

      if(i == 0) r = (in[0] - 48) * 16 + (in[1] - 48);
      if(i == 1) g = (in[0] - 48) * 16 + (in[1] - 48);
      if(i == 2) b = (in[0] - 48) * 16 + (in[1] - 48);
    }

    int d;
    int min, then;

    for(int j = 0; j < 8; j++){
      d = (r - MR[j])*(r - MR[j])+(g - MG[j])*(g - MG[j])+(b - MB[j])*(b - MB[j]);
      if(j == 0 || min > d){
	min = d;
	then = j;
      }
    }

    if(then == 0) cout << "black" <<endl;
    if(then == 1) cout << "blue" <<endl;
    if(then == 2) cout << "lime" <<endl;
    if(then == 3) cout << "aqua" <<endl;
    if(then == 4) cout << "red" <<endl;
    if(then == 5) cout << "fuchsia" <<endl;
    if(then == 6) cout << "yellow" <<endl;
    if(then == 7) cout << "white" <<endl;

  }
  return 0;
}

Measured memory_bytes: 0
import math
a,b,h,m=map(int,input().split())
tkakudo=(h * 60 + m) * 0.5
skakudo = m * 6
kakudo = min(360 - abs(tkakudo - skakudo), abs(tkakudo - skakudo))
rkakudo = math.radians(kakudo)

p = (a**2 + b**2 -2*a*b*math.cos(rkakudo))**0.5

print(p)

Measured memory_bytes: 9500
import math

A, B = list(map(int, input().split()))

p_A = math.floor((A+1) * 100 / 8)
n_A = math.ceil(A * 100 / 8)
p_B = math.floor((B+1) * 100 / 10)
n_B = math.ceil(B * 100 / 10)

if n_A > p_B or n_B > p_A:
    print('-1')
else:
    ans = max(n_A, n_B)
    if math.floor(ans * 0.08) == A and math.floor(ans * 0.1) == B:
        print(ans)
    else:
        print('-1')



Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String N = scanner.next();
        //各行の数字の和
        int sum = 0;

        for (int i = 0; i < N.length(); i++) {
        	//Nの各行を数値に変換し足す
        	int x = Integer.parseInt(N.substring(i, i+1));
        	sum += x;
        }

        int n = Integer.parseInt(N);
        String judge = n % sum == 0 ? "Yes" : "No";

        System.out.println(judge);
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    cin>>a[i];
    ll mi=a[0],ma=0,sum=1000;
    for(ll i=1;i<n;i++)
    {
        while(i<n&&a[i]<=mi)
        {
            mi=a[i];
            i++;
        }
        while(i<n&&a[i]>=ma)
        {
            ma=a[i];
            i++;
        }
        i--;
        sum=max(sum,(sum/mi)*ma+sum%mi);
        mi=INT_MAX;
        ma=INT_MIN;
    }
    ll aa=1000;
    cout<<max(aa,sum);
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
	ll a, b, c, d, n; cin >> a >> b >> c >> d >> n;
	b = min(b, 2*a); c = min(c, 2*b); d = min(d, 2*c);
	cout << d*(n/2) + c*(n%2) << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll N, M;
    cin >> N >> M;

    vector<ll> a(N);

    ll L = 1;
    REP(i, N) {
        cin >> a[i];
        L = lcm(L, a[i]);
    }

    // check if ans exists
    ll cnt;
    REP(i, N) {
        ll div = L / a[i];

        ll tmp = 0;
        while(div % 2 == 0) {
            tmp++;
            div >>= 1;
        }

        if (i == 0) {
            cnt = tmp;
            continue;
        }

        if (cnt != tmp) {
            print(0);
            return 0;
        }

        cnt = tmp;
    }

    print(ll(ceil(2 * M / L / double(2))));
}


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

int main() {

    int n = 0, x = 0;
    while(true){
    
        // 1. input end check.
        scanf("%d %d", &n, &x);
        if(n == 0 && x == 0) break;
        
        // 2. calculate the combination. 
        int ans = 0;
        for(int k = 3; k <= n; k++){
            for(int j = 2; j < k; j++){
                for(int i = 1; i < j; i++){
                    if(i + j + k == x) ans++;
                }
            }
        }
        
        // 3. output answer.
        printf("%d\n", ans);
    
    }
    
    return 0;
    
}


Measured memory_bytes: 3208
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

class UnionFind {
private:
	vector<int> data;

public:
	UnionFind(int size) : data(size, -1) { }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	bool is_same(int x, int y) { return root(x) == root(y); }
	int size(int x) { return -data[root(x)]; }

	bool unify(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
			return true;
		}
		return false;
	}
};


int main() {

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

	int N;
	cin >> N;


	vector<vector<int>> edges(N);
	map<pair<int, int>, int> id;
	for (int i = 0; i < N - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		edges[u].emplace_back(v);
		edges[v].emplace_back(u);
		id[minmax(u, v)] = i;
	}

	vector<int> ans(N - 1);
	auto dfs = [&](auto &&f, int now) -> void {

		set<int> used;
		for (const auto &e : edges[now]) {
			int enow_id = id[minmax(e, now)];
			if (ans[enow_id]) used.emplace(ans[enow_id]);
		}
		int cnt = 1;
		for (const auto &e : edges[now]) {
			int enow_id = id[minmax(e, now)];
			if (!ans[enow_id]) {
				while (used.find(cnt) != used.end()) cnt++;
				ans[enow_id] = cnt++;
				f(f, e);
			}
		
		}

	};

	dfs(dfs, 0);

	cout << *max_element(ans.begin(), ans.end()) << "\n";
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 21120
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 170, task , 2020/06/14
//ms,
/*
*/

int main(void){
  vector<int> inP(200);
  for(int i=0;i<200;i++) inP[i]=1;

  int X, N, p, ans;
  cin >>X >>N;
  for(int i=0;i<N;i++){
    cin >>p;
    inP[p]=0;
  }

  for(int i=0;i<=X;i++){
    if(inP[X-i]){
      ans = X-i;
      break;
    }else if(inP[X+i]){
      ans = X+i;
      break;
    }
  }

  cout <<ans <<endl;

  return 0;
}
/*
出力が負の数にはならない。それならゼロでいいはずなので。
*/


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
 
int main() {
  string W;
  cin >> W;
  if(W == "Sunny"){
    cout << "Cloudy";
  } else if(W == "Cloudy"){
    cout << "Rainy";
  } else {
    cout << "Sunny";
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int sum[300000];
signed main(){
    int  n;
    string s;
    cin>>n>>s;
    for(int i=0;i<n;i++)
        sum[i+1]=sum[i]+(s[i]=='E');
    int ans=300000;
    for(int i=0;i<n;i++)
        ans=min(ans,sum[n]-sum[i+1]+i-sum[i]);
    cout<<ans<<endl;
}


Measured memory_bytes: 3076
#include<iostream>
using namespace std;
int main()
{
    int S,h,m,s;
    cin>>S;
    h=S/60/60;
    m = (S-S/60/60*60*60)/60;
    s = S - h*3600-m*60;
    cout<<h<<":"<<m<<":"<<s<<endl;
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vl;

const int N = 20003, M = 30000;
int n, arr[N], used[M + 3];
vector <int> two, three, six;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	for (int i = M; i >= 1; i--) {
		if (i % 6 == 0) {
			six.pb(i);
		}	else {
			if (i % 2 == 0) {
				two.pb(i);
			}
			if (i % 3 == 0) {
				three.pb(i);
			}
		}
	}
	cin >> n;
	if (n >= 5) {
		int TWO = M / 2 - M / 6;
		int THREE = M / 3 - M / 6;
		int a = -1, b = -1, c = -1;
		for (int i = 2; i <= min(TWO, n); i += 2) {
			for (int j = 2; j <= min(THREE, n - i); j += 2) {
				if (M / 6 >= n - i - j) {
					a = i, b = j, c = n - i - j;
					break;
				}
			}
		}
		int m = 0;
		while (a--) {
			arr[++m] = two.back();
			two.ppb();
		}
		while (b--) {
			arr[++m] = three.back();
			three.ppb();
		}
		while (c--) {
			arr[++m] = six.back();
			six.ppb();
		}
		for (int i = 1; i <= m; i++) {
			cout << arr[i] << ' ';
		}
		
		//ll total = 0;
		//for (int i = 1; i <= m; i++) {
			//total += arr[i];
		//}
		//cout << '\n';
		//for (int i = 1; i <= m; i++) {
			//if (__gcd((ll)arr[i], total - arr[i]) == 1 || arr[i] > M || arr[i] < 1) {
				//cout << "WA pos " << i;
				//return 0;
			//}
		//}
		//int tmp = 0;
		//for (int i = 1; i <= m; i++) {
			//tmp = __gcd(tmp, arr[i]);
		//}
		//if (tmp != 1) {
			//cout << "WA gcd " << tmp;
			//return 0;
		//}
		//cout << "OK";
	}	else {
		if (n == 3) {
			cout << "2 5 63";
			return 0;
		}
		if (n == 4) {
			cout << "2 5 20 63";
			return 0;
		}
	}
}


Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>

int main(){
  double R;//入力　円の半径
  double L;//出力　円の周長

  scanf("%lf",&R);//Rの値を読み取る

  L=2*M_PI*R;//Lを計算

  printf("%lf\n",L);//Lを表示

  return 0;
}


Measured memory_bytes: 1744
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <bitset>
#include <queue>

using namespace std;

void solve() {
    int64_t n, a, b;
    cin >> n >> a >> b;
    if (a == 0) {
        cout << 0;
        return;
    }

    int64_t c = a + b;
    int64_t x = n / c;
    if (x * c == n) {
        cout << x * a;
        return;
    }
    int64_t result = x * a;
    int64_t rem = n - x * c;
    if (a <= rem) result += a;
    if (a > rem) result += rem;
    cout << result;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fo(i,m,n) for(int i = m; i <= n; i++)
#define fod(i,m,n) for(int i = m; i >= n; i--)
using namespace std;
typedef int64_t i64;
string a[]={"AC", "WA", "TLE", "RE"};
string t;
i64 b[4], n;
typedef pair<int,int> _ii;
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
    cin >> n;
    fo(i, 0, 3) b[i]=0;
    while(n--){
        t.clear();
        cin >> t;
        fo(i, 0, 3){
            if(a[i]==t) b[i]++;
        }
    }
    fo(i, 0, 3){
        cout << a[i] << " x " << b[i] << '\n';
    }
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000007
#define SEP " "

int     main()
{
	ll a;
	ld b;
	cin >> a >> b;
	b *= 100.0;
	ll ans = a * llround(b) / 100;
	printf("%lld\n", ans);
}


Measured memory_bytes: 3832
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0

for i in range(n):
  if a[i] < b[i]:
    ab = b[i] - a[i]
    if a[i+1] > ab:
      ans += b[i]
      a[i+1] -= ab
    else:
      ans += a[i] + a[i+1]
      a[i+1] = 0
  else:
    ans += b[i]

print(ans)


Measured memory_bytes: 24136
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,ll>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=305,Mod=998244353;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
char s[MAXN];int n,a[MAXN],f[MAXN][MAXN][MAXN],g[MAXN][MAXN][MAXN];
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	scanf("%s",s+1),n=strlen(s+1);
	Rep(i,1,n)a[i]=s[i]^48;g[0][0][0]=1;
	Rep(i,1,n){
		Red(j,n,0)Red(k,n,0){
			g[i][j][k]|=g[i-1][j][k];
			if(a[i]==0)g[i][j][k]|=g[i][j][k+1];
			if(a[i]==1)g[i][j][k]|=g[i][j+1][k];
		}
		Rep(j,0,n)Rep(k,0,n)if(i>1){
			if((a[i]==0||a[i-1]==0)&&j)g[i][j][k]|=g[i-2][j-1][k];
			if((a[i]==0&&a[i-1]==0)&&j)g[i][j][k]|=g[i-1][j-1][k+1];
			if((a[i]==1||a[i-1]==1)&&k)g[i][j][k]|=g[i-2][j][k-1];
			if((a[i]==1&&a[i-1]==1)&&k)g[i][j][k]|=g[i-1][j+1][k-1];
		}
	}
	f[n+2][0][0]=1,a[0]=-1;
	Red(i,n+1,1){
		Rep(j,0,n)Rep(k,0,n)f[i][j][k]=f[i+1][j][k];
		if(a[i-1]!=1)Rep(j,0,n)Rep(k,1,n)f[i][j][k]=(f[i][j][k]+f[i][j][k-1])%Mod;
		if(a[i-1]!=0)Rep(j,1,n)Rep(k,0,n)f[i][j][k]=(f[i][j][k]+f[i][j-1][k])%Mod;
	}int c0=0,c1=0,ans=0;
	Rep(i,1,n+1)Rep(j,0,n)Rep(k,0,n)if(g[i-1][j][k])ans=(ans+f[i][j][k])%Mod;
	cout<<(ans-1+Mod)%Mod<<'\n';
	return 0;
}




Measured memory_bytes: 221572
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long A = long.Parse(str[0])-1;
		long B = long.Parse(str[1]);
		long C = long.Parse(str[2]);
		long D = long.Parse(str[3]);
		long L = Lcm(C,D);
		long a1 = B - B/C - B/D + B/L;
		long a2 = A - A/C - A/D + A/L;
		Console.WriteLine(a1-a2);
	}
	
	public static long Gcd(long a, long b) {
		if (a < b)
			return Gcd(b, a);
		while (b != 0) {
			var r = a % b;
			a = b;
			b = r;
		}
		return a;
	}
	public static long Lcm(long a, long b) {
        return a * b / Gcd(a, b);
    }
}

Measured memory_bytes: 13140
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h[ohara], w, x, y, sum, k, q;
V g[ohara];

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

  cin >> n >> m;
  rep(i, n) cin >> h[i];
  rep(i, m) {
    cin >> a >> b;
    a--;
    b--;
    g[a].p_b(b);
    g[b].p_b(a);
  }
  rep(i, n) {
    int ok = 0;
    rep(j, Size(g[i])) {
      ll to = g[i][j];
      if (h[i] <= h[to]) ok = 1;
    }
    if (ok) continue;
    ans++;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 31376
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){

    int N;
    cin >> N;
    int cnt=N;
    vector<int> S(N);
    for (int i=0;i<N;i++){
        cin >> S[i];
    }
    sort(S.begin(),S.end());

    for (int i=1;i<N;i++){
       
        if(S[i]==S[i-1]){
            cnt-=1;
        }
     }
    cout << cnt << endl;
}

Measured memory_bytes: 256
town,sum_road=(int(x) for x in input().split())

al=[list() for x in range(town)]
for x in al:
  x.append(0)

for _ in range(sum_road):
  x,y=(int(x) for x in input().split())
  x-=1
  y-=1
  al[x][0]+=1
  al[y][0]+=1

for x in al:
  print(x[0])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;

int main() {
	int n;
	cin >> n;
	int ans = INF;
	rep(i, n) {
		int x;
		cin >> x;
		int cnt = 0;
		while (x % 2 ==0) {
			x /= 2;
			cnt++;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define pb push_back
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(type,arr,n)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
//=======================
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
//=======================
const int MOD = 1000000007;
const int N = 300005, M = N;

//=======================
vi g[N],adj[N];
int n, m, s, w, W, S, k, i, l, j, p, q, pr, fi, md;


void abhinay()
{
   
    #ifndef ONLINE_JUDGE   
        freopen("input.txt", "r", stdin);   
        freopen("output.txt", "w", stdout);   
    #endif   
    
}

int main(){
    abhinay();
    cin>>n>>w;
    ll dp[101][100005];
    int W[101],V[101];
    fo(i,n+1){ 
        fo(j,100001)
        {
            dp[i][j]=inf;
        }
    }

    fo(i,n) cin>>W[i]>>V[i];
    dp[0][0]=0;
    dp[0][V[0]]=W[0];
    for (int i = 1; i < n+1; i++){
        dp[i][0]=0;  //always empty bag
        for (int j = 1; j <100001; j++)
    {   dp[i][j] = dp[i-1][j];
        if(j>=V[i]) dp[i][j] = min(dp[i][j],W[i]+dp[i-1][j-V[i]]);
    }
}
    ll ret ;
    for (int j = 100000; j >= 0; j--)
    {
        {if(dp[n-1][j]<=w) {ret = j;
        break; }
    } 
}
    cout << ret;
    return 0;
}


Measured memory_bytes: 96548
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    if(c == '-') f = -1;
    c = getchar();
    }
    while(c >= '0' && c <= '9') {
    res = res * 10 +c - '0';
    c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    out(x / 10);
    }
    putchar('0' + x % 10);
}
const int maxn = 5e5 + 5,maxm = 1e6 + 5;;

int N,M,Q,MOD,f[maxn],t[maxn],v[maxn];
int fa[maxm * 6],z,g;
bool able[2][maxm];
int id(int u,int p,int q) {
    return (u - 1) * 6 + p * 3 + q + 1;
}
int gcd(int a,int b) {
    return b == 0 ? a : gcd(b,a % b);
}
int getfa(int u) {
    return u == fa[u] ? u : fa[u] = getfa(fa[u]);
}
void Merge(int u,int v) {
    fa[getfa(u)] = getfa(v);
}
void Init() {
    read(N);read(M);read(Q);read(MOD);
    read(f[1]);read(t[1]);read(v[1]);
    g = MOD;
    for(int i = 2 ; i <= M ; ++i) {
    read(f[i]);read(t[i]);read(v[i]);
    g = gcd(g,abs(v[i] - v[1]));
    }
    MOD = gcd(MOD,3 * g);
    z = v[1] % g;
    int T = id(N,1,2);
    for(int i = 1 ; i <= T; ++i) fa[i] = i;
    for(int i = 1 ; i <= M ; ++i) {
    int w = (v[i]-z )/ g % 3;
    for(int p = 0 ; p < 2 ; ++p) {
        for(int q = 0 ; q < 3 ; ++q) {
        Merge(id(f[i],p,q),id(t[i],p ^ 1,(q * 2 + w) % 3));
        Merge(id(t[i],p,q),id(f[i],p ^ 1,(q * 2 + w) % 3));
        }
    }
    }
    for(int i = 0 , j = z ; i < MOD ; ++i , j = j * 2 % MOD) able[i & 1][j] = 1;
}
void Solve() {
    int s,t,r;
    for(int i = 1 ; i <= Q ; ++i) {
    read(s);read(t);read(r);
    bool res = 0;
    for(int p = 0 ; p < 2 ; ++p) {
        for(int q = 0 ; q < 3 ; ++q) {
        if(getfa(id(t,0,0)) == getfa(id(s,p,q))) {
            if(able[p][(r + z + (3 - q) * g) % MOD]) res = 1;
        }
        }
    }
    if(res) puts("YES");
    else puts("NO");
    }
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Init();
    Solve();
}

Measured memory_bytes: 11260
using System;




class Test {

    static void Main() {

        int i, j;

        for (i = 1; i < 10; i++)
        {

            for (j = 1; j < 10; j++)
            {
                Console.WriteLine("{0}x{1}={2}", i, j, i * j);
            }

        }

    }
    
}

Measured memory_bytes: 5588
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

int main()
{
    IOS();
    ll a,b;
    cin>>a>>b;
    cout<<a + b / 2<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
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 all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

const LL M = 1e9 + 7;

LL pow(LL n, LL m, LL M) {
  if (m == 0) {
    return 1;
  }
  if (m == 1) {
    return n % M;
  }

  LL tmp = pow(n, m / 2, M);
  LL res = (tmp * tmp) % M;
  if (m % 2 == 1) {
    res *= n;
    res %= M;
  }

  return res;
}

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

  vector<int> res(k + 1);

  for (LL i = k; i > 0; i--) {
    res[i] = pow(k / i, n, M);

    for (int j = 2; j * i <= k; j++) {
      res[i] -= res[j * i];
      res[i] += M;
      res[i] %= M;
    }
  }

  LL ans = 0;
  for (LL i = 0; i <= k; i++) {
    ans += (res[i] * i) % M;
    ans %= M;
  }

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

Measured memory_bytes: 3640
#define ONLINE_JUDGE
#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <cmath>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#ifndef ONLINE_JUDGE
#include <prettyprint/prettyprint.hpp>
#endif

#define FOR(i, n) for(int i = 0; i < n; ++i)
#define TEST int T; std::cin >> T; while(T--)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vll = std::vector<ll>;
using vull = std::vector<ull>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	ifstream fin("in.txt");
	ofstream fout("out.txt");
	auto cinbuf = cin.rdbuf(fin.rdbuf());    // save and redirect
	auto coutbuf = cout.rdbuf(fout.rdbuf()); // save and redirect
#endif	
	int n;
	cin >> n;
	int cnt[3] = {0};
	for(int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		++cnt[x - 1];
	}
	double dp[n + 1][n + 1][n + 1];
	dp[0][0][0] = 0;
	for (int k = 0; k <= n; ++k) {
		for (int j = 0; j <= n; ++j) {
			for(int i = 0; i <= n; ++i) {
				if(i == 0 && j == 0 && k == 0) continue;
				int s = i + j + k;
				if(s > n) break;
				dp[i][j][k] = 0;
				if(i > 0) dp[i][j][k] += ((double)i / s) * dp[i - 1][j][k];
				if(j > 0) dp[i][j][k] += ((double)j / s) * dp[i + 1][j - 1][k];
				if(k > 0) dp[i][j][k] += ((double)k / s) * dp[i][j + 1][k - 1];
				dp[i][j][k] += (double)n / s;
			}
		}
	}
	cout << fixed << setprecision(11) << dp[cnt[0]][cnt[1]][cnt[2]] << endl;
#ifndef ONLINE_JUDGE
	cin.rdbuf(cinbuf);    // restore
	cout.rdbuf(coutbuf); // restore
#endif	
}


Measured memory_bytes: 213248
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N = NI()
    A = LI()
    d = {}

    for x in A:
        for i in range(2,int(math.sqrt(x))+1):
            cnt = 0
            while x % i == 0:
                cnt += 1
                x //= i
            if cnt:
                d[i] = max(d.get(i,0),cnt)
            if x == 1: break
        else:
            d[x] = max(d.get(x,0),1)
    m = 1
    for i,x in d.items():
        m = (m * i ** x) % MOD
    ans = 0
    for x in A:
        ans += (m * pow(x,MOD-2,MOD)) % MOD
    print(ans % MOD)


if __name__ == '__main__':
    main()

Measured memory_bytes: 44268
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> w(n);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> w.at(i);
		sum += w.at(i);
	}

	int ans = 1000000000;
	int a = 0;
	for (int i = 0; i < n; i++) {
		a += w.at(i);
		ans = min(ans, abs((sum - a) - a));
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n;
	cin >> n;
	vector<ll> v(n);
	rep(i,n) cin >> v[i];
	sort(ALL(v));
	ll sum = 0;
	int i = 0;
	int cur = 0;
	while(i < n) {
		cur = i;
		sum += v[i];
		while (i < n - 1 && v[i + 1] <= sum * 2) {
			sum += v[i + 1];
			i++;
		}
		i++;
	}
	cout << max(0, n - cur) << endl;
}

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

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(x) setprecision(x)<<fixed
#define ss second
#define fori(v) for(lli i=0; i<v; i++)
#define forj(v) for(lli j=0; j<v; j++)
#define fork(v) for(lli k=0; k<v; k++)
#define forl(v) for(lli l=0; l<v; l++)
#define fort(v) for(lli t=0; t<v; t++)
#define forz(v) for(lli z=0; z<v; z++)
#define lli long long int
#define MAX 100004
#define double long double
#define ch 75
#define pb push_back
lli inf = 8*pow(10,18);
lli modulo = pow(10,9)+7;
double eps = 1e-11;
ifstream in;
ofstream out;
//#define cin in
//#define cout out
void deal(){
	int n;
	cin>>n;
	string a,b;
	fori(n){
		char f;
		cin>>f;
		a+=f;
	}
	fori(n){
		char f;
		cin>>f;
		b+=f;
	}
	reverse(b.begin(),b.end());
	lli num = 0;
	map<string,map<string,lli > > all;
	fori(1<<n){
		string a1= "",a2 = "";
		forj(n){
			if((1<<j)&i)
				a1+=a[j];
			else
				a2+=a[j];
		}
		all[a1][a2]++;
	}	
	fori(1<<n){
		string a1= "",a2 = "";
		forj(n){
			if((1<<j)&i)
				a1+=b[j];
			else
				a2+=b[j];
		}
		num+=all[a1][a2];
	}
	cout<<num;
}
int main(){
	deal();
} 

Measured memory_bytes: 123904
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if ((a * b) % 2 == 0)
            System.out.println("Even");
        else
            System.out.println("Odd");
    }
}

Measured memory_bytes: 35680
#include<bits/stdc++.h>
#define il inline
#define stt static
#define rg register
#define ll long long
#define db double
#define pii pair<int,int>
#define mp make_pair
#define fst first
#define snd second
#define pb push_back
#define y1 substitute_of_y1
#define DEBUG(x) cerr<<#x" = "<<x<<endl;
using namespace std;

template<typename T> il T rd(){
	T nmb=0;int sgn=0;char chr=getchar();
	while(!isdigit(chr)){if(chr=='-')sgn=1;chr=getchar();}
	while(isdigit(chr)){nmb=(nmb<<3)+(nmb<<1)+chr-'0';chr=getchar();}
	return sgn?-nmb:nmb;
}
template<typename T> void wt(T nmb){
	if(nmb>9)wt(nmb/10);
	putchar(nmb%10+'0');
}
template<typename T> il void cmax(T &x,T y){x=x>y?x:y;}
template<typename T> il void cmin(T &x,T y){x=x<y?x:y;}
inline void proc_status(){
	ifstream t ("/proc/self/status");
	cerr<<string(istreambuf_iterator<char>(t),istreambuf_iterator<char>())<<endl;
	/*freopen("/proc/self/status","r",stdin);
	char ch[100];
	while(scanf("%s",ch)!=EOF)cerr<<ch<<endl;*/
}

const int N=410,M=1e5+10;

int n,m;
int a[M][3];
vector<int>f[N];

int Vis[N];

priority_queue<pii>q;

int Flg[N];

il void Sol(int y){
	memset(Vis,0,sizeof Vis);
	Vis[y]=1;
	while(!q.empty())q.pop();
	for(int i=f[y].size()-1;~i;--i){
		int k=f[y][i];
		if(!Vis[a[k][1]])q.push(mp(k,a[k][1]));
		else q.push(mp(k,a[k][2]));
	}
	while(!q.empty()){
		pii t=q.top();
		q.pop();
		if(Vis[t.snd])continue;
		Vis[t.snd]=1;
		for(int i=f[t.snd].size()-1;~i;--i){
			int k=f[t.snd][i];
			if(k>=t.fst)continue;
			if(Vis[a[k][1]]&&Vis[a[k][2]])return;
			if(!Vis[a[k][1]])q.push(mp(k,a[k][1]));
			else q.push(mp(k,a[k][2]));
		}
	}
	Flg[y]=1;
}

bitset<N>S[N];

int main(){
	n=rd<int>(),m=rd<int>();
	for(int k=1;k<=m;++k){
		a[k][1]=rd<int>(),a[k][2]=rd<int>();
		f[a[k][1]].pb(k);
		f[a[k][2]].pb(k);
	}
	for(int i=1;i<=n;++i){
		Sol(i);
		//printf("%d  ",Flg[i]);
		for(int j=1;j<=n;++j)//printf("%d ",Vis[j]),
			S[i][j]=Vis[j];
		//puts("");
	}
	int Ans=0;
	for(int i=1;i<n;++i)
		for(int j=i+1;j<=n;++j)
			if(Flg[i]&&Flg[j]&&(S[i]&S[j]).count()==0)
				++Ans;
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a = 0, b = 0;
  cin >> n;
  vector<int> v(n);
  
  for (int i = 0; i < n; i++)
    cin >> v.at(i);
  
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  
  for (int i = 0; i < n; i += 2) {
    a += v.at(i);
    if (i + 1 == n)
      break;
    
    b += v.at(i + 1);
  }
  
  cout << a - b << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define MAX_HEAP 2000000
#define NEG_INF -100000

int heap_size = 1;
/* 木の移動 */
int parent(int);
int left(int);
int right(int);

void maxHeapfy(int *, int);
void maxHeapInsert(int *, int);
void heapIncreaseKey(int *, int, int);
int heapExtractMax(int *);

int main(void) {
  int key;
  int ary[MAX_HEAP];
  char order[10];

  while (1) {
    scanf("%s %d", order, &key);
    if (order[0] == 'i') {
      maxHeapInsert(ary, key);
    } else if (order[1] == 'x') {
      int max = heapExtractMax(ary);
      printf("%d\n", max);
    } else {
      break;
    } 
  }
    
  return 0;
}

int parent(int i) {
  return i/2;
}
int left(int i) {
  return 2*i;
}
int right(int i) {
  return 2*i + 1;
}

void maxHeapify(int *A, int i) {
  int l = left(i);
  int r = right(i);
  int largest;

  if (l <= heap_size && A[l] > A[i]) {
    largest = l;
  } else {
    largest = i;
  }
  if (r <= heap_size && A[r] > A[largest]) {
    largest = r;
  }

  if (largest != i) {
    /* A[i]とA[largest]の値を交換 */
    int tmp = A[largest];
    A[largest] = A[i];
    A[i] = tmp;

    maxHeapify(A, largest);
  }
}

void maxHeapInsert(int *A, int key) {
  heap_size++;
  A[heap_size] = NEG_INF;
  heapIncreaseKey(A, heap_size, key);
}

void heapIncreaseKey(int *A, int i, int key) {
  if (key < A[i]) {             /* 新しいキーは現在のキーより小さい */
    return;
  }

  A[i] = key;
  while (i > 1 && A[parent(i)] < A[i]) {
    /* 親と子を入れ替える */
    int tmp = A[i];
    A[i] = A[parent(i)];
    A[parent(i)] = tmp;
    i = parent(i);
  }
}

int heapExtractMax(int *A) {
  if (heap_size < 1) {          /* ヒープアンダーフロー */
    return -1;
  }

  int max = A[1];
  A[1] = A[heap_size];
  heap_size--;
  maxHeapify(A, 1);
  return max;
}

Measured memory_bytes: 6076
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

// conversion
//------------------------------------------
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

// math
//-------------------------------------------
template <class T> inline T sqr(T x) { return x * x; }

// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c)                                                             \
  for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

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

// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FILE__ << endl;

const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> p) {
  int cnt=0;
  vector<long long> s = p;
  SORT(s);
  REP(i, N){
    if(s[i]!=p[i])cnt++;
  }
  if(cnt==2||cnt==0)cout<<YES<<endl;
  else cout<<NO<<endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> p(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &p[i]);
  }
  solve(N, std::move(p));
  return 0;
}


Measured memory_bytes: 256