akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()

using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    ll h,w; cin >> h >> w;
    int n; cin >> n;
    map<P,bool> mp;
    vector<P> v;
    rep(i,n){
        int a,b; cin >> a >> b;
        a--; b--;
        v.pb({a,b});
        mp[{a,b}]=1;
    }
    vector<ll> vec(10,0);
    map<P,bool> center;
    rep(num,n){
        P p=v[num];
        for(int i=-1;i<=1;i++){
            for(int j=-1;j<=1;j++){
                P cen={p.fi+i,p.se+j};
                if(center[cen]) continue;
                center[cen]=1;
                int res=0; bool ok=1;
                for(int x=-1;x<=1;x++){
                    for(int y=-1;y<=1;y++){
                        if(mp[{cen.fi+x,cen.se+y}]){
                            res++;
                        }
                        if(cen.fi+x<0||h<=cen.fi+x||cen.se+y<0||w<=cen.se+y) ok=0;
                    }
                }
                if(ok) vec[res]++;
            }
        }
    }
    ll cnt=0;
    rep(i,10){
        cnt+=vec[i];
    }
    vec[0]=(h-2)*(w-2)-cnt;
    rep(i,10){
        cout << vec[i] << endl;
    }
}


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

#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);

/////////////////////////////////////////////

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

////////////////////////////////

void solve(){

	int n;
	cin>>n;
	vector<int> a(n);

	for(auto &i : a)
		cin>>i;

	for(int i = 0 ; i < n ; ++i){

		if(i==0){

			if(a[i] > 1)
				a[i]--;
		}
		else {

			if(a[i] > a[i-1]){

				a[i]--;
			}
		}
	}
	bool f = false;
	for(int i = 0 ; i < n-1 ; ++i){

		if(a[i] > a[i+1])
			f = true;
	}

	if(f){

		cout<<"No\n";
	}
	else cout<<"Yes\n";

}

signed main(int argc , char *argv[]){
	fast;
	
	int t = 1;
	// cin>>t;
	while(t--)
		solve();

}

Measured memory_bytes: 640
H,W=map(int,input().split())
Mine=[]
for i in range(H):
  Mine.append(list(input()))
for i in range(H):
  answer=[]
  for j in range(W):
    if Mine[i][j]=='#':
      answer.append('#')
    else:
      count=0
      if i!=0:
        if j!=0:
          if Mine[i-1][j-1]=='#':
            count+=1
        if j!=W-1:
          if Mine[i-1][j+1]=='#':
            count+=1
        if Mine[i-1][j]=='#':
          count+=1
      if i!=H-1:
        if j!=0:
          if Mine[i+1][j-1]=='#':
            count+=1
        if j!=W-1:
          if Mine[i+1][j+1]=='#':
            count+=1
        if Mine[i+1][j]=='#':
          count+=1
      if j!=0:
        if Mine[i][j-1]=='#':
          count+=1
      if j!=W-1:
        if Mine[i][j+1]=='#':
          count+=1
      answer.append(str(count))
  print("".join(answer))

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

int main() {
    int a,b,m;
    cin >> a >> b >> m;

    vector<int> av(a), bv(b);
    int amin=100001, bmin=100001;
    for (int i=0; i<a; i++) {
        cin >> av.at(i);
        if (amin > av.at(i)) amin = av.at(i);
    }
    for (int i=0; i<b; i++) {
        cin >> bv.at(i);
        if (bmin > bv.at(i)) bmin = bv.at(i);
    }

    int ans = amin + bmin;

    for (int i=0; i<m; i++) {
        int x, y, c;
        cin >> x >> y >> c;

        if (ans > av.at(x-1) + bv.at(y-1) - c) ans = av.at(x-1) + bv.at(y-1) - c;
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <limits>
#include <vector>

using namespace std;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

  	vector<int> h(n);
  	for (int i=0; i<n; i++) {
      	cin >> h[i];
    }

  	vector<int> cost(n, numeric_limits<int>::max());
  	cost[0] = 0;
  	for(int i=1; i<n; i++) {
    	chmin(cost[i], cost[i-1] + abs(h[i-1] - h[i]));
        //printf("#1 i:%d, cost:%d, %d, %d\n", i, cost[i], h[i-1], h[i]);
		if (2<=i) {
	        chmin(cost[i], cost[i-2] + abs(h[i-2] - h[i]));
	        //printf("#2 i:%d, cost:%d\n", i, cost[i]);
        }
    }

	cout << cost[n-1] << endl;

}


Measured memory_bytes: 1024
N = int(raw_input())
s = [0 for i in range(N)]
for i in range(N):
	s[i] = int(raw_input())


ans = 0
for i in range(N):
	ans += s[i]

s.sort()
for i in range(N):
	if ans % 10 != 0:
		print ans
		break
	else:
		for j in range(i , N):
			if s[j] % 10 != 0:
				ans = ans - s[j]
				i = j
				break

if ans % 10 == 0:
	print 0
		

Measured memory_bytes: 2568
#include<cstdio>
#include<cstring>
#define fo(x,a,b) for(int x=(a),e_=(b);x<=e_;x++)
#define Max(a,b) ((a)>(b)?(a):(b))

const int N=300005;
int f[N],a[N],n,B,W,ans;
bool pd[N];

void In(int& a){
	a=0;char c=getchar();for(;c<48||c>57;c=getchar());
	for(;c>47&&c<58;c=getchar()) a=(a<<1)+(a<<3)+c-48;
}
bool ck(int mid){
	int tr=0;
	for(int i=2; i<=n+1; i+=2) {
		if(f[i-1]-f[tr] >= mid) {
			if(f[i]<f[tr]) tr=i;
			if(i==n+1) return true;
		} 
	}return false;
}
int main(){
	In(n);
	fo(i,1,n) {
		In(a[i]);
		f[i]=f[i-1];
		if(i&1) B+=a[i], f[i]+=a[i]; else W+=a[i], f[i]-=a[i];
	}f[n+1]=f[n];
	ans=Max(B,W);
	if(n%2==0) {printf("%d %d",ans,B+W-ans);return 0;}

	int l=ans-W+1,r=B+W,mid,k=0;
	while(l<=r) {
		mid=(l+r)>>1;
//		printf("mid:%d\n",mid);
		if(ck(mid)) l=mid+1, k=mid; else r=mid-1;
	}
	ans=Max(ans,W+k);
	printf("%d %d",ans,B+W-ans);
	return 0;
}



Measured memory_bytes: 3944
import heapq
n, m = map(int, input().split())
work = [list(map(int, input().split())) for _ in range(n)]
work.sort()

cd = []
heapq.heapify(cd)
cnt = 0
ans = 0
# b, a
# aの条件
for k in range(m+1):
    # a = kの仕事をheappush

    for i in range(cnt, n):
        a, b = work[i]

        if a == k:
            heapq.heappush(cd, -b)
        else:
            cnt = i
            break

        if i == n-1:
            cnt = n-1

    if not cd:
        continue
    ans -= heapq.heappop(cd)
print(ans)




Measured memory_bytes: 31676
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    a,b,c,d = map(int, input().split())

    tmp = set(list(range(a,b+1))) & set(list(range(c, d+1)))
    print(max(0, len(tmp)-1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 62752
s = input()

for i in range(1<<len(s)-1):
    t = list(s)
    for j in reversed(range(1,len(s))):
        if i & (1<<(j-1)):
            t = t[:j]+["+"]+t[j:]
        else:
            t = t[:j]+["-"]+t[j:]
    ans = eval("".join(t))
    if ans == 7:
        break

print("".join(t)+"=7")


Measured memory_bytes: 3060
import sys

input = sys.stdin.readline

n_k = list(map(int, input().split()))
n = n_k[0]
k = n_k[1]
a = list(map(int, input().split()))
a_pos = list(filter(lambda v: v >= 0, a))
a_neg = list(filter(lambda v: v < 0, a))

a_pos.sort(reverse=True)
a_neg.sort()

mod = 10**9+7

ans = 1
if n == k:
    for a_i in a:
        ans = ans * a_i % mod
elif len(a_pos) == 0 and k % 2 == 1:
    for i in reversed(range(len(a_neg) - k, len(a_neg))):
        ans = ans * a_neg[i] % mod
else:
    i_p = 0
    i_n = 0
    i = 0
    while i < k:
        if i_p < len(a_pos) and (i == k - 1 or i_n+1 >= len(a_neg) or a_pos[i_p] * (a_pos[i_p+1] if i_p+1 < len(a_pos) else 1) > a_neg[i_n] * a_neg[i_n+1]):
            ans = ans * a_pos[i_p] % mod
            i_p += 1
            i += 1
        else:
            ans = ans * a_neg[i_n] % mod * a_neg[i_n+1] % mod
            i_n += 2
            i += 2
print(ans)


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

int main(){
    int k;
    cin >> k;
    int a, b;
    cin >> a >> b;
    int m=b/k;
    if(m*k>=a){
        cout << "OK" << endl;
    }
    else cout << "NG" << endl;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

class DisjointSet {
public:
  vector<int> rank, p, size;

  DisjointSet() {}
  DisjointSet(int s) {
	rank.resize(s, 0);
	p.resize(s, 0);
	size.resize(s, 0);
	rep (i, s) init(i);
  }

  void init(int x) {
	p[x] = x;
	rank[x] = 0;
	size[x] = 1;
  }

  bool isSame(int x, int y) {
	return root(x) == root(y);
  }

  void makeSet(int x, int y) {
	if (isSame(x, y)) return;
	link(root(x), root(y));
  }

  void link(int x, int y) {
	if (rank[x] > rank[y]) {
	  p[y] = x;
	  size[x] += size[y];
	} else {
	  p[x] = y;
	  size[y] += size[x];
	  if (rank[x] == rank[y]) {
		rank[y]++;
	  }
	}
  }

  int root(int x) {
	if (x != p[x]) {
	  p[x] = root(p[x]);
	}
	return p[x];
  }

  int getSize(int x) {
	return size[root(x)];
  }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n, m, k;
	cin >> n >> m >> k;
	DisjointSet dj = DisjointSet(n);
	vector<int> cnt(n, 1), b[n];
	rep (i, m) {
	  int c, d;
	  cin >> c >> d;
	  cnt[c - 1]++;
	  cnt[d - 1]++;
	  dj.makeSet(c - 1, d - 1);
	}
	rep (i, k) {
	  int c, d;
	  cin >> c >> d;
	  b[c - 1].push_back(d - 1);
	  b[d - 1].push_back(c - 1);
	}
	rep (i, n) {
	  int count = 0;
	  for (auto e: b[i]) {
		if (dj.isSame(i, e)) count++;
	  }
	  cout << dj.getSize(i) - count - cnt[i];
	  if (i == n - 1) cout << endl;
	  else cout << " ";
	}
	
    
    return 0;
}



Measured memory_bytes: 9696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

int main()
{
    ll D, G;
    cin >> D >> G;
    vector<ll> P(D);
    vector<ll> C(D);
    repi(i, D, 0)
    {
        cin >> P[i] >> C[i];
    }

    //完全に解くか、解かないか
    ll ans = INF;

    repb(bit, D, 0)
    {
        ll sum = 0, problems = 0, rest = 0;
        repi(i, D, 0)
        {
            if (bit & (1 << i))
            {
                sum += 100 * (i + 1) * P.at(i) + C.at(i);
                problems += P.at(i);
            }
            else
            {
                rest = i;
            }
        }
        //余ったら中途半端に埋め合わせ
        if (sum < G)
        {
            ll s1 = 100 * (rest + 1);
            ll need = (G - sum + s1 - 1) / s1;
            if (need >= P.at(rest))
            {
                continue;
            }
            problems += need;
        }
        ans = min(ans, problems);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int ans = 0;
    string s, t;
    cin >> s >> t;
    rep(i, 3) if(s.at(i) == t.at(i)) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
def g(a,b)
	a,b=b,a if b>a
	a%b==0?b:g(b,a%b)
end
def l(a,b)
	a*b/g(a,b)
end
while s=gets;a,b=s.split;puts "#{g(a.to_i,b.to_i)} #{l(a.to_i,b.to_i)}"end

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

int mod = 1000000007;
int64_t large = 9223372036854775807;

int main()
{
    int N;
    cin >> N;
    vector<int> C(N - 1);
    vector<int> S(N - 1);
    vector<int> F(N - 1);

    for (int i = 0; i < N - 1; i++)
        cin >> C[i] >> S[i] >> F[i];

    for (int start = 0; start < N - 1; start++)
    {
        int time = 0;
        for (int i = start; i < N - 1; i++)
        {
            if (time < S[i])
                time = S[i];
            else if (time % F[i] != 0)
                time = time + F[i] - (time % F[i]);
            time += C[i];
        }
        cout << time << endl;
    }

    cout << 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cmath>
#include <set>
#include <vector>

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

using namespace std;

int main()
{
  int n, m;
  cin >> n >> m;
  set<int> broken = {};
  vector<int> steps(n+1, 0);

  REP(i, m) {
    int x;
    cin >> x;
    broken.insert(x);
  }

  REP(i, n + 1) {
    if (broken.find(i) != broken.end()) {
      steps[i] = 0;
    } else {
      if (i <= 1) {
        steps[i] = 1;
      } else {
        steps[i] = steps[i - 1] + steps[i - 2];
      }
    }
    steps[i] = steps[i] % 1000000007;
  }
  cout << steps[n];
}


Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String tapMoving = sc.next();
		
		for(int i = 0 ; i < tapMoving.length() ; i++ ) {
			char move = tapMoving.charAt(i);
			
			if (move == 'D' || move == 'U') {
				continue;
			}
			
			if ( i % 2 == 0 ) {
				if ( move == 'R' ) {
					//good move
				}
				else {
					System.out.println("No");
					return;
				}
			}
			
			if ( i % 2 == 1 ) {


				if ( move == 'L' ) {
					//good move
				}
				else {
					System.out.println("No");
					return;
				}
			}
		}
		
		System.out.println("Yes");
	}
}


Measured memory_bytes: 23892
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<vector>
#include<queue>
#include<math.h>
#include<stdlib.h>
#include<algorithm>

typedef long long int ll;

using namespace std;

int main() 
{
    int n;
    cin>>n;
    int k;
    cin>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll dp[n];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        dp[i]=INT32_MAX;
        for(int j=1;j<=k & j<=i;j++){
            dp[i]=min(dp[i],abs(a[i]-a[i-j])+dp[i-j]);
        }
    }
    // for(int i=0;i<n;i++){
    //     cout<<dp[i]<<endl;
    // }
    cout<<dp[n-1];
}

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

Measured memory_bytes: 17816
import sys
sys.setrecursionlimit(100000)

N,M = map(int,input().split())
adj = [ [] for _ in range(N) ]
for _ in range(M):
  u,v = map(int,input().split())
  u -= 1
  v -= 1
  adj[u].append(v)
  adj[v].append(u)

color = [None] * N
def dfs(n, c):
  color[n] = c
  for nei in adj[n]:
    if color[nei] is not None:
      if color[nei] == c: 
        return False
    elif not dfs(nei, 1-c):
      return False
    # else:
    #   dfs(nei, 1-c)

  return True

if dfs(0,1):
  print(color.count(1)*color.count(0) - M)
else:
  print(N*(N-1)//2 - M)


Measured memory_bytes: 212036
import math
import fractions

a, b = map(int, input().split())

n = fractions.gcd(a, b)

cd = []
for i in range(1, math.ceil(math.sqrt(n) + 1)):
    if n % i == 0:
        if n // i == i:
            cd.append(i)
        else:
            cd.append(i)
            cd.append(n // i)

cd.sort()

ans = 0
for i in range(len(cd)):
    for j in range(i + 1):
        if j == i:
            continue
        if cd[j] > 1 and cd[i] % cd[j] == 0:
            break
    else:
        ans += 1
print(ans)

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

int main()
{
    int N;
    cin >> N;
    int d[N+3];
    for(int i = 0; i < N; ++i) cin >> d[i];
    sort(d, d+N);
    cout << d[N/2] - d[N/2-1] << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
#define alrep(i,j,n) for(int i=0;i<(n);++i)for(int j=i+1;j<(n);++j
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int MOD=1e9+7;
const long long INF = 1LL << 60;
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()



signed main(){
  double N;
  cin >> N;
  int a=floor(sqrt(N));
  for(int i=a;i>=0;i--){
    if((int)N%i==0){
      int b=(int)N/i;
      cout << i+b-2 << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    int N;
    cin >> N;
    vector<double> p(N);
    rep(i, N) { cin >> p[i]; }

    double dp[N + 1][2][N + 1];
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1.0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            dp[i + 1][0][j] =
                dp[i][1][j] * (1.0 - p[i]) + dp[i][0][j] * (1.0 - p[i]);
            dp[i + 1][1][j + 1] = dp[i][1][j] * p[i] + dp[i][0][j] * p[i];
        }
    }

    double ans = 0;
    for (int j = N / 2 + 1; j < N + 1; j++) {
        ans += dp[N][0][j] + dp[N][1][j];
    }

    cout << fixed << setprecision(10) << ans << endl;
}

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

typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int>A(N);
    map<int, ll>m;
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
        if (!m.count(A.at(i))) {
            m[A.at(i)] = 1;
        }
        else {
            m[A.at(i)]++;
        }
    }
    int Q;
    cin >> Q;
    vector<int>B(Q), C(Q);
    for (int i = 0; i < Q; i++) {
        cin >> B.at(i) >> C.at(i);
    }
    ll num = 0;
    for (pair<int, ll>p: m) {
        num += p.first * p.second;
    }
    for (int i = 0; i < Q; i++) {
        if (m.count(B.at(i))) {
            num += (C.at(i) - B.at(i)) * m[B.at(i)];
            if (!m.count(C.at(i))) {
                m[C.at(i)] = 0;
            }
            m[C.at(i)] += m[B.at(i)];
            m.erase(B.at(i));
        }
        cout << num << endl;
    }
}

Measured memory_bytes: 8200
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//最小公倍数、最大公約数
ll gcd(ll a, ll b) {
	return b != 0 ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main() {
	ll A, B;
	cin >> A >> B;
	cout << lcm(A, B) << endl;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
AC = [0]*(N+1)
for i in range(1, N):
   AC[i+1] = AC[i]
   if S[i-1:i+1] == 'AC':
      AC[i+1]+=1
l = []
r = []
for i in range(Q):
   L, R = map(int, input().split())
   l.append(L), r.append(R)
for i in range(Q):
   print(AC[r[i]] - AC[l[i]])

Measured memory_bytes: 14244
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);

    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];

    sort(all(a)); sort(all(c));
    ll ans=0;

    for(int i=0; i<n; i++){
        ll d1 = (lower_bound(all(a),b[i])-a.begin());
        ll d2 = c.end()-upper_bound(all(c),b[i]);
        ans += d1*d2;
    }

    dunk(ans);
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define boost std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

using namespace std;
using LL = long long;

constexpr int MAXN = 505;
constexpr LL M = 998244353;

template <typename T> inline void read(T &x) {
    int f = 1; x = 0;
    char ch = getchar();
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

int main() {
    boost;
    long double r;
    cin >> r;
    cout << setprecision(6) << fixed << r * 2 * acos(-1);
    return 0;
}

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

int search_root(int *par, int v)
{

  if(par[v] != v) 
    {
      par[v] = search_root(par, par[v]);
      return par[v];
    }
  else
    return v;

}

int unite(int *par, int v1, int v2)
{
  int r1 = search_root(par, v1);
  int r2 = search_root(par, v2);
    
  if(r1 != r2)
    {
      par[r1] = r2;
      return true;
    }

  else
    return false;
}

int main(int argc, char **argv)
{
  int Vnum,Enum,i;

  std::cin >> Vnum >> Enum;

  int *par, *s, *t;
  s = new int[Enum];
  t = new int[Enum];
  par = new int[Vnum];
  std::pair<int,int> w[Enum];
  
  for(i=0; i<Enum; i++)
    {
      std::cin >> s[i] >> t[i] >> w[i].first;
      w[i].second = i;
    }

  std::sort(w, w+Enum);

  for(i=0; i<Vnum; i++)
    par[i]=i;
      
  int sum = 0;

  for(i=0; i<Enum; i++)
    {
      if(unite(par, s[w[i].second], t[w[i].second]))
	sum += w[i].first;
    }
      
  std::cout << sum << std::endl;

  return 0;
}


Measured memory_bytes: 4676
n, k = map(int, raw_input().split())
d = {}
for i in range(k):
    a, b = map(int, raw_input().split())
    d[a] = b
dp =[[[[0]*(n+1) for i in range(4)] for j in range(4)] for k in range(4)]
def solve(a, b, c, i):
    if dp[a][b][c][i]: return dp[a][b][c][i]
    if a == b == c: return 0
    if i in d and d[i] != c: return 0
    if i == n: return 1
    dp[a][b][c][i] = (solve(b,c,1,i+1) + solve(b,c,2,i+1) + solve(b,c,3,i+1)) % 10000
    return dp[a][b][c][i]
ans = (solve(0,0,1,1) + solve(0,0,2,1) + solve(0,0,3,1)) % 10000
print ans

Measured memory_bytes: 6548
object Scanner {
  private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0
  @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
  @inline private def hasNextByte(): Boolean =
    if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }
  @inline private def hasNext(): Boolean = {
    while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
    hasNextByte()
  }
  @inline private def readByte(): Byte =
    if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }
  def next(): String = {
    if(!hasNext()) ???
    val sb = new StringBuilder; var b = readByte()
    while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
    sb.toString
  }
  def nextInt(): Int = {
    val n = nextLong()
    if (n < Int.MinValue || Int.MaxValue < n) ???
    n.toInt
  }
  def nextLong(): Long = {
    if(!hasNext()) ???
    var minus = false; var b = readByte()
    if (b == '-') { minus = true; b = readByte() }
    def go (b: Byte, n: Long = 0): Long =
      if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }
      else if (minus) { -n } else { n }
    go(b)
  }
  def nextDouble(): Double = next.toDouble
}

object Main extends App {
  val a = Array.fill(5)(Scanner.nextInt)
  val k = Scanner.nextInt

  val result = a.combinations(2).map(x=>{
    x(1)-x(0)<=k
  })

  if (result.contains(false)) {
    println(":(")
  } else {
    println("Yay!")
  }
}

Measured memory_bytes: 25404
#include <bits/stdc++.h>
using namespace std;
using llong = long long;
int main()
{
    llong n;
    cin >> n;
    llong ans(0);
    for (llong i = 2; i <= sqrt(n); ++i)
    {
        if (n % i == 0)
        {
            llong tmp = i;
            while (n % tmp == 0)
            {
                ans++;
                n /= tmp;
                tmp *= i;
            }
            while (n % i == 0)
                n /= i;
        }
    }
    if (n != 1)
        ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3676
<?php
$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
//list($L,$R,$d) = array_map('intval',explode(" ",trim(fgets(STDIN))));
$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

$res=0;
for($i=0;$i<$N;$i++) {
  if ((($i+1) % 2 == 1) && ($A[$i] % 2 == 1)) {
    $res++;
  }
}
printf("%d\n",$res);


Measured memory_bytes: 15996
from collections import defaultdict
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):  #要素xが属するグループの根を返す
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):  #要素xが属するグループと要素yが属するグループを併合
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):  #グループのサイズ
        return -self.parents[self.find(x)]

    def same(self, x, y):   #要素xと要素yが同じグループかどうか
        return self.find(x) == self.find(y)

    def members(self, x):   #要素xが属するグループに属する要素をリストで返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):    #すべての根の要素をリストで返す
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):  #グループの数を変えす
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, k, l = map(int, input().split())

uf = UnionFind(n)

p, q = [0] * k, [0] * k
for i in range(k):
    pp, qq = map(int, input().split())
    p[i] = pp - 1 
    q[i] = qq - 1
    uf.union(pp - 1, qq - 1)

uuff = UnionFind(n)
r, s = [0] * l, [0] * l
for i in range(l):
    rr, ss = map(int, input().split())
    r[i] = rr - 1
    s[i] = ss - 1
    uuff.union(rr - 1, ss - 1)
dic = defaultdict(int)
for i in range(n):
    dic[(uf.find(i), uuff.find(i))] += 1

ans = []
for i in range(n):
    ans.append(dic[uf.find(i), uuff.find(i)])

for i in ans:
    print(i,end=" ")

Measured memory_bytes: 55120
#include<stdio.h>
int main(void){
  int i;
  int number;
  int check = 0;
  
  scanf("%d", &number);
  
  for(i = 0; i < 3; i++) {
    if(number % 10 == 7) {
      check = 1;
    }
    number = number / 10;
  }
  if(check == 1){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 1708
#include<iostream>
using namespace std;
int main()
{
  int n,f,b;
  cin>>n;
  f=n/100;
  b=n%100;
  if(b>0&&b<13&&f>0&&f<13)
    cout<<"AMBIGUOUS";
  else if(b>0&&b<13)
    cout<<"YYMM";
  else if(f>0&&f<13)
    cout<<"MMYY";
  else
    cout<<"NA";
}
      
  


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;
const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}




int main() {

  long n,w,h;

  cin >> n >> w >>h;
  // vector<long> a(n);




  long ans = (n+1 -w )*(n+1 -h ) ;



  // cout << "YES" <<endl;
  cout << ans << endl;


}




















Measured memory_bytes: 256
/*2019/07/29 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
typedef long long int ll;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}
/*
int asc_t(const void *a,const void *b){return ((user_t*)a)->score - ((user_t*)b)->score;}
int desc_t(const void *a,const void *b){return ((user_t*)b)->score - ((user_t*)a)->score;}
*/

int main(){
    int m,d;
    scanf("%d %d",&m,&d);
    char str[10];

    int d10,d1;
    int cnt=0;
    for(int i=1;i<=m;i++){
        for(int j=2;j<=d;j++){
            d1=d10=0;
            d10=j/10;
            d1=j%10;
            if(!(d10>=2&&d1>=2)){
                continue;
            }
            //printf("%d\n",d1);
            
            //printf("%d %d\n",i,j);
            if(d10*d1==i){
                //printf("%d %d?%d\n",i,d10,d1);
                cnt++;
            }
        }
    }

    printf("%d\n",cnt);

    return 0;
}

Measured memory_bytes: 128
from collections import deque


def main():
    N = int(input())
    adj = [set() for _ in range(N)]
    for i in range(N-1):
        a, b = map(int, input().split())
        adj[a-1].add((b-1, i))
    ans = [0] * (N-1)
    q = deque([])
    q.append((0, -1))
    while len(q):
        cur, used = q.popleft()
        idx = 0
        for nxt, edge in adj[cur]:
            idx += 1
            if idx == used:
                idx += 1
            if ans[edge] != 0:
                continue
            ans[edge] = idx
            q.append((nxt, idx))
    mx = max(ans)
    print(mx)
    for i in range(N-1):
        print(ans[i])


if __name__ == "__main__":
    main()


Measured memory_bytes: 76064
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}


//#########################################

int main() {

int a=D(),b=D();
if(a==1&&b>1){
cout<<"Alice";
return 0;
}
if(b==1&&a>1){
cout<<"Bob";
return 0;
}
if(a==b){
cout<<"Draw";
}
else if(a>b){
cout<<"Alice";


}else{
cout<<"Bob";


}





}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){
  if(b==0){
    return a;
  }
  return gcd(b,a%b);
}
int main(){
  ll n,x;cin >> n >> x;
  if(n==x*2){
    cout << x*3 << endl;
  }
  else{
    cout << (n-gcd(n,x))*3 << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null) {
            	String[] str=line.split(" ");
            	double a=Double.parseDouble(str[0]);
            	double b=Double.parseDouble(str[1]);
            	double c=Double.parseDouble(str[2]);
            	double d=Double.parseDouble(str[3]);
            	System.out.println(Math.sqrt(Math.pow(c-a, 2)+Math.pow(d-b,2)));
            	break;
            }
        }
    }


}

Measured memory_bytes: 24584
#include <cstdio>
#include <iostream>
#include <iterator>
#include <vector>

using namespace std;

const int MAX = 10000;
vector<int> G[MAX];

vector<int> ans;

bool visited[MAX];

void dfs(int u) {

	visited[u] = true;
	for (int i = 0; i < G[u].size(); ++i) {
		int next = G[u][i];
		if (visited[next] == false) {
			dfs(next);
		}
	}
	ans.push_back(u);
}

int main() {

	int v, e;
	scanf("%d %d", &v, &e);

	for (int i = 0; i < v; ++i) {
		visited[i] = false;
	}

	for (int i = 0; i < e; ++i) {
		int s, t;
		scanf("%d %d", &s, &t);

		G[s].push_back(t);
	}

	for (int i = 0; i < v; ++i) {
		if (visited[i] == false)
			dfs(i);
	}

	for (auto itr = ans.rbegin(); itr != ans.rend(); ++itr) {
		cout << *itr << endl;
	}

	return 0;
}

Measured memory_bytes: 3924
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    N,S=map(int,input().split())
    A=list(map(int,input().split()))

    # https://qiita.com/drken/items/dc53c683d6de8aeacf5a#%E9%A1%9E%E9%A1%8C-3
    
    INF = 10**10  # INF+INFを計算してもオーバーフローしない範囲で大きく
    MOD=998244353
    
    I, J =N,S
    # dpテーブル dp[i][j]:=i番目以下で選ばれしa_kの和がjになる通り数
    dp = [[0]*(J+1) for _ in range(I+1)]
    # 初期条件
    dp[0][0] = 1
    # ループ
    for i in range(I):
        for j in range(J+1):
            dp[i+1][j]+=2*dp[i][j]
            dp[i+1][j]%=MOD
            if j+A[i]<=S:
                dp[i+1][j+A[i]]+=dp[i][j]
                dp[i+1][j+A[i]]%=MOD

    print(dp[I][J])
    
    
    
resolve()

Measured memory_bytes: 132568
#include<bits/stdc++.h>    
using namespace std;
#define ll long long 
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define pb push_back
#define inf 1e16
#define mod 998244353
#define en '\n'
#define ld long double
#define ff first
#define ss second
#define ull unsigned long long 
ll pw(ll b, ll r, ll md){
	ll ans = 1;
	while(r){
		if(r&1)ans = (ans*b)%md;
		b = (b*b)%md;
		r>>=1;
	}
	return ans;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n,k;cin>>n>>k;
	ll ans = n%k;
	ans = min(ans,k-ans);
	cout<<ans<<en;

	return 0 ; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 998244353
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
//_______________________________________________________________________________
const ll N = 200005;
ll seg[4*N];
ll lazy[8*N];
ll power(ll a,ll b,ll m)
{
   ll ans=1;
   while(b>0)
   {
       if(b%2)
       {
           ans=(ans*a)%m;
       }
       a=(a*a)%m;
       b=b/2;
   }
   return ans;
}
void build(ll ind,ll rl,ll rr)
{
          if(rl == rr)
          {
                    seg[ind] = 1;
                    return;
          }
          ll mid = (rr + rl)/2;
          build(2*ind,rl,mid);
          build((2*ind)+1,mid+1,rr);
          ll mx = rr-mid;
          seg[ind] = seg[2*ind+1] + (seg[2*ind]*power(10,mx,mod))%mod;
          seg[ind] %= mod;
}
ll sz[N];
void propogate(ll ind,ll rl,ll rr)
{
       if(lazy[ind])
       {
              ll curr = rr-rl+1;
              seg[ind] = (sz[curr]*lazy[ind])%mod;
              lazy[2*ind] = lazy[2*ind+1] = lazy[ind];
              lazy[ind] = 0;
       }
}
void update(ll ind,ll rl,ll rr,ll ql,ll qr,ll val)
{
              //cout<<ind<<endl;
              propogate(ind,rl,rr);
              if((ql > rr) || (qr < rl))
              {
                     return;
              }
              if((rl >= ql) && (rr <= qr))
              {
                     ll curr = rr-rl+1;
                     seg[ind] = (sz[curr]*val)%mod;
                     lazy[2*ind] = lazy[2*ind+1] = val;
                     return;
             }
             ll mid = (rl + rr)/2;
             update(2*ind,rl,mid,ql,qr,val);
             update((2*ind)+1,mid+1,rr,ql,qr,val);
             ll mx = rr-mid;
            seg[ind] = seg[2*ind+1] + (seg[2*ind]*power(10,mx,mod))%mod;
            seg[ind] %= mod;
}
ll query(ll ind,ll ql,ll qr,ll rl,ll rr)
{
          propogate(ind,rl,rr);
          if((ql > rr) || (qr < rl))
          {
                    return 0;
          }
          if((rl >= ql) && (rr <= qr))
          {
                    return seg[ind];
          }
          ll mid = (rl + rr)/2;
           ll mx = rr-mid;
          ll x1 = query(2*ind,ql,qr,rl,mid);
          ll x2 = query((2*ind)+1,ql,qr,mid+1,rr);
          return (x1 + (x2*(power(10,mx,mod)))%mod)%mod;
}
int main()
{
       ll curr = 1;
       for(ll i = 1 ; i < N ; i++)
       {
              sz[i] = curr;
              curr *= 10;
              curr++;
              curr %= mod;
       }
       memset(lazy,0,sizeof lazy);
       ll n,q;
       cin>>n>>q;
       build(1,0,n-1);
       while(q--)
       {
              ll l,r,d;
              cin>>l>>r>>d;
              --l;--r;
              update(1,0,n-1,l,r,d);
              cout<<query(1,0,n-1,0,n-1)<<endl;
       }
}


Measured memory_bytes: 21752
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int main(){
  string s,s2;
  cin >> s >> s2; 
  if(s == s2.substr(0,s.length()) && s2.length() == s.length()+1){ 
    cout << "Yes" <<endl;
  }
     else{
       cout << "No" << endl;
     }
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <set>
#include <cmath>
#include <math.h>
#include <sstream> 
 
using namespace std;
 
int main(){
    string s;
    int i=0;
    cin>>s;
    for(i=1;i<4;i++){
        if(s[0]==s[i]){
            continue;
        }else{
            break;
        }
    }
    
    if(i>2){
        cout<<"Yes"<<endl;
        return 0;
    }
        
    for(i=2;i<4;i++){
        if(s[1]==s[i]){
            continue;
        }else{
            break;
        }
    }
   
    if(i==4){
         cout<<"Yes"<<endl;
        return 0;
    }
         cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
// G++ MACRO.CPP -STD=C++17
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair
 
int main(){
 
  CIN(n);
  COUT(800*n - 200*(n/15));
 
  return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    map<ll, ll> cnt;
    rep(i, N) {
        cnt[A[i]]++;
    }
    ll base = 0;
    for (P p : cnt) {
        base += (p.second * (p.second - 1)) / 2;
    }
    rep(i, N) {
        ll a = A[i];
        ll c = cnt[a];
        ll now = (c * (c - 1)) / 2;
        ll minus = ((c - 1) * (c - 2)) / 2;
        base -= now;
        base += minus;
        cout << base << '\n';
        base -= minus;
        base += now;
    }

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

int main() {
    int64_t h;
    cin >> h;

    int64_t ans = 0;
    int64_t num = 1;
    while(h > 0) {
        ans += num;
        num *= 2;
        h /= 2;
    }

    cout << ans << endl;

    return 0;
}

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

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

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i=0; i<N; ++i) cin >> L[i];

    int res = 0;
    for (int i=0; i<N; ++i) {
        for (int j=i+1; j<N; ++j) {
            for (int k=j+1; k<N; ++k) {
                if (L[i] != L[j] && L[j] != L[k] && L[k] != L[i] && L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[k] + L[i] > L[j]) {
                    ++res;
                }
            }
        }
    }
    cout << res << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


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


#define dhai_machli ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int N = 2e5 + 10;


bool f[100001];
int c[100002];

int n, l, r;

using namespace std;

int main()
{



   dhai_machli;



   for ( int i = 2; i * i <= 100000; i ++) if (! f [ i ]) 
      for ( int j = i * i ; j <= 100000; j += i )
            f[ j ] = true ;
   for ( int i = 3; i <= 100000; i += 2) 

      if (! f [ i ] && ! f [( i + 1) / 2]) c [ i ]++;

   for ( int i = 3; i <= 100000; i ++) c [ i ] += c [i - 1];

      
   cin >> n;
   while (n--)
   {
      cin >> l >> r;

      cout << c[r] - c[l - 1] << endl;
   }


   return 0;
}


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

using namespace std;

using uint = unsigned int;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_p(x) cerr<<#x": "<<(x).first<<' '<<(x).second<<endl
#define dbg_v(x, n) {cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<(x)[_]<<' ';cerr<<endl;}
#define all(v) v.begin(), v.end()
#define fi first
#define se second
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
 
template<typename T1, typename T2>
ostream& operator <<(ostream &out, const pair<T1, T2> &item) {
	out << '(' << item.first << ", " << item.second << ')';
	return out;
}
 
template <typename T>
ostream& operator <<(ostream &out, const vector<T>& v) {
	for(const auto &item : v) out << item << ' ';
	return out;
}

const int inf = 1e9;
string s;
int dp[1000006][2];

int main()
{
	ios_base::sync_with_stdio(false);

	cin>>s;
	reverse(s.begin(), s.end());
	s = " " + s;
	int n = s.size();
	dp[0][1] = inf;
	for (int i=1; i<n; i++)
	{
		// fara imprumut
		dp[i][0] = dp[i-1][0] + s[i] - '0';
		if (s[i] != '9')
			dp[i][0] = min(dp[i][0], dp[i-1][1] + s[i] -'0' + 1);

		// cu imprumut
		dp[i][1] = dp[i-1][0] + 10 - (s[i] - '0');
		dp[i][1] = min(dp[i][1], dp[i-1][1] + 9 - (s[i] - '0'));
	}
	cout<<min(dp[n-1][0], dp[n-1][1] + 1)<<'\n';
	return 0;
}

Measured memory_bytes: 9160