akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){
    ll x,y;cin>>x>>y;
    if(x>0 && y>0){
        if(x<=y){
            cout<<y-x<<endl;
        }else{
            cout<<(x-y)+2<<endl;
        }
    }else if(x>0 && y<0){
        if(-y<=x){
            cout<<(x+y)+1<<endl;
        }else{
            cout<<(-y-x)+1<<endl;
        }
    }else if(x<0 && y<0){
        if(x<=y){
            cout<<y-x<<endl;
        }else{
            cout<<x-y+2<<endl;
        }
    }else if(x<0 && y>0){
        if(-x<=y){
            cout<<y+x+1<<endl;
        }else{
            cout<<-x-y+1<<endl;
        }
    }else if(x==0){
        if(y<0){
            cout<<-y+1<<endl;
        }else{
            cout<<y<<endl;
        }
    }else if(y==0){
        if(x>0){
            cout<<x+1<<endl;
        }else{
            cout<<-x<<endl;
        }
    }
    
    return 0;
}






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

using namespace std;

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

  int r;
  cin >> r;
  cout << fixed << setprecision(10) << 2 * acos(-1) * r;

  return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int x = sc.nextInt();
		int m[] = new int[n];
		int summ = 0;
		
		for(int i = 0; i < n; ++i) {
			m[i] = sc.nextInt();
			summ += m[i];
		}
		Arrays.sort(m);
		sc.close();
		int ans = (x - summ) / m[0] + n;
		System.out.println(ans);
	}
}


Measured memory_bytes: 23508
#include<iostream>

using namespace std;

int main(){
	
	int N;
	cin >> N;
	
	int A[N] = {}, B[N] = {}, C[N] = {};
	
	int custo[N][3] = {};
	
	for(int i = 0; i < N; i++){
		cin>>A[i]>>B[i]>>C[i];
	}
	
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j< 3; j++){
			if(i == 0){
				switch(j){
					case 0: custo[i][j] = A[i]; break; 
					case 1:	custo[i][j] = B[i]; break;
					case 2: custo[i][j] = C[i]; break;
				}
			}
			else{
				for(int k = 0; k < 3; k++){
					if(j == k) continue;
					switch(j){
						case 0: custo[i][j] = max(custo[i][j], custo[i-1][k] + A[i]);break;
						case 1:	custo[i][j] = max(custo[i][j], custo[i-1][k] + B[i]);break;
						case 2: custo[i][j] = max(custo[i][j], custo[i-1][k] + C[i]);break;
					}
				}
				
			}
		
		}
	}
	
	int maximo = 0;
	
	for(int i =0; i < 3; i++){
		if(custo[N-1][i] > maximo)
			maximo = custo[N-1][i];
	}
	cout<< maximo << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    vector <int> count(10);
    cin>>s;
    for(int i=0;i<s.size();i++){
        for(int j=0;j<s.size();j++){
            if(s[i+j]=='A'||s[i+j]=='G'||s[i+j]=='T'||s[i+j]=='C') count[i]++;
            else break;
        }
    }
    sort(count.begin(),count.end());
    reverse(count.begin(),count.end());
    cout<<count[0]<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
using namespace std;
#define MOD 1000000007
#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;

struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {//最大フロー求める Ford-fulkerson
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));//最小カットの場合逆辺は0にする
}

ll used[101010];
vector<P> e;

ll dfs(Graph& graph, ll v, ll par, Array& cnt) {
	used[v] = 1;
	ll ret = cnt[v];

	REP(i, graph[v].size()) {
		ll to = graph[v][i].to;
		if (to == par || used[to] == 1)continue;
		if (dfs(graph, to, v, cnt) % 2 == 1) {
			e.push_back({ min(v,to),max(v,to) });
			ret ^= 1;
		}
	}
	return ret;
}

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


	ll n, m;
	cin >> n >> m;
	vector<P> ab(n+2);
	REP(i, n)cin >> ab[i].first >> ab[i].second;
	ab[n] = { 0,0 };
	ab[n + 1] = { INF,0 };
	sort(all(ab));
	Array l(m), r(m);
	REP(i, m)cin >> l[i] >> r[i];
	Graph graph(n + 2);
	map<P, ll> mp;
	Array a(n + 2);
	REP(i, n + 2)a[i] = ab[i].first;
	REP(i, m) {
		auto itrL = lower_bound(all(a), l[i]);
		itrL--;
		auto itrR = upper_bound(all(a), r[i]);
		itrR--;
		l[i] = itrL - a.begin();
		r[i] = itrR - a.begin();
		if (itrL == itrR)continue;
		mp[make_pair(l[i],r[i])] = i;
		add_edge(graph, l[i], r[i], 1, true, 1);
	}
	
	Array cnt(n + 2, 0);
	REP(i, ab.size() - 1) {
		if (ab[i].second != ab[i + 1].second)cnt[i] = 1;
	}
	REP(i, n + 2) {
		if (used[i] == 0) {
			if (dfs(graph, i, -1, cnt) % 2 == 1) {
				cout << -1 << endl;
				return 0;
			}
		}
	}
	cout << e.size() << endl;
	Array ans;
	for (auto itr : e) ans.push_back(mp[{itr.first, itr.second}] + 1);
	sort(all(ans));
	REP(i, ans.size())cout << ans[i] << (i == ans.size() - 1 ? '\n' : ' ');
	cout<<endl;

	return 0;
}

Measured memory_bytes: 47732
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long LL;
const int N=132000;
int read(){
	int x=0;
	char ch=getchar();
	while (!isdigit(ch))
		ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x;
}
int n,son[N][2],a[N],v[N];
vector <pair <LL,LL> > dp[N],tmpL,tmpR,tmp;
LL Min[N],val[N];
LL Limit;
bool cmp1(pair <LL,LL> a,pair <LL,LL> b){
	if (a.first!=b.first)
		return a.first<b.first;
	return a.second<b.second;
}
bool cmp2(pair <LL,LL> a,pair <LL,LL> b){
	if (a.second!=b.second)
		return a.second<b.second;
	return a.first<b.first;
}
void update(vector <pair <LL,LL> > &v){
	if (v.empty())
		return;
	sort(v.begin(),v.end(),cmp2);
	tmp.clear();
	tmp.pb(v[0]);
	for (int i=1;i<v.size();i++)
		if (v[i].second!=v[i-1].second)
			tmp.pb(v[i]);
	v.clear();
	v.pb(tmp[0]);
	for (int i=1;i<tmp.size();i++)
		if (tmp[i].first!=tmp[i-1].first)
			v.pb(tmp[i]);
}
void solve(int x){
	if (!son[x][0]){
		dp[x].clear();
		dp[x].pb(mp(0LL,0LL));
		return;
	}
	int ls=son[x][0],rs=son[x][1];
	solve(ls+1);
	solve(rs+1);
	tmpL.clear(),tmpR.clear();
	for (auto i : dp[ls+1])
		tmpL.pb(mp(i.first+v[ls],i.second+v[ls]));
	for (auto i : dp[rs+1])
		tmpR.pb(mp(i.first+v[rs],i.second+v[rs]));
	if (tmpL.size()>tmpR.size())
		swap(tmpL,tmpR);
	sort(tmpR.begin(),tmpR.end(),cmp1);
	for (int i=0;i<tmpR.size();i++){
		if (i>0)
			Min[i]=min(Min[i-1],tmpR[i].second);
		else
			Min[i]=tmpR[i].second;
		val[i]=tmpR[i].first;
	}
	dp[x].clear();
	for (int i=0;i<tmpL.size();i++){
		int p=upper_bound(val,val+(int)tmpR.size()
				,Limit-tmpL[i].second)-val-1;
		if (p==-1)
			continue;
		dp[x].pb(mp(tmpL[i].first,Min[p]));
		dp[x].pb(mp(Min[p],tmpL[i].first));
	}
	update(dp[x]);
}
bool check(LL x){
	Limit=x;
	solve(1);
	return ((int)dp[1].size())>0;
}
int main(){
	n=read();
	for (int i=1;i<n;i++){
		a[i]=read();
		v[i]=read();
		son[a[i]][(bool)son[a[i]][0]]=i;
	}
	LL L=0,R=1LL<<36,mid,ans=R;
	while (L<=R){
		mid=(L+R)>>1;
		if (check(mid))
			R=mid-1,ans=mid;
		else
			L=mid+1;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 30808
import sys
input = sys.stdin.readline
from collections import defaultdict
def main():
    N, M = map( int, input().split())
    X = list( map( int, input().split()))
    d = defaultdict( int)
    Same = [0]*M
    Mod = [0]*M
    for x in X:
        Mod[x%M] += 1
        if d[x] > 0:
            d[x] = 0
            Same[x%M] += 2
        else:
            d[x] += 1
    ans = 0
    ans += Mod[0]//2
    Mod[0] = Mod[0]%2
    if M%2 == 0:
        ans += Mod[M//2]//2
        Mod[M//2] = Mod[M//2]%2
    
    for i in range(1,(M+1)//2):
        m = min(Mod[i], Mod[-i])
        ans += m
        Mod[i] = Mod[i] - m
        Mod[-i] = Mod[-i] - m

    for i in range(M):
        ans += min(Mod[i], Same[i])//2
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 21280
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod= 1e9 +7;
//bool a[22][22];
int n;
int dp[21][1<<22];
int arr[21][21];

int solve(int k, int mask)
{
    if(k<0) return 0; 
    if(dp[k][mask]!= -1) return dp[k][mask];
    
    dp[k][mask]=0;
    for(int w=0;w<n;++w)
    {
        if(arr[k][w] && (mask&(1<<w)))
        dp[k][mask]= (dp[k][mask]+solve(k-1,mask&(~(1<<w))))%mod;
    }
    
    return dp[k][mask];
    
}


main()
{  
    cin>>n;
    
    for(int i=0;i<n;++i) 
        for(int j=0;j<n;++j)
            cin>>arr[i][j];
    for(int i=0;i<n;++i)
		for(int mask=0;mask < (1<<n); ++mask)
			dp[i][mask] = -1;
    for(int i=0;i<n;++i) //base cases
       { dp[i][0]=1; if(arr[0][i]) dp[0][1<<i]=1;}
    
    
    
   cout<<solve(n-1,((1<<n) -1 ))<<endl;
   /*
   for(int i=0;i<n;++i) 
    {
        for(int j=0;j< (1<<n);++j)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    } 
    */
    
}

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

int gcd(int a, int b)
{
  if(a>b) return gcd(b,a);
  if(a==0) return b;
  int r = b%a;
  return gcd(a,r);
}

int main()
{
  int n;
  cin >> n;
  std::vector<int> v;
  for(int i=0; i<n; i++)
  {
    int tmp;
    cin >> tmp;
    v.push_back(tmp);
  }
  std::vector<int> L(n);
  std::vector<int> R(n);
  L[0] = 0;
  R[n-1] = 0;
  for(int i=0; i<n-1; i++)
  {
    L[i+1] = gcd(L[i],v[i]);
    R[n-i-2] = gcd(R[n-i-1],v[n-i-1]);
  }
  int tmp=0;
  for(int i=0; i<n; i++)
  {
    tmp = max(tmp,gcd(L[i],R[i]));
  }
  cout << tmp << endl;
  return 0;
}


Measured memory_bytes: 1528
#include <cstdio>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
int fa[100010];
vector <int> v[100010], vf[100010];

int find_root(int u) {
	if (!fa[u] || fa[u] == u) return u;
	return fa[u] = find_root(fa[u]);
}

void merge(int a, int b) {
	int ra = find_root(a), rb = find_root(b);
	if (ra != rb) fa[ra] = rb;
}

int main() {
	int n, m;
	ll ans = 0;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j < v[i].size(); ++j)
			merge(v[i][j], v[i][j - 1]);
	}
	for (int i = 1; i <= n; ++i) {
		fa[i] = find_root(i);
		vf[fa[i]].push_back(i);
	}
	for (int i = 1; i <= n; ++i)
		if (fa[i] == i) {
			set <int> s;
			for (auto k : vf[i])
				for (auto j : v[k])
					s.insert(j);
			ans += 1ll * vf[i].size() * s.size();
			for (auto k : vf[i])
				if (s.count(k)) --ans;
		}
	printf("%lld\n", ans / 2 - m);
	return 0;
}


Measured memory_bytes: 16204
import java.util.Arrays;
import java.util.Scanner;
 
class Main {
	
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
 
        //一行目をインプット
        int n = scan.nextInt();
        int[] S = new int[n];
        for (int i=0; i<n; i++) {
            S[i] = scan.nextInt();
        }
 
        //二行目をインプット
        int q = scan.nextInt();
        int[] T = new int[q];
        for (int i=0; i<q; i++) {
            T[i] = scan.nextInt();
        }
         
        Arrays.sort(S);
        Arrays.sort(T);
        int count =0;
        
        if(n < q){
        	
        	for(int i = 0; i < n;i++){
        		for(int j = 0;j < q;j++){
        			if(S[i] == T[j]){
        				count++;
        				break;
        			}
        		}
        	}
        }
        
        if(q < n){
        	for(int i = 0; i < q;i++){
        		for(int j = 0;j < n;j++){
        			if(S[j] == T[i]){
        				count++;
        				break;
        			}
        		}
        	}
        }
        
        System.out.println(count);
    }
}



Measured memory_bytes: 40068
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rin(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rin(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }

int main() {
  int x, a;
  cin >> x >> a;
  cout << (a <= x) * 10 << endl;
}


Measured memory_bytes: 256
N = int(input())
S = str(input())

ans = 0
a = 0
n = 0
for i in range(1,N):
    X = S[:i]
    Y = S[i:]
    lis = list(set(X))
    for j in range(len(lis)):
        if Y.count(lis[j]) != 0:
            a += 1

    if a > ans:
        ans = a
    a = 0

print(ans)

Measured memory_bytes: 3064
n = int(input())
h_inputs = [int(i) for i in input().split()]

#単調非減少
#Hi-1or0でHi<=Hi+1になればいい。右の柱から見ていく
ans='Yes'
for i in range(n-1,0,-1):
    if h_inputs[i]<(h_inputs[i-1]-1):
        ans='No'
        break
    if h_inputs[i]>=(h_inputs[i-1]):
        continue
    if h_inputs[i]==(h_inputs[i-1]-1):
        h_inputs[i-1]-=1
print(ans)    


Measured memory_bytes: 14396
//
//  Competitive Programming
//  Don't Copy Be Original - Ehsaan Rahman
//  Copyright © 2020 Ehsaan Rahman. All rights reserved.
//
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<map>
#include<bitset>
#include<cstring>
#include<stack>
#include<queue>
#include<set>
#include<chrono>
#include<list>
#include<climits>
#include<iomanip>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #define PBDS tree<long long int,null_type,less<long long int>, rb_tree_tag,tree_order_statistics_node_update>
// using namespace __gnu_pbds;
#define arrsize 300001
#define dpsize 1001
#define w(t) while(t--)
#define PP pair<ll,ll>
#define INF 1999999996000000010
#define ll long long int
#define takeINP(arr,n) for(long long int i=0;i<n;i++) cin>>arr[i];
#define f(i,s,e) for(long long int i=s;i<e;i++)
#define cf(i,s,e) for(long long int i=s;i<=e;i++)
#define rf(i,e,s) for(long long int i=e-1;i>=s;i--)
#define mem(arr) memset(arr,0,sizeof(arr));
#define MOD 1000000007
#define pp(a,b) make_pair(a,b)
#define print(arr,s,e) f(i,s,e) cout<<arr[i]<<" "; cout<<endl;
#define PP pair<ll,ll>
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define vll vector<ll>
#define triplet pair<ll,pair<ll,ll> >
#define MITR(a,b) map<a,b>::reverse_iterator 
using namespace std;
using namespace chrono;

///Author - Ehsaan Rahman - Don't Copy Be Original
///---------------Functions---------------------///
ll advceil(ll num,ll den){return (num%den==0?num/den:num/den+1);}
ll lstbt(ll val){ ll msk = val&(val-1); return log2(val^msk);}
///---------x------------x----------x-----------///
ll BIT[arrsize]={};
ll n;
void update(ll idx,ll val){
	for(ll i=idx;i<=n;i+=(i&(-i))) BIT[i]=max(BIT[i],val);
}
ll query(ll idx){
	ll res = 0;
	for(ll i=idx;i;i-=(i&(-i))) res = max(res,BIT[i]);
	return res;
}
void solve(){
	cin>>n;
	ll arr[arrsize];
	ll brr[arrsize];
	takeINP(arr,n);
	takeINP(brr,n);
	ll ans = 0;
	f(i,0,n){
		ll pref = query(arr[i]-1);
		update(arr[i],pref+brr[i]);
		ans = max(pref+brr[i],ans);
	}
	cout<<ans<<endl;
}

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r" ,stdin);
		freopen("output.txt", "w" ,stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    auto start1 = high_resolution_clock::now();
    solve();
    auto stop1 = high_resolution_clock::now();
	auto duration = duration_cast<microseconds>(stop1 - start1);
    #ifndef ONLINE_JUDGE
		cerr << "Time: " << duration.count() / 1000.0 << endl;
	    cout<<duration.count()/1000.0<<endl;
    #endif
}

Measured memory_bytes: 8316
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

const int N = 2e6+7;
int a[N];
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int n;cin >> n;
	set<string > s;
    while(n--)
    {
    	string x;cin >> x;
    	s.insert(x);
    }
    cout << s.size();
    return 0;
}


Measured memory_bytes: 19140
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    cout << fixed << setprecision(15);
    int n;cin >> n;
    //string s;cin >> s;
    
    int ans=0;
    fff(i,n+1) {
        if(i%3!=0 and i%5!=0)
        ans+=i;
    }
    
    cout << ans;
    
    
	return 0;
    
}


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

int Solve(const string& s) {
  int ret = 0;
  for (int i = 0, j = s.size() - 1; i < j;) {
    while (i < j && s[i] == s[j]) {
      ++i, --j;
    }
    if (i >= j)
      return ret;
    while (s[i] == 'x' && i < j) {
      ++i;
      ++ret;
    }
    while (s[j] == 'x' && i < j) {
      --j;
      ++ret;
    }
    if (s[i] != s[j])
      return -1;
  }
  return ret;
}

int main() {
  string s;
  cin >> s;
  cout << Solve(s) << "\n";
  return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        int max = 0;
        int max2 = 0;
        for(int i = 0;i<n;i++){
            a[i] = Integer.parseInt(sc.next());
            
            if(a[i] == max){
                max2 = max;
            }else{
                if(max < a[i]){
                    max2 = max;
                    max = Math.max(a[i],max);
                }else{
                    max2 = Math.max(a[i],max2);
                }
            }
        }
        for(int i = 0;i<n;i++){
            if(max == a[i]){
                System.out.println(max2);
            }else{
                System.out.println(max);
            }
            
        }
    }
}

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

int main() {
    int D;
  	cin >> D;
  	string S;
  	S = "Christmas";
  
  	for (int i = 0; D + i < 25; i++) {
     	S += " Eve"; 
    }
  
  	cout << S << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);

        int X = scanner.nextInt();
        int Y = scanner.nextInt();

        for (int i = 0; i <= X; i++) {
            for (int j = 0; j <= X - i; j++) {
                // 1000えん
                int k = X - i - j;

                if (10000 * i + 5000 * j + 1000 * k == Y) {
                    System.out.printf("%d %d %d", i, j, k);
                    return;
                }
            }
        }

        System.out.println("-1 -1 -1");
    }
}


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

ans = 0
for i in range(1, n+1):
    if i % 2 == 0:
        continue
    cnt = 0
    for j in range(1, i+1):
        if i % j == 0:
            cnt += 1
    if cnt == 8:
        ans += 1
print(ans)



Measured memory_bytes: 2940
n,k,c=map(int,input().split())
s=input()
left=[k+1]*n
right=[k+1]*n
l,r=1,1
i=0
while i<n:
    if s[i]=='o':
        left[i]=l
        l+=1
        i+=c
    i+=1
i=1
while i<n+1:
    if s[-i]=='o':
        right[-i]=r
        r+=1
        i+=c
    i+=1
for i in range(n):
    if left[i]+right[i]==k+1:
        print(i+1)


Measured memory_bytes: 20632
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int min(int x, int y)
{
    if (x <= y) return x;
    else return y;
}

int main()
{
    int n, k, i;
    scanf("%d%d", &n, &k);
    int ans = 1;
    for (i=0; i<n; i++)
    {
        ans = min(ans * 2, ans + k);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll  long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i : c)
#define pii pair< int,int >
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
using namespace std;
const int dx[] = { 1, -1 , 0 , 0  };
const int dy [] = { 0 ,0 , 1 , -1  };
const int MOD = 1000 * 1000 * 1000 + 7 ;
const int N = 4  ;
const int M = 13;
const int INF = INT_MAX ; 
int main ( ){
fast_io();
string s , t ; 
cin >> s >> t ; 
int a , b ; 
cin >> a >> b ; 
string u ; 
cin >> u ; 
a-=( u == s ) ; 
b-= (u==t) ; 
cout << max(0 , a ) << " " << max ( 0 , b)  ; 
 
 
return 0 ;
 
}


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

using namespace std;

int main() {
    string s;
    cin >> s;
    int n_0 = 0, n_1 = 0;
    for(char c : s) {
        if(c == '0') n_0 += 1;
        else n_1 += 1;
    }
    cout << 2 * min(n_0, n_1) << endl;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;
const int MAXN = 100005;
const int INF = 2000000000;
int star[MAXN];
int n, t;
set<pair<int, int> > S;
int main()
{
    scanf("%d%d", &n, &t);
    S.clear();
    int minNum = INF, maxNum = 0;
    for(int i = 1; i <= n; i++)
    {
        scanf("%d", &star[i]);
        maxNum = max(maxNum, star[i] - minNum);
        minNum = min(minNum, star[i]);
        S.insert(make_pair(star[i], i));
    }
    int ans = 0;
    for(int i = 1; i <= n; i++)
    {
        S.erase(make_pair(star[i], i));
        set<pair<int, int> >::iterator it = S.lower_bound(make_pair(star[i] + maxNum, -1));
        if(it == S.end() || it->first != star[i] + maxNum) continue;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5376
dur=int(input())
c=list(map(int,input().split()))
d=[0]*26
for i in range(dur):
  t=0
  s=list(map(int,input().split()))
  m=-1<<64
  for j in range(26):
    alt=s[j]+c[j]*(i+1-d[j])+sum([-c[k]*(i+1-d[k]) for k in range(26)])
    if alt>m:
      m=alt
      t=j
  print(t+1)
  d[t]=i+1


Measured memory_bytes: 75460
import bisect
N, M, X = map(int, input().split())
C = [0] * N
A = [0] * N
for i in range(N):
    x = list(map(int, input().split()))
    C[i] = x[0]
    A[i] = [0] * M
    for j in range(M):
        A[i][j] = x[j + 1]
cnt = [0] * (2 ** N)
ans_list = []
for i in range(2 ** N):
    bag = []
    cnt[i] = [0] * M
    for j in range(N):
        if ((i >> j) & 1):
            bag.append(C[j])
            for k in range(M):
                cnt[i][k] += A[j][k]
    cnt[i].sort()
    if bisect.bisect_left(cnt[i], X) == 0:
        ans_list.append(sum(bag))
if ans_list == []:
    print(-1)
else:
    print(min(ans_list))

Measured memory_bytes: 11276
n,k = map(int,input().split())
num_list = list(map(int,input().split()))
ans = 10e12
for i in range(n-k+1):
    left = num_list[i]
    right = num_list[i+k-1]
    if (right <= 0) and (left <= 0):
        tmp = abs(left)
    elif (right >= 0) and (left <= 0):
        tmp = min(abs(right) , abs(left)) + abs(right) + abs(left)
    elif (right >= 0) and (left >= 0):
        tmp = abs(right)
    if tmp < ans:
        ans = tmp
print(ans)

Measured memory_bytes: 14224
import itertools
import math
N = int(input())
XY = [list(map(int,input().split())) for _ in range(N)]
P = list(itertools.permutations(XY))
L = []
for p in P:
    length = 0
    for i in range(1,N):
        length += math.sqrt((p[i][0]-p[i-1][0])**2+(p[i][1]-p[i-1][1])**2)
    L.append(length)
print(sum(L)/len(P))

Measured memory_bytes: 9252
// https://atcoder.jp/contests/nikkei2019-2-qual/tasks/nikkei2019_2_qual_b
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

const MOD: i64 = 998244353;

fn solve(n: usize, d: Vec<usize>, cnt: Vec<i64>) -> i64 {
    if cnt[0] == 1 && d[0] == 0 {
    } else {
        return 0;
    }

    let mut ret = 1;
    for i in 1..n {
        for k in 0..cnt[i] {
            ret *= cnt[i-1];
            ret %= MOD;
        }
    }
    return ret;
}

fn main() {
    input! {
        n: usize, d: [usize; n]
    };

    let mut cnt = vec![0; n];
    for i in 0..n {
        cnt[d[i]] += 1
    }
    println!("{}", solve(n, d, cnt));
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>; // グラフ型
using pint = pair<int, int>;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N,0);
    rep(i,N-1){
        ll a;
        cin >> a;
        a--;
        A[a]++;
    }
    rep(i,N)
    {
        cout << A[i] << endl;
    }
}

Measured memory_bytes: 4748
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

const int MAXN = 2 * 100000 + 1;
int a[MAXN];
int dp[MAXN];
int N;

int main() 
{
    // freopen("./input.txt", "r", stdin);
    // freopen("./output.txt", "w", stdout);
    
    scanf("%d", &N);
    int ans = 0;
    memset(dp, 0, sizeof(dp));
    for (int i = 1; i <= N; i++) {
        scanf("%d", &a[i]);
    }
    for (int i = 1; i <= N; i++) {
        dp[a[i]] = dp[a[i] - 1] + 1;
        ans = max(ans, dp[a[i]]);
    }    
    printf("%d\n", N - ans);

	return 0;
}

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

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    for (auto &e : a) cin >> e;
    
    reverse(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        printf("%d", a[i]);
        if (i != n - 1) putchar(' ');
    }
    putchar('\n');
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll , ll> P;
typedef pair<ll, ll> PL;
const ll INT_INF = 2147483646;
const ll ll_INF = 9223372036854775807;
ll mod = 1e9+7;

bool SecondCompare(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
       return a.second>b.second;
}


int n,k;
int l[51];

int main(){
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    sort(l,l+n);

    int ans = 0;
    for(int i = 0; i < k; i++){
        ans += l[n-1-i];
    }
    cout << ans << endl; 
}

Measured memory_bytes: 256
#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 COUNTOF1(array) (sizeof(array) / sizeof(array[0]))
#define COUNTOF2(array) (sizeof(array[0]) / sizeof(array[0][0]))

char con_to_ope(int b){
  if(b) return '+';
  else return '-';
}

main(){
  string S;
  cin >> S;
  int figures[4];
  rep(i,4) figures[i]=S[i]-'0';
  bool ans = false;

  for(int tmp=0;tmp<(1<<3);tmp++){
    bitset<3> s(tmp);

    int sum = figures[0];
    rep(i,3){
      if(s.test(i)) sum+=figures[i+1];
      else sum -= figures[i+1];
    }
    if(sum==7){
      ans = true;
      cout << S[0];
      rep(i,3){
        cout << con_to_ope(s.test(i))<< S[i+1];
      }
      cout << "=7";
      break;
    }
  }
  if(!ans) cout << "No" << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;

vector <int> ve[100010];
int a[100020];
int dfs (int b)
{
	a[b]=1;
	for(int i=0;i<ve[b].size();i++)
	{
		if(a[ve[b][i]]==0)
		{
			dfs(ve[b][i]);
		}
	}
	return 0;
}


int main() {
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++)
{
	a[i]=0;
}
int ve1,ve2;
for(int i=0;i<m;i++)
{
	cin>>ve1>>ve2;
	ve[ve1].push_back(ve2);
	ve[ve2].push_back(ve1);
}
int ans=0;
for(int i=1;i<=n;i++)
{

	if(a[i]==0)
	{
		dfs(i);
	
      	ans+=1;
    }
}
cout<<ans-1<<endl;
    
	return 0;
}

Measured memory_bytes: 9932
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rp(i,n) for (int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define all_acc(x) (x).begin(), (x).end(), 0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using ll = long long;
double pi=3.14159265359;

//出力するよ
void output_tate(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        //if (i != 0)
        //    cout << " ";
        cout << s[i]<<endl;
    }
    //cout << endl;
}

void output_yoko(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        if (i != 0)
            cout << " ";
        cout << s[i];//<<endl;
    }
    cout << endl;
}
int MOD = pow(10, 9) + 7;


const long long MAX=100000+1;
long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int kaijou(int n){
    if(n==0) return 1;
    else{
        return ((n%MOD)*(kaijou(n-1)%MOD))%MOD;
    }
}

signed main() {
    int n; string s;
    cin>>n>>s;
    
    //各文字の出現回数と各文字がダブっている組の数
    map<char,int> chars;
    map<char,int> kaburi;
    int kabu=0;
    COMinit();

    
    for(int i=0;i<n;i++){
        kaburi[s[i]]+=chars[s[i]];
        chars[s[i]]++;
    }

    int ans=1;

    for(auto c:chars){
        //cout<<c.second<<endl;
        ans=(ans%MOD*((c.second+1)%MOD))%MOD;
    }


    ans--;
    if(ans<0) ans+=MOD;
    

    cout<<ans%MOD<<endl;
}


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

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

using ll = long long;
using pii = pair<int, int>;

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int n, m; cin >> n >> m;
    vector<int> a(n);
    int s = 0;
    for (auto &ai : a) {
        cin >> ai;
        s += ai;
    }
    int c = 0;
    for (auto &ai : a) {
        if (ai * 4 * m < s)
            continue;
        ++c;
    }
    cout << (c >= m ? "Yes" : "No");
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    S = input().strip()
    T = input().strip()

    x = 0
    for i in range(N):
        if S[i:] == T[:N - i]:
            x = N - i
            break

    print(N * 2 - x)


    

if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}

long long ksc(long long u,long long v,long long n){
	return (u*v-(long long)((long double)u/n*v)*n+n)%n;
}
long long ksm(long long u,long long v,long long n){
	long long o=1;
	while(v){
		if(v&1)
			o=ksc(o,u,n);
		u=ksc(u,u,n);
		v>>=1;
	}
	return o;
}
long long miller(long long n){
	if(n<=28){
		if(n==2||n==3||n==5||n==7||n==11||n==13||n==17||n==19||n==23)
			return 1;
		return 0;
	}
	long long book[9]={2,3,5,7,11,13,17,19,23},i,j,x,y;
	for(i=0;i<=8;i++){
		j=n-1;
		while((j&1)==0)
			j>>=1;
		if(ksm(book[i],n-1,n)!=1)
			return 0;
		x=ksm(book[i],j,n);
		if(x!=1){
			while(j!=n-1){
				if(x==n-1)
					break;
				if(x==1)
					return 0;
				x=ksc(x,x,n);
				j<<=1;
			}
			if(x!=n-1)
				return 0;
		}
	}
	return 1;
}
int n,m,s,t,i,j,x,y,z,zhan[100005],book[100005],flag,ans,a[10000005],top1,top2,b[205],c[205];
int top,fir[100005],qu[200005],to[200005],nex[200005],iter[100005];
int lj(int u,int v,int w){
	top++;
	nex[top]=fir[u];
	fir[u]=top;
	to[top]=v;
	qu[top]=w;
	return 0;
}
int BFS(){
	int head=0,tail=0,v;
	zhan[0]=s;book[s]=1;
	while(head<=tail){
		v=zhan[head];
		for(int top1=fir[v];top1;top1=nex[top1])
			if(book[to[top1]]==0&&qu[top1]){
				tail++;
				zhan[tail]=to[top1];
				book[to[top1]]=book[v]+1;
			}
		head++;
	}
	return 0;
}
int DFS(int v,int w){
	if(v==t){
		flag=w;
		ans+=w;
		return 0;
	}
	for(int &top1=iter[v];top1;top1=nex[top1])
		if(book[to[top1]]==book[v]+1&&qu[top1]){
			DFS(to[top1],min(w,qu[top1]));
			if(flag){
				qu[top1]-=flag;
				if(top1&1)
					qu[top1+1]+=flag;
				else
					qu[top1-1]+=flag;
				return 0;
			}
		}
}
int main(){
	//freopen("7.in","r",stdin);
    //freopen("7.out","w",stdout);
   	n=read();
   	for(i=1;i<=n;i++){
		x=read();
		a[x-1]^=1;
		a[x]^=1;
	}
	for(i=0;i<=10000000;i++)
		if(a[i]==1){
			if(i&1){
				top1++;
				b[top1]=i;
			}
			else{
				top2++;
				c[top2]=i;
			}
		}
	s=top1+top2+1;
	t=top1+top2+2;
	n=t;
	for(i=1;i<=top1;i++)
		for(j=1;j<=top2;j++)
			if(miller(abs(c[j]-b[i]))==1){
				lj(i,j+top1,1);
				lj(j+top1,i,0);
			}
	for(i=1;i<=top1;i++){
		lj(s,i,1);
		lj(i,s,0);
	}
	for(i=1;i<=top2;i++){
		lj(i+top1,t,1);
		lj(t,i+top1,0);
	}
	do{
		for(i=1;i<=n;i++){
			book[i]=0;
			iter[i]=fir[i];
		}
		BFS();
		do{
			flag=0;
			DFS(s,2147483647);
		}while(flag);
	}while(book[t]);
	if(((top1-ans)&1)==0)
		pus(top1+top2-ans,2);
	else
		pus(top1+top2-ans+1,2);
    return 0;
}

Measured memory_bytes: 39296
try :
    from math import gcd
except ImportError :
    from fractions import gcd

def lcs(c,d,g) :
    return (c*d)//g


A,B,C,D = map(int,input().split())

al = B-(A-1)

divisible_c = B//C - (A-1)//C
divisible_d = B//D - (A-1)//D

G = gcd(C,D)
L = lcs(C,D,G)

divisible_c_and_d = B//L - (A-1)//L

ans = al - (divisible_c + divisible_d - divisible_c_and_d)

print(ans)


Measured memory_bytes: 5044
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
long X[10000];
long Y[10000];
void Calc(){
	int N = rei();
	for(int i=0;i<N;i++){
		X[i] = rel();
		Y[i] = rel();
	}
	for(int i=1;i<N;i++){
		if((X[i] + Y[i] + 1000000000000) % 2 != (X[i-1] + Y[i-1] + 1000000000000) % 2){
			cout << -1 << endl;
			return;
		}
	}
	long sum = 0;
	if((X[0] + Y[0] + 1000000000000) % 2 == 0){
		cout << 33 << endl;
		for(int i=0;i<32;i++){
			cout << (((long)(1)) << i) << " ";
			sum += (((long)(1)) << i);
		}
		cout << 1 << endl;
		sum++;
		for(int i=0;i<N;i++){
			long plus = X[i] + Y[i];
			long minus = X[i] - Y[i];
			plus = sum - plus;
			minus = sum - minus;
			plus /= 2;
			minus /= 2;
			for(int j=0;j<32;j++){
				bool p = (plus & (((long)(1)) << j)) == 0;
				bool m = (minus & (((long)(1)) << j)) == 0;
				if(p && m){
					cout << 'R';
				}
				if(p && !m){
					cout << 'U';
				}
				if(!p && m){
					cout << 'D';
				}
				if(!p && !m){
					cout << 'L';
				}
			}
			cout << 'R' << endl;
		}
	}
	else{
		cout << 32 << endl;
		for(int i=0;i<31;i++){
			cout << (((long)(1)) << i) << " ";
			sum += (((long)(1)) << i);
		}
		cout << (((long)(1)) << 31) << endl;
		sum += (((long)(1)) << 31);
		for(int i=0;i<N;i++){
			long plus = X[i] + Y[i];
			long minus = X[i] - Y[i];
			plus = sum - plus;
			minus = sum - minus;
			plus /= 2;
			minus /= 2;
			for(int j=0;j<32;j++){
				bool p = (plus & (((long)(1)) << j)) == 0;
				bool m = (minus & (((long)(1)) << j)) == 0;
				if(p && m){
					cout << 'R';
				}
				if(p && !m){
					cout << 'U';
				}
				if(!p && m){
					cout << 'D';
				}
				if(!p && !m){
					cout << 'L';
				}
			}
			cout << endl;
		}
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    vi a(n); for(auto& e : a) cin >> e;
    vector<vll> dp(n + 1, vll(2));
    dp[0][0] = 1;
    rep(i, n){
        rep(j, 2){
            ll& cur = dp[i][j];
            if(cur == 0) continue;

            if(j == 0){
                if(a[i] % 2){
                    dp[i + 1][1] += cur * 2;
                    dp[i + 1][0] += cur * 1;
                }
                else {
                    dp[i + 1][1] += cur * 1;
                    dp[i + 1][0] += cur * 2;
                }
            }
            else {
                dp[i + 1][1] += cur * 3;
            }
        }
    }

    cout << dp[n][1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << #x << " " << x << endl
inline void filehandling()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
}
#define int long long
#define MOD 1000000007
int power(int x,int y)
{
  int res = 1LL ;
  while(y > 0)
  {
    if(y & 1)
    {
      res = ((res % MOD) * (x % MOD)) % MOD;
    }
      
      y >>= 1 ;
      x = ( (x % MOD) * (x % MOD) ) % MOD;
  }

  return res % MOD;
} 
void Solve_Case()
{
  int n;
  cin >> n;
  vector< pair<double,double> > v(n);
  for (int i = 0; i < n; ++i)
   {
     cin >> v[i].first >> v[i].second;
   } 
   double sum = 0;
   for(int i=0;i<n;i++)
   {
    for(int j=i+1;j<n;j++)
    {
      sum += sqrt((v[i].first-v[j].first)*(v[i].first-v[j].first)+ (v[i].second-v[j].second)*(v[i].second-v[j].second));
    }
   }
  
   cout << setprecision(10) << 2.0*sum/(double)n << endl;
}
signed main()
{
   //filehandling();
   int TestCases = 1;
  // cin >> TestCases;
   while(TestCases--)
   {
      Solve_Case();
   }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
li = [0] * 1100000
is_prime = [True] * 1100000
is_prime[0] = is_prime[1] = False
for i in a:
    li[i] += 1
is_pairwise = True
for i in range(2, 1100000):
    if is_prime[i]:
        cnt = 0
        for j in range(i, 1100000, i):
            is_prime[j] = False
            cnt += li[j]
        if cnt == n:
            print("not coprime")
            exit()
        if cnt > 1:
            is_pairwise = False
if is_pairwise:
    print("pairwise coprime")
else:
    print("setwise coprime")

Measured memory_bytes: 127376