akhauriyash/Code-Regression huggingface dataset:
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}
void _main();
int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); return 0;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-5,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

void _main(){
  ll N,Q;
  cin >> N >> Q;
  string s;
  cin >> s ;
  vl num(N+1);
  ll c = 0;
  REP(i,1,N){
    if(s[i]=='C'&&s[i-1]=='A') c++;
    num[i+1] = c;
  }
  dump(num);
  rep(qq,Q){
    int l,r; cin >> l >> r ;
    l--; r--;
    ll flag = ll(s[l]=='C'&&s[l-1]=='A');
    cout << num[r+1]-num[l]-flag << endl;
  }
}

Measured memory_bytes: 1872
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

int main() {
    int n, count = 0, mini = 0;
    std::string str;
    std::cin >> n >> str;
    std::vector<int> v(n);
    for (auto i = 0; i < n; i++) {
        if (str[i] == ')') count--;
        else count++;

        v[i] = count;
        if (v[mini] > count) mini = i;
    }

    str.insert(str.end(), abs(v[n - 1] - v[mini] + (v[mini] > 0 ? 1 : 0)), ')');
    str.insert(str.begin(), abs(std::min(0, v[mini])), '(');
    std::cout << str << std::endl;

    return 0;
}

Measured memory_bytes: 384
n,m = (int(num) for num in input().split())
ans = ["empty"] * n
isPossible = True
for _ in range(m):
    s,c = (int(num) for num in input().split())
    idx = s - 1
    if ans[idx] == "empty" or ans[idx] == c:
        ans[idx] = c
    else:
        isPossible = False
if n != 1 and ans[0] == 0:
    isPossible = False
    
ans_str = ""
    
if isPossible:
    for i in range(len(ans)):
        num = ans[i]
        if num == "empty":
            if i == 0 and n != 1:
                ans_str += "1"
            else:
                ans_str += "0"
        else:
            ans_str += str(num)
else:
    ans_str = "-1"
    
print(ans_str)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define gc getchar
inline int read(){
	char ch=gc();
	int res=0,f=1;
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
	return f?res:-res;
}
#define re register
#define pb push_back
#define cs const
#define pii pair<int,int>
#define fi first
#define se second
#define ll long long
cs int mod=1e9+7;
inline int add(int a,int b){return (a+=b)>=mod?a-mod:a;}
inline void Add(int &a,int b){(a+=b)>=mod?(a-=mod):0;}
inline int dec(int a,int b){return (a-=b)<0?a+mod:a;}
inline void Dec(int &a,int b){(a-=b)<0?(a+=mod):0;}
inline int mul(int a,int b){return 1ll*a*b>=mod?1ll*a*b%mod:a*b;}
inline void Mul(int &a,int b){a=mul(a,b);}
inline int ksm(int a,int b,int res=1){
	for(;b;b>>=1,a=mul(a,a))(b&1)&&(res=mul(res,a));return res;
}
inline void chemx(ll &a,ll b){a<b?a=b:0;}
inline void chemn(int &a,int b){a>b?a=b:0;}
int n,L,l,r;
long double tmp,siz;
cs int N=500005;
struct node{
	long double v,t;
}q[N];
int main(){
	n=read(),L=read();
	l=1;
	for(int i=1;i<=n;i++){
		node now;
		now.t=read(),now.v=read();
		while(l<=r&&siz+now.v>L){
			long double del=min(q[l].v,siz+now.v-L);
			q[l].v-=del,siz-=del,tmp-=del*q[l].t;
			if(!q[l].v)l++;
		}
		siz+=now.v,tmp+=now.v*now.t;
		printf("%.7Lf\n",(1.0*tmp/L));
		while(l<=r&&q[r].t>=now.t){
			now.t=(now.v*now.t+q[r].t*q[r].v)/(q[r].v+now.v);
			now.v+=q[r].v,r--;
		}
		q[++r]=now;
	}
}

Measured memory_bytes: 24704
#include <stdio.h>

int bubble_sort(int n, int *a)
{
	int i, f, x;
int ans = 0;

	do {
		f = 0;
		for (i = n-1; i > 0; i--) {
			if (a[i] < a[i-1]) {
				x = a[i], a[i] = a[i-1], a[i-1] = x;
ans++;
				f = 1;
			}
		}
	} while (f);
return ans;
}

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int a[102];

int main()
{
	int N, i, k;

	N = in();
	for (i = 0; i < N; i++) a[i] = in();
	k = bubble_sort(N, a);
	printf("%d", a[0]);
	for (i = 1; i < N; i++) printf(" %d", a[i]);
	putchar('\n');
	printf("%d\n", k);
	return 0;
}


Measured memory_bytes: 2148
import math

N,D = map(int, input().split())
X = [0] * (N +1)
Y = [0] * (N +1)
Ans = 0

for i in range(1,N + 1):
  X[i],Y[i] = map(int, input().split())
  if math.sqrt(X[i]**2 + Y[i]**2) <= D:
    Ans += 1

print(Ans)





Measured memory_bytes: 24660
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define lld double
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define vc vector
#define rep1(it,v) for(it=v.begin();it!=v.end();it++)
#define ayush ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define input(v) for(auto &it:v)cin>>it
#define M 1000000007
#define pb push_back

ll dp[105][100005]; 


int main()
{
    ll n,k; cin>>n>>k; vc<ll> v1(n); input(v1);
    
    rep(i,0,v1[0]) dp[0][i]=1; 
    
    rep(i,1,n-1)
    {
        vc<ll> v2(k+1); v2[0]=dp[i-1][0];
        rep(j,1,k) v2[j]=(v2[j-1] + dp[i-1][j])%M;
        rep(j,0,k)
        {
            if(j-v1[i] > 0)
            dp[i][j]=(v2[j] + M - v2[j-v1[i]-1])%M;
            else 
            dp[i][j]=v2[j];
        }
    }
    
    cout<<dp[n-1][k];
    
}

Measured memory_bytes: 82412
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int s;
    cin >> s;
    int before = s;
    int now;
    int m;
    set<int> log={s};
    reps(i, 1000001, 1)
    {
        if (before % 2 == 0)
        {
            now = before / 2;
        }
        else
        {
            now = 3 * before + 1;
        }

        if (log.count(now))
        {
            m = i + 1;
            break;
        }
        log.insert(now);
        before = now;
    }

    cout << m << endl;
 //   system("pause");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long
#define pb push_back 
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<ll>
#define vll vector<long long>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl;
#define cno cout << "No" << endl;
#define mod 1000000007
#define mod2 998244353
#define INT_MAX1 900000000
//////////////////////////////////////////////////////////////////////////////////////////////


int n;
double p[3000];
double dp[3000][3000];
bool v[3000][3000];

double s1(int i, int t)
{
    if(i==n)
    {
        if(t>(n-t))
            return 1;
        else
            return 0;
    }
    if(v[i][t])
        return dp[i][t];
    v[i][t] = 1;
    return dp[i][t] = p[i]*s1(i+1,t+1) + ((double)1-p[i])*s1(i+1,t);
}


void solve()
{
    cin >> n;
    inp(p,n);
    cout << setprecision(25) << s1(0,0);
}
 
int32_t main()
{
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 79616
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#define endl "\n"
#define whats(x) cout<<#x<<" is: "<<x<<endl;
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin>>n>>k;
    int heights[n];
    int costs[n];
    for(int i=0; i<n; ++i)
        cin>>heights[i];
    costs[0]=0;
    for(int i=1; i<n; ++i)
        costs[i]=INT_MAX;
    for(int i=1; i<n; ++i){
        for(int j=1; j<=k; ++j){
            if(i-j<0)
                break;
            costs[i]=min(costs[i], abs(heights[i]-heights[i-j])+costs[i-j]);
        }
    }
    cout<<costs[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 999999999
#define MINF -999999999

int main() {
	char a[3];
	REP(i, 3) {
		cin >> a[i];
		if (a[i] == '1') a[i] = '9';
		else a[i] = '1';
	}
	cout << a[0] << a[1] << a[2] << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>

#define max(a, b)  (((a) > (b)) ? (a) : (b))

int
main(void)
{
        int N;
        int M;

        scanf("%d %d", &N, &M);

        int L;
        int R;
        int min_R = N;
        int max_L = 1;
        for (int i = 0; i < M; i++) {
                scanf("%d %d\n", &L, &R);
                if (max_L < L)
                        max_L = L;
                if (R < min_R)
                        min_R = R;
        }

        printf("%d", max(0, min_R - max_L + 1));

        return 0;
}


Measured memory_bytes: 128
#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
//#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve(bool);
void precalc();
clock_t start;
int main() {
#ifdef AIM
  freopen("/home/alexandero/ClionProjects/ACM/input.txt", "r", stdin);
  //freopen("/home/alexandero/ClionProjects/ACM/output.txt", "w", stdout);
  //freopen("out.txt", "w", stdout);
#else
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
#endif
  start = clock();
  int t = 1;
  cout.sync_with_stdio(0);
  cin.tie(0);
  precalc();
  cout.precision(10);
  cout << fixed;
  //cin >> t;
  int testNum = 1;
  while (t--) {
    //cout << "Case #" << testNum++ << ": ";
    //cerr << testNum << endl;
    solve(true);
    //cerr << testNum - 1 << endl;
  }
  cout.flush();
#ifdef AIM1
  while (true) {
      solve(false);
  }
#endif

#ifdef AIM
  cerr << "\n\n time: " << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n";
#endif

  return 0;
}

//BE CAREFUL: IS INT REALLY INT?

template<typename T>
T binpow(T q, T w, T mod) {
  if (!w)
    return 1 % mod;
  if (w & 1)
    return q * 1LL * binpow(q, w - 1, mod) % mod;
  return binpow(q * 1LL * q % mod, w / 2, mod);
}

template<typename T>
T gcd(T q, T w) {
  while (w) {
    q %= w;
    swap(q, w);
  }
  return q;
}
template<typename T>
T lcm(T q, T w) {
  return q / gcd(q, w) * w;
}

void precalc() {

}

template<typename T>
void relax_min(T& cur, T val) {
  cur = min(cur, val);
}

template<typename T>
void relax_max(T& cur, T val) {
  cur = max(cur, val);
}

//#define int li
//const int mod = 1000000007;


void solve(bool read) {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(all(a));
  int g = 0;
  for (int i = 0; i < n; ++i) {
    g = gcd(g, a[i]);
  }
  if (g == 0) {
    if (k == a[0]) {
      cout << "POSSIBLE\n";
    } else {
      cout << "IMPOSSIBLE\n";
    }
    return;
  }
  if (a[n - 1] % g == k % g && a[n - 1] >= k) {
    cout << "POSSIBLE\n";
  } else {
    cout << "IMPOSSIBLE\n";
  }


}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int d,n;
  cin >> d >> n;
  int ans=0;
  int div=pow(100,d+1);
  while(n){
    ans+=pow(100,d);
    if(ans%div!=0){
      n--;
    }
  }
  cout << ans << endl;
}

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
const ll MAX = 1e5+1;
int main(){
    int n,h[MAX];
    int ans = 0;
    cin >> n;

    REP(i,n) cin >> h[i];
    int ren = 0;

    REP(i,n-1){
        if(h[i] >= h[i+1]) ren++;
        else{
        ans = max(ans,ren);
         ren = 0;
        } 
       // cout << ren << endl;
    }
    ans = max(ans,ren);

    cout << ans << endl;
}

Measured memory_bytes: 640
use proconio::{fastout, input};

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

const MOD: usize = 1e9 as usize + 7;

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
    }

    let mut ans = 0;
    for i in k..=n + 1 {
        let mi = (0 + i - 1) * i / 2;
        let ma = (n - (i - 1) + n) * i / 2;
        ans += ma - mi + 1;
        ans = ans % MOD;
        // eprintln!("{} {}", i, ans)
    }

    println!("{}", ans);
}


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

const int mn=1e6+7;
int p[mn],n,vis[mn];
bool np[mn];

void get_prime()
{
    for(int i=2;i<mn;++i) {
        if(!np[i]) p[++p[0]]=i;
        for(int j=1;j<=p[0]&&i*p[j]<mn;++j) {
            np[i*p[j]]=1;
            if(i%p[j]==0) break;
        }
    }
}

int gcd(int a,int b) {
    if(!b) return a;
    return gcd(b,a%b);
}

int main()
{
    get_prime();
    scanf("%d",&n);
    int a,g=0;
    for(int i=1;i<=n;++i) {
        scanf("%d",&a);
        g=gcd(a,g);
        vis[a]++;
    }
    int flag=1;
    for(int i=1;i<=p[0];++i) {
        int t=(mn-1)/p[i],cnt=0;
        for(int j=1;j<=t;++j) cnt+=vis[p[i]*j];
        if(cnt>1) flag=0;
    }
    if(flag) {puts("pairwise coprime");return 0;}
    if(g==1) puts("setwise coprime");
    else puts("not coprime");
    return 0;
}

Measured memory_bytes: 8840
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long long fact[12100];
long long inv[12100];
long long finv[12100];
long long C(int a,int b){
	if(a<b)return 0;
	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
int main(){
	fact[0]=finv[0]=1;
	inv[1]=1;
	for(int i=2;i<12100;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<12100;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
	int n,a,b,c;
	scanf("%d%d%d%d",&n,&a,&b,&c);
	if(b%2){
		printf("0\n");return 0;
	}
	long long ks=C(a+b/2,a);
	long long ret=0;
	if(b==0){
		for(int i=0;i<=c/3;i++){
			ret=(ret+C(a,c-i*3)*C(a+c/3,a))%mod;	
		}
	}else{
		for(int i=0;i<=c/3;i++){
			long long ks2=C(a+b/2+i,i);
			for(int j=0;j<=min(a,c-i*3);j++){
				long long tmp=C(a,j);
				int rem=c-i*3-j;
				ret=(ret+tmp*C(rem+b/2-1,rem)%mod*ks2)%mod;
			}
		}
	}
	ret=ret*ks%mod;
	printf("%lld\n",ret);
}

Measured memory_bytes: 384
#include <stdio.h>

#define MAX_N 1000000

int isPrime[ MAX_N + 1 ] = { 0, 0, 1 };
int sum_p[ MAX_N / 2 ] = { 2 }, p = 1;

int main( void ) {
	int i, j, n;

	for ( i = 3; i <= MAX_N; i += 2 )
		isPrime[ i ] = 1;

	for ( i = 3; i * i <= MAX_N; i += 2 )
		if ( isPrime[ i ] )
			for ( j = i * 2; j <= MAX_N; j += i )
				isPrime[ j ] = 0;

	for ( i = 3; i <= MAX_N; i += 2 )
		if ( isPrime[ i ] ) {
			sum_p[ p ] = sum_p[ p - 1 ] + i;
			p++;
		}

	for ( ; scanf( "%d", &n ), n; printf( "%d\n", sum_p[ n - 1 ] ) ) ;

	return 0;
}

Measured memory_bytes: 4812
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<cstring>
#define maxn 105
using namespace std;
int u,v,m;
struct edge
{
    int t;
    edge* next;
};
edge* con[1010];
bool visit[1010];
int link[1010];
int n,x1[maxn],y1[maxn],x2[maxn],y2[maxn];
void ins(int x,int y)
{
    edge* p;
    p=new edge;
    p->t=y;
    p->next=con[x];
    con[x]=p;
}
bool pipei(int v)
{
    edge* p;
    p=con[v];
    while (p!=NULL)
    {
        if (!visit[p->t])
        {
            visit[p->t]=1;
            if ((!link[p->t])||(pipei(link[p->t]))){ link[p->t]=v; return 1;}
        }
        p=p->next;
    }
    return 0;
}
int main()
{
    scanf("%d",&n); 
    for (int i=1;i<=n;i++)
        cin>>x1[i]>>y1[i];
    for(int i=1;i<=n;++i) 
    	cin>>x2[i]>>y2[i];
    for(int i=1;i<=n;++i)
    	for(int j=1;j<=n;++j)
    	if(x1[i]<x2[j]&&y1[i]<y2[j]) ins(i,j+n);
    int ans=0;
    for (int i=1;i<=n;i++)
    {
        memset(visit,0,sizeof(visit));
        ans+=pipei(i);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 384
#17D8101028I tou koutetsu  2019/10/3
#ID:tanghaozhe 
#python
import math
#==============================================================================
# str = input()
# list=str.split(" ")
#==============================================================================

n=int(input())
list = [0]*n
for i in range(n):
    list[i]=int(input())

#print(list)
count=0
for i in list:
    i=int(i)
    p=i
    flag=True
    n=int(math.sqrt(i))
    if i>=2:
        for j in range(2,n+1):
            if(p%j==0):
                flag=False
                break
    else:
        flag=False
    if flag==True:
        count=count+1
        #print(p)
print(count)


Measured memory_bytes: 6044
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N, P = map(int, input().split())

i = 2
facts = defaultdict(int)
while i ** 2 <= P:
    while P % i == 0:
        facts[i] += 1
        P //= i
    i += 1
if P > 1:
    facts[P] += 1
ans = 1
for k, v in facts.items():
    ans *= k ** (v // N)
print(ans)



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

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  bool kawaiso = false;
  if(A == B){
    if (A != C){
      kawaiso = true;
    }
  }
  if (B == C){
      if (C != A){
      kawaiso = true;
    }
  }
  if (A == C){
      if (B != C){
      kawaiso = true;
    }
  }
  if (kawaiso){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}



Measured memory_bytes: 256
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 03/28/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int N,X,Y; cin>>N>>X>>Y;
  X--; Y--;

  vector<int> ans(N);
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      int dist = j-i;
      dist = min(dist, abs(X-i)+1+abs(j-Y));
      dist = min(dist, abs(Y-i)+1+abs(j-X));
      ans[dist]++;
    }
  }
  for (int k = 1; k <= N-1; k++)
    cout << ans[k] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

int main(void)
{
    int q;
    char x[1001], y[1001];
    int table[1001][1001];
    
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> x >> y;
        int xl = strlen(x), yl = strlen(y);

        for (int i = 0; i < xl; i++)
            for (int j = 0; j < yl; j++)
                if (x[i] == y[j])
                    table[i+1][j+1] = 1 + table[i][j];
                else
                    table[i+1][j+1] = max(table[i][j+1], table[i+1][j]);

        cout << table[xl][yl] << endl;
    }

    return 0;
}

Measured memory_bytes: 5076
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    rem_value = 2019
    [l, r] = li()
    l_mod = l % rem_value
    r_mod = r % rem_value
    if r - l >= 2019 or l_mod > r_mod:
        print(0)
    else:
        candidate = range(l_mod, r_mod + 1)
        min_value = rem_value
        for index, i in enumerate(candidate[:-1]):
            for j in candidate[index + 1:]:
                if i * j % rem_value < min_value:
                    min_value = i * j % rem_value
        print(min_value)

# 2019の倍数があれば0　L以上の2019の倍数で最小のものがR以下　Lが0の場合も0
# 2019 = 3 * 673

# 言い換え
# 3の倍数と673の倍数が両方あれば0　L以上の3の倍数で最小のものがR以下　かつ　L以上の673の倍数で最小のものがR以下　Lが0の場合も0
# i * j mod 2019 = (i mod 2019 * j mod 2019) mod 2019
# 0-2018で使える使えないが決まる
# 全ての組み合わせ　最悪　2019 C 2
# 全ての組み合わせを調べる


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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;

int main(){
  ll x, now = 100,year = 0; cin>>x;
  while(now<x){
    now += now/100; year++;
  }
  cout<<year<<endl;
}

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

int main()
{
    int h,m,s;
    
    cin >> s;
    h=s/3600;
    m=(s%3600)/60;
    s=(s%3600)%60;
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define REP(i,a,b) for(int(i)=(a);(i)<(b);++(i))
#define RREP(i,a,b) for(int(i)=(a)-1;(i)>=(b);--(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;

double N,K;

int main()
{
  cin >> N >> K;
  double res = 0;  // 勝つ確率

  REP(i,1,N+1) {
    // N面サイコロの目がi
    int score = i;
    int c = 0;  // コインの回数
    while (score < K) {
      score *= 2;
      ++c;
    }
    res += (double)1/N * pow(0.5,c);
  }
  cout << fixed << setprecision(15) << res << endl;

  return 0;
}


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

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

    int a = 0, un = 0;
    string w;
    for (int i=0; i<n; ++i) {
        cin >> w;
        if (w == "A") {
            a ++;
        } else {
            un ++;
        }
        if (un > a) {
            cout << "NO" << endl;
            return 0;
        }
    }
    if (a == un) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	set<int>s;
	rep(i,3){
		int tmp;
		cin>>tmp;
		s.insert(tmp);
	}
	cout<<s.size()<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <bitset>
using namespace std;
const int N=100010;
int a[N],b[N];
bitset <410> w[410];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n,m,ans=0;
    cin>>n>>m;
    for(int i=1;i<=m;i++) a[i]=gi(),b[i]=gi();
    for(int i=1;i<=n;i++) {
	w[i][i]=1;
	for(int j=m;j;j--) {
	    int x=a[j],y=b[j];
	    if(w[i][x]&&w[i][y]) {w[i].set();break;}
	    if(w[i][x]) w[i].set(y);
	    else if(w[i][y]) w[i].set(x);
	}
    }
    for(int i=1;i<=n;i++)
	for(int j=i+1;j<=n;j++) ans+=((w[i]&w[j])==0);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
def main():

    s = str(input())
    t = str(input())

    count = 0

    if(s[0] == t[0]):
        count += 1
    
    if(s[1] == t[1]):
        count += 1

    if(s[2] == t[2]):
        count += 1
    
    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int c=a+b;
	int d=a-b;
	int f=a*b;
	if(c>=d&&c>=f)cout<<c<<endl;
	else if(d>=c&&d>=f)cout<<d<<endl;
	else cout<<f<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c[] = new int[a];
    int counter = 0;                   
    for(int i = 0;i < c.length;i++){
      c[i] = sc.nextInt();
      if(c[i] >= b){
        counter++;
      }
    }
    System.out.println(counter);                   
  }
}

Measured memory_bytes: 48120
N,K,Q=map(int, input().split())
*A,=map(int, input().split())

import heapq
ans = 10**10
A.append(-1)
for y in A:
    if y==-1: break
    p,q=[],[]
    for a in A:
        if a >= y:
            heapq.heappush(p, a)
        else:
            for i in range(max(0,len(p)-(K-1))):
                heapq.heappush(q, heapq.heappop(p))
            p=[]
    if len(q) < Q: continue
    x = -1
    for i in range(Q):
        x = heapq.heappop(q)
    ans = min(ans, x-y)
print(ans)

Measured memory_bytes: 83676
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
  public static long bij(int x,int y){
    long c= (long) (x+y)*(x+y+1);
    return (long)c/2 +y;
  }
public static void main(String[] args) throws FileNotFoundException, IOException{
      Scanner s=new Scanner(System.in);
      int n=s.nextInt();
      int[][] arr1=new int[n+1][2];
      int[] bap=new int[n+1];
      Map<Integer,Set<Integer>>map=new HashMap<>();
      Map<Long,Integer>map1=new HashMap<>();
      int[] in=new int[n+1];
      int max=0;
      for(int i=1;i<n;i++){
        int x=s.nextInt(),y=s.nextInt();
        arr1[i][0]=x;arr1[i][1]=y;
       bap[y]=x;
        in[y]++;
        if(map.get(x)==null){
          map.put(x,new HashSet<>());
          map.get(x).add(y);
        }
        else{map.get(x).add(y);}

        if(map.get(y)==null){
          map.put(y,new HashSet<>());
          map.get(y).add(x);
        }
        else{map.get(y).add(x);}
        max=Math.max(max,Math.max(map.get(x).size(),map.get(y).size()));
      }
      int root=1;
      for(int z=1;z<=n;z++){
        if(in[z]==0){root=z;}
      }
      int k=1;
      map1.put(bij(0,root),0);
      Queue<Integer> q=new LinkedList<>();
      q.add(root);
      while(!q.isEmpty()){
        int curr=q.poll(),tmp=map1.get(bij(bap[curr],curr)); 
          for(int xx:map.get(curr)){
          if(map1.get(bij(xx,curr))!=null){
            continue;
          }
          if(k==tmp){k++;}
          map1.put(bij(curr,xx),k);
          k++;
          q.add(xx);
        }
      
        k=1;
      }
      BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
      System.out.println(max);
      for(int i=1;i<n;i++){
        out.write(map1.get(bij(arr1[i][0],arr1[i][1]))+" ");
        out.write("\n");
        out.flush();
      }
        }
      }
      
      
      
    


Measured memory_bytes: 135948
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>
#include <set>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  string s;
  cin >> s;
  vector<string> keywords = {"dreamer", "eraser", "dream", "erase"};

  ll i;
  for (i = s.size(); i > 0;)
  {
    ll match_len = 0;
    for (auto key : keywords)
    {
      // cout << "i=" << i << " key=" << key << " (i-key.size())=" << (i-(ll)key.size()) << endl;
      if (i - (ll)key.size() >= 0 && s.compare(i - (ll)key.size(), key.size(), key) == 0)
      {
        // cout << "i=" << i << " key=" << key << " s.substr=" << s.substr(i-key.size()) << endl;
        // cout << s.substr(0, i) << " matches " << key << endl;
        match_len = key.size();
        break;
      }
    }
    if (match_len == 0) {
      break;
    }
    i -= match_len;
  }

  cout << (i > 0 ? "NO" : "YES") << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template <class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template <class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n;
    cin>>n;
    if(n==1) {
        cout<<1<<endl;
        return 0;
    }
    int a=2;
    int b=1;
    int c;
    REP(i,n-1) {
        c=b+a;
        a=b;
        b=c;
    }
    cout<<c<<endl;
    return 0;
}


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

int main()
{
    int n, a, b, res1=0, res2=0, res3=0, res=0, res4=0, res5=0, sum = 0;
    cin >> n >> a >> b;
    for(int i=1; i<=n; i++)
    {
        res1 = i % 10;
        res2 = (i/10)%10;
        res3 = (i/100)%10;
        res4 = (i/1000)%10;
        res5 = (i/10000)%10;
        res = res1+res2+res3+res4+res5;
        if(((res >= a) && (res <= b))) sum += i;
    }
    cout << sum << endl;
    return 0;
}

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

int main(){
  int n;
  cin >>n;
  vector<char> a(n);  bool d =true;
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    if(a.at(i)=='Y') d = false;
  }
  if(d) cout << "Three" << endl;
  else cout << "Four" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int in, ans = 0;
    FOR(i, 0, 10) {
        cin >> in;
        ans += in;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3160
from collections import Counter
S = input()
S = S + '0'
mod = 2019
p = [0] * mod
r = 0
d = 1
for s in S[::-1]:
  t = int(s)%mod
  r += t*d
  r %= mod
  d = d*10%mod
  p[r] += 1

#ans = 0
#c = Counter(p)
#for k,n in c.most_common()[::-1]:
#  if k > 1 and k%2 == 0:
#    ans += n
#  else:break
#print(ans)
print(sum([i*(i-1)//2 for i in p]))

Measured memory_bytes: 9456
// a.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include <vector>
#include <numeric>

struct DrinkEffect {
	int pi, xi; 
};

int main()
{
	int n, m;
	std::vector<int> t;
	std::vector<DrinkEffect> drink;

	std::cin >> n;
	t.resize(n);
	for (int i = 0; i < n; ++i) {
		int ti = 0;
		std::cin >> ti;
		t[i] = ti;
	}
 
	std::cin >> m;
	drink.resize(m);
	for (int i = 0; i < m; ++i) {
		DrinkEffect df;
		std::cin >> df.pi >> df.xi;
		drink[i] = df;
	}
	
	//ドリンクを用いず 全問解くのにかかる時間を調べる
	int total = std::accumulate(t.begin(), t.end(), 0);

	// total - (ドリンク使用によるタイム減)を出力
	for (int i = 0; i < m; ++i) {
		int diff =  drink[i].xi - t[ drink[i].pi-1];
		std::cout <<  (total + diff) << std::endl;
	}

	return 0;
}



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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; ll m;
	cin >>n >>m;
	VL a(n), sm(n+1);
	rep(i, n) cin >>a[i];
	sort(all(a));
	rep(i, n) sm[i+1] = sm[i] + a[i];
	
	auto f=[&](ll md){
		ll ct = 0;
		repr(i, n-1, 0){
			int ps = lower_bound(all(a), md - a[i]) - a.begin();
			ct += n - ps;
		}
		return ct >= m;
	};
	
	ll lf = 0, rg=1e7;
	while(rg - lf >1){
		ll md = (rg + lf) >> 1;
		if( f(md) ) lf = md; else rg = md; 
	}
	ll wt = 0, ct = 0;
	repr(i, n-1, 0){
		int ps = lower_bound(all(a), rg - a[i]) - a.begin();
		ct += n-ps ;
		wt += (sm[n] - sm[ps]) + a[i] * (n-ps);
	}
	if(m - ct > 0) wt += lf * (m - ct);
	cout << wt <<"\n";
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main()
{
  int N;
  cin>>N;
  int n = N % 10;
  if(n == 2||n == 4||n == 5||n == 7||n == 9) {
  	cout<<"hon"<<endl;
    return 0;
  }
  else if(n == 3){
    cout<<"bon"<<endl;
    return 0;
  }
  else{
    cout<<"pon"<<endl;
    return 0;
  }
}

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

int main(){
  int hp,N;
  int bash;
  int sum;
  
  cin >> hp >> N;
  for(int i = 0; i < N; i++){
    cin >> bash;
    sum += bash;
  }
  if(sum >= hp){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

using namespace std;

#define int long long

int inf = 1e18;

int cal(int N){
  if(N <= 2) return 0;
  N--;
  return cal(N/2)+1;
}

signed main(){
  int X;

  cin>>X;

  int l = 0, h = inf, m;
  /*
  for(int i = 0; i < 20; i++){
    cout<<"i = "<<i<<" "<<cal(i)<<endl;
  }
  */
  while(l+1<h){
    m = (l+h)>>1;

    if(cal(m) <= X) l = m;
    else h = m;
  }

  cout<<l<<endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

H,W = map(int, input().split())

a = []
for i in range(0,H):
    data = str(input())
    a.append(list(data))

for i in range(H-1,-1,-1):
    if '#' in a[i]:
        pass
    else:
        del a[i]

for i in range(W-1,-1,-1):
    check = 0
    for j in range(0,int(len(a))):
        if a[j][i] == "#":
            check = 1
            break
        else:
            pass
    if check == 0:
        for j in range(0,int(len(a))):
            del a[j][i]

for i in a:
    print(''.join(i))

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 999999999;

int main() {
    int N;
    cin >> N;
    priority_queue<double, vector<double>, greater<>> pq;

    for (int i = 0; i < N; ++i) {
        double inp;
        cin >> inp;
        pq.push(inp);
    }

    while (pq.size() != 1) {
        double n1 = pq.top();
        pq.pop();
        double n2 = pq.top();
        pq.pop();
        double nmean = (n1 + n2) / 2.0;
        pq.push(nmean);
    }
    cout << pq.top() << endl;
}

Measured memory_bytes: 256
n = int(input())

dic = {}
for i in range(n):
    tmp = int(input())
    if tmp not in dic:
        dic[tmp] = 1
    elif dic[tmp] == 1:
        dic[tmp] = 0
    else:
        dic[tmp] = 1

ans = 0
for k,v in dic.items():
    if v == 1:
        ans += 1

print(ans)


Measured memory_bytes: 15076
while True:
    N = input()
    if N == "0":
        break

    r = int(N[1:3],16)
    g = int(N[3:5],16)
    b = int(N[5:7],16)

    ans = ""
    D = 255*255*3+1

    R, G, B = 0, 0, 0
    d = (R-r)**2 + (G-g)**2 + (B-b)**2
    if d < D:
        D = d
        ans = "black"

    R, G, B = 0, 0, 255
    d = (R - r) ** 2 + (G - g) ** 2 + (B - b) ** 2
    if d < D:
        D = d
        ans = "blue"

    R, G, B = 0, 255, 0
    d = (R - r) ** 2 + (G - g) ** 2 + (B - b) ** 2
    if d < D:
        D = d
        ans = "lime"

    R, G, B = 0, 255, 255
    d = (R - r) ** 2 + (G - g) ** 2 + (B - b) ** 2
    if d < D:
        D = d
        ans = "aqua"

    R, G, B = 255, 0, 0
    d = (R - r) ** 2 + (G - g) ** 2 + (B - b) ** 2
    if d < D:
        D = d
        ans = "red"

    R, G, B = 255, 0, 255
    d = (R - r) ** 2 + (G - g) ** 2 + (B - b) ** 2
    if d < D:
        D = d
        ans = "fuchsia"

    R, G, B = 255, 255, 0
    d = (R - r) ** 2 + (G - g) ** 2 + (B - b) ** 2
    if d < D:
        D = d
        ans = "yellow"

    R, G, B = 255, 255, 255
    d = (R - r) ** 2 + (G - g) ** 2 + (B - b) ** 2
    if d < D:
        D = d
        ans = "white"

    print(ans)



Measured memory_bytes: 5584
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        x: i64,
        k: i64,
        d: i64,
    }

    let x = x.abs();

    if k <= x / d {
        println!("{}", x - k * d);
        return;
    }

    let c = x / d;
    let k2 = k - c;
    let ans = if k2 % 2 == 0 { x % d } else { d - (x % d) };
    println!("{}", ans);
}


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

int main()
{
  int n, k;
  
  cin >> n >> k;
  
  register int i;
  
  int arr[n];
  
  for(i = 0; i < n; i++)
  cin >> arr[i];
  
  sort(arr, arr + n);
  
  int ans = 0;
  
  for(i = 0; i < k; i++)
    ans += arr[i];
    
  cout << ans;
  return 0;
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int r;
vi a(3);

signed main() {
	rep(i,3) cin >> a[i];
	sort(all(a));
	r = inf;
	do {
		chmin(r, abs(a[1]-a[0]) + abs(a[2]-a[1]));
	} while (next_permutation(all(a)));
	cout << r << ln;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;


public class Main {
	public void exec() throws IOException {
		InputUtil input = new InputUtil();
		PrintWriter out = new PrintWriter(System.out);
		int n = input.nextInt();
		int[] a = input.nextInt(new int[n]);
		int max = -1000001;
		int min =  1000001;
		long sum = 0L;
		for(int ai: a){
			if(ai<min) min=ai;
			if(max<ai) max=ai;
			sum += ai;
		}
		out.print(min);
		out.print(' ');
		out.print(max);
		out.print(' ');
		out.println(sum);
		out.flush();
		input.close();
	}

	public static void main(String[] args) throws IOException {
		new Main().exec();
	}
}

/**
 * --------------------------------------------------
 * Input Utility
 * --------------------------------------------------
 */
class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 50000;
	
	//Fields
	protected InputStream in;
	private char[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private BufferedReader br = null;
	
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(int bufsiz) {this(System.in,bufsiz);}
	public InputUtil(InputStream in) {this(in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {br = new BufferedReader(new InputStreamReader(this.in = in));}
	protected void initBuf(int bufsiz) {buf = new char[bufsiz];}
	
	//String Input Reader/Parser
	private void readBuf() throws IOException {
		if(ptr >= max && br.ready()) {
			max = br.read(buf);
			ptr = 0;
		}
	}
	
	public BufferedReader getReader() {return br;}
	
	//Number Input Reader/Parser
	private boolean isNum(char b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(char b) {return b=='-'; }
	private void next() throws IOException {ptr++; readBuf();}


	public int nextInt() throws IOException {return nextInt(new int[1])[0];}
	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			int sign = 1;
			int res = 0;
			char c;
			while (!isNum(c=buf[ptr]) && !isMinus(c)) 
				next();
			if (isMinus(buf[ptr])) {
				sign = -1;
				next();
			}
			while (isNum(c=buf[ptr])) {
				res *= 10;
				res += c - '0' ;
				next();
			}
			next();
			result[i] = sign * res;
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

}

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

int fibans[44];
bool fibflag[44];

int fib(int n){
  if(n<2)return 1;
  if(fibflag[n] != true){
    fibans[n] = fib(n-1) + fib(n-2);
    fibflag[n] = true;
  }
  return fibans[n];
} 

int main(){
  int _n;
  cin >> _n;
  cout << fib(_n) << endl;
  return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
using namespace std;

int main()
{
	int n,tmp=0,tmp2=0,cnt=0;
	cin >> n;
	vector<int>p(n),pS;
	for (int i = 0; i < n;i++)cin >> p[i],pS.push_back(p[i]);
	sort(pS.begin(),pS.end());
	if (pS == p)return cout << "YES" << endl,0;
	for (int i = 0; i < n; i++) {
		if (pS[i] == p[i])continue;
		else if (cnt == 0)tmp = i, cnt++;
		else {
			tmp2 = p[i];
			p[i] = p[tmp];
			p[tmp] = tmp2;
			return cout << (pS == p ? "YES" : "NO") << endl, 0;
		}
	}
}


Measured memory_bytes: 256
from collections import deque
H,W=map(int, input().split())
S = ["#"]*(W+2)
MAP=[]
MAP.append(S)
cnt = 0
for _ in range(H):
    tmp = ["#"]+list(input())+["#"]
    cnt += tmp.count(".")
    MAP.append(tmp)
MAP.append(S)

move=[[1,0],[-1,0],[0,1],[0,-1]]
start=[1,1]

cheak = [[-1]*(W+2) for _ in range(H+2)]
cheak[1][1] = 0

que = deque()
que.append(start)
while que:
    tmp = que.popleft()
    x = tmp[0]
    y = tmp[1]
    for dx,dy in move:
        nx = x + dx
        ny = y + dy
        if MAP[nx][ny] == "." and cheak[nx][ny] == -1:
            que.append([nx,ny])
            cheak[nx][ny]=cheak[x][y]+1
if cheak[H][W] == -1:
    print(-1)
else:
    print(cnt-cheak[H][W]-1)#スタート地点も白くなくてはいけないので-1

Measured memory_bytes: 9468