akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#define MN 20000
using namespace std;
inline int read()
{
    int x=0;char ch=getchar();
    while (ch<'0'||ch>'9')ch=getchar();
    while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x;
}
struct Tree{int l,r;}T[MN*4+5];
int n,a[MN+5],b[MN+5],cnt,id,top,head[MN*5+5],dfn[MN*5+5],low[MN*5+5],cc,dn,bel[MN*5+5],mx,inq[MN*5+5],Q[MN*5+5],Top;
pair<int,int> q[MN+5];
struct edge{int to,next;}e[MN*100+5];
inline void ins(int f,int t){e[++cnt]=(edge){t,head[f]};head[f]=cnt;}
int Build(int l,int r)
{
    int x=++id;
    if(l==r) return mx=max(mx,x+n*2),ins(x+n*2,(q[l].second+n-1)%(n*2)+1),x;
    int mid=l+r>>1;
    ins(x+n*2,(T[x].l=Build(l,mid))+n*2);ins(x+n*2,(T[x].r=Build(mid+1,r))+n*2);
    return x;
}
void Ins(int x,int lt,int rt,int l,int r,int v)
{
    if(lt==l&&r==rt) return ins(v,x+n*2);
    int mid=lt+rt>>1;
    if(r<=mid) Ins(T[x].l,lt,mid,l,r,v);
    else if(l>mid) Ins(T[x].r,mid+1,rt,l,r,v);
    else Ins(T[x].l,lt,mid,l,mid,v),Ins(T[x].r,mid+1,rt,mid+1,r,v);
}
void Tarjan(int x)
{
    dfn[x]=low[x]=++dn;Q[++Top]=x;inq[x]=1;
    for(int i=head[x];i;i=e[i].next)
        if(!dfn[e[i].to]) Tarjan(e[i].to),low[x]=min(low[x],low[e[i].to]);
        else if(inq[e[i].to]) low[x]=min(low[x],dfn[e[i].to]);
    if(low[x]==dfn[x])
        for(++cc,Q[Top+1]=0;Q[Top+1]!=x;--Top) inq[Q[Top]]=0,bel[Q[Top]]=cc;
}
int main()
{
    n=read();
    for(int i=1;i<=n;++i) a[i]=read(),b[i]=read(),q[++top]=make_pair(a[i],i),q[++top]=make_pair(b[i],i+n);
    sort(q+1,q+top+1);
    int l=1,r=1e9/(n-1)+2,mid,res=0;
    while(l<=r)
    {
        mid=l+r>>1;cnt=id=0;memset(head,0,sizeof(head));Build(1,n*2);
        for(int i=1;i<=n;++i)
        {
            int p=lower_bound(q+1,q+top+1,make_pair(a[i],i))-q,
                l=lower_bound(q+1,q+top+1,make_pair(a[i]-mid+1,0))-q,
                r=lower_bound(q+1,q+top+1,make_pair(a[i]+mid,0))-q-1;
            if(l<p) Ins(1,1,n*2,l,p-1,i);
            if(p<r) Ins(1,1,n*2,p+1,r,i);
            int P=lower_bound(q+1,q+top+1,make_pair(b[i],i+n))-q,
                L=lower_bound(q+1,q+top+1,make_pair(b[i]-mid+1,0))-q,
                R=lower_bound(q+1,q+top+1,make_pair(b[i]+mid,0))-q-1;
            if(L<P) Ins(1,1,n*2,L,P-1,i+n);
            if(P<R) Ins(1,1,n*2,P+1,R,i+n);
        }
        memset(dfn,0,sizeof(dfn));memset(low,0,sizeof(low));dn=cc=0;
        for(int i=1;i<=mx;++i) if(!dfn[i]) Tarjan(i);
        int flag=1;
        for(int i=1;i<=n;++i) if(bel[i]==bel[i+n]) flag=0;
        if(flag) res=mid,l=mid+1; else r=mid-1;
    }
    printf("%d",res);
    return 0;
}


Measured memory_bytes: 14080
N = int(input())
a = sorted(list(map(int, input().split())))

A = 0
B = 0
i = 0
while len(a) > 0:
    if i % 2 == 0:
        A += a.pop()
    else:
        B += a.pop()
    i += 1
print(A - B)


Measured memory_bytes: 3060
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = (1..3).map { sc.next().map { it - 'a' } }
    val idx = Array(3) {0}
    var now = 0
    while (true) {
        if (idx[now] == s[now].size) {
            println('A' + now)
            break
        }
        idx[now]++
        now = s[now][idx[now] - 1]
    }
}

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

int main() {
  int N;
  cin >>N;
  vector<int> vec(N);
  for(int i=0;i < N;i++){
    cin >>vec[i];
  }
  bool ans=true;
    
  for(int i=0;i < N;i++){
    if(vec[i]%2 ==0 && vec[i]%3 != 0 && vec[i]%5 != 0){
      ans =false;
    }
  }
  
  if(ans)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

//inline int read(){int t = 0;int neg=1;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1;continue;}t=t*10+c-48;}return neg*t;}
//inline int readl(){long long t = 0;long long neg=1ll;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1ll;continue;}t=t*10+c-48;}return neg*t;}

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pi> vpi;
typedef vector<plli> vplli;
const lli M=1000000007ll;

int main(){
	fast_io 
	int k,a,b,p;
	cin>>k>>a>>b;
	if(a%k==0) p=a/k;
	else p=a/k+1;
	if(p*k<=b) cout<<"OK";
	else cout<<"NG";
	
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t % 13;
    } else {
        return modpow(m, n - 1) * m % 13;
    }
}
long long power(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = pow(m, n / 2);
        return t * t;
    } else {
        return pow(m, n - 1) * m;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

const ll INF = 1LL << 60;

string change_binary(long long a) {
    string ret;
    for (int i = 31; i >= 0; i--) {
        ret += (a >> i & 1) + '0';
    }
    return ret;
}

ll nCkmod(ll n, ll k) {
    ll denomi = 1;
    for (int i = n; i > n - k; i--) {
        denomi *= i;
        denomi %= mod;
    }
    ll numera = 1;
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}
string s;
ll memo[100001][14];
ll func(ll row, ll m13) {
    if (row == s.size()) {
        if (m13 == 5) {
            return 1;
        } else {
            return 0;
        }
    }
    if (memo[row][m13] != -1) {
        return memo[row][m13];
    }
    if (s[row] != '?') {
        memo[row][m13] = func(row + 1, (m13 + (s[row] - '0') * modpow(10, s.size() - row - 1)) % 13);
        memo[row][m13] %= mod;
        return memo[row][m13];
    }
    ll ret = 0;
    REP(i, 10) {
        ret += func(row + 1, (m13 + i * modpow(10, s.size() - row - 1)) % 13);
        ret %= mod;
    }
    memo[row][m13] = ret;
    ret %= mod;
    return ret;
}
int main() {
    Fill(memo, -1);
    cin >> s;
    cout << func(0, 0) << endl;
}

Measured memory_bytes: 22560
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
const int mod = 1e9 + 7;
typedef long long ll;
typedef long double ld;
const ld eps = 1e-30;

int n, k;
int main()
{
    //ios::sync_with_stdio(0); cin.tie(0); //C++关同步
    ll a, b, n;
    cin >> a >> b >> n;
    cout << a * min(b - 1, n) / b << "\n";
    return 0;
}


Measured memory_bytes: 3636
#include<iomanip>
#include<queue>
#include<iostream>
#include<cmath>
#include<cstdio>
#define pi acos(-1)
using namespace std;

/*int arr[10000];
vector<int>adj[10000];
vector<int>v1;
bool visited[10000];
void bfs(int s)
{
    int cnt=0;
    queue<int>q;
    q.push(s);
    v1.push_back(s);
    visited[s]=1;
    cnt++;
    while(!q.empty()){
        int u=q.front();
        q.pop();
        for(int i=0;i<adj[u].size();i++){
            if(visited[adj[u][i]]==0){
                int v=adj[u][i];
                visited[v]=1;
                v1.push_back(v);
                q.push(v);
                cnt++;
            }
        }
    }
    int u=v1.size();
    for(int i=0;i<u;i++){
        arr[v1[i]-1]=cnt;
    }
    v1.clear();
}
void solve(int n)
{
    for(int i=0;i<n;i++)cout<<arr[i]<<" ";
}
int main()
{
    int m,n;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int k,j=0;
        cin>>k;
        int ara[k];
        while(j<k){
            cin>>ara[j];
            if(j){
                adj[ara[j-1]].push_back(ara[j]);
                adj[ara[j]].push_back(ara[j-1]);
            }
            j++;
        }
    }
    for(int i=0;i<n;i++){
        if(visited[i+1]==0){
          bfs(i+1);
        }
    }
    solve(n);
    //cout<<v2.size();
}
*/
int main()
{
    int a,b,t,k;
    cin>>t;
    cout<<setprecision(8)<<fixed<<t*2*pi;
}



Measured memory_bytes: 3788
#include<iostream>
#include<cstdint>

using namespace std;

int main() {
	uint64_t num1, num2;
	cin >> num1 >> num2;
	uint64_t min = num1 <= num2 ? num1 : num2;
	uint64_t max = num1 >= num2 ? num1 : num2;

	uint64_t m_min = min;
	uint64_t m_max = max;
	while(m_min != m_max) {
		if (m_min < m_max) {
			uint64_t multi = (m_max - m_min) / min;
			if (multi == 0) {
				multi = 1;
			}
			m_min += min * multi;
		}else {
			m_max += max;
		}
	}
	
	cout << m_min << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
// #include <numeric>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define LF "\n"

int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;

int main()
{
	FAST;

	int n;
	cin >> n;
	
	int ans=0;
	while(n>0) {
		if (n%10 == 2) ans++;
		n /= 10;
	}
	cout << ans << LF;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+7
#define MOD 1000000007
using namespace std;



int main(){
    int ans=INF;
    
    int H,W,N;
    cin>>H>>W>>N;
    
    pair<int,int> sgb[N];
    for(int i=0; i<N; i++){
        cin >> sgb[i].first >> sgb[i].second;
        sgb[i].first--;
        sgb[i].second--;
    }
    
  
    map<int, int> sgb_exist[W];
    for(int i=0; i<N; i++){
        sgb_exist[sgb[i].second].insert( make_pair(sgb[i].first,1) );
    }
    
    vector<int> sgb_x[W];
    for(int i=0; i<N; i++){
        sgb_x[sgb[i].second].push_back(sgb[i].first);
    }
    
    for(int i=0; i<W; i++){
        sort(sgb_x[i].begin(), sgb_x[i].end());
    }
    
    
    int x=0;
    int y=0;
    

    for(int i=0; i<W; i++){
        int tmp=INF;
        
        if(sgb_x[i].size()==0){
            ans=min(ans,H);
        }else{
            int bound = lower_bound(sgb_x[i].begin(), sgb_x[i].end(), x) - sgb_x[i].begin();
            if(bound==sgb_x[i].end()-sgb_x[i].begin()){
                tmp=H;
            }else{
                tmp=sgb_x[i][bound];
            }
            
            
            ans=min(tmp,ans);
        }
    //    cout << "y=" << i <<"; tmp=" <<tmp<<endl;
        
        
        int next=1;
        if(i==W-1){
            next=0;
        }else{
            if(x==H-1){
                break;
            }
            
            if(sgb_exist[i].count(x+1)==0){
                x++;
            }else{
                break;
            }
            
            if(sgb_exist[i+1].count(x)==0){
                next=1;
            }else{
                while(sgb_exist[i+1].count(x)>0){
                    if(x==H-1 || sgb_exist[i].count(x)>0){
                        next=0;
                        break;
                    }else{
                        x++;
                    }
                }
                
            }
        }
        
        if(next==0){
            break;
        }
    }
    

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


Measured memory_bytes: 29056
#include <bits/stdc++.h>
using namespace std;
int main() 
{
  int n,x;cin>>n>>x;
  int ans=1,sum=0;
  vector<int>l(n);
  for(int i=0;i<n;i++)
    cin>>l.at(i);
  for(int i=0;i<n;i++)
  {
    sum=sum+l.at(i);
    if(sum>x)
    {
      break;
    }
    ans++;
  }
  cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int Maxn=100010;
const int inf=2147483647;
int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return x*f;
}
int fa[Maxn],n,m,to[Maxn];
vector<int>G[Maxn];
struct P{int a,b,id;}p[Maxn];
bool cmp(P a,P b)
{
	return max(a.a-a.b,0)<max(b.a-b.b,0);
//	if(a.a!=b.a)return a.a<b.a;
//	return a.b>b.b;
}
struct Edge{int y,next;}e[Maxn];
int last[Maxn],len=0;
void ins(int x,int y)
{
	int t=++len;
	e[t].y=y;e[t].next=last[x];last[x]=t;
}
int rt[Maxn];
int findrt(int x){return((rt[x]==x)?x:rt[x]=findrt(rt[x]));}
LL f[Maxn],g[Maxn];
void dfs(int x)
{
	bool flag=true;g[x]=p[x].b;
	for(int i=last[x];i;i=e[i].next)
	{
		int y=e[i].y;
		dfs(y);flag=false;
		g[x]+=g[y];
	}
	if(flag)
	{
		f[x]=max(p[x].a,p[x].b);
		return;
	}
	f[x]=1LL<<60;
	for(int i=last[x];i;i=e[i].next)
	{
		int y=e[i].y;
		f[x]=min(f[x],max((LL)max(p[x].a-p[x].b,0),f[y])+g[x]-g[y]);
	}
}
int main()
{
	n=read(),m=read();
	for(int i=1;i<=n;i++)rt[i]=i,p[i].a=read(),p[i].b=read(),p[i].id=i;
	sort(p+1,p+1+n,cmp);
	for(int i=1;i<=n;i++)to[p[i].id]=i;
//	for(int i=1;i<=n;i++)printf("%d %d %d\n",i,p[i].a,p[i].b);
	for(int i=1;i<=m;i++)
	{
		int x=to[read()],y=to[read()];
//		printf("  %d %d\n",x,y);
		G[x].push_back(y),G[y].push_back(x);
	}
	for(int x=1;x<=n;x++)
	{
		for(int i=0;i<G[x].size();i++)
		{
			int y=G[x][i],fy=findrt(y);
			if(y>x)continue;
			if(fy==x)continue;
			fa[fy]=x,rt[fy]=x;
		}
	}
	int root;
	for(int i=1;i<=n;i++)
	if(!fa[i])root=i;
	else ins(fa[i],i);//printf("ins %d %d\n",fa[i],i);
	dfs(root);
//	for(int i=1;i<=n;i++)printf("%d %lld %lld\n",i,f[i],g[i]);
	printf("%lld",f[root]);
}

Measured memory_bytes: 13180
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for(int i=m; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <typename T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0; }
template <typename T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1;} return 0; }
const int INF = 1000000000;

int main(){
    int n; cin>>n;
    vi P(n); rep(i,0,n) cin>>P[i];
    vi Q(n); rep(i,0,n) cin>>Q[i];
    int ans=0;
    if(P>Q) swap(P,Q);
    do{
        if(P==Q) break;
        ans++;
    }while(next_permutation(P.begin(),P.end()));
    cout<<ans<<endl;
}

Measured memory_bytes: 256
//                                                        ,.へ 
//___ 　　　　　　　 　 　 　 　 　　　　　　　　　　　     　ﾑ　　i 
//「 ﾋ_i〉　　　 　 　　　　　　 　 　　　　　　　　　　　　 ゝ　〈 
//ﾄ　ノ 　　　　　　　　　　　　　　　　　　　　　　　　　　iニ(() 
//i 　{ 　 　　　　　　　 　　　＿＿＿_ 　 　　　　　　　　| 　ヽ 
//i　　i　　　 　　　　　　　／__,　 , ‐-＼ 　 　 　 　 　　i 　　} 
//|　　 i　　　　　　 　　／（●) 　 ( ● )＼　　　　　　 {､　 λ 
//ト－┤.　　　　　　／ 　 　（__人__） 　　　＼　　　 ,ノ　￣ ,! 
//i　　　ゝ､_ 　　　　|　　　　　´￣` 　 　　　　|　,. '´ﾊ　　　,! 
//.　ヽ、 　　　｀`　､,__＼ 　　 　 　　　　　 　 ／"　＼ 　ヽ／ 
//＼ノ　ﾉ　　　ﾊ￣r/:::r―--―/::７　　 ﾉ　　　　／ 
//ヽ.　　　　　　ヽ::〈； . '::. :' |::/　　 /　　　,. " 
//`ｰ ､　　　　＼ヽ::. ;::：|/　　　　　ｒ'" 
//／￣二二二二二二二二二二二二二二二二ヽ 
//| 答 |　　　　　コ　ロ　ン　ビ　ア　　　　　　　│| 
//＼＿二二二二二二二二二二二二二二二二ノ
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[]args){
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	long w=0,h=0;
	int d[]=new int[a];
	int e[]=new int[a];
	int count=0;
	for(int i=0;i<a;i++) {
		d[i]=scan.nextInt();
	}
	Arrays.sort(d);
	for(int i=0;i<a;i++) {
		e[i]=d[a-i-1];
	}
	for(int i=1;i<a;i++) {
		if(e[i]==e[i-1]) {
			i++;
			if(count==0) {
				w=e[i-1];
				count++;
			}
			else {
				h=e[i-1];
				break;
			}
		}
	}
	System.out.println(w*h);
	}
}

Measured memory_bytes: 50224
#include <bits/stdc++.h>
using namespace std;
template<typename T> void in(T &x) { x = 0; bool neg = false; register T c = getchar(); if (c == '-')neg = true, c = getchar(); while ((c < 48) || (c > 57))c = getchar(); for (; c < 48 || c > 57; c = getchar()); for (; c > 47 && c < 58; c = getchar())x = (x << 3) + (x << 1) + (c & 15); if (neg) x *= -1; }
template<typename T> void out(T n) {bool neg = 0; if (n < 0)n *= -1, neg = 1; char snum[65]; int i = 0; do { snum[i++] = n % 10 + '0'; n /= 10; } while (n); --i; if (neg)putchar('-'); while (i >= 0)putchar(snum[i--]); }
template<typename T> void outln(T n) {bool neg = 0; if (n < 0)n *= -1, neg = 1; char snum[65]; int i = 0; do { snum[i++] = n % 10 + '0'; n /= 10; } while (n); --i; if (neg)putchar('-'); while (i >= 0)putchar(snum[i--]); putchar('\n');}
#define len(x) (sizeof((x)) / sizeof(x)[0])
#define fastIO ios_base::sync_with_stdio(false); cin.tie(false);
#define ll long long 
#define f(_x)for (int i = 0; i < _x; ++i)
#define fr(_x)for (int i = _x; i >0; i--)
#define f2(_x,_y)for (int i = _x; i < _y; ++i)
#define fileIO 	freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi; typedef vector<string> vs; typedef vector<bool> vb; vector<long long>vll;
typedef pair<int, int> ii; 
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;


int main()
{
	int n; in(n);vi v; si s;
	 while (n--)
	{
		int x; in(x); if (!s.insert(x).second) { v.push_back(x); s.erase(x); }
	}
	sort(v.begin(), v.end());
	if (v.size() >= 2)out((ll)*(v.end() - 1)*(ll)*(v.end() - 2));
	else out(0);
}

		

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

#define INF 1e+9
#define MAX_V 2010

struct edge {
    int to;
    int cost;
};

// <最短距離, 頂点の番号>
using P = pair<int, int>;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    int x, y;
    cin >> V >> x >> y;
    int ans[V] = {0};
    int E;
    for (int i=0; i<V; ++i) {
        edge e = {i+1, 1};
        G[i].push_back(e);
        e = {i, 1};
        G[i+1].push_back(e);
    }
    edge e = {y-1, 1};
    G[x-1].push_back(e);
    e = {x-1, 1};
    G[y-1].push_back(e);

    for(int i = 0; i < V; ++i) {
        dijkstra(i);
        for(int j = i+1; j < V; ++j) {
            ans[d[j]]++;
        }
        
    }

    for(int i = 1; i < V; ++i) cout << ans[i] << '\n';

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

int main(){
   int A, B, C, D, E;
   std::cin >> A >> B >> C >> D >> E;
   std::vector<int> v = {A, B, C, D, E};
   int amari = 0;
   int max = v.at(0);
   for (int x : v){
      if (x % 10 != 0){
         int temp = 10 - x % 10;
         if (temp >= amari){
            amari = temp;
            max = x;
         }
      }
   }
   std::vector<int> V(5);
   for (int i=0; i<5; i++){
      if (v.at(i) % 10 != 0){
         int temp = 10 - v.at(i) % 10;
         V.at(i) = v.at(i) + temp;
      }
      else{
         V.at(i) = v.at(i);
      }
   }
   if (max % 10 == 0){
      std::cout << std::accumulate(v.begin(), v.end(), 0);
   } else{
      std::cout << std::accumulate(V.begin(), V.end(), 0) - (max + (10 - (max % 10))) + max << std::endl;
   }

}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/* Coding Space*/

const ll base = 100001;
using tli = tuple<ll,int>;
unordered_map<ll,bool> used;

map<ll,vector<tli> > mm; // comp-index, to comp-index,cost
int main(){
  int n,m; cin >> n >> m;
  rep(i,m){
    ll p,q,c; cin >> p >> q >> c;
    mm[p + base*c].pb(tli{q + base*c,0});
    mm[q + base*c].pb(tli{p + base*c,0});
    mm[p + base*c].pb(tli{p,1});
    mm[p].pb(tli{p + base*c,0});
    mm[q + base*c].pb(tli{q,1});
    mm[q].pb(tli{q + base*c,0});
  }
  using til = tuple<int,ll>;
  priority_queue<til,vector<til>,greater<til>> q;
  q.push(til{0,1});
  while(!q.empty()){
    ll comp_index;
    int turn;
    tie(turn,comp_index) = q.top(); q.pop();
    //ll comp = comp_index / base;
    used[comp_index] = 1;
    ll index = comp_index % base;
    if(index == n){
      cout << turn +1 << endl;
      return 0;
    }else{
      for(auto i:mm[comp_index]){
        ll next; int cost;
        tie(next,cost) = i;
        if(used[next] == 0)
          used[next] = 1,q.push(til{turn+cost,next});
      }
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 84016
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	string s; cin >> s;
	reverse( s.begin(), s.end() );
	ll cnt = 0;
	ll ans = 0;
	for( char c : s ){
		if( c == 'W' ){
			++cnt;
		} else {
			ans += cnt;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

/*「hon」表示判定用定義*/
#define hon_2	2
#define hon_4	4
#define hon_5	5
#define hon_7	7
#define hon_9	9
#define hon		"hon"


/*「pon」表示判定用定義*/
#define pon_0	0
#define pon_1	1
#define pon_6	6
#define pon_8	8
#define pon		"pon"


/*「bon」表示判定用定義*/
#define bon_3	3
#define bon		"bon"


int main()
{
    int		N;
	int		temp_yo;		/* 1桁目算出用用変数	*/
	char	*s;
	
	scanf("%d", &N);		/* Nの取得 */
	
	temp_yo = N % 10;

	if((hon_2 == temp_yo)
	|| (hon_4 == temp_yo)
	|| (hon_5 == temp_yo)
	|| (hon_7 == temp_yo)
	|| (hon_9 == temp_yo) ){		/* 2,4,5,7,9の時	*/
		s = hon;
	}
	else if((pon_0 == temp_yo)
	||		(pon_1 == temp_yo)
	||		(pon_6 == temp_yo)
	||		(pon_8 == temp_yo) ){	/* 0,1,6,8の時	*/
		s = pon;
	}
	else{							/* 上記以外(3の時)*/
		s = bon;
	}
		
	
    printf("%s\n", s);		/* 回答表示*/
    return 0;
}

Measured memory_bytes: 1632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int n, sum, a1, a2;
VI x;

int main()
{
    cin>>n;
    x.resize(n);
    REP(i,n) {
        cin>>x[i];
        sum += x[i];
    }
    sum /= n;
    REP(i,n) {
        a1 += (x[i] - sum) * (x[i] - sum);
        a2 += (x[i] - sum - 1) * (x[i] - sum - 1);
    }
    cout<<min(a1, a2)<<endl;

    return 0;
}


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

#define MOD 1000000007
#define MAX_P 500005
Int fact[MAX_P],inv[MAX_P],finv[MAX_P];;

Int extgcd(Int a,Int b,Int& x,Int& y){
  Int d=a;
  if(b!=0){
    d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }else{
    x=1;y=0;
  }
  return d;
}
Int mod_inverse(Int a,Int mod){
  Int x,y;
  extgcd(a,mod,x,y);
  return (mod+x%mod)%mod;
}

Int mod_pow(Int x,Int n,Int mod){
  Int res=1;
  while(n){
    if(n&1) (res*=x)%=mod;
    (x*=x)%=mod;
    n>>=1;
  }
  return res;
}

Int mod_inverse2(Int a,Int mod){
  return mod_pow(a,mod-2,mod);
}

void init(Int mod){
  fact[0]=1;
  for(Int i=1;i<MAX_P;i++)
    fact[i]=(fact[i-1]*i)%mod;

  inv[1]=1;
  for(Int i=2;i<MAX_P;i++)
    inv[i]=inv[mod%i]*(mod-mod/i)%mod;
  
  finv[0]=1;
  for(Int i=1;i<MAX_P;i++)
    finv[i]=finv[i-1]*inv[i]%mod;
}

//only for prime mod
Int mod_comb3(Int n,Int k,Int mod){
  if(k<0||k>n) return 0;
  return fact[n]*finv[k]%mod*finv[n-k]%mod;
}


template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> a(m);
  for(Int i=0;i<m;i++) cin>>a[i];

  init(MOD);
  Int s=1<<n;
  assert(is_sorted(a.begin(),a.end()));
  reverse(a.begin(),a.end());

  //assert(n>=m);
  //assert(m&&a.back()==2);
  
  auto dp=make_v<Int>(m+1,s);
  fill_v(dp,0);
  dp[0][0]=1;
  for(Int i=0;i<m;i++){
    for(Int j=i;j<m;j++){
      for(Int b=0;b<s;b++){
	for(Int k=0;k<n;k++){
	  if((b>>k)&1) continue;
	  Int nb=b|(1<<k);
	  Int rs=(s-a[j])-b;
	  Int cb=mod_comb3(rs,(1<<k)-1,MOD);
	  Int res=dp[i][b]*cb%MOD;
	  res=res*fact[1<<k]%MOD;
	  dp[j+1][nb]+=res;
	  dp[j+1][nb]%=MOD;
	}
      }
    }
  }
  
  vector<Int> dp2(s,0);
  for(Int i=0;i<=m;i++)
    for(Int j=0;j<s;j++)
      dp2[j]+=dp[i][j];

  Int ans=0;
  for(Int i=0;i<s;i++){
    dp2[i]%=MOD;
    if(__builtin_parityll(i)) ans-=dp2[i]*fact[s-(i+1)]%MOD;
    else ans+=dp2[i]*fact[s-(i+1)]%MOD;
    ans+=MOD;
    ans%=MOD;
  }
  ans=ans*s%MOD;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 21248
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    static int Res = 0;
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        MergeSort(a, 0, a.Length);
        Console.WriteLine(string.Join(" ", a));
        Console.WriteLine(Res);
    }
    static void MergeSort(int[] a, int left, int right)
    {
        if (left + 1 >= right) return;
        var mid = (left + right) / 2;
        MergeSort(a, left, mid);
        MergeSort(a, mid, right);
        Merge(a, left, mid, right);
    }
    static void Merge(int[] a, int left, int mid, int right)
    {
        int n1 = mid - left;
        int n2 = right - mid;
        var L = new int[n1 + 1];
        var R = new int[n2 + 1];
        for (int i = 0; i < n1; i++)
        {
            L[i] = a[left + i];
        }
        for (int i = 0; i < n2; i++)
        {
            R[i] = a[mid + i];
        }
        L[n1] = int.MaxValue / 2;
        R[n2] = int.MaxValue / 2;
        int lind = 0;
        int rind = 0;
        for (int i = left; i < right; i++)
        {
            a[i] = L[lind] <= R[rind] ? L[lind++] : R[rind++];
            Res++;
        }
    }
}



Measured memory_bytes: 86688
import java.io.*;

public class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader reader =
            new BufferedReader (new InputStreamReader (System.in));
        String S = reader.readLine();
        int ans = 0;
        for (int i = 0; i < S.length() / 2; i++)
            if (S.charAt (i) != S.charAt (S.length() - i - 1))
                ans++;
        System.out.println (ans);
        return;
    }
}

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

using namespace std;
using ll=long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = (a); i < (n); i++)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n,a;cin>>n>>a;
  int l=a,r=a+n-1,eat;
  eat= r<=0 ? r : l>=0 ? l:0;
  cout<<(r+l)*(r-l+1)/2-eat<<endl;
  //cout<<n*(l+l+n-1)/2-l<<endl;
}


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

int main() {
  int n;
  cin >> n;
  int k4 = n / 1000;
  int k3 = n / 100 % 10;
  int k2 = n / 10 % 10;
  int k1 = n % 10;

  if (k2 == k3 && (k2 == k1 || k2 == k4)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// 2020-08-15 15:37:34
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

using T = tuple<int, int, int>;
void answer() {
  int n, q;
  cin >> n >> q;
  vector<T> ws(n); // x, s, t
  rep(i, n) {
    int s, t, x;
    cin >> s >> t >> x;
    s -= x;
    t -= x;
    ws[i] = T(x, s, t);
  }
  sort(ALL(ws));
  set<P> qs; // d, qi
  rep(qi, q) {
    int d;
    cin >> d;
    qs.emplace(d, qi);
  }
  vector<int> ans(q, -1);
  for(const auto& w : ws) {
    int x, s, t;
    tie(x, s, t) = w;
    auto itr = qs.lower_bound(P(s, -1));
    while(itr != qs.end()) {
      int d, qi;
      tie(d, qi) = (*itr);
      if(t <= d) break;
      ans[qi] = x;
      itr++;
      qs.erase(prev(itr));
    }
  }
  for(auto a : ans) {
    cout << a << '\n';
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 15852
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

pair<vector<bool>, vector<int>> eratosthenes(int n){
    vector<int> res;
    vector<bool> is_prime(n + 1, true);
    for (int p = 2; p <= n; p++) {
        if (!is_prime[p]){
            continue;
        }
        for (int k = p * 2; k <= n; k += p){
            is_prime[k] = false;
        }
        res.push_back(p);
    }
    return make_pair(is_prime, res);
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint a, b;
    while(cin >> a >> b){
        cout << gcd(a, b) << " " << lcm(a, b) << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

    double A, B, P, Q, R, b;
    cin >> A >> B >> P >> Q >> R;
    b=B;
    A = (B - A) * Q;
    B *= P;
    //cout << A << " " << B << " " << R << " " << Q << endl;
    cout << b+(B - A) / (Q + R) << endl;

    //-Rx + B = Qx + A
    //(Q+R)x = B-A

    return 0;
}



Measured memory_bytes: 3272
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    #divisors.sort()
    return divisors

n = int(input())
cnt = 0
for i in range(n):
  if (i+1) % 2 == 1:
    if len(make_divisors(i+1)) == 8:
      cnt += 1
print(cnt)

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

int main() {
  string S,T;
  int maxCount=0;
  cin >> S >> T;
  for(int i=0;i<(S.size()-T.size()+1);i++){
    int tmp=0;
    for(int j=0;j<T.size();j++){
      if(T.at(j)==S.at(i+j)){
        tmp++;
      }
    }
    maxCount=max(maxCount,tmp);
  }
  cout << (T.size()-maxCount) << endl;
}


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


bool has3(int x){
  while(x){
    if(x%10==3)return true;
    x/=10;
  }
  return false;
}

void call(int n){
  for(int x=1;x<=n;x++){
    if(x%3==0||has3(x)){
      cout<<" "<<x;
    }
  }
cout<<endl;
}

int main(void){
  int n;
  cin>>n;
  call(n);
}


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

#define  ll   long long
#define  pb  push_back
#define  mp  make_pair
#define  MAX  500006
#define  MAX1  10000008
#define  mem(a,v)   memset(a,v,sizeof(a))

template <typename T>
T mymax (T a,T b){return (a>b)?a:b;}
template <typename T>
T mymin (T a,T b){return (a<b)?a:b;}
template <typename T>
T myabs (T a){return (a<0)?(-1*a):a;}
template <typename T>
T mysqrt (T x){if (x == 0 | x == 1)return x;int start = 1, End = x, ans;while (start <= End){int mid = (start + End) / 2;if (mid*mid == x)return mid;if (mid*mid < x){start = mid + 1;ans = mid;}else End = mid-1;}return ans;}

void fastIO (){ios_base::sync_with_stdio(false);cin.tie(0); cout.precision(20);}

ll A[MAX];
ll B[MAX];
ll C[MAX];
vector< ll >V;
vector< ll >Ans;
vector< pair<ll,ll> >VP;
map< ll,ll >M;
vector<ll>prime;
bool mark[MAX1];
ll N=1e7;
void seive (){int limit = sqrt(N*1.0)+2;mark[1]=1;for (int i=4;i<=N;i+=2)mark[i]=1;prime.push_back(2);for (int i=3;i<=N;i+=2){if(!mark[i]){prime.push_back(i);if(i<=limit){for (int j=i*i;j<=N;j+=i*2)mark[j]=1;}}}}

int main ()
{
    fastIO();
    ll a,b,c,n,m,k,p,q,r;
    ll cnt=0,cntr=0,sum=0,ans=1,check=0;
    float x,y,z;
    ll Max= 0,Max1=-1e18+1;
    ll Min = 1e18;
    string s,s1,s3,s4;

    cin>>a>>p;

    cin>>b>>q;
    cin>>r;

    if(a<=b){
        b+=(r*q);
        a+=(r*p);

        if(b<=a)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    else {
        b-=(r*q);
        a-=(r*p);

        if(b>=a)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }



    return 0;
}


Measured memory_bytes: 3644
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/2/16
Solved on 2019/2/16
@author: shinjisu
"""


# ABC 118
def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


def dmp(x):
    global debug
    if debug:
        print(x)
    return x


def probA():
    A, B = getIntList()
    dmp((A, B))
    if B % A == 0:
        return A+B
    else:
        return B-A


debug = False  # True False
print(probA())


def probB():
    N = getInt()
    A = getIntList()
    dmp((N, A))
    return 123


def probC():
    N = getInt()
    A = getIntList()
    dmp((N, A))
    return 123


def probD():
    N = getInt()
    A = getIntList()
    dmp((N, A))
    return 123


Measured memory_bytes: 3064
from sys import exit


def mpow(x, n):
    result = 1
    while n != 0:
        if n & 1 == 1:
            result *= x
            result %= 1000000007
        x *= x
        x %= 1000000007
        n >>= 1
    return result


def mcomb(n, k):
    if n == 0 and k == 0:
        return 1
    if n < k or k < 0:
        return 0

    fac = [0] * (n + 1)
    fac[0] = 1
    for i in range(n):
        fac[i + 1] = fac[i] * (i + 1) % p
    return fac[n] * mpow(fac[n - k], p - 2) * mpow(fac[k], p - 2) % p


p = 1000000007

X, Y = map(int, input().split())

if (X+Y) % 3 != 0:
    print(0)
    exit()

a = (2 * Y - X) // 3
b = (2 * X - Y) // 3

if a < 0 or b < 0:
    print(0)
    exit()

print(mcomb(a + b, min(a, b)))


Measured memory_bytes: 31052
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = Integer.parseInt(sc.next()) % 10;
        String reuslt;
        switch (num) {
            case 2:
            case 4:
            case 5:
            case 7:
            case 9:
                reuslt = "hon";
                break;
            case 0:
            case 1:
            case 6:
            case 8:
                reuslt = "pon";
                break;
            case 3:
                reuslt = "bon";
                break;
            default:
                throw new IllegalArgumentException();
        }

        System.out.println(reuslt);
    }
}

Measured memory_bytes: 35672
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  string s; cin >> s;
  int Q; cin >> Q;
  int parity = 0;
  string a = "", b = "";

  rep(q,Q){
    int t; cin >> t;
    if (t==1){
      (parity += 1) %= 2;
      swap(a,b);
      // reverse(all(a));
      // reverse(all(b));
    }
    else {
      int f; cin >> f;
      char c; cin >> c;
      if (f==1) {
        if (parity) a = a + c;
        else a = c + a;
      }
      else {
        if (parity) b = c + b;
        else b = b + c;
      }
    }
  }
  if (parity) {
    reverse(all(s));
    reverse(all(a));
    reverse(all(b));
  }
  cout << a+s+b << endl;

  // cout << fixed << setprecision(10);
  
  return 0;
}



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

int main() {
  int n;
  cin >> n;
  string s[n];
  for (int i = 0; i < n; i++) cin >> s[i];
  int a[27] = {};
  for (char c : s[0]) a[c-'a']++;
  for (int i = 1; i < n; i++) {
    int b[27] = {};
    for (char c : s[i]) b[c-'a']++;
    for (int j = 0; j < 27; j++) a[j] = min(a[j], b[j]);
  }
  for (int i = 0; i < 27; i++) {
    for (int j = 0; j < a[i]; j++) cout << char('a'+i);
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a==0||b==0){
    if(a){
      if(a>0){
	printf("%d\n",a+1);
	return 0;
      }
      printf("%d\n",-a);
      return 0;
    }
    if(b>=0){
      printf("%d\n",b);
      return 0;
    }
    printf("%d\n",-b+1);
    return 0;
  }
  if(1LL*a*b<0){
    printf("%d\n",abs(abs(a)-abs(b))+1);
    return 0;
  }
  if(a>b){
    printf("%d\n",a-b+2);
    return 0;
  }
  printf("%d\n",b-a);  
  return 0;
}


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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


int main()
{
    int R,G;
    cin >> R >> G;

    cout << G*2 - R << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(5e2 + 5);
const int LOG = (int)(20);

int n, m;
char s[N][N], r[N][N], b[N][N];

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		cin >> s[i] + 1;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			r[i][j] = '.', b[i][j] = '.';

	for(int i = 1; i <= n; i++)
		r[i][1] = '#';
	for(int i = 1; i <= n; i += 2)
		for(int j = 1; j <= m - 1; j++)
			r[i][j] = '#';

	for(int i = 1; i <= n; i++)
		b[i][m] = '#';
	for(int i = 2; i <= n; i += 2)
		for(int j = m; j >= 2; j--)
			b[i][j] = '#';

	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(s[i][j] == '#')
				r[i][j] = '#', b[i][j] = '#';

	for(int i = 1; i <= n; i++)
		cout << b[i] + 1 << endl;
	for(int i = 1; i <= n; i++)
		cout << r[i] + 1 << endl;
}

Measured memory_bytes: 1536
X, N = list(map(int, input().split()))
P = list(map(int, input().split()))

ans1 = X
ans2 = X

while True:

    if not ans1 in P:
        print(ans1)
        exit()
    if not ans2 in P:
        print(ans2)
        exit()
    ans1 -= 1
    ans2 += 1

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

class Main {
    static Scanner scanner = new Scanner();
    static long mod = 1000000007;

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        PriorityQueue<Integer> queue = new PriorityQueue<>(Comparator.reverseOrder());
        for (int i = 0; i < n; i++) {
            queue.add(scanner.nextInt());
        }
        for (int i = 0; i < m; i++) {
            Integer poll = queue.poll();
            queue.add(poll / 2);
        }
        long sum = 0;
        for (Integer integer : queue) {
            sum += integer;
        }
        System.out.println(sum);
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 45220
from collections import deque

N = int(input())

dic = {}

for i in range(N-1):

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

    if a not in dic:
        dic[a] = []
    if b not in dic:
        dic[b] = []

    dic[a].append(b)
    dic[b].append(a)

alis = [""] * N
alis[0] = 0

Q = deque([])
Q.append(0)

while len(Q) > 0:

    now = Q.pop()

    if now not in dic:
        continue

    for b in dic[now]:

        if alis[b] == "":
            alis[b] = alis[now] + 1

            Q.append(b)

blis = [""] * N
blis[N-1] = 0

Q = deque([])
Q.append(N-1)

while len(Q) > 0:

    now = Q.pop()

    if now not in dic:
        continue

    for b in dic[now]:

        if blis[b] == "":
            blis[b] = blis[now] + 1

            Q.append(b)

F = 0
S = 0

for i in range(N):
    if alis[i] <= blis[i]:
        F += 1
    else:
        S += 1

if F <= S:
    print ("Snuke")
else:
    print ("Fennec")



Measured memory_bytes: 34744